00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043 #include "magick/studio.h"
00044 #include "magick/client.h"
00045 #include "magick/configure.h"
00046 #include "magick/exception.h"
00047 #include "magick/exception-private.h"
00048 #include "magick/memory_.h"
00049 #include "magick/monitor.h"
00050 #include "magick/monitor-private.h"
00051 #include "magick/option.h"
00052 #include "magick/policy.h"
00053 #include "magick/semaphore.h"
00054 #include "magick/string_.h"
00055 #include "magick/token.h"
00056 #include "magick/utility.h"
00057 #include "magick/xml-tree.h"
00058
00059
00060
00061
00062 #define PolicyFilename "policy.xml"
00063
00064
00065
00066
00067 struct _PolicyInfo
00068 {
00069 char
00070 *path;
00071
00072 PolicyDomain
00073 domain;
00074
00075 PolicyRights
00076 rights;
00077
00078 char
00079 *name,
00080 *pattern,
00081 *value;
00082
00083 MagickBooleanType
00084 exempt,
00085 stealth,
00086 debug;
00087
00088 SemaphoreInfo
00089 *semaphore;
00090
00091 unsigned long
00092 signature;
00093 };
00094
00095 typedef struct _PolicyMapInfo
00096 {
00097 const PolicyDomain
00098 domain;
00099
00100 const PolicyRights
00101 rights;
00102
00103 const char
00104 *name,
00105 *pattern,
00106 *value;
00107 } PolicyMapInfo;
00108
00109
00110
00111
00112 static const PolicyMapInfo
00113 PolicyMap[] =
00114 {
00115 { UndefinedPolicyDomain, UndefinedPolicyRights, (const char *) NULL,
00116 (const char *) NULL, (const char *) NULL }
00117 };
00118
00119 static LinkedListInfo
00120 *policy_list = (LinkedListInfo *) NULL;
00121
00122 static SemaphoreInfo
00123 *policy_semaphore = (SemaphoreInfo *) NULL;
00124
00125 static volatile MagickBooleanType
00126 instantiate_policy = MagickFalse;
00127
00128
00129
00130
00131 static MagickBooleanType
00132 InitializePolicyList(ExceptionInfo *),
00133 LoadPolicyLists(const char *,ExceptionInfo *);
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160 static PolicyInfo *GetPolicyInfo(const char *name,ExceptionInfo *exception)
00161 {
00162 char
00163 policyname[MaxTextExtent];
00164
00165 register PolicyInfo
00166 *p;
00167
00168 register char
00169 *q;
00170
00171 assert(exception != (ExceptionInfo *) NULL);
00172 if ((policy_list == (LinkedListInfo *) NULL) ||
00173 (instantiate_policy == MagickFalse))
00174 if (InitializePolicyList(exception) == MagickFalse)
00175 return((PolicyInfo *) NULL);
00176 if ((policy_list == (LinkedListInfo *) NULL) ||
00177 (IsLinkedListEmpty(policy_list) != MagickFalse))
00178 return((PolicyInfo *) NULL);
00179 if ((name == (const char *) NULL) || (LocaleCompare(name,"*") == 0))
00180 return((PolicyInfo *) GetValueFromLinkedList(policy_list,0));
00181
00182
00183
00184 (void) CopyMagickString(policyname,name,MaxTextExtent);
00185 for (q=policyname; *q != '\0'; q++)
00186 {
00187 if (isspace((int) ((unsigned char) *q)) == 0)
00188 continue;
00189 (void) CopyMagickString(q,q+1,MaxTextExtent);
00190 q--;
00191 }
00192
00193
00194
00195 (void) LockSemaphoreInfo(policy_semaphore);
00196 ResetLinkedListIterator(policy_list);
00197 p=(PolicyInfo *) GetNextValueInLinkedList(policy_list);
00198 while (p != (PolicyInfo *) NULL)
00199 {
00200 if (LocaleCompare(policyname,p->name) == 0)
00201 break;
00202 p=(PolicyInfo *) GetNextValueInLinkedList(policy_list);
00203 }
00204 if (p != (PolicyInfo *) NULL)
00205 (void) InsertValueInLinkedList(policy_list,0,
00206 RemoveElementByValueFromLinkedList(policy_list,p));
00207 (void) UnlockSemaphoreInfo(policy_semaphore);
00208 return(p);
00209 }
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238 MagickExport const PolicyInfo **GetPolicyInfoList(const char *pattern,
00239 unsigned long *number_policies,ExceptionInfo *exception)
00240 {
00241 const PolicyInfo
00242 **policies;
00243
00244 register const PolicyInfo
00245 *p;
00246
00247 register long
00248 i;
00249
00250
00251
00252
00253 assert(pattern != (char *) NULL);
00254 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",pattern);
00255 assert(number_policies != (unsigned long *) NULL);
00256 *number_policies=0;
00257 p=GetPolicyInfo("*",exception);
00258 if (p == (const PolicyInfo *) NULL)
00259 return((const PolicyInfo **) NULL);
00260 policies=(const PolicyInfo **) AcquireQuantumMemory((size_t)
00261 GetNumberOfElementsInLinkedList(policy_list)+1UL,sizeof(*policies));
00262 if (policies == (const PolicyInfo **) NULL)
00263 return((const PolicyInfo **) NULL);
00264
00265
00266
00267 (void) LockSemaphoreInfo(policy_semaphore);
00268 ResetLinkedListIterator(policy_list);
00269 p=(const PolicyInfo *) GetNextValueInLinkedList(policy_list);
00270 for (i=0; p != (const PolicyInfo *) NULL; )
00271 {
00272 if ((p->stealth == MagickFalse) &&
00273 (GlobExpression(p->name,pattern,MagickFalse) != MagickFalse))
00274 policies[i++]=p;
00275 p=(const PolicyInfo *) GetNextValueInLinkedList(policy_list);
00276 }
00277 (void) UnlockSemaphoreInfo(policy_semaphore);
00278 policies[i]=(PolicyInfo *) NULL;
00279 *number_policies=(unsigned long) i;
00280 return(policies);
00281 }
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310 MagickExport char **GetPolicyList(const char *pattern,
00311 unsigned long *number_policies,ExceptionInfo *exception)
00312 {
00313 char
00314 **policies;
00315
00316 register const PolicyInfo
00317 *p;
00318
00319 register long
00320 i;
00321
00322
00323
00324
00325 assert(pattern != (char *) NULL);
00326 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",pattern);
00327 assert(number_policies != (unsigned long *) NULL);
00328 *number_policies=0;
00329 p=GetPolicyInfo("*",exception);
00330 if (p == (const PolicyInfo *) NULL)
00331 return((char **) NULL);
00332 policies=(char **) AcquireQuantumMemory((size_t)
00333 GetNumberOfElementsInLinkedList(policy_list)+1UL,sizeof(*policies));
00334 if (policies == (char **) NULL)
00335 return((char **) NULL);
00336
00337
00338
00339 (void) LockSemaphoreInfo(policy_semaphore);
00340 ResetLinkedListIterator(policy_list);
00341 p=(const PolicyInfo *) GetNextValueInLinkedList(policy_list);
00342 for (i=0; p != (const PolicyInfo *) NULL; )
00343 {
00344 if ((p->stealth == MagickFalse) &&
00345 (GlobExpression(p->name,pattern,MagickFalse) != MagickFalse))
00346 policies[i++]=ConstantString(p->name);
00347 p=(const PolicyInfo *) GetNextValueInLinkedList(policy_list);
00348 }
00349 (void) UnlockSemaphoreInfo(policy_semaphore);
00350 policies[i]=(char *) NULL;
00351 *number_policies=(unsigned long) i;
00352 return(policies);
00353 }
00354
00355
00356
00357
00358
00359
00360
00361
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376
00377 MagickExport char *GetPolicyValue(const char *name)
00378 {
00379 const char
00380 *value;
00381
00382 const PolicyInfo
00383 *policy_info;
00384
00385 ExceptionInfo
00386 *exception;
00387
00388 assert(name != (const char *) NULL);
00389 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",name);
00390 exception=AcquireExceptionInfo();
00391 policy_info=GetPolicyInfo(name,exception);
00392 exception=DestroyExceptionInfo(exception);
00393 if (policy_info == (PolicyInfo *) NULL)
00394 return((char *) NULL);
00395 value=policy_info->value;
00396 if ((value == (const char *) NULL) || (*value == '\0'))
00397 return((char *) NULL);
00398 return(ConstantString(value));
00399 }
00400
00401
00402
00403
00404
00405
00406
00407
00408
00409
00410
00411
00412
00413
00414
00415
00416
00417
00418
00419
00420
00421
00422
00423 static MagickBooleanType InitializePolicyList(ExceptionInfo *exception)
00424 {
00425 if ((policy_list == (LinkedListInfo *) NULL) &&
00426 (instantiate_policy == MagickFalse))
00427 {
00428 if (policy_semaphore == (SemaphoreInfo *) NULL)
00429 AcquireSemaphoreInfo(&policy_semaphore);
00430 (void) LockSemaphoreInfo(policy_semaphore);
00431 if ((policy_list == (LinkedListInfo *) NULL) &&
00432 (instantiate_policy == MagickFalse))
00433 {
00434 (void) LoadPolicyLists(PolicyFilename,exception);
00435 instantiate_policy=MagickTrue;
00436 }
00437 (void) UnlockSemaphoreInfo(policy_semaphore);
00438 }
00439 return(policy_list != (LinkedListInfo *) NULL ? MagickTrue : MagickFalse);
00440 }
00441
00442
00443
00444
00445
00446
00447
00448
00449
00450
00451
00452
00453
00454
00455
00456
00457
00458
00459
00460
00461
00462
00463
00464
00465
00466
00467
00468
00469
00470 MagickExport MagickBooleanType IsRightsAuthorized(const PolicyDomain domain,
00471 const PolicyRights rights,const char *pattern)
00472 {
00473 const PolicyInfo
00474 *policy_info;
00475
00476 ExceptionInfo
00477 *exception;
00478
00479 MagickBooleanType
00480 authorized;
00481
00482 register PolicyInfo
00483 *p;
00484
00485 (void) LogMagickEvent(PolicyEvent,GetMagickModule(),
00486 "Domain: %s; rights=%s; pattern=\"%s\" ...",
00487 MagickOptionToMnemonic(MagickPolicyDomainOptions,domain),
00488 MagickOptionToMnemonic(MagickPolicyRightsOptions,rights),pattern);
00489 exception=AcquireExceptionInfo();
00490 policy_info=GetPolicyInfo("*",exception);
00491 exception=DestroyExceptionInfo(exception);
00492 if (policy_info == (PolicyInfo *) NULL)
00493 return(MagickTrue);
00494 authorized=MagickTrue;
00495 (void) LockSemaphoreInfo(policy_semaphore);
00496 ResetLinkedListIterator(policy_list);
00497 p=(PolicyInfo *) GetNextValueInLinkedList(policy_list);
00498 while ((p != (PolicyInfo *) NULL) && (authorized != MagickFalse))
00499 {
00500 if ((p->domain == domain) &&
00501 (GlobExpression(pattern,p->pattern,MagickFalse) != MagickFalse))
00502 {
00503 if (((rights & ReadPolicyRights) != 0) &&
00504 ((p->rights & ReadPolicyRights) == 0))
00505 authorized=MagickFalse;
00506 if (((rights & WritePolicyRights) != 0) &&
00507 ((p->rights & WritePolicyRights) == 0))
00508 authorized=MagickFalse;
00509 if (((rights & ExecutePolicyRights) != 0) &&
00510 ((p->rights & ExecutePolicyRights) == 0))
00511 authorized=MagickFalse;
00512 }
00513 p=(PolicyInfo *) GetNextValueInLinkedList(policy_list);
00514 }
00515 (void) UnlockSemaphoreInfo(policy_semaphore);
00516 return(authorized);
00517 }
00518
00519
00520
00521
00522
00523
00524
00525
00526
00527
00528
00529
00530
00531
00532
00533
00534
00535
00536
00537
00538
00539
00540
00541
00542
00543 MagickExport MagickBooleanType ListPolicyInfo(FILE *file,
00544 ExceptionInfo *exception)
00545 {
00546 const char
00547 *path,
00548 *domain;
00549
00550 const PolicyInfo
00551 **policy_info;
00552
00553 register long
00554 i;
00555
00556 unsigned long
00557 number_policies;
00558
00559
00560
00561
00562 if (file == (const FILE *) NULL)
00563 file=stdout;
00564 policy_info=GetPolicyInfoList("*",&number_policies,exception);
00565 if (policy_info == (const PolicyInfo **) NULL)
00566 return(MagickFalse);
00567 path=(const char *) NULL;
00568 for (i=0; i < (long) number_policies; i++)
00569 {
00570 if (policy_info[i]->stealth != MagickFalse)
00571 continue;
00572 if (((path == (const char *) NULL) ||
00573 (LocaleCompare(path,policy_info[i]->path) != 0)) &&
00574 (policy_info[i]->path != (char *) NULL))
00575 (void) fprintf(file,"\nPath: %s\n",policy_info[i]->path);
00576 path=policy_info[i]->path;
00577 domain=MagickOptionToMnemonic(MagickPolicyDomainOptions,
00578 policy_info[i]->domain);
00579 (void) fprintf(file," Policy: %s\n",domain);
00580 if (policy_info[i]->domain == ResourcePolicyDomain)
00581 {
00582 if (policy_info[i]->name != (char *) NULL)
00583 (void) fprintf(file," name: %s\n",policy_info[i]->name);
00584 if (policy_info[i]->value != (char *) NULL)
00585 (void) fprintf(file," value: %s\n",policy_info[i]->value);
00586 }
00587 else
00588 {
00589 (void) fprintf(file," rights: ");
00590 if (policy_info[i]->rights == NoPolicyRights)
00591 (void) fprintf(file,"None ");
00592 if ((policy_info[i]->rights & ReadPolicyRights) != 0)
00593 (void) fprintf(file,"Read ");
00594 if ((policy_info[i]->rights & WritePolicyRights) != 0)
00595 (void) fprintf(file,"Write ");
00596 if ((policy_info[i]->rights & ExecutePolicyRights) != 0)
00597 (void) fprintf(file,"Execute ");
00598 (void) fprintf(file,"\n");
00599 if (policy_info[i]->pattern != (char *) NULL)
00600 (void) fprintf(file," pattern: %s\n",policy_info[i]->pattern);
00601 }
00602 }
00603 policy_info=(const PolicyInfo **) RelinquishMagickMemory((void *)
00604 policy_info);
00605 (void) fflush(file);
00606 return(MagickTrue);
00607 }
00608
00609
00610
00611
00612
00613
00614
00615
00616
00617
00618
00619
00620
00621
00622
00623
00624
00625
00626
00627
00628
00629
00630
00631
00632
00633
00634
00635
00636
00637
00638
00639 static MagickBooleanType LoadPolicyList(const char *xml,const char *filename,
00640 const unsigned long depth,ExceptionInfo *exception)
00641 {
00642 char
00643 keyword[MaxTextExtent],
00644 *token;
00645
00646 PolicyInfo
00647 *policy_info;
00648
00649 const char
00650 *q;
00651
00652 MagickBooleanType
00653 status;
00654
00655
00656
00657
00658 (void) LogMagickEvent(ConfigureEvent,GetMagickModule(),
00659 "Loading policy file \"%s\" ...",filename);
00660 if (xml == (char *) NULL)
00661 return(MagickFalse);
00662 if (policy_list == (LinkedListInfo *) NULL)
00663 {
00664 policy_list=NewLinkedList(0);
00665 if (policy_list == (LinkedListInfo *) NULL)
00666 {
00667 ThrowFileException(exception,ResourceLimitError,
00668 "MemoryAllocationFailed",filename);
00669 return(MagickFalse);
00670 }
00671 }
00672 status=MagickTrue;
00673 policy_info=(PolicyInfo *) NULL;
00674 token=AcquireString(xml);
00675 for (q=(const char *) xml; *q != '\0'; )
00676 {
00677
00678
00679
00680 GetMagickToken(q,&q,token);
00681 if (*token == '\0')
00682 break;
00683 (void) CopyMagickString(keyword,token,MaxTextExtent);
00684 if (LocaleNCompare(keyword,"<!DOCTYPE",9) == 0)
00685 {
00686
00687
00688
00689 while ((LocaleNCompare(q,"]>",2) != 0) && (*q != '\0'))
00690 GetMagickToken(q,&q,token);
00691 continue;
00692 }
00693 if (LocaleNCompare(keyword,"<!--",4) == 0)
00694 {
00695
00696
00697
00698 while ((LocaleNCompare(q,"->",2) != 0) && (*q != '\0'))
00699 GetMagickToken(q,&q,token);
00700 continue;
00701 }
00702 if (LocaleCompare(keyword,"<include") == 0)
00703 {
00704
00705
00706
00707 while (((*token != '/') && (*(token+1) != '>')) && (*q != '\0'))
00708 {
00709 (void) CopyMagickString(keyword,token,MaxTextExtent);
00710 GetMagickToken(q,&q,token);
00711 if (*token != '=')
00712 continue;
00713 GetMagickToken(q,&q,token);
00714 if (LocaleCompare(keyword,"file") == 0)
00715 {
00716 if (depth > 200)
00717 (void) ThrowMagickException(exception,GetMagickModule(),
00718 ConfigureError,"IncludeElementNestedTooDeeply","`%s'",token);
00719 else
00720 {
00721 char
00722 path[MaxTextExtent],
00723 *xml;
00724
00725 GetPathComponent(filename,HeadPath,path);
00726 if (*path != '\0')
00727 (void) ConcatenateMagickString(path,DirectorySeparator,
00728 MaxTextExtent);
00729 if (*token == *DirectorySeparator)
00730 (void) CopyMagickString(path,token,MaxTextExtent);
00731 else
00732 (void) ConcatenateMagickString(path,token,MaxTextExtent);
00733 xml=FileToString(path,~0,exception);
00734 if (xml != (char *) NULL)
00735 {
00736 status=LoadPolicyList(xml,path,depth+1,exception);
00737 xml=(char *) RelinquishMagickMemory(xml);
00738 }
00739 }
00740 }
00741 }
00742 continue;
00743 }
00744 if (LocaleCompare(keyword,"<policy") == 0)
00745 {
00746
00747
00748
00749 policy_info=(PolicyInfo *) AcquireMagickMemory(sizeof(*policy_info));
00750 if (policy_info == (PolicyInfo *) NULL)
00751 ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
00752 (void) ResetMagickMemory(policy_info,0,sizeof(*policy_info));
00753 policy_info->path=ConstantString(filename);
00754 policy_info->exempt=MagickFalse;
00755 policy_info->signature=MagickSignature;
00756 continue;
00757 }
00758 if (policy_info == (PolicyInfo *) NULL)
00759 continue;
00760 if (LocaleCompare(keyword,"/>") == 0)
00761 {
00762 status=AppendValueToLinkedList(policy_list,policy_info);
00763 if (status == MagickFalse)
00764 (void) ThrowMagickException(exception,GetMagickModule(),
00765 ResourceLimitError,"MemoryAllocationFailed","`%s'",
00766 policy_info->name);
00767 policy_info=(PolicyInfo *) NULL;
00768 }
00769 GetMagickToken(q,(const char **) NULL,token);
00770 if (*token != '=')
00771 continue;
00772 GetMagickToken(q,&q,token);
00773 GetMagickToken(q,&q,token);
00774 switch (*keyword)
00775 {
00776 case 'D':
00777 case 'd':
00778 {
00779 if (LocaleCompare((char *) keyword,"domain") == 0)
00780 {
00781 policy_info->domain=(PolicyDomain) ParseMagickOption(
00782 MagickPolicyDomainOptions,MagickTrue,token);
00783 break;
00784 }
00785 break;
00786 }
00787 case 'N':
00788 case 'n':
00789 {
00790 if (LocaleCompare((char *) keyword,"name") == 0)
00791 {
00792 policy_info->name=ConstantString(token);
00793 break;
00794 }
00795 break;
00796 }
00797 case 'P':
00798 case 'p':
00799 {
00800 if (LocaleCompare((char *) keyword,"pattern") == 0)
00801 {
00802 policy_info->pattern=ConstantString(token);
00803 break;
00804 }
00805 break;
00806 }
00807 case 'R':
00808 case 'r':
00809 {
00810 if (LocaleCompare((char *) keyword,"rights") == 0)
00811 {
00812 policy_info->rights=(PolicyRights) ParseMagickOption(
00813 MagickPolicyRightsOptions,MagickTrue,token);
00814 break;
00815 }
00816 break;
00817 }
00818 case 'S':
00819 case 's':
00820 {
00821 if (LocaleCompare((char *) keyword,"stealth") == 0)
00822 {
00823 policy_info->stealth=IsMagickTrue(token);
00824 break;
00825 }
00826 break;
00827 }
00828 case 'V':
00829 case 'v':
00830 {
00831 if (LocaleCompare((char *) keyword,"value") == 0)
00832 {
00833 policy_info->value=ConstantString(token);
00834 break;
00835 }
00836 break;
00837 }
00838 default:
00839 break;
00840 }
00841 }
00842 token=(char *) RelinquishMagickMemory(token);
00843 return(status);
00844 }
00845
00846
00847
00848
00849
00850
00851
00852
00853
00854
00855
00856
00857
00858
00859
00860
00861
00862
00863
00864
00865
00866
00867
00868
00869
00870
00871
00872 static MagickBooleanType LoadPolicyLists(const char *filename,
00873 ExceptionInfo *exception)
00874 {
00875 const StringInfo
00876 *option;
00877
00878 LinkedListInfo
00879 *options;
00880
00881 MagickStatusType
00882 status;
00883
00884 register long
00885 i;
00886
00887
00888
00889
00890 status=MagickFalse;
00891 if (policy_list == (LinkedListInfo *) NULL)
00892 {
00893 policy_list=NewLinkedList(0);
00894 if (policy_list == (LinkedListInfo *) NULL)
00895 {
00896 ThrowFileException(exception,ResourceLimitError,
00897 "MemoryAllocationFailed",filename);
00898 return(MagickFalse);
00899 }
00900 }
00901 for (i=0; i < (long) (sizeof(PolicyMap)/sizeof(*PolicyMap)); i++)
00902 {
00903 PolicyInfo
00904 *policy_info;
00905
00906 register const PolicyMapInfo
00907 *p;
00908
00909 p=PolicyMap+i;
00910 policy_info=(PolicyInfo *) AcquireMagickMemory(sizeof(*policy_info));
00911 if (policy_info == (PolicyInfo *) NULL)
00912 {
00913 (void) ThrowMagickException(exception,GetMagickModule(),
00914 ResourceLimitError,"MemoryAllocationFailed","`%s'",policy_info->name);
00915 continue;
00916 }
00917 (void) ResetMagickMemory(policy_info,0,sizeof(*policy_info));
00918 policy_info->path=(char *) "[built-in]";
00919 policy_info->domain=p->domain;
00920 policy_info->rights=p->rights;
00921 policy_info->name=(char *) p->name;
00922 policy_info->pattern=(char *) p->pattern;
00923 policy_info->value=(char *) p->value;
00924 policy_info->exempt=MagickTrue;
00925 policy_info->signature=MagickSignature;
00926 status=AppendValueToLinkedList(policy_list,policy_info);
00927 if (status == MagickFalse)
00928 (void) ThrowMagickException(exception,GetMagickModule(),
00929 ResourceLimitError,"MemoryAllocationFailed","`%s'",policy_info->name);
00930 }
00931
00932
00933
00934 options=GetConfigureOptions(filename,exception);
00935 option=(const StringInfo *) GetNextValueInLinkedList(options);
00936 while (option != (const StringInfo *) NULL)
00937 {
00938 status|=LoadPolicyList((const char *) GetStringInfoDatum(option),
00939 GetStringInfoPath(option),0,exception);
00940 option=(const StringInfo *) GetNextValueInLinkedList(options);
00941 }
00942 options=DestroyConfigureOptions(options);
00943 return(status != 0 ? MagickTrue : MagickFalse);
00944 }
00945
00946
00947
00948
00949
00950
00951
00952
00953
00954
00955
00956
00957
00958
00959
00960
00961
00962
00963
00964 MagickExport MagickBooleanType PolicyComponentGenesis(void)
00965 {
00966 AcquireSemaphoreInfo(&policy_semaphore);
00967 return(MagickTrue);
00968 }
00969
00970
00971
00972
00973
00974
00975
00976
00977
00978
00979
00980
00981
00982
00983
00984
00985
00986
00987
00988
00989 static void *DestroyPolicyElement(void *policy_info)
00990 {
00991 register PolicyInfo
00992 *p;
00993
00994 p=(PolicyInfo *) policy_info;
00995 if (p->exempt == MagickFalse)
00996 {
00997 if (p->value != (char *) NULL)
00998 p->value=DestroyString(p->value);
00999 if (p->pattern != (char *) NULL)
01000 p->pattern=DestroyString(p->pattern);
01001 if (p->name != (char *) NULL)
01002 p->name=DestroyString(p->name);
01003 if (p->path != (char *) NULL)
01004 p->path=DestroyString(p->path);
01005 }
01006 p=(PolicyInfo *) RelinquishMagickMemory(p);
01007 return((void *) NULL);
01008 }
01009
01010 MagickExport void PolicyComponentTerminus(void)
01011 {
01012 if (policy_semaphore == (SemaphoreInfo *) NULL)
01013 AcquireSemaphoreInfo(&policy_semaphore);
01014 (void) LockSemaphoreInfo(policy_semaphore);
01015 if (policy_list != (LinkedListInfo *) NULL)
01016 policy_list=DestroyLinkedList(policy_list,DestroyPolicyElement);
01017 instantiate_policy=MagickFalse;
01018 (void) UnlockSemaphoreInfo(policy_semaphore);
01019 DestroySemaphoreInfo(&policy_semaphore);
01020 }