]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Only use domain socket if we can access it, and clean up conditional code.
authormike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Wed, 1 Feb 2006 16:54:50 +0000 (16:54 +0000)
committermike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Wed, 1 Feb 2006 16:54:50 +0000 (16:54 +0000)
cups/usersys.c:
    - cupsServer(): Only use domain socket if it is rwx for others.

scheduler/listen.c:
    - cupsdStartListening(): Fix indentation of preprocessor
      directives (# must appear in column 0/1)

git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@5041 7a7537e8-13f0-0310-91df-b6672ffda945

cups/usersys.c
scheduler/listen.c

index c9638672a262f76d5ce26b4c0b3ea16d31c377c1..1393a9aab2674bd42bd752a1dfba90cb7a0fd488 100644 (file)
@@ -44,6 +44,7 @@
 #include "http-private.h"
 #include "globals.h"
 #include <stdlib.h>
+#include <sys/stat.h>
 #ifdef WIN32
 #  include <windows.h>
 #endif /* WIN32 */
@@ -184,6 +185,9 @@ cupsServer(void)
   char         line[1024],             /* Line from file */
                *value;                 /* Value on line */
   int          linenum;                /* Line number in file */
+#ifdef CUPS_DEFAULT_DOMAINSOCKET
+  struct stat  sockinfo;               /* Domain socket information */
+#endif /* CUPS_DEFAULT_DOMAINSOCKET */
   _cups_globals_t *cg = _cupsGlobals();        /* Pointer to library globals */
 
 
@@ -218,7 +222,13 @@ cupsServer(void)
       }
 
 #ifdef CUPS_DEFAULT_DOMAINSOCKET
-      if (!access(CUPS_DEFAULT_DOMAINSOCKET, 0))
+     /*
+      * If we are compiled with domain socket support, only use the
+      * domain socket if it exists and has the right permissions...
+      */
+
+      if (!stat(CUPS_DEFAULT_DOMAINSOCKET, &sockinfo) &&
+          (sockinfo.st_mode & S_IRWXO) == S_IRWXO)
         server = CUPS_DEFAULT_DOMAINSOCKET;
       else
 #endif /* CUPS_DEFAULT_DOMAINSOCKET */
index b3107a7b04bf4a4dde9dbb6f740c2686ba8d5395..ed8ed7b625aa469c0fe05638d8a7c9b56dacca71 100644 (file)
@@ -193,20 +193,20 @@ cupsdStartListening(void)
       */
   
       val = 1;
-  #ifdef __sun
+#ifdef __sun
       setsockopt(lis->fd, SOL_SOCKET, SO_REUSEADDR, (char *)&val, sizeof(val));
-  #else
+#else
       setsockopt(lis->fd, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val));
-  #endif /* __sun */
+#endif /* __sun */
   
      /*
       * Bind to the port we found...
       */
   
-  #ifdef AF_INET6
+#ifdef AF_INET6
       if (lis->address.addr.sa_family == AF_INET6)
       {
-  #  ifdef IPV6_V6ONLY
+#  ifdef IPV6_V6ONLY
        /*
        * Accept only IPv6 connections on this socket, to avoid
        * potential security issues and to make all platforms behave
@@ -214,19 +214,19 @@ cupsdStartListening(void)
        */
   
        val = 1;
-  #    ifdef __sun
+#    ifdef __sun
        setsockopt(lis->fd, IPPROTO_IPV6, IPV6_V6ONLY, (char *)&val, sizeof(val));
-  #    else
+#    else
        setsockopt(lis->fd, IPPROTO_IPV6, IPV6_V6ONLY, &val, sizeof(val));
-  #    endif /* __sun */
-  #  endif /* IPV6_V6ONLY */
+#    endif /* __sun */
+#  endif /* IPV6_V6ONLY */
   
        status = bind(lis->fd, (struct sockaddr *)&(lis->address),
                      httpAddrLength(&(lis->address)));
       }
       else
-  #endif /* AF_INET6 */
-  #ifdef AF_LOCAL
+#endif /* AF_INET6 */
+#ifdef AF_LOCAL
       if (lis->address.addr.sa_family == AF_LOCAL)
       {
        mode_t  mask;                   /* Umask setting */
@@ -258,7 +258,7 @@ cupsdStartListening(void)
        umask(mask);
       }
       else
-  #endif /* AF_LOCAL */
+#endif /* AF_LOCAL */
       status = bind(lis->fd, (struct sockaddr *)&(lis->address),
                    sizeof(lis->address.ipv4));