From: Cristy Date: Mon, 13 Mar 2017 12:45:31 +0000 (-0400) Subject: ... X-Git-Tag: 7.0.5-3~14 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2d44ac8aa0e1f5fa5a07cab9194563738b653037;p=imagemagick ... --- diff --git a/MagickCore/cache.c b/MagickCore/cache.c index 82fe3b69a..8a110f886 100644 --- a/MagickCore/cache.c +++ b/MagickCore/cache.c @@ -217,7 +217,7 @@ MagickPrivate Cache AcquirePixelCache(const size_t number_threads) cache_info->synchronize=IsStringTrue(value); value=DestroyString(value); } - value=GetPolicyValue("synchronize"); + value=GetPolicyValue("cache:synchronize"); if (value != (const char *) NULL) { cache_info->synchronize=IsStringTrue(value); @@ -3449,6 +3449,8 @@ static MagickBooleanType OpenPixelCache(Image *image,const MapMode mode, */ cache_anonymous_memory=0; value=GetPolicyValue("pixel-cache-memory"); + if (value == (char *) NULL) + value=GetPolicyValue("cache:memory-map"); if (LocaleCompare(value,"anonymous") == 0) { #if defined(MAGICKCORE_HAVE_MMAP) && defined(MAP_ANONYMOUS) diff --git a/MagickCore/distribute-cache.c b/MagickCore/distribute-cache.c index 669d1f09c..76882b3bc 100644 --- a/MagickCore/distribute-cache.c +++ b/MagickCore/distribute-cache.c @@ -201,7 +201,7 @@ static int ConnectPixelCacheServer(const char *hostname,const int port, Connect to distributed pixel cache and get session key. */ *session_key=0; - shared_secret=GetPolicyValue("shared-secret"); + shared_secret=GetPolicyValue("cache:shared-secret"); if (shared_secret == (char *) NULL) { shared_secret=DestroyString(shared_secret); @@ -805,7 +805,7 @@ static HANDLER_RETURN_TYPE DistributePixelCacheClient(void *socket) /* Distributed pixel cache client. */ - shared_secret=GetPolicyValue("shared-secret"); + shared_secret=GetPolicyValue("cache:shared-secret"); if (shared_secret == (char *) NULL) ThrowFatalException(CacheFatalError,"shared secret expected"); p=session; diff --git a/MagickCore/magick.c b/MagickCore/magick.c index 16ce0776a..df7b5d8e1 100644 --- a/MagickCore/magick.c +++ b/MagickCore/magick.c @@ -1680,7 +1680,7 @@ MagickExport int SetMagickPrecision(const int precision) magick_precision=MagickPrecision; limit=GetEnvironmentValue("MAGICK_PRECISION"); if (limit == (char *) NULL) - limit=GetPolicyValue("precision"); + limit=GetPolicyValue("system:precision"); if (limit != (char *) NULL) { magick_precision=StringToInteger(limit); diff --git a/MagickCore/policy.c b/MagickCore/policy.c index ee81b3208..535bb43db 100644 --- a/MagickCore/policy.c +++ b/MagickCore/policy.c @@ -264,6 +264,9 @@ static PolicyInfo *GetPolicyInfo(const char *name,ExceptionInfo *exception) char policyname[MagickPathExtent]; + PolicyDomain + domain; + register PolicyInfo *p; @@ -286,6 +289,19 @@ static PolicyInfo *GetPolicyInfo(const char *name,ExceptionInfo *exception) (void) CopyMagickString(q,q+1,MagickPathExtent); q--; } + /* + Strip domain from policy name (e.g. resource:map). + */ + domain=UndefinedPolicyDomain; + for (q=policyname; *q != '\0'; q++) + { + if (*q != ':') + continue; + *q='\0'; + domain=(PolicyDomain) ParseCommandOption(MagickPolicyDomainOptions, + MagickTrue,policyname); + (void) CopyMagickString(policyname,q+1,MagickPathExtent); + } /* Search for policy tag. */ @@ -299,8 +315,9 @@ static PolicyInfo *GetPolicyInfo(const char *name,ExceptionInfo *exception) } while (p != (PolicyInfo *) NULL) { - if (LocaleCompare(policyname,p->name) == 0) - break; + if ((domain == UndefinedPolicyDomain) || (p->domain == domain)) + if (LocaleCompare(policyname,p->name) == 0) + break; p=(PolicyInfo *) GetNextValueInLinkedList(policy_cache); } if (p != (PolicyInfo *) NULL) @@ -599,11 +616,14 @@ MagickExport MagickBooleanType IsRightsAuthorized(const PolicyDomain domain, (GlobExpression(pattern,p->pattern,MagickFalse) != MagickFalse)) { if ((rights & ReadPolicyRights) != 0) - authorized=(p->rights & ReadPolicyRights) != 0; + authorized=(p->rights & ReadPolicyRights) != 0 ? MagickTrue : + MagickFalse; if ((rights & WritePolicyRights) != 0) - authorized=(p->rights & WritePolicyRights) != 0; + authorized=(p->rights & WritePolicyRights) != 0 ? MagickTrue : + MagickFalse; if ((rights & ExecutePolicyRights) != 0) - authorized=(p->rights & ExecutePolicyRights) != 0; + authorized=(p->rights & ExecutePolicyRights) != 0 ? MagickTrue : + MagickFalse; } p=(PolicyInfo *) GetNextValueInLinkedList(policy_cache); } diff --git a/MagickCore/policy.h b/MagickCore/policy.h index d4657f55d..6cffe9d1a 100644 --- a/MagickCore/policy.h +++ b/MagickCore/policy.h @@ -51,7 +51,7 @@ typedef struct _PolicyInfo PolicyInfo; extern MagickExport char - *GetPolicyValue(const char *name), + *GetPolicyValue(const char *), **GetPolicyList(const char *,size_t *,ExceptionInfo *); extern MagickExport const PolicyInfo diff --git a/MagickCore/resource.c b/MagickCore/resource.c index 40c5593fb..f3bd06735 100644 --- a/MagickCore/resource.c +++ b/MagickCore/resource.c @@ -436,7 +436,7 @@ MagickExport MagickBooleanType GetPathTemplate(char *path) #endif if (directory == (char *) NULL) return(MagickTrue); - value=GetPolicyValue("temporary-path"); + value=GetPolicyValue("resource:temporary-path"); if (value != (char *) NULL) { (void) CloneString(&directory,value); @@ -1249,7 +1249,7 @@ MagickExport MagickBooleanType SetMagickResourceLimit(const ResourceType type, case WidthResource: { resource_info.width_limit=limit; - value=GetPolicyValue("width"); + value=GetPolicyValue("resource:width"); if (value != (char *) NULL) resource_info.width_limit=MagickMin(limit,StringToSizeType(value, 100.0)); @@ -1258,7 +1258,7 @@ MagickExport MagickBooleanType SetMagickResourceLimit(const ResourceType type, case HeightResource: { resource_info.height_limit=limit; - value=GetPolicyValue("height"); + value=GetPolicyValue("resource:height"); if (value != (char *) NULL) resource_info.height_limit=MagickMin(limit,StringToSizeType(value, 100.0)); @@ -1267,7 +1267,7 @@ MagickExport MagickBooleanType SetMagickResourceLimit(const ResourceType type, case AreaResource: { resource_info.area_limit=limit; - value=GetPolicyValue("area"); + value=GetPolicyValue("resource:area"); if (value != (char *) NULL) resource_info.area_limit=MagickMin(limit,StringToSizeType(value,100.0)); break; @@ -1275,7 +1275,7 @@ MagickExport MagickBooleanType SetMagickResourceLimit(const ResourceType type, case MemoryResource: { resource_info.memory_limit=limit; - value=GetPolicyValue("memory"); + value=GetPolicyValue("resource:memory"); if (value != (char *) NULL) resource_info.memory_limit=MagickMin(limit,StringToSizeType(value, 100.0)); @@ -1284,7 +1284,7 @@ MagickExport MagickBooleanType SetMagickResourceLimit(const ResourceType type, case MapResource: { resource_info.map_limit=limit; - value=GetPolicyValue("map"); + value=GetPolicyValue("resource:map"); if (value != (char *) NULL) resource_info.map_limit=MagickMin(limit,StringToSizeType(value,100.0)); break; @@ -1292,7 +1292,7 @@ MagickExport MagickBooleanType SetMagickResourceLimit(const ResourceType type, case DiskResource: { resource_info.disk_limit=limit; - value=GetPolicyValue("disk"); + value=GetPolicyValue("resource:disk"); if (value != (char *) NULL) resource_info.disk_limit=MagickMin(limit,StringToSizeType(value,100.0)); break; @@ -1300,7 +1300,7 @@ MagickExport MagickBooleanType SetMagickResourceLimit(const ResourceType type, case FileResource: { resource_info.file_limit=limit; - value=GetPolicyValue("file"); + value=GetPolicyValue("resource:file"); if (value != (char *) NULL) resource_info.file_limit=MagickMin(limit,StringToSizeType(value,100.0)); break; @@ -1308,7 +1308,7 @@ MagickExport MagickBooleanType SetMagickResourceLimit(const ResourceType type, case ThreadResource: { resource_info.thread_limit=limit; - value=GetPolicyValue("thread"); + value=GetPolicyValue("resource:thread"); if (value != (char *) NULL) resource_info.thread_limit=MagickMin(limit,StringToSizeType(value, 100.0)); @@ -1322,7 +1322,7 @@ MagickExport MagickBooleanType SetMagickResourceLimit(const ResourceType type, case ThrottleResource: { resource_info.throttle_limit=limit; - value=GetPolicyValue("throttle"); + value=GetPolicyValue("resource:throttle"); if (value != (char *) NULL) resource_info.throttle_limit=MagickMax(limit,StringToSizeType(value, 100.0)); @@ -1331,7 +1331,7 @@ MagickExport MagickBooleanType SetMagickResourceLimit(const ResourceType type, case TimeResource: { resource_info.time_limit=limit; - value=GetPolicyValue("time"); + value=GetPolicyValue("resource:time"); if (value != (char *) NULL) resource_info.time_limit=MagickMin(limit,StringToSizeType(value,100.0)); ResetPixelCacheEpoch(); diff --git a/MagickCore/utility.c b/MagickCore/utility.c index ebe8d5d67..6fa0f5c52 100644 --- a/MagickCore/utility.c +++ b/MagickCore/utility.c @@ -1826,7 +1826,7 @@ MagickPrivate MagickBooleanType ShredFile(const char *path) if ((path == (const char *) NULL) || (*path == '\0')) return(MagickFalse); - passes=GetPolicyValue("shred"); + passes=GetPolicyValue("system:shred"); if (passes == (char *) NULL) passes=GetEnvironmentValue("MAGICK_SHRED_PASSES"); if (passes == (char *) NULL) diff --git a/config/policy.xml b/config/policy.xml index b0df62995..fef14cf65 100644 --- a/config/policy.xml +++ b/config/policy.xml @@ -62,10 +62,8 @@ --> - - @@ -80,5 +78,7 @@ + +