18#ifndef MAGICKCORE_POLICY_PRIVATE_H
19#define MAGICKCORE_POLICY_PRIVATE_H
21#if defined(__cplusplus) || defined(c_plusplus)
25#include "magick/resource-private.h"
26#include "magick/utility-private.h"
28#if MAGICKCORE_ZERO_CONFIGURATION_SUPPORT
34 *ZeroConfigurationPolicy = \
39static inline MagickBooleanType IsPathContainsSymlink(
const char *path)
42 partial[MagickPathExtent];
50 if (path == (
const char *) NULL)
54 if (*p == *DirectorySeparator)
59 if ((offset+1) >= (ssize_t)
sizeof(partial))
61 partial[offset++]=(*p++);
67 component[MagickPathExtent];
75 while ((*p !=
'\0') && (*p != *DirectorySeparator) &&
76 ((i+1) < (ssize_t)
sizeof(component)))
77 component[i++]=(*p++);
84 if (*p == *DirectorySeparator)
88 if ((offset > 0) && (partial[offset-1] != *DirectorySeparator))
93 if ((offset+1) >= (ssize_t)
sizeof(partial))
95 partial[offset++]=(*DirectorySeparator);
101 if ((offset+i) >= (ssize_t)
sizeof(partial))
103 (void) memcpy(partial+offset,component,i);
105 partial[offset]=
'\0';
111 if (is_symlink_utf8(partial) != MagickFalse)
117 if (*p == *DirectorySeparator)
123static inline MagickBooleanType IsPathAuthorized(
const PolicyRights rights,
126 MagickBooleanType symlink_follow_allowed = IsRightsAuthorizedByName(
127 SystemPolicyDomain,
"symlink",rights,
"follow");
128 MagickBooleanType status =
129 ((IsRightsAuthorized(PathPolicyDomain,rights,path) != MagickFalse) &&
130 ((symlink_follow_allowed != MagickFalse) ||
131 (is_symlink_utf8(path) == MagickFalse))) ? MagickTrue : MagickFalse;
132 if ((status != MagickFalse) && (symlink_follow_allowed == MagickFalse))
134 if ((is_symlink_utf8(path) != MagickFalse) ||
135 (IsPathContainsSymlink(path) != MagickFalse))
138 if (status != MagickFalse)
139 status=IsFileResourceIdentityValid(path);
143#if defined(__cplusplus) || defined(c_plusplus)