]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - scheduler/conf.c
Merge more Common UNIX Printing System -> CUPS changes.
[thirdparty/cups.git] / scheduler / conf.c
index b3fcbc379183b8466806ccf1a2dad6f94fd39849..26ca30b9624181ebedb026cbdaa56ab2fdd16aa3 100644 (file)
@@ -1,9 +1,9 @@
 /*
- * "$Id: conf.c 7694 2008-06-26 00:23:20Z mike $"
+ * "$Id: conf.c 7952 2008-09-17 00:56:20Z mike $"
  *
  *   Configuration routines for the Common UNIX Printing System (CUPS).
  *
- *   Copyright 2007-2008 by Apple Inc.
+ *   Copyright 2007-2009 by Apple Inc.
  *   Copyright 1997-2007 by Easy Software Products, all rights reserved.
  *
  *   These coded instructions, statements, and computer programs are the
@@ -21,6 +21,7 @@
  *   get_addr_and_mask()      - Get an IP address and netmask.
  *   parse_aaa()              - Parse authentication, authorization, and
  *                              access control lines.
+ *   parse_fatal_errors()     - Parse FatalErrors values in a string.
  *   parse_groups()           - Parse system group names in a string.
  *   parse_protocols()        - Parse browse protocols in a string.
  *   read_configuration()     - Read a configuration file.
@@ -94,6 +95,7 @@ static const cupsd_var_t      variables[] =
   { "BrowseRemoteOptions",     &BrowseRemoteOptions,   CUPSD_VARTYPE_STRING },
   { "BrowseShortNames",                &BrowseShortNames,      CUPSD_VARTYPE_BOOLEAN },
   { "BrowseTimeout",           &BrowseTimeout,         CUPSD_VARTYPE_INTEGER },
+  { "BrowseWebIF",             &BrowseWebIF,           CUPSD_VARTYPE_BOOLEAN },
   { "Browsing",                        &Browsing,              CUPSD_VARTYPE_BOOLEAN },
   { "CacheDir",                        &CacheDir,              CUPSD_VARTYPE_STRING },
   { "Classification",          &Classification,        CUPSD_VARTYPE_STRING },
@@ -103,6 +105,7 @@ static const cupsd_var_t    variables[] =
   { "DefaultCharset",          &DefaultCharset,        CUPSD_VARTYPE_STRING },
   { "DefaultLanguage",         &DefaultLanguage,       CUPSD_VARTYPE_STRING },
   { "DefaultLeaseDuration",    &DefaultLeaseDuration,  CUPSD_VARTYPE_INTEGER },
+  { "DefaultPaperSize",                &DefaultPaperSize,      CUPSD_VARTYPE_STRING },
   { "DefaultPolicy",           &DefaultPolicy,         CUPSD_VARTYPE_STRING },
   { "DefaultShared",           &DefaultShared,         CUPSD_VARTYPE_BOOLEAN },
   { "DirtyCleanInterval",      &DirtyCleanInterval,    CUPSD_VARTYPE_INTEGER },
@@ -147,6 +150,7 @@ static const cupsd_var_t    variables[] =
   { "MaxSubscriptionsPerJob",  &MaxSubscriptionsPerJob,        CUPSD_VARTYPE_INTEGER },
   { "MaxSubscriptionsPerPrinter",&MaxSubscriptionsPerPrinter,  CUPSD_VARTYPE_INTEGER },
   { "MaxSubscriptionsPerUser", &MaxSubscriptionsPerUser,       CUPSD_VARTYPE_INTEGER },
+  { "MultipleOperationTimeout",        &MultipleOperationTimeout,      CUPSD_VARTYPE_INTEGER },
   { "PageLog",                 &PageLog,               CUPSD_VARTYPE_STRING },
   { "PageLogFormat",           &PageLogFormat,         CUPSD_VARTYPE_STRING },
   { "PreserveJobFiles",                &JobFiles,              CUPSD_VARTYPE_BOOLEAN },
@@ -198,6 +202,7 @@ static int          get_addr_and_mask(const char *value, unsigned *ip,
                                          unsigned *mask);
 static int             parse_aaa(cupsd_location_t *loc, char *line,
                                  char *value, int linenum);
+static int             parse_fatal_errors(const char *s);
 static int             parse_groups(const char *s);
 static int             parse_protocols(const char *s);
 static int             read_configuration(cups_file_t *fp);
@@ -222,6 +227,7 @@ cupsdCheckPermissions(
   int          dir_created = 0;        /* Did we create a directory? */
   char         pathname[1024];         /* File name with prefix */
   struct stat  fileinfo;               /* Stat buffer */
