Commit db477ffda for imagemagick.org

commit db477ffda5ba3f2d783bc074e3296ac79ceca1a0
Author: Cristy <urban-warrior@imagemagick.org>
Date:   Mon Nov 30 18:53:51 2026 -0500

    cosmetic

diff --git a/MagickCore/distribute-cache.c b/MagickCore/distribute-cache.c
index d23cf71e9..357cee03e 100644
--- a/MagickCore/distribute-cache.c
+++ b/MagickCore/distribute-cache.c
@@ -83,6 +83,8 @@
 #include <netinet/tcp.h>
 #include <netdb.h>
 #include <sys/socket.h>
+#include <sys/stat.h>
+#include <sys/un.h>
 #include <arpa/inet.h>
 #define CLOSE_SOCKET(socket) (void) close_utf8(socket)
 #define HANDLER_RETURN_TYPE void *
@@ -455,8 +457,8 @@ static inline void DeriveSIPKeyFromSecret(const char *shared_secret,
   (void) memcpy(key+8,&k1,8);
 }

-static inline uint64_t GenerateSessionKey(const char *shared_secret,
-  const unsigned char *nonce,size_t length)
+static inline uint64_t GenerateSessionKey(const char *shared_secret,const unsigned char *nonce,
+  size_t length)
 {
   uint8_t
     key[16];
@@ -465,42 +467,24 @@ static inline uint64_t GenerateSessionKey(const char *shared_secret,
   return(SIPHash24(key,nonce,length));
 }

-static int ConnectPixelCacheServer(const char *hostname,const int port,
-  uint64_t *session_key,ExceptionInfo *exception)
+static SOCKET_TYPE ConnectTCPSocket(const char *hostname,const int port,ExceptionInfo *exception)
 {
   char
     *message,
-    service[MagickPathExtent],
-    *shared_secret;
+    service[MagickPathExtent];

   int
     error,
     status;

-  MagickOffsetType
-    received;
-
   SOCKET_TYPE
     client_socket;

-  ssize_t
-    count;
-
   struct addrinfo
     hints,
     *p,
     *result;

-  unsigned char
-    nonce[DPCSessionKeyLength];
-
-  /*
-    Connect to distributed pixel cache server and get session key.
-  */
-  *session_key=0;
-#if defined(MAGICKCORE_HAVE_WINSOCK2)
-  InitializeWinsock2(MagickTrue);
-#endif
   (void) memset(&hints,0,sizeof(hints));
   hints.ai_family=AF_INET;
   hints.ai_socktype=SOCK_STREAM;
@@ -508,9 +492,9 @@ static int ConnectPixelCacheServer(const char *hostname,const int port,
   status=getaddrinfo(hostname,service,&hints,&result);
   if (status != 0)
     {
-      (void) ThrowMagickException(exception,GetMagickModule(),CacheError,
-        "DistributedPixelCache","'%s': %s",hostname,gai_strerror(status));
-      return(-1);
+      (void) ThrowMagickException(exception,GetMagickModule(),CacheError,"DistributedPixelCache",
+        "'%s': %s",hostname,gai_strerror(status));
+      return((SOCKET_TYPE) -1);
     }
   /*
     Try each resolved address until one accepts the connection.
@@ -519,8 +503,7 @@ static int ConnectPixelCacheServer(const char *hostname,const int port,
   error=0;
   for (p=result; p != (struct addrinfo *) NULL; p=p->ai_next)
   {
-    client_socket=(SOCKET_TYPE) socket(p->ai_family,p->ai_socktype,
-      p->ai_protocol);
+    client_socket=(SOCKET_TYPE) socket(p->ai_family,p->ai_socktype,p->ai_protocol);
     if (client_socket == -1)
       {
         error=errno;
@@ -536,13 +519,113 @@ static int ConnectPixelCacheServer(const char *hostname,const int port,
   if (client_socket == -1)
     {
       message=GetExceptionMessage(error);
+      (void) ThrowMagickException(exception,GetMagickModule(),CacheError,"DistributedPixelCache",
+        "'%s': %s",hostname,message);
+      message=DestroyString(message);
+      return((SOCKET_TYPE) -1);
+    }
+  return(client_socket);
+}
+
+#if !defined(MAGICKCORE_HAVE_WINSOCK2)
+static SOCKET_TYPE ConnectUnixSocket(const char *path,ExceptionInfo *exception)
+{
+  char
+    *message;
+
+  int
+    error;
+
+  SOCKET_TYPE
+    client_socket;
+
+  struct sockaddr_un
+    address;
+
+  /*
+    Connect to a distributed pixel cache server on a Unix domain socket.
+  */
+  (void) memset(&address,0,sizeof(address));
+  address.sun_family=AF_UNIX;
+  if (strlen(path) >= sizeof(address.sun_path))
+    {
       (void) ThrowMagickException(exception,GetMagickModule(),CacheError,
-        "DistributedPixelCache","'%s': %s",hostname,message);
+        "DistributedPixelCache","'%s': socket path too long",path);
+      return((SOCKET_TYPE) -1);
+    }
+  (void) CopyMagickString(address.sun_path,path,sizeof(address.sun_path));
+  client_socket=(SOCKET_TYPE) socket(AF_UNIX,SOCK_STREAM,0);
+  if (client_socket == -1)
+    {
+      error=errno;
+      message=GetExceptionMessage(error);
+      (void) ThrowMagickException(exception,GetMagickModule(),CacheError,
+        "DistributedPixelCache","'%s': %s",path,message);
       message=DestroyString(message);
-      return(-1);
+      return((SOCKET_TYPE) -1);
+    }
+  if (connect(client_socket,(struct sockaddr *) &address,
+      (socklen_t) sizeof(address)) != 0)
+    {
+      error=errno;  /* capture before close() can overwrite it */
+      CLOSE_SOCKET(client_socket);
+      message=GetExceptionMessage(error);
+      (void) ThrowMagickException(exception,GetMagickModule(),CacheError,
+        "DistributedPixelCache","'%s': %s",path,message);
+      message=DestroyString(message);
+      return((SOCKET_TYPE) -1);
+    }
+  return(client_socket);
+}
+#endif
+
+static int ConnectPixelCacheServer(const char *hostname,const int port,
+  uint64_t *session_key,ExceptionInfo *exception)
+{
+  char
+    *shared_secret;
+
+  MagickOffsetType
+    received;
+
+  SOCKET_TYPE
+    client_socket;
+
+  ssize_t
+    count;
+
+  unsigned char
+    nonce[DPCSessionKeyLength];
+
+  /*
+    Connect to distributed pixel cache server and get session key.  A port of
+    0 means that hostname is the path of a Unix domain socket.
+  */
+  *session_key=0;
+#if defined(MAGICKCORE_HAVE_WINSOCK2)
+  InitializeWinsock2(MagickTrue);
+#endif
+  if (port == 0)
+    {
+#if !defined(MAGICKCORE_HAVE_WINSOCK2)
+      client_socket=ConnectUnixSocket(hostname,exception);
+#else
+      (void) ThrowMagickException(exception,GetMagickModule(),CacheError,
+        "DistributedPixelCache","'%s': Unix domain sockets are not supported "
+        "on this platform",hostname);
+      client_socket=(SOCKET_TYPE) -1;
+#endif
+      if (client_socket == -1)
+        return(-1);
+    }
+  else
+    {
+      client_socket=ConnectTCPSocket(hostname,port,exception);
+      if (client_socket == -1)
+        return(-1);
+      SetSocketNoDelay(client_socket);
+      SetSocketKeepAlive(client_socket);
     }
-  SetSocketNoDelay(client_socket);
-  SetSocketKeepAlive(client_socket);
   /*
     Receive server nonce (all of it, and without hanging on a silent server).
   */
@@ -587,6 +670,24 @@ static int ConnectPixelCacheServer(const char *hostname,const int port,
 }
 #endif

+static inline const char *GetDPCUnixPath(const char *host)
+{
+  /*
+    A cache:hosts entry that names a Unix domain socket: path (/run/magick/dpc.sock) or a
+    path with a "unix:" prefix (unix:dpc.sock).
+  */
+  if (host == (const char *) NULL)
+    return((const char *) NULL);
+  if (LocaleNCompare(host,"unix:",5) == 0)
+    {
+      host+=5;
+      return(*host != '\0' ? host : (const char *) NULL);
+    }
+  if (*host == '/')
+    return(host);
+  return((const char *) NULL);
+}
+
 static char **RelinquishHostList(char **hostlist,const int argc)
 {
   ssize_t
@@ -611,7 +712,8 @@ static char *GetHostname(int *port,ExceptionInfo *exception)
     id = 0;

   /*
-    Parse host list (e.g. 192.168.100.1:6668,192.168.100.2:6668).
+    Parse host list (e.g. 192.168.100.1:6668,192.168.100.2:6668 or
+    unix:/run/magick/dpc.sock).
   */
   *port=DPCPort;
   hosts=(char *) GetImageRegistry(StringRegistryType,"cache:hosts",exception);
@@ -633,6 +735,22 @@ static char *GetHostname(int *port,ExceptionInfo *exception)
     hosts=AcquireString(hostlist[index]);
   }
   hostlist=RelinquishHostList(hostlist,argc);
+  {
+    const char
+      *unix_path;
+
+    /*
+      A Unix socket entry keeps its path as is: no host:port splitting.
+    */
+    unix_path=GetDPCUnixPath(hosts);
+    if (unix_path != (const char *) NULL)
+      {
+        host=AcquireString(unix_path);
+        hosts=DestroyString(hosts);
+        *port=0;
+        return(host);
+      }
+  }
   (void) SubstituteString(&hosts,":"," ");
   hostlist=StringToArgv(hosts,&argc);
   hosts=DestroyString(hosts);  /* was leaked on every call */
@@ -1015,7 +1133,10 @@ MagickPrivate DistributeCacheInfo *DestroyDistributeCacheInfo(
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
 %  DistributePixelCacheServer() waits on the specified port for commands to
-%  create, read, update, or destroy a pixel cache.
+%  create, read, update, or destroy a pixel cache.  If the cache:unix-socket
+%  policy is set, the server instead listens on that Unix domain socket (the
+%  port is ignored) and creates it accessible to its owner only.  Clients
+%  select it with a cache:hosts entry of unix:/path or an absolute /path.
 %
 %  The format of the DistributePixelCacheServer() method is:
 %
@@ -1935,11 +2056,82 @@ static MagickBooleanType AcquireDPCClientWorker(void)
   return(status);
 }

+#if !defined(MAGICKCORE_HAVE_WINSOCK2)
+static SOCKET_TYPE ListenUnixSocket(const char *path)
+{
+  int
+    error,
+    status;
+
+  mode_t
+    mask;
+
+  SOCKET_TYPE
+    probe_socket,
+    server_socket;
+
+  struct sockaddr_un
+    address;
+
+  struct stat
+    attributes;
+
+  /*
+    Bind a Unix domain socket that only the owner can connect to.
+  */
+  (void) memset(&address,0,sizeof(address));
+  address.sun_family=AF_UNIX;
+  if (strlen(path) >= sizeof(address.sun_path))
+    return((SOCKET_TYPE) -1);
+  (void) CopyMagickString(address.sun_path,path,sizeof(address.sun_path));
+  if (lstat(path,&attributes) == 0)
+    {
+      /*
+        Replace a stale socket, never a regular file or a live server.
+      */
+      if (S_ISSOCK(attributes.st_mode) == 0)
+        return((SOCKET_TYPE) -1);
+      probe_socket=(SOCKET_TYPE) socket(AF_UNIX,SOCK_STREAM,0);
+      if (probe_socket == -1)
+        return((SOCKET_TYPE) -1);
+      status=connect(probe_socket,(struct sockaddr *) &address,
+        (socklen_t) sizeof(address));
+      error=errno;
+      CLOSE_SOCKET(probe_socket);
+      if ((status == 0) || (error != ECONNREFUSED))
+        return((SOCKET_TYPE) -1);
+      (void) unlink(path);
+    }
+  server_socket=(SOCKET_TYPE) socket(AF_UNIX,SOCK_STREAM,0);
+  if (server_socket == -1)
+    return((SOCKET_TYPE) -1);
+  SetSocketReceiveTimeout(server_socket,5.0);
+  /*
+    The umask is process wide, which is safe here: the server is still single
+    threaded when it binds.
+  */
+  mask=umask(0177);
+  status=bind(server_socket,(struct sockaddr *) &address,
+    (socklen_t) sizeof(address));
+  (void) umask(mask);
+  if (status == -1)
+    {
+      CLOSE_SOCKET(server_socket);
+      return((SOCKET_TYPE) -1);
+    }
+  return(server_socket);
+}
+#endif
+
 MagickExport void DistributePixelCacheServer(const int port,
   ExceptionInfo *exception)
 {
   char
-    service[MagickPathExtent];
+    service[MagickPathExtent],
+    *unix_path;
+
+  MagickBooleanType
+    unix_socket;

   int
     status;
@@ -1985,43 +2177,61 @@ MagickExport void DistributePixelCacheServer(const int port,
 #if defined(MAGICKCORE_HAVE_WINSOCK2)
   InitializeWinsock2(MagickFalse);
 #endif
-  (void) memset(&hint,0,sizeof(hint));
-  hint.ai_family=AF_INET;
-  hint.ai_socktype=SOCK_STREAM;
-  hint.ai_flags=AI_PASSIVE;
-  (void) FormatLocaleString(service,MagickPathExtent,"%d",port);
-  status=getaddrinfo(NULL,service,&hint,&result);
-  if (status != 0)
-    ThrowFatalException(CacheFatalError,"UnableToListen");
-  server_socket=(SOCKET_TYPE) 0;
-  for (p=result; p != NULL; p=p->ai_next)
-  {
-    int
-      one = 1;
-
-    server_socket=(SOCKET_TYPE) socket(p->ai_family,p->ai_socktype,
-      p->ai_protocol);
-    if (server_socket == -1)
-      continue;
-    status=setsockopt(server_socket,SOL_SOCKET,SO_REUSEADDR,(char *) &one,
-      (socklen_t) sizeof(one));
-    if (status == -1)
-      {
-        CLOSE_SOCKET(server_socket);
-        continue;
-      }
-    SetSocketReceiveTimeout(server_socket,5.0);
-    status=bind(server_socket,p->ai_addr,(socklen_t) p->ai_addrlen);
-    if (status == -1)
+  unix_socket=MagickFalse;
+  unix_path=GetPolicyValue("cache:unix-socket");
+  if (unix_path != (char *) NULL)
+    {
+#if !defined(MAGICKCORE_HAVE_WINSOCK2)
+      server_socket=ListenUnixSocket(unix_path);
+      unix_path=DestroyString(unix_path);
+      if (server_socket == -1)
+        ThrowFatalException(CacheFatalError,"UnableToBind");
+      unix_socket=MagickTrue;
+#else
+      unix_path=DestroyString(unix_path);
+      ThrowFatalException(CacheFatalError,"UnableToBind");
+#endif
+    }
+  else
+    {
+      (void) memset(&hint,0,sizeof(hint));
+      hint.ai_family=AF_INET;
+      hint.ai_socktype=SOCK_STREAM;
+      hint.ai_flags=AI_PASSIVE;
+      (void) FormatLocaleString(service,MagickPathExtent,"%d",port);
+      status=getaddrinfo(NULL,service,&hint,&result);
+      if (status != 0)
+        ThrowFatalException(CacheFatalError,"UnableToListen");
+      server_socket=(SOCKET_TYPE) 0;
+      for (p=result; p != NULL; p=p->ai_next)
       {
-        CLOSE_SOCKET(server_socket);
-        continue;
+        int
+          one = 1;
+
+        server_socket=(SOCKET_TYPE) socket(p->ai_family,p->ai_socktype,
+          p->ai_protocol);
+        if (server_socket == -1)
+          continue;
+        status=setsockopt(server_socket,SOL_SOCKET,SO_REUSEADDR,(char *) &one,
+          (socklen_t) sizeof(one));
+        if (status == -1)
+          {
+            CLOSE_SOCKET(server_socket);
+            continue;
+          }
+        SetSocketReceiveTimeout(server_socket,5.0);
+        status=bind(server_socket,p->ai_addr,(socklen_t) p->ai_addrlen);
+        if (status == -1)
+          {
+            CLOSE_SOCKET(server_socket);
+            continue;
+          }
+        break;
       }
-    break;
-  }
-  if (p == (struct addrinfo *) NULL)
-    ThrowFatalException(CacheFatalError,"UnableToBind");
-  freeaddrinfo(result);
+      if (p == (struct addrinfo *) NULL)
+        ThrowFatalException(CacheFatalError,"UnableToBind");
+      freeaddrinfo(result);
+    }
   status=listen(server_socket,DPCPendingConnections);
   if (status != 0)
     ThrowFatalException(CacheFatalError,"UnableToListen");
@@ -2056,8 +2266,11 @@ MagickExport void DistributePixelCacheServer(const int port,
         continue;
       }
     SetSocketReceiveTimeout(*client_socket_ptr,5.0);
-    SetSocketNoDelay(*client_socket_ptr);
-    SetSocketKeepAlive(*client_socket_ptr);
+    if (unix_socket == MagickFalse)
+      {
+        SetSocketNoDelay(*client_socket_ptr);
+        SetSocketKeepAlive(*client_socket_ptr);
+      }
 #if defined(MAGICKCORE_THREAD_SUPPORT)
     status=pthread_create(&thread_id,&attributes,
       DistributePixelCacheConnectionHandler,(void *) client_socket_ptr);
diff --git a/config/policy-limited.xml b/config/policy-limited.xml
index de8953c25..f2d870e14 100644
--- a/config/policy-limited.xml
+++ b/config/policy-limited.xml
@@ -57,12 +57,11 @@
   <!-- Maximum number of simultaneously open pixel cache files. -->
   <policy domain="resource" name="file" value="768"/>

-  <!-- Maximum heap memory used for pixel cache data. Excess pixels are
-       stored in mapped or disk-backed cache. -->
+  <!-- Maximum heap memory used for pixel cache data. Excess pixels are stored in mapped or
+       disk-backed cache. -->
   <policy domain="resource" name="memory" value="768MiB"/>

-  <!-- Maximum memory-mapped pixel cache size. Excess cache data is
-       written to disk. -->
+  <!-- Maximum memory-mapped pixel cache size. Excess cache data is written to disk. -->
   <policy domain="resource" name="map" value="2GiB"/>

   <!-- Maximum in-memory image area before pixels are cached to disk. -->
@@ -92,10 +91,10 @@
   <!-- Optional: fully synchronize image cache data to disk before closing. -->
   <!-- <policy domain="cache" name="synchronize" value="true"/> -->

-  <!-- Optional: shared secret used by distributed pixel cache operations.
-       Replace with a site-specific value if enabled. -->
-  <!-- <policy domain="cache" name="shared-secret"
-            value="secret-passphrase" stealth="true"/> -->
+  <!-- Optional: shared secret used by distributed pixel cache operations.  Replace with a
+       site-specific value if enabled. -->
+  <!-- <policy domain="cache" name="shared-secret" value="secret-passphrase" stealth="true"/> -->
+  <!-- <policy domain="cache" name="unix-socket" value="/run/magick/dpc.sock"/> -->

   <!-- Optional: disable execution of all delegates. -->
   <!-- <policy domain="delegate" rights="none" pattern="*"/> -->
@@ -118,9 +117,9 @@
   <!--
     Restrict embedded scripting coders.

-    Certain modules are denied, whereas, read access is denied while write
-    access remains permitted for others.  This allows ImageMagick to generate
-    these formats without accepting potentially untrusted input through them.
+    Certain modules are denied, whereas, read access is denied while write access remains permitted
+    for others.  This allows ImageMagick to generate these formats without accepting potentially
+    untrusted input through them.
   -->
   <policy domain="module" rights="none" pattern="{MSL,URL,VIDEO}"/>
   <policy domain="coder" rights="write" pattern="{AI,EPS,MVG,PDF,PS,SVG,TXT,XPS}"/>
@@ -138,7 +137,6 @@
   <policy domain="system" name="max-profile-size" value="16MiB"/>
   <policy domain="system" name="max-profile-count" value="16"/>

-  <!-- Treat filenames with percent signs (%) as plain text rather than
-       formatting placeholders. -->
+  <!-- Treat filenames with percent signs (%) as plain text rather than formatting placeholders. -->
   <policy domain="system" name="filename:literal" value="true"/>
 </policymap>
diff --git a/config/policy-open.xml b/config/policy-open.xml
index 599b74b2c..7f7f9b8a2 100644
--- a/config/policy-open.xml
+++ b/config/policy-open.xml
@@ -120,33 +120,27 @@
   <!-- <policy domain="resource" name="throttle" value="2"/> -->

   <!-- Use a private directory for ImageMagick temporary files. -->
-  <!-- <policy domain="resource" name="temporary-path"
-             value="/magick/tmp/"/> -->
+  <!-- <policy domain="resource" name="temporary-path" value="/magick/tmp/"/> -->

   <!-- ================================================================== -->
   <!-- Pixel Cache Policies                                                -->
   <!-- ================================================================== -->

   <!-- Use anonymous memory mapping to initialize cache memory. -->
-  <!-- <policy domain="cache" name="memory-map"
-             value="anonymous"/> -->
+  <!-- <policy domain="cache" name="memory-map" value="anonymous"/> -->

   <!-- Force cache data to be flushed and synchronized to disk. -->
-  <!-- <policy domain="cache" name="synchronize"
-             value="true"/> -->
+  <!-- <policy domain="cache" name="synchronize" value="true"/> -->

   <!-- Shared secret for distributed pixel cache clients. -->
-  <!-- <policy domain="cache" name="shared-secret"
-             value="secret-passphrase" stealth="true"/> -->
+  <!-- <policy domain="cache" name="shared-secret" value="secret-passphrase" stealth="true"/> -->
+  <!-- <policy domain="cache" name="unix-socket" value="/run/magick/dpc.sock"/> -->

   <!-- Maximum authenticated distributed pixel cache clients. -->
-  <!-- <policy domain="cache" name="max-dpc-clients"
-             value="128"/> -->
+  <!-- <policy domain="cache" name="max-dpc-clients" value="128"/> -->

   <!-- Maximum unauthenticated distributed pixel cache clients. -->
-  <!-- <policy domain="cache"
-             name="max-dpc-unauthenticated-clients"
-             value="16"/> -->
+  <!-- <policy domain="cache" name="max-dpc-unauthenticated-clients" value="16"/> -->

   <!-- ================================================================== -->
   <!-- Delegate and Filter Policies                                        -->
@@ -177,13 +171,12 @@
   <!--
     Restrict embedded scripting coders.

-    Certain modules are denied, whereas, read access is denied while write
-    access remains permitted for others.  This allows ImageMagick to generate
-    these formats without accepting potentially untrusted input through them.
+    Certain modules are denied, whereas, read access is denied while write access remains permitted
+    for others.  This allows ImageMagick to generate these formats without accepting potentially
+    untrusted input through them.
   -->
   <!-- <policy domain="module" rights="none" pattern="{MSL,URL,VIDEO}"/> -->
-  <!-- <policy domain="coder" rights="write"
-          pattern="{AI,EPS,MVG,PDF,PS,SVG,TXT,XPS}"/> -->
+  <!-- <policy domain="coder" rights="write" pattern="{AI,EPS,MVG,PDF,PS,SVG,TXT,XPS}"/> -->

   <!-- ================================================================== -->
   <!-- System Policies                                                     -->
@@ -193,33 +186,22 @@
   <!-- <policy domain="system" name="shred" value="1"/> -->

   <!-- Initialize newly allocated memory with zeros. -->
-  <!-- <policy domain="system" name="memory-map"
-             value="anonymous"/> -->
+  <!-- <policy domain="system" name="memory-map" value="anonymous"/> -->

   <!-- Maximum permitted single memory allocation request. -->
-  <!-- <policy domain="system" name="max-memory-request"
-             value="256MiB"/> -->
+  <!-- <policy domain="system" name="max-memory-request" value="256MiB"/> -->

   <!-- Maximum size and count of an image profile. -->
-  <!-- <policy domain="system" name="max-profile-size"
-             value="16MiB"/> -->
-  <!-- <policy domain="system" name="max-profile-count"
-             value="16"/> -->
+  <!-- <policy domain="system" name="max-profile-size" value="16MiB"/> -->
+  <!-- <policy domain="system" name="max-profile-count" value="16"/> -->

   <!-- Refuse paths whose basename is a symbolic link. -->
-  <!-- <policy domain="system"
-             name="symlink"
-             rights="none"
-             pattern="follow"/> -->
+  <!-- <policy domain="system" name="symlink" rights="none" pattern="follow"/> -->

   <!-- Disable SVG entity substitution. -->
-  <!-- <policy domain="system"
-             name="svg"
-             rights="none"
-             pattern="substitute-entities"/> -->
+  <!-- <policy domain="system" name="svg" rights="none" pattern="substitute-entities"/> -->

-  <!-- Treat filenames with percent signs (%) as plain text rather than
-       formatting placeholders. -->
+  <!-- Treat filenames with percent signs (%) as plain text rather than formatting placeholders. -->
   <!-- <policy domain="system" name="filename:literal" value="true"/> -->

   <!-- Temporarily take ImageMagick offline for maintenance -->
diff --git a/config/policy-secure.xml b/config/policy-secure.xml
index 883d804d0..606609d1a 100644
--- a/config/policy-secure.xml
+++ b/config/policy-secure.xml
@@ -88,8 +88,8 @@
   <policy domain="cache" name="synchronize" value="true"/>

   <!-- Shared secret for distributed cache operations. -->
-  <!-- <policy domain="cache" name="shared-secret"
-            value="secret-passphrase" stealth="true"/> -->
+  <!-- <policy domain="cache" name="shared-secret" value="secret-passphrase" stealth="true"/> -->
+  <!-- <policy domain="cache" name="unix-socket" value="/run/magick/dpc.sock"/> -->

   <!-- Disable execution of all delegates. -->
   <policy domain="delegate" rights="none" pattern="*"/>
@@ -118,9 +118,9 @@
   <!--
     Restrict embedded scripting coders.

-    Certain modules are denied, whereas, read access is denied while write
-    access remains permitted for others.  This allows ImageMagick to generate
-    these formats without accepting potentially untrusted input through them.
+    Certain modules are denied, whereas, read access is denied while write access remains permitted
+    for others.  This allows ImageMagick to generate these formats without accepting potentially
+    untrusted input through them.
   -->
   <policy domain="module" rights="none" pattern="{MSL,URL,VIDEO}"/>
   <policy domain="coder" rights="write" pattern="{AI,EPS,MVG,PDF,PS,SVG,TEXT,TXT,XPS}"/>
@@ -139,10 +139,8 @@
   <policy domain="system" name="max-profile-count" value="16"/>

   <!-- Fail if the target path is a symbolic link. -->
-  <policy domain="system" name="symlink"
-          rights="none" pattern="follow"/>
+  <policy domain="system" name="symlink" rights="none" pattern="follow"/>

-  <!-- Treat filenames with percent signs (%) as plain text rather than
-       formatting placeholders. -->
+  <!-- Treat filenames with percent signs (%) as plain text rather than formatting placeholders. -->
   <policy domain="system" name="filename:literal" value="true"/>
 </policymap>
diff --git a/config/policy-websafe.xml b/config/policy-websafe.xml
index 15e9381e4..eabd408c9 100644
--- a/config/policy-websafe.xml
+++ b/config/policy-websafe.xml
@@ -126,14 +126,13 @@
   <!--
     Restrict embedded scripting coders.

-    Certain modules are denied, whereas, read access is denied while write
-    access remains permitted for others.  This allows ImageMagick to generate
-    these formats without accepting potentially untrusted input through them.
+    Certain modules are denied, whereas, read access is denied while write access remains permitted
+    for others.  This allows ImageMagick to generate these formats without accepting potentially
+    untrusted input through them.
   -->
   <policy domain="module" rights="none" pattern="{MSL,URL,VIDEO}"/>
   <policy domain="coder" rights="write" pattern="{AI,EPS,MVG,PDF,PS,SVG,TXT,XPS}"/>

-  <!-- Treat filenames with percent signs (%) as plain text rather than
-       formatting placeholders. -->
+  <!-- Treat filenames with percent signs (%) as plain text rather than formatting placeholders. -->
   <policy domain="system" name="filename:literal" value="true"/>
 </policymap>