]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Do not allow users to configure CUPS with "User" set to "root" or any
authormike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Thu, 10 Nov 2005 17:36:06 +0000 (17:36 +0000)
committermike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Thu, 10 Nov 2005 17:36:06 +0000 (17:36 +0000)
other account with a UID == 0.

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

scheduler/conf.c

index 49b7dfbba4fc1fd33f12d55227748da90d409a59..aeec69ab0e864559af4441bbfd07aa07780d4f28 100644 (file)
@@ -2435,22 +2435,46 @@ read_configuration(cups_file_t *fp)     /* I - File to read from */
       * User ID to run as...
       */
 
-      if (isdigit(value[0]))
-        User = atoi(value);
-      else
+      if (value && isdigit(value[0] & 255))
+      {
+        int uid = atoi(value);
+
+       if (!uid)
+         cupsdLogMessage(CUPSD_LOG_ERROR,
+                         "Will not use User 0 as specified on line %d "
+                         "for security reasons.  You must use a non-"
+                         "privileged account instead.",
+                         linenum);
+        else
+         User = atoi(value);
+      }
+      else if (value)
       {
         struct passwd *p;      /* Password information */
 
         endpwent();
        p = getpwnam(value);
 
-       if (p != NULL)
-         User = p->pw_uid;
+       if (p)
+       {
+         if (!p->pw_uid)
+           cupsdLogMessage(CUPSD_LOG_ERROR,
+                           "Will not use User %s (UID=0) as specified on line "
+                           "%d for security reasons.  You must use a non-"
+                           "privileged account instead.",
+                           value, linenum);
+         else
+           User = p->pw_uid;
+       }
        else
          cupsdLogMessage(CUPSD_LOG_ERROR,
                          "Unknown User \"%s\" on line %d, ignoring!",
                          value, linenum);
       }
+      else
+       cupsdLogMessage(CUPSD_LOG_ERROR,
+                       "User directive on line %d missing the username!",
+                       linenum);
     }
     else if (!strcasecmp(line, "Group"))
     {