+  int          is_symlink;             /* Is "filename" a symlink? */
 
 
  /*
@@ -238,7 +244,7 @@ cupsdCheckPermissions(
   * See if we can stat the file/directory...
   */
 
-  if (stat(filename, &fileinfo))
+  if (lstat(filename, &fileinfo))
   {
     if (errno == ENOENT && create_dir)
     {
@@ -259,14 +265,25 @@ cupsdCheckPermissions(
         return (-1);
       }
 
-      dir_created = 1;
+      dir_created      = 1;
+      fileinfo.st_mode = mode | S_IFDIR;
     }
     else
       return (create_dir ? -1 : 1);
   }
 
+  if ((is_symlink = S_ISLNK(fileinfo.st_mode)) != 0)
+  {
+    if (stat(filename, &fileinfo))
+    {
+      cupsdLogMessage(CUPSD_LOG_ERROR, "\"%s\" is a bad symlink - %s",
+                      filename, strerror(errno));
+      return (-1);
+    }
+  }
+
  /*
-  * Make sure it's a regular file...
+  * Make sure it's a regular file or a directory as needed...
   */
 
   if (!dir_created && !is_dir && !S_ISREG(fileinfo.st_mode))
@@ -285,6 +302,13 @@ cupsdCheckPermissions(
     return (-1);
   }
 
+ /*
+  * If the filename is a symlink, do not change permissions (STR #2937)...
+  */
+
+  if (is_symlink)
+    return (0);
+
  /*
   * Fix owner, group, and mode as needed...
   */
@@ -403,12 +427,14 @@ cupsdReadConfiguration(void)
 
   cupsdDeleteAllListeners();
 
+  RemoteAccessEnabled = 0;
+
  /*
   * String options...
   */
 
-  cupsdSetString(&ServerName, httpGetHostname(NULL, temp, sizeof(temp)));
-  cupsdSetStringf(&ServerAdmin, "root@%s", temp);
+  cupsdClearString(&ServerName);
+  cupsdClearString(&ServerAdmin);
   cupsdSetString(&ServerBin, CUPS_SERVERBIN);
   cupsdSetString(&RequestRoot, CUPS_REQUESTS);
   cupsdSetString(&CacheDir, CUPS_CACHEDIR);
@@ -432,6 +458,9 @@ cupsdReadConfiguration(void)
 
   if (!strcmp(CUPS_DEFAULT_PRINTCAP, "/etc/printers.conf"))
     PrintcapFormat = PRINTCAP_SOLARIS;
+  else if (!strcmp(CUPS_DEFAULT_PRINTCAP,
+                   "/Library/Preferences/org.cups.printers.plist"))
+    PrintcapFormat = PRINTCAP_PLIST;
   else
     PrintcapFormat = PRINTCAP_BSD;
 
@@ -462,6 +491,8 @@ cupsdReadConfiguration(void)
 
   cupsdSetString(&DefaultCharset, _cupsEncodingName(language->encoding));
 
+  cupsdClearString(&DefaultPaperSize);
+
   cupsdSetString(&RIPCache, "8m");
 
   cupsdSetString(&TempDir, NULL);
@@ -519,46 +550,51 @@ cupsdReadConfiguration(void)
   * Numeric options...
   */
 
-  AccessLogLevel        = CUPSD_ACCESSLOG_ACTIONS;
-  ConfigFilePerm        = CUPS_DEFAULT_CONFIG_FILE_PERM;
-  DefaultAuthType       = CUPSD_AUTH_BASIC;
+  AccessLogLevel           = CUPSD_ACCESSLOG_ACTIONS;
+  ConfigFilePerm           = CUPS_DEFAULT_CONFIG_FILE_PERM;
+  FatalErrors              = parse_fatal_errors(CUPS_DEFAULT_FATAL_ERRORS);
+  DefaultAuthType          = CUPSD_AUTH_BASIC;
 #ifdef HAVE_SSL
-  DefaultEncryption     = HTTP_ENCRYPT_REQUIRED;
+  DefaultEncryption        = HTTP_ENCRYPT_REQUIRED;
+  SSLOptions               = CUPSD_SSL_NONE;
 #endif /* HAVE_SSL */
