]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
The scheduler now supports multiple addresses in Allow and Deny lines, just
authormike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Thu, 18 Sep 2008 17:43:37 +0000 (17:43 +0000)
committermike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Thu, 18 Sep 2008 17:43:37 +0000 (17:43 +0000)
like Apache (STR #2947)

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

CHANGES.txt
scheduler/conf.c

index bc6050185fbc26b638bbcec98d655454129b6ac2..6689e453f7c8e50ffa48e23651ffb58eeeafe4f0 100644 (file)
@@ -4,6 +4,8 @@ CHANGES.txt - 2008-09-18
 CHANGES IN CUPS V1.4b1
 
        - Documentation updates (STR #2567)
+       - The scheduler now supports multiple addresses in Allow and
+         Deny lines, just like Apache (STR #2947)
        - Added CUPS_JOBTYPE environment variable for job filters so
          they know whether they are printing a banner or document
          file (STR #2799)
index a820b3c4629c4e6e04e1559165ec7c1f926dbb5a..6ce7ae55c2b85ff35d466eb8dfe41173fc2c802a 100644 (file)
@@ -1690,92 +1690,113 @@ parse_aaa(cupsd_location_t *loc,       /* I - Location */
     * Deny [From] host/ip...
     */
 
-    if (!strncasecmp(value, "from", 4))
+    while (*value)
     {
-     /*
-      * Strip leading "from"...
-      */
+      if (!strncasecmp(value, "from", 4))
+      {
+       /*
+       * Strip leading "from"...
+       */
 
-      value += 4;
+       value += 4;
 
-      while (isspace(*value & 255))
-       value ++;
-    }
+       while (isspace(*value & 255))
+         value ++;
 
-   /*
-    * Figure out what form the allow/deny address takes:
-    *
-    *    All
-    *    None
-    *    *.domain.com
-    *    .domain.com
-    *    host.domain.com
-    *    nnn.*
-    *    nnn.nnn.*
-    *    nnn.nnn.nnn.*
-    *    nnn.nnn.nnn.nnn
-    *    nnn.nnn.nnn.nnn/mm
-    *    nnn.nnn.nnn.nnn/mmm.mmm.mmm.mmm
-    */
+        if (!*value)
+         break;
+      }
 
-    if (!strcasecmp(value, "all"))
-    {
      /*
-      * All hosts...
+      * Find the end of the value...
       */
 
-      if (!strcasecmp(line, "Allow"))
-       cupsdAllowIP(loc, zeros, zeros);
-      else
-       cupsdDenyIP(loc, zeros, zeros);
-    }
-    else if (!strcasecmp(value, "none"))
-    {
+      for (valptr = value; *valptr && !isspace(*valptr & 255); valptr ++);
+
+      while (isspace(*valptr & 255))
+        *valptr++ = '\0';
+
      /*
-      * No hosts...
+      * Figure out what form the allow/deny address takes:
+      *
+      *    All
+      *    None
+      *    *.domain.com
+      *    .domain.com
+      *    host.domain.com
+      *    nnn.*
+      *    nnn.nnn.*
+      *    nnn.nnn.nnn.*
+      *    nnn.nnn.nnn.nnn
+      *    nnn.nnn.nnn.nnn/mm
+      *    nnn.nnn.nnn.nnn/mmm.mmm.mmm.mmm
       */
 
-      if (!strcasecmp(line, "Allow"))
-       cupsdAllowIP(loc, ones, zeros);
-      else
-       cupsdDenyIP(loc, ones, zeros);
-    }
+      if (!strcasecmp(value, "all"))
+      {
+       /*
+       * All hosts...
+       */
+
+       if (!strcasecmp(line, "Allow"))
+         cupsdAllowIP(loc, zeros, zeros);
+       else
+         cupsdDenyIP(loc, zeros, zeros);
+      }
+      else if (!strcasecmp(value, "none"))
+      {
+       /*
+       * No hosts...
+       */
+
+       if (!strcasecmp(line, "Allow"))
+         cupsdAllowIP(loc, ones, zeros);
+       else
+         cupsdDenyIP(loc, ones, zeros);
+      }
 #ifdef AF_INET6
-    else if (value[0] == '*' || value[0] == '.' || 
-             (!isdigit(value[0] & 255) && value[0] != '['))
+      else if (value[0] == '*' || value[0] == '.' || 
+              (!isdigit(value[0] & 255) && value[0] != '['))
 #else
-    else if (value[0] == '*' || value[0] == '.' || !isdigit(value[0] & 255))
+      else if (value[0] == '*' || value[0] == '.' || !isdigit(value[0] & 255))
 #endif /* AF_INET6 */
-    {
-     /*
-      * Host or domain name...
-      */
+      {
+       /*
+       * Host or domain name...
+       */
 
-      if (value[0] == '*')
-       value ++;
+       if (value[0] == '*')
+         value ++;
 
-      if (!strcasecmp(line, "Allow"))
-       cupsdAllowHost(loc, value);
+       if (!strcasecmp(line, "Allow"))
+         cupsdAllowHost(loc, value);
+       else
+         cupsdDenyHost(loc, value);
+      }
       else
-       cupsdDenyHost(loc, value);
-    }
-    else
-    {
-     /*
-      * One of many IP address forms...
-      */
-
-      if (!get_addr_and_mask(value, ip, mask))
       {
-        cupsdLogMessage(CUPSD_LOG_ERROR, "Bad netmask value %s on line %d.",
-                       value, linenum);
-        return (0);
+       /*
+       * One of many IP address forms...
+       */
+
+       if (!get_addr_and_mask(value, ip, mask))
+       {
+         cupsdLogMessage(CUPSD_LOG_ERROR, "Bad netmask value %s on line %d.",
+                         value, linenum);
+         return (0);
+       }
+
+       if (!strcasecmp(line, "Allow"))
+         cupsdAllowIP(loc, ip, mask);
+       else
+         cupsdDenyIP(loc, ip, mask);
       }
 
-      if (!strcasecmp(line, "Allow"))
-       cupsdAllowIP(loc, ip, mask);
-      else
-       cupsdDenyIP(loc, ip, mask);
+     /*
+      * Advance to next value...
+      */
+
+      value = valptr;
     }
   }
   else if (!strcasecmp(line, "AuthType"))
@@ -2579,93 +2600,114 @@ read_configuration(cups_file_t *fp)    /* I - File to read from */
                        "Unable to initialize browse access control list!");
       else
       {
-       if (!strncasecmp(value, "from ", 5))
+       while (*value)
        {
-        /*
-          * Strip leading "from"...
-         */
+         if (!strncasecmp(value, "from", 4))
+         {
+          /*
+           * Strip leading "from"...
+           */
 
-         value += 5;
+           value += 4;
 
-         while (isspace(*value))
-           value ++;
-       }
+           while (isspace(*value & 255))
+             value ++;
 
-       /*
-       * Figure out what form the allow/deny address takes:
-       *
-       *    All
-       *    None
-       *    *.domain.com
-       *    .domain.com
-       *    host.domain.com
-       *    nnn.*
-       *    nnn.nnn.*
-       *    nnn.nnn.nnn.*
-       *    nnn.nnn.nnn.nnn
-       *    nnn.nnn.nnn.nnn/mm
-       *    nnn.nnn.nnn.nnn/mmm.mmm.mmm.mmm
-       */
+           if (!*value)
+             break;
+         }
 
-       if (!strcasecmp(value, "all"))
-       {
         /*
-          * All hosts...
+         * Find the end of the value...
          */
 
-          if (!strcasecmp(line, "BrowseAllow"))
-           cupsdAllowIP(location, zeros, zeros);
-         else
-           cupsdDenyIP(location, zeros, zeros);
-       }
-       else if (!strcasecmp(value, "none"))
-       {
+         for (valueptr = value; *valueptr && !isspace(*valueptr & 255); valueptr ++);
+
+         while (isspace(*valueptr & 255))
+           *valueptr++ = '\0';
+
         /*
-          * No hosts...
+         * Figure out what form the allow/deny address takes:
+         *
+         *    All
+         *    None
+         *    *.domain.com
+         *    .domain.com
+         *    host.domain.com
+         *    nnn.*
+         *    nnn.nnn.*
+         *    nnn.nnn.nnn.*
+         *    nnn.nnn.nnn.nnn
+         *    nnn.nnn.nnn.nnn/mm
+         *    nnn.nnn.nnn.nnn/mmm.mmm.mmm.mmm
          */
 
-          if (!strcasecmp(line, "BrowseAllow"))
-           cupsdAllowIP(location, ones, zeros);
-         else
-           cupsdDenyIP(location, ones, zeros);
-       }
+         if (!strcasecmp(value, "all"))
+         {
+          /*
+           * All hosts...
+           */
+
+           if (!strcasecmp(line, "BrowseAllow"))
+             cupsdAllowIP(location, zeros, zeros);
+           else
+             cupsdDenyIP(location, zeros, zeros);
+         }
+         else if (!strcasecmp(value, "none"))
+         {
+          /*
+           * No hosts...
+           */
+
+           if (!strcasecmp(line, "BrowseAllow"))
+             cupsdAllowIP(location, ones, zeros);
+           else
+             cupsdDenyIP(location, ones, zeros);
+         }
 #ifdef AF_INET6
-       else if (value[0] == '*' || value[0] == '.' || 
-                (!isdigit(value[0] & 255) && value[0] != '['))
+         else if (value[0] == '*' || value[0] == '.' || 
+                  (!isdigit(value[0] & 255) && value[0] != '['))
 #else
-       else if (value[0] == '*' || value[0] == '.' || !isdigit(value[0] & 255))
+         else if (value[0] == '*' || value[0] == '.' || !isdigit(value[0] & 255))
 #endif /* AF_INET6 */
-       {
-        /*
-          * Host or domain name...
-         */
+         {
+          /*
+           * Host or domain name...
+           */
 
-         if (value[0] == '*')
-           value ++;
+           if (value[0] == '*')
+             value ++;
 
-          if (!strcasecmp(line, "BrowseAllow"))
-           cupsdAllowHost(location, value);
+           if (!strcasecmp(line, "BrowseAllow"))
+             cupsdAllowHost(location, value);
+           else
+             cupsdDenyHost(location, value);
+         }
          else
-           cupsdDenyHost(location, value);
-       }
-       else
-       {
-        /*
-          * One of many IP address forms...
-         */
-
-          if (!get_addr_and_mask(value, ip, mask))
          {
-            cupsdLogMessage(CUPSD_LOG_ERROR, "Bad netmask value %s on line %d.",
-                           value, linenum);
-           break;
-         }
+          /*
+           * One of many IP address forms...
+           */
 
-          if (!strcasecmp(line, "BrowseAllow"))
-           cupsdAllowIP(location, ip, mask);
-         else
-           cupsdDenyIP(location, ip, mask);
+           if (!get_addr_and_mask(value, ip, mask))
+           {
+             cupsdLogMessage(CUPSD_LOG_ERROR, "Bad netmask value %s on line %d.",
+                             value, linenum);
+             break;
+           }
+
+           if (!strcasecmp(line, "BrowseAllow"))
+             cupsdAllowIP(location, ip, mask);
+           else
+             cupsdDenyIP(location, ip, mask);
+         }
        }
+
+       /*
+        * Advance to next value...
+       */
+
+        value = valueptr;
       }
     }
     else if (!strcasecmp(line, "BrowseRelay") && value)