-  DirtyCleanInterval    = 60;
-  JobRetryLimit         = 5;
-  JobRetryInterval      = 300;
-  FileDevice            = FALSE;
-  FilterLevel           = 0;
-  FilterLimit           = 0;
-  FilterNice            = 0;
-  HostNameLookups       = FALSE;
-  ImplicitClasses       = CUPS_DEFAULT_IMPLICIT_CLASSES;
-  ImplicitAnyClasses    = FALSE;
-  HideImplicitMembers   = TRUE;
-  KeepAlive             = TRUE;
-  KeepAliveTimeout      = DEFAULT_KEEPALIVE;
-  ListenBackLog         = SOMAXCONN;
-  LogFilePerm           = CUPS_DEFAULT_LOG_FILE_PERM;
-  LogLevel              = CUPSD_LOG_WARN;
-  MaxClients            = 100;
-  MaxClientsPerHost     = 0;
-  MaxLogSize            = 1024 * 1024;
-  MaxPrinterHistory     = 10;
-  MaxRequestSize        = 0;
-  ReloadTimeout                = 60;
-  RootCertDuration      = 300;
-  Timeout               = DEFAULT_TIMEOUT;
-  NumSystemGroups       = 0;
-
-  BrowseInterval        = DEFAULT_INTERVAL;
-  BrowsePort            = ippPort();
-  BrowseLocalProtocols  = parse_protocols(CUPS_DEFAULT_BROWSE_LOCAL_PROTOCOLS);
-  BrowseRemoteProtocols = parse_protocols(CUPS_DEFAULT_BROWSE_REMOTE_PROTOCOLS);
-  BrowseShortNames      = CUPS_DEFAULT_BROWSE_SHORT_NAMES;
-  BrowseTimeout         = DEFAULT_TIMEOUT;
-  Browsing              = CUPS_DEFAULT_BROWSING;
-  DefaultShared         = CUPS_DEFAULT_DEFAULT_SHARED;
+  DirtyCleanInterval       = DEFAULT_KEEPALIVE;
+  JobRetryLimit            = 5;
+  JobRetryInterval         = 300;
+  FileDevice               = FALSE;
+  FilterLevel              = 0;
+  FilterLimit              = 0;
+  FilterNice               = 0;
+  HostNameLookups          = FALSE;
+  ImplicitClasses          = CUPS_DEFAULT_IMPLICIT_CLASSES;
+  ImplicitAnyClasses       = FALSE;
+  HideImplicitMembers      = TRUE;
+  KeepAlive                = TRUE;
+  KeepAliveTimeout         = DEFAULT_KEEPALIVE;
+  ListenBackLog            = SOMAXCONN;
+  LogFilePerm              = CUPS_DEFAULT_LOG_FILE_PERM;
+  LogLevel                 = CUPSD_LOG_WARN;
+  LogTimeFormat            = CUPSD_TIME_STANDARD;
+  MaxClients               = 100;
+  MaxClientsPerHost        = 0;
+  MaxLogSize               = 1024 * 1024;
+  MaxPrinterHistory        = 10;
+  MaxRequestSize           = 0;
+  MultipleOperationTimeout = DEFAULT_TIMEOUT;
+  ReloadTimeout                   = DEFAULT_KEEPALIVE;
+  RootCertDuration         = 300;
+  Timeout                  = DEFAULT_TIMEOUT;
+  NumSystemGroups          = 0;
+
+  BrowseInterval           = DEFAULT_INTERVAL;
+  BrowsePort               = ippPort();
+  BrowseLocalProtocols     = parse_protocols(CUPS_DEFAULT_BROWSE_LOCAL_PROTOCOLS);
+  BrowseRemoteProtocols    = parse_protocols(CUPS_DEFAULT_BROWSE_REMOTE_PROTOCOLS);
+  BrowseShortNames         = CUPS_DEFAULT_BROWSE_SHORT_NAMES;
+  BrowseTimeout            = DEFAULT_TIMEOUT;
+  BrowseWebIF              = FALSE;
+  Browsing                 = CUPS_DEFAULT_BROWSING;
+  DefaultShared            = CUPS_DEFAULT_DEFAULT_SHARED;
 
   cupsdSetString(&LPDConfigFile, CUPS_DEFAULT_LPD_CONFIG_FILE);
   cupsdSetString(&SMBConfigFile, CUPS_DEFAULT_SMB_CONFIG_FILE);
@@ -626,14 +662,38 @@ cupsdReadConfiguration(void)
 
   RunUser = getuid();
 
+  cupsdLogMessage(CUPSD_LOG_INFO, "Remote access is %s.",
+                  RemoteAccessEnabled ? "enabled" : "disabled");
+
  /*
   * See if the ServerName is an IP address...
   */
 
+  if (!ServerName)
+  {
+    if (HostNameLookups || RemoteAccessEnabled)
+      httpGetHostname(NULL, temp, sizeof(temp));
+    else if (gethostname(temp, sizeof(temp)))
+    {
+      cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to get hostname: %s",
+                      strerror(errno));
+      strlcpy(temp, "localhost", sizeof(temp));
+    }
+
+    cupsdSetString(&ServerName, temp);
+  }
+
   for (slash = ServerName; isdigit(*slash & 255) || *slash == '.'; slash ++);
 
   ServerNameIsIP = !*slash;
 
+ /*
+  * Make sure ServerAdmin is initialized...
+  */
+
+  if (!ServerAdmin)
+    cupsdSetStringf(&ServerAdmin, "root@%s", ServerName);
+
  /*
   * Use the default system group if none was supplied in cupsd.conf...
   */
@@ -734,7 +794,8 @@ cupsdReadConfiguration(void)
     */
 
     cupsdLogMessage(CUPSD_LOG_EMERG,
-                    "No valid Listen or Port lines were found in the configuration file!");
+                    "No valid Listen or Port lines were found in the "
+                   "configuration file!");
 
    /*
     * Commit suicide...
@@ -772,21 +833,20 @@ cupsdReadConfiguration(void)
   if (ServerCertificate[0] != '/')
     cupsdSetStringf(&ServerCertificate, "%s/%s", ServerRoot, ServerCertificate);
 
-  if (!strncmp(ServerRoot, ServerCertificate, strlen(ServerRoot)))
-  {
-    chown(ServerCertificate, RunUser, Group);
-    chmod(ServerCertificate, 0600);
-  }
+  if (!strncmp(ServerRoot, ServerCertificate, strlen(ServerRoot)) &&
+      cupsdCheckPermissions(ServerCertificate, NULL, 0600, RunUser, Group,
+                            0, 0) < 0 &&
+      (FatalErrors & CUPSD_FATAL_PERMISSIONS))
+    return (0);
 
 #  if defined(HAVE_LIBSSL) || defined(HAVE_GNUTLS)
   if (ServerKey[0] != '/')
     cupsdSetStringf(&ServerKey, "%s/%s", ServerRoot, ServerKey);
 
-  if (!strncmp(ServerRoot, ServerKey, strlen(ServerRoot)))
-  {
-    chown(ServerKey, RunUser, Group);
-    chmod(ServerKey, 0600);
-  }
+  if (!strncmp(ServerRoot, ServerKey, strlen(ServerRoot)) &&
+      cupsdCheckPermissions(ServerKey, NULL, 0600, RunUser, Group, 0, 0) < 0 &&
+      (FatalErrors & CUPSD_FATAL_PERMISSIONS))
+    return (0);
 #  endif /* HAVE_LIBSSL || HAVE_GNUTLS */
 #endif /* HAVE_SSL */
 
@@ -797,30 +857,31 @@ cupsdReadConfiguration(void)
 
   snprintf(temp, sizeof(temp), "%s/rss", CacheDir);
 
-  if (cupsdCheckPermissions(RequestRoot, NULL, 0710, RunUser,
-                           Group, 1, 1) < 0 ||
-      cupsdCheckPermissions(CacheDir, NULL, 0775, RunUser,
-                           Group, 1, 1) < 0 ||
-      cupsdCheckPermissions(temp, NULL, 0775, RunUser,
-                           Group, 1, 1) < 0 ||
-      cupsdCheckPermissions(StateDir, NULL, 0755, RunUser,
-                           Group, 1, 1) < 0 ||
-      cupsdCheckPermissions(StateDir, "certs", RunUser ? 0711 : 0511, User,
-                           SystemGroupIDs[0], 1, 1) < 0 ||
-      cupsdCheckPermissions(ServerRoot, NULL, 0755, RunUser, 
-                           Group, 1, 0) < 0 ||
-      cupsdCheckPermissions(ServerRoot, "ppd", 0755, RunUser,
-                           Group, 1, 1) < 0 ||
-      cupsdCheckPermissions(ServerRoot, "ssl", 0700, RunUser,
-                           Group, 1, 0) < 0 ||
-      cupsdCheckPermissions(ServerRoot, "cupsd.conf", ConfigFilePerm, RunUser,
-                           Group, 0, 0) < 0 ||
-      cupsdCheckPermissions(ServerRoot, "classes.conf", 0600, RunUser,
-                           Group, 0, 0) < 0 ||
-      cupsdCheckPermissions(ServerRoot, "printers.conf", 0600, RunUser,
-                           Group, 0, 0) < 0 ||
-      cupsdCheckPermissions(ServerRoot, "passwd.md5", 0600, User,
-                           Group, 0, 0) < 0)
+  if ((cupsdCheckPermissions(RequestRoot, NULL, 0710, RunUser,
+                            Group, 1, 1) < 0 ||
+       cupsdCheckPermissions(CacheDir, NULL, 0775, RunUser,
+                            Group, 1, 1) < 0 ||
+       cupsdCheckPermissions(temp, NULL, 0775, RunUser,
+                            Group, 1, 1) < 0 ||
+       cupsdCheckPermissions(StateDir, NULL, 0755, RunUser,
+                            Group, 1, 1) < 0 ||
+       cupsdCheckPermissions(StateDir, "certs", RunUser ? 0711 : 0511, User,
+                            SystemGroupIDs[0], 1, 1) < 0 ||
+       cupsdCheckPermissions(ServerRoot, NULL, 0755, RunUser, 
+                            Group, 1, 0) < 0 ||
+       cupsdCheckPermissions(ServerRoot, "ppd", 0755, RunUser,
+                            Group, 1, 1) < 0 ||
+       cupsdCheckPermissions(ServerRoot, "ssl", 0700, RunUser,
+                            Group, 1, 0) < 0 ||
+       cupsdCheckPermissions(ServerRoot, "cupsd.conf", ConfigFilePerm, RunUser,
+                            Group, 0, 0) < 0 ||
+       cupsdCheckPermissions(ServerRoot, "classes.conf", 0600, RunUser,
+                            Group, 0, 0) < 0 ||
+       cupsdCheckPermissions(ServerRoot, "printers.conf", 0600, RunUser,
+                            Group, 0, 0) < 0 ||
+       cupsdCheckPermissions(ServerRoot, "passwd.md5", 0600, User,
+                            Group, 0, 0) < 0) &&
+      (FatalErrors & CUPSD_FATAL_PERMISSIONS))
     return (0);
 
  /*
@@ -870,7 +931,8 @@ cupsdReadConfiguration(void)
     * is under the spool directory or does not exist...
     */
 
-    if (cupsdCheckPermissions(TempDir, NULL, 01770, RunUser, Group, 1, 1) < 0)
+    if (cupsdCheckPermissions(TempDir, NULL, 01770, RunUser, Group, 1, 1) < 0 &&
+       (FatalErrors & CUPSD_FATAL_PERMISSIONS))
       return (0);
   }
 
@@ -880,6 +942,48 @@ cupsdReadConfiguration(void)
 
   cupsdInitEnv();
 
+ /*
+  * Update default paper size setting as needed...
+  */
+
+  if (!DefaultPaperSize)
+  {
+#ifdef HAVE_LIBPAPER
+    char       *paper_result;          /* Paper size name from libpaper */
+
+    if ((paper_result = systempapername()) != NULL)
+      cupsdSetString(&DefaultPaperSize, paper_result);
+    else
+#endif /* HAVE_LIBPAPER */
+    if (!DefaultLanguage ||
+        !strcasecmp(DefaultLanguage, "C") ||
+        !strcasecmp(DefaultLanguage, "POSIX") ||
+       !strcasecmp(DefaultLanguage, "en") ||
+       !strncasecmp(DefaultLanguage, "en.", 3) ||
+       !strncasecmp(DefaultLanguage, "en_US", 5) ||
+       !strncasecmp(DefaultLanguage, "en_CA", 5) ||
+       !strncasecmp(DefaultLanguage, "fr_CA", 5))
+    {
+     /*
+      * These are the only locales that will default to "letter" size...
+      */
+
+      cupsdSetString(&DefaultPaperSize, "Letter");
+    }
+    else
+      cupsdSetString(&DefaultPaperSize, "A4");
+  }
+
+ /*
+  * Update classification setting as needed...
+  */
+
+  if (Classification && !strcasecmp(Classification, "none"))
+    cupsdClearString(&Classification);
+
+  if (Classification)
+    cupsdLogMessage(CUPSD_LOG_INFO, "Security set to \"%s\"", Classification);
+
  /*
   * Check the MaxClients setting, and then allocate memory for it...
   */
@@ -887,8 +991,10 @@ cupsdReadConfiguration(void)
   if (MaxClients > (MaxFDs / 3) || MaxClients <= 0)
   {
     if (MaxClients > 0)
-      cupsdLogMessage(CUPSD_LOG_INFO, "MaxClients limited to 1/3 (%d) of the file descriptor limit (%d)...",
-                 MaxFDs / 3, MaxFDs);
+      cupsdLogMessage(CUPSD_LOG_INFO,
+                      "MaxClients limited to 1/3 (%d) of the file descriptor "
+                     "limit (%d)...",
+                      MaxFDs / 3, MaxFDs);
 
     MaxClients = MaxFDs / 3;
   }
@@ -904,12 +1010,6 @@ cupsdReadConfiguration(void)
   if (MaxActiveJobs > (MaxFDs / 3))
     MaxActiveJobs = MaxFDs / 3;
 
-  if (Classification && !strcasecmp(Classification, "none"))
-    cupsdClearString(&Classification);
-
-  if (Classification)
-    cupsdLogMessage(CUPSD_LOG_INFO, "Security set to \"%s\"", Classification);
-
  /*
   * Update the MaxClientsPerHost value, as needed...
   */
@@ -1098,7 +1198,6 @@ cupsdReadConfiguration(void)
 
     cupsdDeleteAllSubscriptions();
     cupsdFreeAllJobs();
-    cupsdDeleteAllClasses();
     cupsdDeleteAllPrinters();
 
     DefaultPrinter = NULL;
@@ -1131,7 +1230,8 @@ cupsdReadConfiguration(void)
       cupsdLogMessage(CUPSD_LOG_EMERG,
                       "Unable to load MIME database from \"%s\" or \"%s\"!",
                      mimedir, ServerRoot);
-      exit(errno);
+      if (FatalErrors & CUPSD_FATAL_CONFIG)
+        return (0);
     }
 
     cupsdLogMessage(CUPSD_LOG_INFO,
@@ -1622,92 +1722,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"))
@@ -1927,6 +2048,86 @@ parse_aaa(cupsd_location_t *loc, /* I - Location */
 }
 
 
+/*
+ * 'parse_fatal_errors()' - Parse FatalErrors values in a string.
+ */
+
+static int                             /* O - FatalErrors bits */
+parse_fatal_errors(const char *s)      /* I - FatalErrors string */
+{
+  int  fatal;                          /* FatalErrors bits */
+  char value[1024],                    /* Value string */
+       *valstart,                      /* Pointer into value */
+       *valend;                        /* End of value */
+
+
+ /*
+  * Empty FatalErrors line yields NULL pointer...
+  */
+
+  if (!s)
+    return (CUPSD_FATAL_NONE);
+
+ /*
+  * Loop through the value string,...
+  */
+
+  strlcpy(value, s, sizeof(value));
+
+  fatal = CUPSD_FATAL_NONE;
+
+  for (valstart = value; *valstart;)
+  {
+   /*
+    * Get the current space/comma-delimited kind name...
+    */
+
+    for (valend = valstart; *valend; valend ++)
+      if (isspace(*valend & 255) || *valend == ',')
+       break;
+
+    if (*valend)
+      *valend++ = '\0';
+
+   /*
+    * Add the error to the bitmask...
+    */
+
+    if (!strcasecmp(valstart, "all"))
+      fatal = CUPSD_FATAL_ALL;
+    else if (!strcasecmp(valstart, "browse"))
+      fatal |= CUPSD_FATAL_BROWSE;
+    else if (!strcasecmp(valstart, "-browse"))
+      fatal &= ~CUPSD_FATAL_BROWSE;
+    else if (!strcasecmp(valstart, "config"))
+      fatal |= CUPSD_FATAL_CONFIG;
+    else if (!strcasecmp(valstart, "-config"))
+      fatal &= ~CUPSD_FATAL_CONFIG;
+    else if (!strcasecmp(valstart, "listen"))
+      fatal |= CUPSD_FATAL_LISTEN;
+    else if (!strcasecmp(valstart, "-listen"))
+      fatal &= ~CUPSD_FATAL_LISTEN;
+    else if (!strcasecmp(valstart, "log"))
+      fatal |= CUPSD_FATAL_LOG;
+    else if (!strcasecmp(valstart, "-log"))
+      fatal &= ~CUPSD_FATAL_LOG;
+    else if (!strcasecmp(valstart, "permissions"))
+      fatal |= CUPSD_FATAL_PERMISSIONS;
+    else if (!strcasecmp(valstart, "-permissions"))
+      fatal &= ~CUPSD_FATAL_PERMISSIONS;
+    else if (strcasecmp(valstart, "none"))
+      cupsdLogMessage(CUPSD_LOG_ERROR,
+                      "Unknown FatalErrors kind \"%s\" ignored!", valstart);
+
+    for (valstart = valend; *valstart; valstart ++)
+      if (!isspace(*valstart & 255) || *valstart != ',')
+       break;
+  }
+
+  return (fatal);
+}
+
+
 /*
  * 'parse_groups()' - Parse system group names in a string.
  */
@@ -2161,6 +2362,8 @@ read_configuration(cups_file_t *fp)       /* I - File to read from */
       if (linenum == 0)
        return (0);
     }
+    else if (!strcasecmp(line, "FatalErrors"))
+      FatalErrors = parse_fatal_errors(value);
     else if (!strcasecmp(line, "FaxRetryInterval") && value)
     {
       JobRetryInterval = atoi(value);
@@ -2207,6 +2410,25 @@ read_configuration(cups_file_t *fp)      /* I - File to read from */
 
       for (addr = addrlist; addr; addr = addr->next)
       {
+       /*
+        * See if this address is already present...
+       */
+
+        for (lis = (cupsd_listener_t *)cupsArrayFirst(Listeners);
+            lis;
+            lis = (cupsd_listener_t *)cupsArrayNext(Listeners))
+          if (httpAddrEqual(&(addr->addr), &(lis->address)) &&
+             _httpAddrPort(&(addr->addr)) == _httpAddrPort(&(lis->address)))
+           break;
+
+        if (lis)
+       {
+         httpAddrString(&lis->address, temp, sizeof(temp));
+         cupsdLogMessage(CUPSD_LOG_WARN,
+                         "Duplicate listen address \"%s\" ignored!", temp);
+          continue;
+       }
+
        /*
         * Allocate another listener...
        */
@@ -2259,6 +2481,9 @@ read_configuration(cups_file_t *fp)       /* I - File to read from */
 #endif /* AF_LOCAL */
        cupsdLogMessage(CUPSD_LOG_INFO, "Listening to %s:%d (IPv4)", temp,
                         ntohs(lis->address.ipv4.sin_port));
+
+        if (!httpAddrLocalhost(&(lis->address)))
+         RemoteAccessEnabled = 1;
       }
 
      /*
@@ -2410,92 +2635,113 @@ 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 (!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);
          }
 
-          if (!strcasecmp(line, "BrowseAllow"))
-           cupsdAllowIP(location, ip, mask);
-         else
-           cupsdDenyIP(location, ip, mask);
+        /*
+         * Advance to next value...
+         */
+
+         value = valueptr;
        }
       }
     }
@@ -2760,7 +3006,8 @@ read_configuration(cups_file_t *fp)       /* I - File to read from */
        cupsdLogMessage(CUPSD_LOG_WARN,
                        "Unknown default authorization type %s on line %d.",
                        value, linenum);
-       return (0);
+       if (FatalErrors & CUPSD_FATAL_CONFIG)
+         return (0);
       }
     }
 #ifdef HAVE_SSL
@@ -2781,7 +3028,8 @@ read_configuration(cups_file_t *fp)       /* I - File to read from */
        cupsdLogMessage(CUPSD_LOG_WARN,
                        "Unknown default encryption %s on line %d.",
                        value, linenum);
-       return (0);
+       if (FatalErrors & CUPSD_FATAL_CONFIG)
+         return (0);
       }
     }
 #endif /* HAVE_SSL */
@@ -2937,6 +3185,20 @@ read_configuration(cups_file_t *fp)      /* I - File to read from */
         cupsdLogMessage(CUPSD_LOG_WARN, "Unknown LogLevel %s on line %d.",
                        value, linenum);
     }
+    else if (!strcasecmp(line, "LogTimeFormat") && value)
+    {
+     /*
+      * Amount of logging to do to error log...
+      */
+
+      if (!strcasecmp(value, "standard"))
+        LogTimeFormat = CUPSD_TIME_STANDARD;
+      else if (!strcasecmp(value, "usecs"))
+        LogTimeFormat = CUPSD_TIME_USECS;
+      else
+        cupsdLogMessage(CUPSD_LOG_WARN, "Unknown LogTimeFormat %s on line %d.",
+                       value, linenum);
+    }
     else if (!strcasecmp(line, "PrintcapFormat") && value)
     {
      /*
@@ -2945,6 +3207,8 @@ read_configuration(cups_file_t *fp)       /* I - File to read from */
 
       if (!strcasecmp(value, "bsd"))
         PrintcapFormat = PRINTCAP_BSD;
+      else if (!strcasecmp(value, "plist"))
+        PrintcapFormat = PRINTCAP_PLIST;
       else if (!strcasecmp(value, "solaris"))
         PrintcapFormat = PRINTCAP_SOLARIS;
       else
@@ -3030,6 +3294,23 @@ read_configuration(cups_file_t *fp)      /* I - File to read from */
                        "Missing value for SetEnv directive on line %d.",
                        linenum);
     }
+#ifdef HAVE_SSL
+    else if (!strcasecmp(line, "SSLOptions"))
+    {
+     /*
+      * SSLOptions options
+      */
+
+      if (!value || !strcasecmp(value, "none"))
+        SSLOptions = CUPSD_SSL_NONE;
+      else if (!strcasecmp(value, "noemptyfragments"))
+        SSLOptions = CUPSD_SSL_NOEMPTY;
+      else
+        cupsdLogMessage(CUPSD_LOG_ERROR,
+                       "Unknown value \"%s\" for SSLOptions directive on "
+                       "line %d.", value, linenum);
+    }
+#endif /* HAVE_SSL */
     else
     {
      /*
@@ -3184,7 +3465,10 @@ read_location(cups_file_t *fp,           /* I - Configuration file */
       if (!value)
       {
         cupsdLogMessage(CUPSD_LOG_ERROR, "Syntax error on line %d.", linenum);
-        return (0);
+        if (FatalErrors & CUPSD_FATAL_CONFIG)
+         return (0);
+        else
+         continue;
       }
       
       if ((loc = cupsdCopyLocation(&parent)) == NULL)
@@ -3232,7 +3516,8 @@ read_location(cups_file_t *fp,            /* I - Configuration file */
       cupsdLogMessage(CUPSD_LOG_ERROR,
                       "Unknown Location directive %s on line %d.",
                      line, linenum);
-      return (0);
+      if (FatalErrors & CUPSD_FATAL_CONFIG)
+       return (0);
     }
   }
 
@@ -3240,7 +3525,7 @@ read_location(cups_file_t *fp,            /* I - Configuration file */
                   "Unexpected end-of-file at line %d while reading location!",
                   linenum);
 
-  return (0);
+  return ((FatalErrors & CUPSD_FATAL_CONFIG) ? 0 : linenum);
 }
 
 
@@ -3322,7 +3607,10 @@ read_policy(cups_file_t *fp,             /* I - Configuration file */
       if (!value)
       {
         cupsdLogMessage(CUPSD_LOG_ERROR, "Syntax error on line %d.", linenum);
-        return (0);
+        if (FatalErrors & CUPSD_FATAL_CONFIG)
+         return (0);
+        else
+         continue;
       }
       
      /*
@@ -3396,7 +3684,8 @@ read_policy(cups_file_t *fp,              /* I - Configuration file */
       cupsdLogMessage(CUPSD_LOG_ERROR,
                       "Missing <Limit ops> directive before %s on line %d.",
                       line, linenum);
-      return (0);
+      if (FatalErrors & CUPSD_FATAL_CONFIG)
+       return (0);
     }
     else if (!parse_aaa(op, line, value, linenum))
     {
@@ -3409,7 +3698,8 @@ read_policy(cups_file_t *fp,              /* I - Configuration file */
                        "Unknown Policy directive %s on line %d.",
                        line, linenum);
 
-      return (0);
+      if (FatalErrors & CUPSD_FATAL_CONFIG)
+       return (0);
     }
   }
 
@@ -3417,10 +3707,10 @@ read_policy(cups_file_t *fp,            /* I - Configuration file */
                   "Unexpected end-of-file at line %d while reading policy \"%s\"!",
                   linenum, policy);
 
-  return (0);
+  return ((FatalErrors & CUPSD_FATAL_CONFIG) ? 0 : linenum);
 }
 
 
 /*
- * End of "$Id: conf.c 7694 2008-06-26 00:23:20Z mike $".
+ * End of "$Id: conf.c 7952 2008-09-17 00:56:20Z mike $".
  */