]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - scheduler/conf.c
Merge changes from CUPS 1.5svn-r9352.
[thirdparty/cups.git] / scheduler / conf.c
index 29e43f7859ec4428f8b9a196762ab16d1e0fd173..b85c79ce663b05311d17ca0ed62b7ee5919b2c17 100644 (file)
@@ -1,9 +1,9 @@
 /*
- * "$Id: conf.c 6930 2007-09-08 00:28:06Z mike $"
+ * "$Id: conf.c 9352 2010-11-06 04:55:26Z mike $"
  *
- *   Configuration routines for the Common UNIX Printing System (CUPS).
+ *   Configuration routines for the CUPS scheduler.
  *
- *   Copyright 2007-2008 by Apple Inc.
+ *   Copyright 2007-2010 by Apple Inc.
  *   Copyright 1997-2007 by Easy Software Products, all rights reserved.
  *
  *   These coded instructions, statements, and computer programs are the
  *
  * Contents:
  *
+ *   cupsdAddAlias()          - Add a host alias.
  *   cupsdCheckPermissions()  - Fix the mode and ownership of a file or
  *                              directory.
+ *   cupsdFreeAliases()       - Free all of the alias entries.
  *   cupsdReadConfiguration() - Read the cupsd.conf file.
  *   get_address()            - Get an address + port number from a line.
  *   get_addr_and_mask()      - Get an IP address and netmask.
- *   parse_aaa()              - Parse authentication, authorization, and
- *                              access control lines.
+ *   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.
  *   read_location()          - Read a <Location path> definition.
  *   read_policy()            - Read a <Policy name> definition.
+ *   set_policy_defaults()    - Set default policy values as needed.
  */
 
 /*
 #include <sys/utsname.h>
 #include <syslog.h>
 
+#ifdef HAVE_LIBPAPER
+#  include <paper.h>
+#endif /* HAVE_LIBPAPER */
+
 
 /*
  * Possibly missing network definitions...
@@ -75,14 +83,13 @@ typedef struct
 static const cupsd_var_t       variables[] =
 {
   { "AccessLog",               &AccessLog,             CUPSD_VARTYPE_STRING },
-#ifdef __APPLE__
-  { "AppleQuotas",             &AppleQuotas,           CUPSD_VARTYPE_BOOLEAN },
-#endif  /* __APPLE__ */
   { "AutoPurgeJobs",           &JobAutoPurge,          CUPSD_VARTYPE_BOOLEAN },
   { "BrowseInterval",          &BrowseInterval,        CUPSD_VARTYPE_INTEGER },
 #ifdef HAVE_LDAP
   { "BrowseLDAPBindDN",                &BrowseLDAPBindDN,      CUPSD_VARTYPE_STRING },
+#  ifdef HAVE_LDAP_SSL
   { "BrowseLDAPCACertFile",    &BrowseLDAPCACertFile,  CUPSD_VARTYPE_PATHNAME },
+#  endif /* HAVE_LDAP_SSL */
   { "BrowseLDAPDN",            &BrowseLDAPDN,          CUPSD_VARTYPE_STRING },
   { "BrowseLDAPPassword",      &BrowseLDAPPassword,    CUPSD_VARTYPE_STRING },
   { "BrowseLDAPServer",                &BrowseLDAPServer,      CUPSD_VARTYPE_STRING },
@@ -92,15 +99,16 @@ 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 },
   { "ClassifyOverride",                &ClassifyOverride,      CUPSD_VARTYPE_BOOLEAN },
   { "ConfigFilePerm",          &ConfigFilePerm,        CUPSD_VARTYPE_INTEGER },
   { "DataDir",                 &DataDir,               CUPSD_VARTYPE_STRING },
-  { "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 },
@@ -111,22 +119,20 @@ static const cupsd_var_t  variables[] =
   { "FilterLimit",             &FilterLimit,           CUPSD_VARTYPE_INTEGER },
   { "FilterNice",              &FilterNice,            CUPSD_VARTYPE_INTEGER },
   { "FontPath",                        &FontPath,              CUPSD_VARTYPE_STRING },
-#ifdef HAVE_GSSAPI
-  { "GSSServiceName",          &GSSServiceName,        CUPSD_VARTYPE_STRING },
-#endif /* HAVE_GSSAPI */
   { "HideImplicitMembers",     &HideImplicitMembers,   CUPSD_VARTYPE_BOOLEAN },
   { "ImplicitClasses",         &ImplicitClasses,       CUPSD_VARTYPE_BOOLEAN },
   { "ImplicitAnyClasses",      &ImplicitAnyClasses,    CUPSD_VARTYPE_BOOLEAN },
+  { "JobKillDelay",            &JobKillDelay,          CUPSD_VARTYPE_INTEGER },
   { "JobRetryLimit",           &JobRetryLimit,         CUPSD_VARTYPE_INTEGER },
   { "JobRetryInterval",                &JobRetryInterval,      CUPSD_VARTYPE_INTEGER },
   { "KeepAliveTimeout",                &KeepAliveTimeout,      CUPSD_VARTYPE_INTEGER },
   { "KeepAlive",               &KeepAlive,             CUPSD_VARTYPE_BOOLEAN },
 #ifdef HAVE_LAUNCHD
   { "LaunchdTimeout",          &LaunchdTimeout,        CUPSD_VARTYPE_INTEGER },
-  { "LaunchdConf",             &LaunchdConf,           CUPSD_VARTYPE_STRING },
 #endif /* HAVE_LAUNCHD */
   { "LimitRequestBody",                &MaxRequestSize,        CUPSD_VARTYPE_INTEGER },
   { "ListenBackLog",           &ListenBackLog,         CUPSD_VARTYPE_INTEGER },
+  { "LogDebugHistory",         &LogDebugHistory,       CUPSD_VARTYPE_INTEGER },
   { "LogFilePerm",             &LogFilePerm,           CUPSD_VARTYPE_INTEGER },
   { "LPDConfigFile",           &LPDConfigFile,         CUPSD_VARTYPE_STRING },
   { "MaxActiveJobs",           &MaxActiveJobs,         CUPSD_VARTYPE_INTEGER },
@@ -145,6 +151,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 },
@@ -191,16 +198,43 @@ static const unsigned     zeros[4] =
 /*
  * Local functions...
  */
+
 static http_addrlist_t *get_address(const char *value, int defport);
 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);
 static int             read_location(cups_file_t *fp, char *name, int linenum);
 static int             read_policy(cups_file_t *fp, char *name, int linenum);
+static void            set_policy_defaults(cupsd_policy_t *pol);
+
+
+/*
+ * 'cupsdAddAlias()' - Add a host alias.
+ */
+
+void
+cupsdAddAlias(cups_array_t *aliases,   /* I - Array of aliases */
+              const char   *name)      /* I - Name to add */
+{
+  cupsd_alias_t        *a;                     /*  New alias */
+  size_t       namelen;                /* Length of name */
+
+
+  namelen = strlen(name);
+
+  if ((a = (cupsd_alias_t *)malloc(sizeof(cupsd_alias_t) + namelen)) == NULL)
+    return;
+
+  a->namelen = namelen;
+  strcpy(a->name, name);               /* OK since a->name is allocated */
+
+  cupsArrayAdd(aliases, a);
+}
 
 
 /*
@@ -220,6 +254,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? */
 
 
  /*
@@ -236,7 +271,7 @@ cupsdCheckPermissions(
   * See if we can stat the file/directory...
   */
 
-  if (stat(filename, &fileinfo))
+  if (lstat(filename, &fileinfo))
   {
     if (errno == ENOENT && create_dir)
     {
@@ -257,14 +292,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))
@@ -283,6 +329,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...
   */
@@ -335,6 +388,25 @@ cupsdCheckPermissions(
 }
 
 
+/*
+ * 'cupsdFreeAliases()' - Free all of the alias entries.
+ */
+
+void
+cupsdFreeAliases(cups_array_t *aliases)        /* I - Array of aliases */
+{
+  cupsd_alias_t        *a;                     /* Current alias */
+
+
+  for (a = (cupsd_alias_t *)cupsArrayFirst(aliases);
+       a;
+       a = (cupsd_alias_t *)cupsArrayNext(aliases))
+    free(a);
+
+  cupsArrayDelete(aliases);
+}
+
+
 /*
  * 'cupsdReadConfiguration()' - Read the cupsd.conf file.
  */
@@ -346,12 +418,14 @@ cupsdReadConfiguration(void)
   cups_file_t  *fp;                    /* Configuration file */
   int          status;                 /* Return status */
   char         temp[1024],             /* Temporary buffer */
+               mimedir[1024],          /* MIME directory */
                *slash;                 /* Directory separator */
   cups_lang_t  *language;              /* Language */
   struct passwd        *user;                  /* Default user */
   struct group *group;                 /* Default group */
   char         *old_serverroot,        /* Old ServerRoot */
                *old_requestroot;       /* Old RequestRoot */
+  int          old_remote_port;        /* Old RemotePort */
   const char   *tmpdir;                /* TMPDIR environment variable */
   struct stat  tmpinfo;                /* Temporary directory info */
   cupsd_policy_t *p;                   /* Policy */
@@ -390,8 +464,7 @@ cupsdReadConfiguration(void)
   if (NumRelays > 0)
   {
     for (i = 0; i < NumRelays; i ++)
-      if (Relays[i].from.type == CUPSD_AUTH_NAME)
-       free(Relays[i].from.mask.name.name);
+      cupsArrayDelete(Relays[i].from);
 
     free(Relays);
 
@@ -400,12 +473,18 @@ cupsdReadConfiguration(void)
 
   cupsdDeleteAllListeners();
 
+  old_remote_port = RemotePort;
+  RemotePort      = 0;
+
  /*
   * String options...
   */
 
-  cupsdSetString(&ServerName, httpGetHostname(NULL, temp, sizeof(temp)));
-  cupsdSetStringf(&ServerAdmin, "root@%s", temp);
+  cupsdFreeAliases(ServerAlias);
+  ServerAlias = NULL;
+
+  cupsdClearString(&ServerName);
+  cupsdClearString(&ServerAdmin);
   cupsdSetString(&ServerBin, CUPS_SERVERBIN);
   cupsdSetString(&RequestRoot, CUPS_REQUESTS);
   cupsdSetString(&CacheDir, CUPS_CACHEDIR);
@@ -423,12 +502,12 @@ cupsdReadConfiguration(void)
   cupsdSetString(&RemoteRoot, "remroot");
   cupsdSetString(&ServerHeader, "CUPS/1.4");
   cupsdSetString(&StateDir, CUPS_STATEDIR);
-#ifdef HAVE_GSSAPI
-  cupsdSetString(&GSSServiceName, CUPS_DEFAULT_GSSSERVICENAME);
-#endif /* HAVE_GSSAPI */
 
   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;
 
@@ -457,7 +536,7 @@ cupsdReadConfiguration(void)
   else
     cupsdSetString(&DefaultLanguage, language->language);
 
-  cupsdSetString(&DefaultCharset, _cupsEncodingName(language->encoding));
+  cupsdClearString(&DefaultPaperSize);
 
   cupsdSetString(&RIPCache, "8m");
 
@@ -516,45 +595,53 @@ cupsdReadConfiguration(void)
   * Numeric options...
   */
 
-  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_ERROR;
-  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;
+  JobKillDelay             = DEFAULT_TIMEOUT;
+  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;
+  LogDebugHistory          = 200;
+  LogFilePerm              = CUPS_DEFAULT_LOG_FILE_PERM;
+  LogLevel                 = CUPSD_LOG_WARN;
+  LogTimeFormat            = CUPSD_TIME_STANDARD;
+  MaxClients               = 100;
+  MaxClientsPerHost        = 0;
+  MaxLogSize               = 1024 * 1024;
+  MaxPrinterHistory        = 0;
+  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);
@@ -569,7 +656,9 @@ cupsdReadConfiguration(void)
   cupsdClearString(&BrowseLDAPDN);
   cupsdClearString(&BrowseLDAPPassword);
   cupsdClearString(&BrowseLDAPServer);
+#  ifdef HAVE_LDAP_SSL
   cupsdClearString(&BrowseLDAPCACertFile);
+#  endif /* HAVE_LDAP_SSL */
 #endif /* HAVE_LDAP */
 
   JobHistory          = DEFAULT_HISTORY;
@@ -597,13 +686,8 @@ cupsdReadConfiguration(void)
 
 #ifdef HAVE_LAUNCHD
   LaunchdTimeout = DEFAULT_TIMEOUT + 10;
-  cupsdSetString(&LaunchdConf, CUPS_DEFAULT_LAUNCHD_CONF);
 #endif /* HAVE_LAUNCHD */
 
-#ifdef __APPLE__
-  AppleQuotas = TRUE;
-#endif  /* __APPLE__ */
-
  /*
   * Read the configuration file...
   */
@@ -620,14 +704,90 @@ cupsdReadConfiguration(void)
 
   RunUser = getuid();
 
+  cupsdLogMessage(CUPSD_LOG_INFO, "Remote access is %s.",
+                  RemotePort ? "enabled" : "disabled");
+
+  if (!RemotePort)
+    BrowseLocalProtocols = 0;          /* Disable sharing - no remote access */
+
  /*
   * See if the ServerName is an IP address...
   */
 
+  if (ServerName)
+  {
+    if (!ServerAlias)
+      ServerAlias = cupsArrayNew(NULL, NULL);
+
+    cupsdLogMessage(CUPSD_LOG_DEBUG, "Added auto ServerAlias %s", ServerName);
+  }
+  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);
+
+    if (!ServerAlias)
+      ServerAlias = cupsArrayNew(NULL, NULL);
+
+    cupsdAddAlias(ServerAlias, temp);
+    cupsdLogMessage(CUPSD_LOG_DEBUG, "Added auto ServerAlias %s", temp);
+
+    if (HostNameLookups || RemotePort)
+    {
+      struct hostent   *host;          /* Host entry to get FQDN */
+
+      if ((host = gethostbyname(temp)) != NULL)
+      {
+        if (strcasecmp(temp, host->h_name))
+        {
+         cupsdSetString(&ServerName, host->h_name);
+         cupsdAddAlias(ServerAlias, host->h_name);
+          cupsdLogMessage(CUPSD_LOG_DEBUG, "Added auto ServerAlias %s",
+                         host->h_name);
+       }
+
+        if (host->h_aliases)
+       {
+          for (i = 0; host->h_aliases[i]; i ++)
+           if (strcasecmp(temp, host->h_aliases[i]))
+           {
+             cupsdAddAlias(ServerAlias, host->h_aliases[i]);
+             cupsdLogMessage(CUPSD_LOG_DEBUG, "Added auto ServerAlias %s",
+                             host->h_aliases[i]);
+           }
+       }
+      }
+    }
+
+   /*
+    * Make sure we have the base hostname added as an alias, too!
+    */
+
+    if ((slash = strchr(temp, '.')) != NULL)
+    {
+      *slash = '\0';
+      cupsdAddAlias(ServerAlias, temp);
+      cupsdLogMessage(CUPSD_LOG_DEBUG, "Added auto ServerAlias %s", 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...
   */
@@ -728,7 +888,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...
@@ -741,7 +902,7 @@ cupsdReadConfiguration(void)
   * Set the default locale using the language and charset...
   */
 
-  cupsdSetStringf(&DefaultLocale, "%s.%s", DefaultLanguage, DefaultCharset);
+  cupsdSetStringf(&DefaultLocale, "%s.UTF-8", DefaultLanguage);
 
  /*
   * Update all relative filenames to include the full path from ServerRoot...
@@ -766,21 +927,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 */
 
@@ -791,30 +951,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);
 
  /*
@@ -864,7 +1025,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);
   }
 
@@ -874,6 +1036,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...
   */
@@ -881,8 +1085,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;
   }
@@ -898,12 +1104,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...
   */
@@ -967,13 +1167,48 @@ cupsdReadConfiguration(void)
       DefaultPolicyPtr = p = cupsdAddPolicy("default");
 
       cupsdLogMessage(CUPSD_LOG_INFO, "<Policy default>");
+
+      cupsdLogMessage(CUPSD_LOG_INFO, "JobPrivateAccess default");
+      cupsdAddString(&(p->job_access), "@OWNER");
+      cupsdAddString(&(p->job_access), "@SYSTEM");
+
+      cupsdLogMessage(CUPSD_LOG_INFO, "JobPrivateValues default");
+      cupsdAddString(&(p->job_attrs), "job-name");
+      cupsdAddString(&(p->job_attrs), "job-originating-host-name");
+      cupsdAddString(&(p->job_attrs), "job-originating-user-name");
+
+      cupsdLogMessage(CUPSD_LOG_INFO, "SubscriptionPrivateAccess default");
+      cupsdAddString(&(p->sub_access), "@OWNER");
+      cupsdAddString(&(p->sub_access), "@SYSTEM");
+
+      cupsdLogMessage(CUPSD_LOG_INFO, "SubscriptionPrivateValues default");
+      cupsdAddString(&(p->job_attrs), "notify-events");
+      cupsdAddString(&(p->job_attrs), "notify-pull-method");
+      cupsdAddString(&(p->job_attrs), "notify-recipient-uri");
+      cupsdAddString(&(p->job_attrs), "notify-subscriber-user-name");
+      cupsdAddString(&(p->job_attrs), "notify-user-data");
+
+      cupsdLogMessage(CUPSD_LOG_INFO,
+                      "<Limit Create-Job Print-Job Print-URI Validate-Job>");
+      cupsdLogMessage(CUPSD_LOG_INFO, "Order Deny,Allow");
+
+      po = cupsdAddPolicyOp(p, NULL, IPP_CREATE_JOB);
+      po->order_type = CUPSD_AUTH_ALLOW;
+
+      cupsdAddPolicyOp(p, po, IPP_PRINT_JOB);
+      cupsdAddPolicyOp(p, po, IPP_PRINT_URI);
+      cupsdAddPolicyOp(p, po, IPP_VALIDATE_JOB);
+
+      cupsdLogMessage(CUPSD_LOG_INFO, "</Limit>");
+
       cupsdLogMessage(CUPSD_LOG_INFO,
                       "<Limit Send-Document Send-URI Cancel-Job Hold-Job "
                       "Release-Job Restart-Job Purge-Jobs "
                      "Set-Job-Attributes Create-Job-Subscription "
                      "Renew-Subscription Cancel-Subscription "
                      "Get-Notifications Reprocess-Job Cancel-Current-Job "
-                     "Suspend-Current-Job Resume-Job CUPS-Move-Job "
+                     "Suspend-Current-Job Resume-Job "
+                     "Cancel-My-Jobs Close-Job CUPS-Move-Job "
                      "CUPS-Authenticate-Job CUPS-Get-Document>");
       cupsdLogMessage(CUPSD_LOG_INFO, "Order Deny,Allow");
 
@@ -1000,6 +1235,8 @@ cupsdReadConfiguration(void)
       cupsdAddPolicyOp(p, po, IPP_CANCEL_CURRENT_JOB);
       cupsdAddPolicyOp(p, po, IPP_SUSPEND_CURRENT_JOB);
       cupsdAddPolicyOp(p, po, IPP_RESUME_JOB);
+      cupsdAddPolicyOp(p, po, IPP_CANCEL_MY_JOBS);
+      cupsdAddPolicyOp(p, po, IPP_CLOSE_JOB);
       cupsdAddPolicyOp(p, po, CUPS_MOVE_JOB);
       cupsdAddPolicyOp(p, po, CUPS_AUTHENTICATE_JOB);
       cupsdAddPolicyOp(p, po, CUPS_GET_DOCUMENT);
@@ -1013,7 +1250,7 @@ cupsdReadConfiguration(void)
                      "Hold-New-Jobs Release-Held-New-Jobs "
                      "Deactivate-Printer Activate-Printer Restart-Printer "
                      "Shutdown-Printer Startup-Printer Promote-Job "
-                     "Schedule-Job-After CUPS-Add-Printer "
+                     "Schedule-Job-After Cancel-Jobs CUPS-Add-Printer "
                      "CUPS-Delete-Printer CUPS-Add-Class CUPS-Delete-Class "
                      "CUPS-Accept-Jobs CUPS-Reject-Jobs CUPS-Set-Default>");
       cupsdLogMessage(CUPSD_LOG_INFO, "Order Deny,Allow");
@@ -1041,6 +1278,7 @@ cupsdReadConfiguration(void)
       cupsdAddPolicyOp(p, po, IPP_STARTUP_PRINTER);
       cupsdAddPolicyOp(p, po, IPP_PROMOTE_JOB);
       cupsdAddPolicyOp(p, po, IPP_SCHEDULE_JOB_AFTER);
+      cupsdAddPolicyOp(p, po, IPP_CANCEL_JOBS);
       cupsdAddPolicyOp(p, po, CUPS_ADD_PRINTER);
       cupsdAddPolicyOp(p, po, CUPS_DELETE_PRINTER);
       cupsdAddPolicyOp(p, po, CUPS_ADD_CLASS);
@@ -1076,6 +1314,7 @@ cupsdReadConfiguration(void)
   */
 
   if (NeedReload == RELOAD_ALL ||
+      old_remote_port != RemotePort ||
       !old_serverroot || !ServerRoot || strcmp(old_serverroot, ServerRoot) ||
       !old_requestroot || !RequestRoot || strcmp(old_requestroot, RequestRoot))
   {
@@ -1092,7 +1331,6 @@ cupsdReadConfiguration(void)
 
     cupsdDeleteAllSubscriptions();
     cupsdFreeAllJobs();
-    cupsdDeleteAllClasses();
     cupsdDeleteAllPrinters();
 
     DefaultPrinter = NULL;
@@ -1113,20 +1351,26 @@ cupsdReadConfiguration(void)
     */
 
     snprintf(temp, sizeof(temp), "%s/filter", ServerBin);
+    snprintf(mimedir, sizeof(mimedir), "%s/mime", DataDir);
 
-    MimeDatabase = mimeLoad(ServerRoot, temp);
+    MimeDatabase = mimeLoadTypes(NULL, mimedir);
+    MimeDatabase = mimeLoadTypes(MimeDatabase, ServerRoot);
+    MimeDatabase = mimeLoadFilters(MimeDatabase, mimedir, temp);
+    MimeDatabase = mimeLoadFilters(MimeDatabase, ServerRoot, temp);
 
     if (!MimeDatabase)
     {
       cupsdLogMessage(CUPSD_LOG_EMERG,
-                      "Unable to load MIME database from \'%s\'!", ServerRoot);
-      exit(errno);
+                      "Unable to load MIME database from \"%s\" or \"%s\"!",
+                     mimedir, ServerRoot);
+      if (FatalErrors & CUPSD_FATAL_CONFIG)
+        return (0);
     }
 
     cupsdLogMessage(CUPSD_LOG_INFO,
-                    "Loaded MIME database from \'%s\': %d types, %d filters...",
-                    ServerRoot, mimeNumTypes(MimeDatabase),
-                   mimeNumFilters(MimeDatabase));
+                    "Loaded MIME database from \"%s\" and \"%s\": %d types, "
+                   "%d filters...", mimedir, ServerRoot,
+                   mimeNumTypes(MimeDatabase), mimeNumFilters(MimeDatabase));
 
    /*
     * Create a list of MIME types for the document-format-supported
@@ -1194,10 +1438,16 @@ cupsdReadConfiguration(void)
     cupsdLoadAllPrinters();
     cupsdLoadAllClasses();
     cupsdLoadRemoteCache();
-    cupsdMarkDirty(CUPSD_DIRTY_PRINTCAP);
 
     cupsdCreateCommonData();
 
+   /*
+    * Update the printcap file as needed...
+    */
+
+    if (Printcap && *Printcap && access(Printcap, 0))
+      cupsdWritePrintcap();
+
    /*
     * Load queued jobs...
     */
@@ -1611,92 +1861,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"))
+         cupsdAddIPMask(&(loc->allow), zeros, zeros);
+       else
+         cupsdAddIPMask(&(loc->deny), zeros, zeros);
+      }
+      else if (!strcasecmp(value, "none"))
+      {
+       /*
+       * No hosts...
+       */
+
+       if (!strcasecmp(line, "Allow"))
+         cupsdAddIPMask(&(loc->allow), ones, zeros);
+       else
+         cupsdAddIPMask(&(loc->deny), 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"))
+         cupsdAddNameMask(&(loc->allow), value);
+       else
+         cupsdAddNameMask(&(loc->deny), 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"))
+         cupsdAddIPMask(&(loc->allow), ip, mask);
+       else
+         cupsdAddIPMask(&(loc->deny), 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"))
@@ -1917,48 +2188,128 @@ parse_aaa(cupsd_location_t *loc,       /* I - Location */
 
 
 /*
- * 'parse_groups()' - Parse system group names in a string.
+ * 'parse_fatal_errors()' - Parse FatalErrors values in a string.
  */
 
-static int                             /* O - 1 on success, 0 on failure */
-parse_groups(const char *s)            /* I - Space-delimited groups */
+static int                             /* O - FatalErrors bits */
+parse_fatal_errors(const char *s)      /* I - FatalErrors string */
 {
-  int          status;                 /* Return status */
-  char         value[1024],            /* Value string */
-               *valstart,              /* Pointer into value */
-               *valend,                /* End of value */
-               quote;                  /* Quote character */
-  struct group *group;                 /* Group */
+  int  fatal;                          /* FatalErrors bits */
+  char value[1024],                    /* Value string */
+       *valstart,                      /* Pointer into value */
+       *valend;                        /* End of value */
 
 
  /*
-  * Make a copy of the string and parse out the groups...
+  * Empty FatalErrors line yields NULL pointer...
+  */
+
+  if (!s)
+    return (CUPSD_FATAL_NONE);
+
+ /*
+  * Loop through the value string,...
   */
 
   strlcpy(value, s, sizeof(value));
 
-  status   = 1;
-  valstart = value;
+  fatal = CUPSD_FATAL_NONE;
 
-  while (*valstart && NumSystemGroups < MAX_SYSTEM_GROUPS)
+  for (valstart = value; *valstart;)
   {
-    if (*valstart == '\'' || *valstart == '\"')
-    {
-     /*
-      * Scan quoted name...
-      */
+   /*
+    * Get the current space/comma-delimited kind name...
+    */
 
-      quote = *valstart++;
+    for (valend = valstart; *valend; valend ++)
+      if (isspace(*valend & 255) || *valend == ',')
+       break;
 
-      for (valend = valstart; *valend; valend ++)
-       if (*valend == quote)
-         break;
-    }
-    else
-    {
-     /*
-      * Scan space or comma-delimited name...
-      */
+    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.
+ */
+
+static int                             /* O - 1 on success, 0 on failure */
+parse_groups(const char *s)            /* I - Space-delimited groups */
+{
+  int          status;                 /* Return status */
+  char         value[1024],            /* Value string */
+               *valstart,              /* Pointer into value */
+               *valend,                /* End of value */
+               quote;                  /* Quote character */
+  struct group *group;                 /* Group */
+
+
+ /*
+  * Make a copy of the string and parse out the groups...
+  */
+
+  strlcpy(value, s, sizeof(value));
+
+  status   = 1;
+  valstart = value;
+
+  while (*valstart && NumSystemGroups < MAX_SYSTEM_GROUPS)
+  {
+    if (*valstart == '\'' || *valstart == '\"')
+    {
+     /*
+      * Scan quoted name...
+      */
+
+      quote = *valstart++;
+
+      for (valend = valstart; *valend; valend ++)
+       if (*valend == quote)
+         break;
+    }
+    else
+    {
+     /*
+      * Scan space or comma-delimited name...
+      */
 
       for (valend = valstart; *valend; valend ++)
        if (isspace(*valend) || *valend == ',')
@@ -2078,8 +2429,6 @@ read_configuration(cups_file_t *fp)       /* I - File to read from */
                                        /* Line from file */
                        temp[HTTP_MAX_BUFFER],
                                        /* Temporary buffer for value */
-                       temp2[HTTP_MAX_BUFFER],
-                                       /* Temporary buffer 2 for value */
                        *ptr,           /* Pointer into line/temp */
                        *value,         /* Pointer to value */
                        *valueptr;      /* Pointer into value */
@@ -2109,7 +2458,7 @@ read_configuration(cups_file_t *fp)       /* I - File to read from */
     * Decode the directive...
     */
 
-    if (!strcasecmp(line, "Include"))
+    if (!strcasecmp(line, "Include") && value)
     {
      /*
       * Include filename
@@ -2130,72 +2479,41 @@ read_configuration(cups_file_t *fp)     /* I - File to read from */
        cupsFileClose(incfile);
       }
     }
-    else if (!strcasecmp(line, "<Location"))
+    else if (!strcasecmp(line, "<Location") && value)
     {
      /*
       * <Location path>
       */
 
-      if (value)
-      {
-       linenum = read_location(fp, value, linenum);
-       if (linenum == 0)
-         return (0);
-      }
-      else
-      {
-        cupsdLogMessage(CUPSD_LOG_ERROR, "Syntax error on line %d.",
-                  linenum);
-        return (0);
-      }
+      linenum = read_location(fp, value, linenum);
+      if (linenum == 0)
+       return (0);
     }
-    else if (!strcasecmp(line, "<Policy"))
+    else if (!strcasecmp(line, "<Policy") && value)
     {
      /*
       * <Policy name>
       */
 
-      if (value)
-      {
-       linenum = read_policy(fp, value, linenum);
-       if (linenum == 0)
-         return (0);
-      }
-      else
-      {
-        cupsdLogMessage(CUPSD_LOG_ERROR, "Syntax error on line %d.", linenum);
-        return (0);
-      }
+      linenum = read_policy(fp, value, linenum);
+      if (linenum == 0)
+       return (0);
     }
-    else if (!strcasecmp(line, "FaxRetryInterval"))
+    else if (!strcasecmp(line, "FatalErrors"))
+      FatalErrors = parse_fatal_errors(value);
+    else if (!strcasecmp(line, "FaxRetryInterval") && value)
     {
-      if (value)
-      {
-        JobRetryInterval = atoi(value);
-       cupsdLogMessage(CUPSD_LOG_WARN,
-                       "FaxRetryInterval is deprecated; use "
-                       "JobRetryInterval on line %d.", linenum);
-      }
-      else
-      {
-        cupsdLogMessage(CUPSD_LOG_ERROR, "Syntax error on line %d.", linenum);
-        return (0);
-      }
+      JobRetryInterval = atoi(value);
+      cupsdLogMessage(CUPSD_LOG_WARN,
+                     "FaxRetryInterval is deprecated; use "
+                     "JobRetryInterval on line %d.", linenum);
     }
-    else if (!strcasecmp(line, "FaxRetryLimit"))
+    else if (!strcasecmp(line, "FaxRetryLimit") && value)
     {
-      if (value)
-      {
-        JobRetryLimit = atoi(value);
-       cupsdLogMessage(CUPSD_LOG_WARN,
-                       "FaxRetryLimit is deprecated; use "
-                       "JobRetryLimit on line %d.", linenum);
-      }
-      else
-      {
-        cupsdLogMessage(CUPSD_LOG_ERROR, "Syntax error on line %d.", linenum);
-        return (0);
-      }
+      JobRetryLimit = atoi(value);
+      cupsdLogMessage(CUPSD_LOG_WARN,
+                     "FaxRetryLimit is deprecated; use "
+                     "JobRetryLimit on line %d.", linenum);
     }
     else if (!strcasecmp(line, "Port") || !strcasecmp(line, "Listen")
 #ifdef HAVE_SSL
@@ -2229,6 +2547,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...
        */
@@ -2281,6 +2618,16 @@ 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)))
+       {
+#ifdef AF_INET6
+         if (lis->address.addr.sa_family == AF_INET6)
+           RemotePort = ntohs(lis->address.ipv6.sin6_port);
+         else
+#endif /* AF_INET6 */
+         RemotePort = ntohs(lis->address.ipv4.sin_port);
+       }
       }
 
      /*
@@ -2289,7 +2636,7 @@ read_configuration(cups_file_t *fp)       /* I - File to read from */
 
       httpAddrFreeList(addrlist);
     }
-    else if (!strcasecmp(line, "BrowseAddress"))
+    else if (!strcasecmp(line, "BrowseAddress") && value)
     {
      /*
       * Add a browse address to the list...
@@ -2347,7 +2694,7 @@ read_configuration(cups_file_t *fp)       /* I - File to read from */
 
        for (addr = addrlist; addr; addr = addr->next)
          if (addr->addr.addr.sa_family == AF_INET)
-           break;          
+           break;
 
        if (addr)
        {
@@ -2357,7 +2704,7 @@ read_configuration(cups_file_t *fp)       /* I - File to read from */
          cupsdLogMessage(CUPSD_LOG_INFO,
                          "Sending browsing info to %s:%d (IPv4)",
                          temp, ntohs(dira->to.ipv4.sin_port));
-  
+
          NumBrowsers ++;
        }
        else
@@ -2370,14 +2717,15 @@ read_configuration(cups_file_t *fp)     /* I - File to read from */
         cupsdLogMessage(CUPSD_LOG_ERROR, "Bad BrowseAddress %s at line %d.",
                        value, linenum);
     }
-    else if (!strcasecmp(line, "BrowseOrder"))
+    else if (!strcasecmp(line, "BrowseOrder") && value)
     {
      /*
       * "BrowseOrder Deny,Allow" or "BrowseOrder Allow,Deny"...
       */
 
       if ((location = cupsdFindLocation("CUPS_INTERNAL_BROWSE_ACL")) == NULL)
-        location = cupsdAddLocation("CUPS_INTERNAL_BROWSE_ACL");
+        if ((location = cupsdNewLocation("CUPS_INTERNAL_BROWSE_ACL")) != NULL)
+         cupsdAddLocation(location);
 
       if (location == NULL)
         cupsdLogMessage(CUPSD_LOG_ERROR,
@@ -2416,8 +2764,8 @@ read_configuration(cups_file_t *fp)       /* I - File to read from */
       if (strcasecmp(line, "BrowseRemoteProtocols"))
         BrowseLocalProtocols = protocols;
     }
-    else if (!strcasecmp(line, "BrowseAllow") ||
-             !strcasecmp(line, "BrowseDeny"))
+    else if ((!strcasecmp(line, "BrowseAllow") ||
+              !strcasecmp(line, "BrowseDeny")) && value)
     {
      /*
       * BrowseAllow [From] host/ip...
@@ -2425,103 +2773,130 @@ read_configuration(cups_file_t *fp)   /* I - File to read from */
       */
 
       if ((location = cupsdFindLocation("CUPS_INTERNAL_BROWSE_ACL")) == NULL)
-        location = cupsdAddLocation("CUPS_INTERNAL_BROWSE_ACL");
+        if ((location = cupsdNewLocation("CUPS_INTERNAL_BROWSE_ACL")) != NULL)
+         cupsdAddLocation(location);
+
 
       if (location == NULL)
         cupsdLogMessage(CUPSD_LOG_ERROR,
                        "Unable to initialize browse access control list!");
       else
       {
-       if (!strncasecmp(value, "from ", 5))
+       if (!strncasecmp(value, "from", 4))
        {
         /*
-          * Strip leading "from"...
+         * Skip leading "from"...
          */
 
-         value += 5;
-
-         while (isspace(*value))
-           value ++;
+         value += 4;
        }
 
-       /*
-       * 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(value, "all"))
+       while (*value)
        {
         /*
-          * All hosts...
+         * Skip leading whitespace...
          */
 
-          if (!strcasecmp(line, "BrowseAllow"))
-           cupsdAllowIP(location, zeros, zeros);
-         else
-           cupsdDenyIP(location, zeros, zeros);
-       }
-       else if (!strcasecmp(value, "none"))
-       {
-        /*
-          * No hosts...
-         */
+         while (isspace(*value & 255))
+           value ++;
+
+         if (!*value)
+           break;
 
-          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
-       else if (value[0] == '*' || value[0] == '.' || !isdigit(value[0] & 255))
-#endif /* AF_INET6 */
-       {
         /*
-          * Host or domain name...
+         * Find the end of the value...
          */
 
-         if (value[0] == '*')
-           value ++;
+         for (valueptr = value;
+              *valueptr && !isspace(*valueptr & 255);
+              valueptr ++);
+
+         while (isspace(*valueptr & 255))
+           *valueptr++ = '\0';
 
-          if (!strcasecmp(line, "BrowseAllow"))
-           cupsdAllowHost(location, value);
-         else
-           cupsdDenyHost(location, value);
-       }
-       else
-       {
         /*
-          * One of many IP address forms...
+         * 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 (!get_addr_and_mask(value, ip, mask))
+         if (!strcasecmp(value, "all"))
          {
-            cupsdLogMessage(CUPSD_LOG_ERROR, "Bad netmask value %s on line %d.",
-                           value, linenum);
-           break;
+          /*
+           * All hosts...
+           */
+
+           if (!strcasecmp(line, "BrowseAllow"))
+             cupsdAddIPMask(&(location->allow), zeros, zeros);
+           else
+             cupsdAddIPMask(&(location->deny), zeros, zeros);
          }
+         else if (!strcasecmp(value, "none"))
+         {
+          /*
+           * No hosts...
+           */
+
+           if (!strcasecmp(line, "BrowseAllow"))
+             cupsdAddIPMask(&(location->allow), ones, zeros);
+           else
+             cupsdAddIPMask(&(location->deny), ones, zeros);
+         }
+#ifdef AF_INET6
+         else if (value[0] == '*' || value[0] == '.' ||
+                  (!isdigit(value[0] & 255) && value[0] != '['))
+#else
+         else if (value[0] == '*' || value[0] == '.' ||
+                  !isdigit(value[0] & 255))
+#endif /* AF_INET6 */
+         {
+          /*
+           * Host or domain name...
+           */
 
-          if (!strcasecmp(line, "BrowseAllow"))
-           cupsdAllowIP(location, ip, mask);
+           if (!strcasecmp(line, "BrowseAllow"))
+             cupsdAddNameMask(&(location->allow), value);
+           else
+             cupsdAddNameMask(&(location->deny), value);
+         }
          else
-           cupsdDenyIP(location, ip, mask);
+         {
+          /*
+           * 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"))
+             cupsdAddIPMask(&(location->allow), ip, mask);
+           else
+             cupsdAddIPMask(&(location->deny), ip, mask);
+         }
+
+        /*
+         * Advance to next value...
+         */
+
+         value = valueptr;
        }
       }
     }
-    else if (!strcasecmp(line, "BrowseRelay"))
+    else if (!strcasecmp(line, "BrowseRelay") && value)
     {
      /*
       * BrowseRelay [from] source [to] destination
@@ -2548,15 +2923,30 @@ read_configuration(cups_file_t *fp)     /* I - File to read from */
       if (!strncasecmp(value, "from ", 5))
       {
        /*
-        * Strip leading "from"...
+       * Skip leading "from"...
        */
 
        value += 5;
 
+       /*
+        * Skip leading whitespace...
+       */
+
        while (isspace(*value))
          value ++;
       }
 
+     /*
+      * Find the end of the from value...
+      */
+
+      for (valueptr = value;
+          *valueptr && !isspace(*valueptr & 255);
+          valueptr ++);
+
+      while (isspace(*valueptr & 255))
+       *valueptr++ = '\0';
+
      /*
       * Figure out what form the from address takes:
       *
@@ -2572,7 +2962,7 @@ read_configuration(cups_file_t *fp)       /* I - File to read from */
       */
 
 #ifdef AF_INET6
-      if (value[0] == '*' || value[0] == '.' || 
+      if (value[0] == '*' || value[0] == '.' ||
           (!isdigit(value[0] & 255) && value[0] != '['))
 #else
       if (value[0] == '*' || value[0] == '.' || !isdigit(value[0] & 255))
@@ -2582,24 +2972,13 @@ read_configuration(cups_file_t *fp)     /* I - File to read from */
         * Host or domain name...
        */
 
-       if (value[0] == '*')
-         value ++;
-
-        strlcpy(temp, value, sizeof(temp));
-       if ((ptr = strchr(temp, ' ')) != NULL)
-         *ptr = '\0';
-
-        relay->from.type = CUPSD_AUTH_NAME;
-
-       if ((relay->from.mask.name.name = strdup(temp)) == NULL)
+        if (!cupsdAddNameMask(&(relay->from), value))
        {
          cupsdLogMessage(CUPSD_LOG_ERROR,
                          "Unable to allocate BrowseRelay name at line %d - %s.",
                          linenum, strerror(errno));
          continue;
        }
-
-       relay->from.mask.name.length = strlen(temp);
       }
       else
       {
@@ -2614,41 +2993,32 @@ read_configuration(cups_file_t *fp)     /* I - File to read from */
          break;
        }
 
-        relay->from.type = CUPSD_AUTH_IP;
-       memcpy(relay->from.mask.ip.address, ip,
-              sizeof(relay->from.mask.ip.address));
-       memcpy(relay->from.mask.ip.netmask, mask,
-              sizeof(relay->from.mask.ip.netmask));
+        if (!cupsdAddIPMask(&(relay->from), ip, mask))
+       {
+         cupsdLogMessage(CUPSD_LOG_ERROR,
+                         "Unable to allocate BrowseRelay IP at line %d - %s.",
+                         linenum, strerror(errno));
+         continue;
+       }
       }
 
      /*
-      * Skip value and trailing whitespace...
+      * Get "to" address and port...
       */
 
-      for (; *value; value ++)
-       if (isspace(*value))
-         break;
-
-      while (isspace(*value))
-        value ++;
-
-      if (!strncasecmp(value, "to ", 3))
+      if (!strncasecmp(valueptr, "to ", 3))
       {
        /*
         * Strip leading "to"...
        */
 
-       value += 3;
+       valueptr += 3;
 
-       while (isspace(*value))
-         value ++;
+       while (isspace(*valueptr))
+         valueptr ++;
       }
 
-     /*
-      * Get "to" address and port...
-      */
-
-      if ((addrlist = get_address(value, BrowsePort)) != NULL)
+      if ((addrlist = get_address(valueptr, BrowsePort)) != NULL)
       {
        /*
         * Only IPv4 addresses are supported...
@@ -2656,48 +3026,40 @@ read_configuration(cups_file_t *fp)     /* I - File to read from */
 
        for (addr = addrlist; addr; addr = addr->next)
          if (addr->addr.addr.sa_family == AF_INET)
-           break;          
+           break;
 
        if (addr)
        {
          memcpy(&(relay->to), &(addrlist->addr), sizeof(relay->to));
-  
+
          httpAddrString(&(relay->to), temp, sizeof(temp));
-  
-         if (relay->from.type == CUPSD_AUTH_IP)
-           snprintf(temp2, sizeof(temp2), "%u.%u.%u.%u/%u.%u.%u.%u",
-                    relay->from.mask.ip.address[0] >> 24,
-                    (relay->from.mask.ip.address[0] >> 16) & 255,
-                    (relay->from.mask.ip.address[0] >> 8) & 255,
-                    relay->from.mask.ip.address[0] & 255,
-                    relay->from.mask.ip.netmask[0] >> 24,
-                    (relay->from.mask.ip.netmask[0] >> 16) & 255,
-                    (relay->from.mask.ip.netmask[0] >> 8) & 255,
-                    relay->from.mask.ip.netmask[0] & 255);
-         else
-           strlcpy(temp2, relay->from.mask.name.name, sizeof(temp2));
-  
+
          cupsdLogMessage(CUPSD_LOG_INFO, "Relaying from %s to %s:%d (IPv4)",
-                         temp2, temp, ntohs(relay->to.ipv4.sin_port));
-  
+                         value, temp, ntohs(relay->to.ipv4.sin_port));
+
          NumRelays ++;
        }
        else
+       {
+         cupsArrayDelete(relay->from);
+         relay->from = NULL;
+
          cupsdLogMessage(CUPSD_LOG_ERROR, "Bad relay address %s at line %d.",
-                         value, linenum);
+                         valueptr, linenum);
+       }
 
        httpAddrFreeList(addrlist);
       }
       else
       {
-        if (relay->from.type == CUPSD_AUTH_NAME)
-         free(relay->from.mask.name.name);
+       cupsArrayDelete(relay->from);
+       relay->from = NULL;
 
         cupsdLogMessage(CUPSD_LOG_ERROR, "Bad relay address %s at line %d.",
-                       value, linenum);
+                       valueptr, linenum);
       }
     }
-    else if (!strcasecmp(line, "BrowsePoll"))
+    else if (!strcasecmp(line, "BrowsePoll") && value)
     {
      /*
       * BrowsePoll address[:port]
@@ -2759,7 +3121,7 @@ read_configuration(cups_file_t *fp)       /* I - File to read from */
       cupsdLogMessage(CUPSD_LOG_INFO, "Polling %s:%d", pollp->hostname,
                      pollp->port);
     }
-    else if (!strcasecmp(line, "DefaultAuthType"))
+    else if (!strcasecmp(line, "DefaultAuthType") && value)
     {
      /*
       * DefaultAuthType {basic,digest,basicdigest,negotiate}
@@ -2782,7 +3144,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
@@ -2803,30 +3166,18 @@ 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 */
-#ifdef HAVE_GSSAPI
-    else if (!strcasecmp(line, "Krb5Keytab"))
-    {
-      cupsdSetStringf(&Krb5Keytab, "KRB5_KTNAME=%s", value);
-      putenv(Krb5Keytab);
-
-#  ifdef HAVE_GSSKRB5_REGISTER_ACCEPTOR_IDENTITY
-      gsskrb5_register_acceptor_identity(value);
-#  else
-      cupsdSetEnv("KRB5_KTNAME", value);
-#  endif /* HAVE_GSSKRB5_REGISTER_ACCEPTOR_IDENTITY */
-    }
-#endif /* HAVE_GSSAPI */
-    else if (!strcasecmp(line, "User"))
+    else if (!strcasecmp(line, "User") && value)
     {
      /*
       * User ID to run as...
       */
 
-      if (value && isdigit(value[0] & 255))
+      if (isdigit(value[0] & 255))
       {
         int uid = atoi(value);
 
@@ -2839,7 +3190,7 @@ read_configuration(cups_file_t *fp)       /* I - File to read from */
         else
          User = atoi(value);
       }
-      else if (value)
+      else
       {
         struct passwd *p;      /* Password information */
 
@@ -2862,12 +3213,8 @@ read_configuration(cups_file_t *fp)      /* I - File to read from */
                          "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"))
+    else if (!strcasecmp(line, "Group") && value)
     {
      /*
       * Group ID to run as...
@@ -2888,7 +3235,7 @@ read_configuration(cups_file_t *fp)       /* I - File to read from */
                          value, linenum);
       }
     }
-    else if (!strcasecmp(line, "SystemGroup"))
+    else if (!strcasecmp(line, "SystemGroup") && value)
     {
      /*
       * SystemGroup (admin) group(s)...
@@ -2899,15 +3246,17 @@ read_configuration(cups_file_t *fp)     /* I - File to read from */
                        "Unknown SystemGroup \"%s\" on line %d, ignoring!",
                        value, linenum);
     }
-    else if (!strcasecmp(line, "HostNameLookups"))
+    else if (!strcasecmp(line, "HostNameLookups") && value)
     {
      /*
       * Do hostname lookups?
       */
 
-      if (!strcasecmp(value, "off"))
+      if (!strcasecmp(value, "off") || !strcasecmp(value, "no") ||
+          !strcasecmp(value, "false"))
         HostNameLookups = 0;
-      else if (!strcasecmp(value, "on"))
+      else if (!strcasecmp(value, "on") || !strcasecmp(value, "yes") ||
+          !strcasecmp(value, "true"))
         HostNameLookups = 1;
       else if (!strcasecmp(value, "double"))
         HostNameLookups = 2;
@@ -2915,10 +3264,26 @@ read_configuration(cups_file_t *fp)     /* I - File to read from */
        cupsdLogMessage(CUPSD_LOG_WARN, "Unknown HostNameLookups %s on line %d.",
                        value, linenum);
     }
-    else if (!strcasecmp(line, "LogLevel"))
+    else if (!strcasecmp(line, "AccessLogLevel") && value)
+    {
+     /*
+      * Amount of logging to do to access log...
+      */
+
+      if (!strcasecmp(value, "all"))
+        AccessLogLevel = CUPSD_ACCESSLOG_ALL;
+      else if (!strcasecmp(value, "actions"))
+        AccessLogLevel = CUPSD_ACCESSLOG_ACTIONS;
+      else if (!strcasecmp(value, "config"))
+        AccessLogLevel = CUPSD_ACCESSLOG_CONFIG;
+      else
+        cupsdLogMessage(CUPSD_LOG_WARN, "Unknown AccessLogLevel %s on line %d.",
+                       value, linenum);
+    }
+    else if (!strcasecmp(line, "LogLevel") && value)
     {
      /*
-      * Amount of logging to do...
+      * Amount of logging to do to error log...
       */
 
       if (!strcasecmp(value, "debug2"))
@@ -2945,7 +3310,21 @@ 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, "PrintcapFormat"))
+    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)
     {
      /*
       * Format of printcap file?
@@ -2953,13 +3332,15 @@ 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
        cupsdLogMessage(CUPSD_LOG_WARN, "Unknown PrintcapFormat %s on line %d.",
                        value, linenum);
     }
-    else if (!strcasecmp(line, "ServerTokens"))
+    else if (!strcasecmp(line, "ServerTokens") && value)
     {
      /*
       * Set the string used for the Server header...
@@ -2989,7 +3370,7 @@ read_configuration(cups_file_t *fp)       /* I - File to read from */
        cupsdLogMessage(CUPSD_LOG_WARN, "Unknown ServerTokens %s on line %d.",
                         value, linenum);
     }
-    else if (!strcasecmp(line, "PassEnv"))
+    else if (!strcasecmp(line, "PassEnv") && value)
     {
      /*
       * PassEnv variable [... variable]
@@ -3014,7 +3395,14 @@ read_configuration(cups_file_t *fp)      /* I - File to read from */
            break;
       }
     }
-    else if (!strcasecmp(line, "SetEnv"))
+    else if (!strcasecmp(line, "ServerAlias") && value)
+    {
+      if (!ServerAlias)
+        ServerAlias = cupsArrayNew(NULL, NULL);
+
+      cupsdAddAlias(ServerAlias, value);
+    }
+    else if (!strcasecmp(line, "SetEnv") && value)
     {
      /*
       * SetEnv variable value
@@ -3038,6 +3426,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
     {
      /*
@@ -3054,8 +3459,12 @@ read_configuration(cups_file_t *fp)      /* I - File to read from */
         * Unknown directive!  Output an error message and continue...
        */
 
-        cupsdLogMessage(CUPSD_LOG_ERROR, "Unknown directive %s on line %d.",
-                       line, linenum);
+        if (!value)
+         cupsdLogMessage(CUPSD_LOG_ERROR, "Missing value for %s on line %d.",
+                         line, linenum);
+       else
+         cupsdLogMessage(CUPSD_LOG_ERROR, "Unknown directive %s on line %d.",
+                         line, linenum);
         continue;
       }
 
@@ -3119,7 +3528,15 @@ read_configuration(cups_file_t *fp)      /* I - File to read from */
            break;
 
        case CUPSD_VARTYPE_PATHNAME :
-            if (value[0] == '/')
+            if (!value)
+           {
+             cupsdLogMessage(CUPSD_LOG_ERROR,
+                             "Missing pathname value for %s on line %d!",
+                             line, linenum);
+              break;
+           }
+
+           if (value[0] == '/')
              strlcpy(temp, value, sizeof(temp));
            else
              snprintf(temp, sizeof(temp), "%s/%s", ServerRoot, value);
@@ -3160,9 +3577,11 @@ read_location(cups_file_t *fp,           /* I - Configuration file */
                        *valptr;        /* Pointer into value */
 
 
-  if ((parent = cupsdAddLocation(location)) == NULL)
+  if ((parent = cupsdNewLocation(location)) == NULL)
     return (0);
 
+  cupsdAddLocation(parent);
+
   parent->limit = CUPSD_AUTH_LIMIT_ALL;
   loc           = parent;
 
@@ -3180,12 +3599,17 @@ 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)
+
+      if ((loc = cupsdCopyLocation(parent)) == NULL)
         return (0);
 
+      cupsdAddLocation(loc);
+
       loc->limit = 0;
       while (*value)
       {
@@ -3228,7 +3652,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);
     }
   }
 
@@ -3236,7 +3661,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);
 }
 
 
@@ -3287,29 +3712,7 @@ read_policy(cups_file_t *fp,             /* I - Configuration file */
                        "Missing </Limit> before </Policy> on line %d!",
                        linenum);
 
-     /*
-      * Verify that we have an explicit policy for CUPS-Get-Document
-      * (ensures that upgrades do not introduce new security issues...)
-      */
-
-      if ((op = cupsdFindPolicyOp(pol, CUPS_GET_DOCUMENT)) == NULL ||
-          op->op == IPP_ANY_OPERATION)
-      {
-        if ((op = cupsdFindPolicyOp(pol, IPP_SEND_DOCUMENT)) != NULL &&
-            op->op != IPP_ANY_OPERATION)
-       {
-        /*
-         * Add a new limit for CUPS-Get-Document using the Send-Document
-         * limit as a template...
-         */
-
-          cupsdLogMessage(CUPSD_LOG_WARN,
-                         "No limit for CUPS-Get-Document defined in policy %s "
-                         "- using Send-Document's policy", pol->name);
-
-          cupsdAddPolicyOp(pol, op, CUPS_GET_DOCUMENT);
-       }
-      }
+      set_policy_defaults(pol);
 
       return (linenum);
     }
@@ -3318,9 +3721,12 @@ 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;
       }
-      
+
      /*
       * Scan for IPP operation names...
       */
@@ -3387,12 +3793,116 @@ read_policy(cups_file_t *fp,           /* I - Configuration file */
 
       op = NULL;
     }
+    else if (!strcasecmp(line, "JobPrivateAccess") ||
+            !strcasecmp(line, "JobPrivateValues") ||
+            !strcasecmp(line, "SubscriptionPrivateAccess") ||
+            !strcasecmp(line, "SubscriptionPrivateValues"))
+    {
+      if (op)
+      {
+        cupsdLogMessage(CUPSD_LOG_ERROR,
+                       "%s directive must appear outside <Limit>...</Limit> "
+                       "on line %d.", line, linenum);
+       if (FatalErrors & CUPSD_FATAL_CONFIG)
+         return (0);
+      }
+      else
+      {
+       /*
+        * Pull out whitespace-delimited values...
+       */
+
+       while (*value)
+       {
+        /*
+         * Find the end of the current value...
+         */
+
+         for (valptr = value; !isspace(*valptr & 255) && *valptr; valptr ++);
+
+         if (*valptr)
+           *valptr++ = '\0';
+
+         /*
+         * Save it appropriately...
+         */
+
+         if (!strcasecmp(line, "JobPrivateAccess"))
+         {
+          /*
+           * JobPrivateAccess {all|default|user/group list|@@ACL}
+           */
+
+            if (!strcasecmp(value, "default"))
+           {
+             cupsdAddString(&(pol->job_access), "@OWNER");
+             cupsdAddString(&(pol->job_access), "@SYSTEM");
+           }
+           else
+             cupsdAddString(&(pol->job_access), value);
+         }
+         else if (!strcasecmp(line, "JobPrivateValues"))
+         {
+          /*
+           * JobPrivateValues {all|none|default|attribute list}
+           */
+
+           if (!strcasecmp(value, "default"))
+           {
+             cupsdAddString(&(pol->job_attrs), "job-name");
+             cupsdAddString(&(pol->job_attrs), "job-originating-host-name");
+             cupsdAddString(&(pol->job_attrs), "job-originating-user-name");
+           }
+           else
+             cupsdAddString(&(pol->job_attrs), value);
+         }
+         else if (!strcasecmp(line, "SubscriptionPrivateAccess"))
+         {
+          /*
+           * SubscriptionPrivateAccess {all|default|user/group list|@@ACL}
+           */
+
+            if (!strcasecmp(value, "default"))
+           {
+             cupsdAddString(&(pol->sub_access), "@OWNER");
+             cupsdAddString(&(pol->sub_access), "@SYSTEM");
+           }
+           else
+             cupsdAddString(&(pol->sub_access), value);
+         }
+         else /* if (!strcasecmp(line, "SubscriptionPrivateValues")) */
+         {
+          /*
+           * SubscriptionPrivateValues {all|none|default|attribute list}
+           */
+
+           if (!strcasecmp(value, "default"))
+           {
+             cupsdAddString(&(pol->sub_attrs), "notify-events");
+             cupsdAddString(&(pol->sub_attrs), "notify-pull-method");
+             cupsdAddString(&(pol->sub_attrs), "notify-recipient-uri");
+             cupsdAddString(&(pol->sub_attrs), "notify-subscriber-user-name");
+             cupsdAddString(&(pol->sub_attrs), "notify-user-data");
+           }
+           else
+             cupsdAddString(&(pol->sub_attrs), value);
+         }
+
+        /*
+         * Find the next string on the line...
+         */
+
+         for (value = valptr; isspace(*value & 255); value ++);
+       }
+      }
+    }
     else if (!op)
     {
       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))
     {
@@ -3405,7 +3915,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);
     }
   }
 
@@ -3413,10 +3924,188 @@ 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);
+}
+
+
+/*
+ * 'set_policy_defaults()' - Set default policy values as needed.
+ */
+
+static void
+set_policy_defaults(cupsd_policy_t *pol)/* I - Policy */
+{
+  cupsd_location_t     *op;            /* Policy operation */
+
+
+ /*
+  * Verify that we have an explicit policy for Validate-Job, Cancel-Jobs,
+  * Cancel-My-Jobs, Close-Job, and CUPS-Get-Document, which ensures that
+  * upgrades do not introduce new security issues...
+  */
+
+  if ((op = cupsdFindPolicyOp(pol, IPP_VALIDATE_JOB)) == NULL ||
+      op->op == IPP_ANY_OPERATION)
+  {
+    if ((op = cupsdFindPolicyOp(pol, IPP_PRINT_JOB)) != NULL &&
+       op->op != IPP_ANY_OPERATION)
+    {
+     /*
+      * Add a new limit for Validate-Job using the Print-Job limit as a
+      * template...
+      */
+
+      cupsdLogMessage(CUPSD_LOG_WARN,
+                     "No limit for Validate-Job defined in policy %s "
+                     "- using Print-Job's policy.", pol->name);
+
+      cupsdAddPolicyOp(pol, op, IPP_VALIDATE_JOB);
+    }
+    else
+      cupsdLogMessage(CUPSD_LOG_WARN,
+                     "No limit for Validate-Job defined in policy %s "
+                     "and no suitable template found.", pol->name);
+  }
+
+  if ((op = cupsdFindPolicyOp(pol, IPP_CANCEL_JOBS)) == NULL ||
+      op->op == IPP_ANY_OPERATION)
+  {
+    if ((op = cupsdFindPolicyOp(pol, IPP_PAUSE_PRINTER)) != NULL &&
+       op->op != IPP_ANY_OPERATION)
+    {
+     /*
+      * Add a new limit for Cancel-Jobs using the Pause-Printer limit as a
+      * template...
+      */
+
+      cupsdLogMessage(CUPSD_LOG_WARN,
+                     "No limit for Cancel-Jobs defined in policy %s "
+                     "- using Pause-Printer's policy.", pol->name);
+
+      cupsdAddPolicyOp(pol, op, IPP_CANCEL_JOBS);
+    }
+    else
+      cupsdLogMessage(CUPSD_LOG_WARN,
+                     "No limit for Cancel-Jobs defined in policy %s "
+                     "and no suitable template found.", pol->name);
+  }
+
+  if ((op = cupsdFindPolicyOp(pol, IPP_CANCEL_MY_JOBS)) == NULL ||
+      op->op == IPP_ANY_OPERATION)
+  {
+    if ((op = cupsdFindPolicyOp(pol, IPP_SEND_DOCUMENT)) != NULL &&
+       op->op != IPP_ANY_OPERATION)
+    {
+     /*
+      * Add a new limit for Cancel-My-Jobs using the Send-Document limit as
+      * a template...
+      */
+
+      cupsdLogMessage(CUPSD_LOG_WARN,
+                     "No limit for Cancel-My-Jobs defined in policy %s "
+                     "- using Send-Document's policy.", pol->name);
+
+      cupsdAddPolicyOp(pol, op, IPP_CANCEL_MY_JOBS);
+    }
+    else
+      cupsdLogMessage(CUPSD_LOG_WARN,
+                     "No limit for Cancel-My-Jobs defined in policy %s "
+                     "and no suitable template found.", pol->name);
+  }
+
+  if ((op = cupsdFindPolicyOp(pol, IPP_CLOSE_JOB)) == NULL ||
+      op->op == IPP_ANY_OPERATION)
+  {
+    if ((op = cupsdFindPolicyOp(pol, IPP_SEND_DOCUMENT)) != NULL &&
+       op->op != IPP_ANY_OPERATION)
+    {
+     /*
+      * Add a new limit for Close-Job using the Send-Document limit as a
+      * template...
+      */
+
+      cupsdLogMessage(CUPSD_LOG_WARN,
+                     "No limit for Close-Job defined in policy %s "
+                     "- using Send-Document's policy.", pol->name);
+
+      cupsdAddPolicyOp(pol, op, IPP_CLOSE_JOB);
+    }
+    else
+      cupsdLogMessage(CUPSD_LOG_WARN,
+                     "No limit for Close-Job defined in policy %s "
+                     "and no suitable template found.", pol->name);
+  }
+
+  if ((op = cupsdFindPolicyOp(pol, CUPS_GET_DOCUMENT)) == NULL ||
+      op->op == IPP_ANY_OPERATION)
+  {
+    if ((op = cupsdFindPolicyOp(pol, IPP_SEND_DOCUMENT)) != NULL &&
+       op->op != IPP_ANY_OPERATION)
+    {
+     /*
+      * Add a new limit for CUPS-Get-Document using the Send-Document
+      * limit as a template...
+      */
+
+      cupsdLogMessage(CUPSD_LOG_WARN,
+                     "No limit for CUPS-Get-Document defined in policy %s "
+                     "- using Send-Document's policy.", pol->name);
+
+      cupsdAddPolicyOp(pol, op, CUPS_GET_DOCUMENT);
+    }
+    else
+      cupsdLogMessage(CUPSD_LOG_WARN,
+                     "No limit for CUPS-Get-Document defined in policy %s "
+                     "and no suitable template found.", pol->name);
+  }
+
+ /*
+  * Verify we have JobPrivateAccess, JobPrivateValues,
+  * SubscriptionPrivateAccess, and SubscriptionPrivateValues in the policy.
+  */
+
+  if (!pol->job_access)
+  {
+    cupsdLogMessage(CUPSD_LOG_WARN,
+                   "No JobPrivateAccess defined in policy %s "
+                   "- using defaults.", pol->name);
+    cupsdAddString(&(pol->job_access), "@OWNER");
+    cupsdAddString(&(pol->job_access), "@SYSTEM");
+  }
+
+  if (!pol->job_attrs)
+  {
+    cupsdLogMessage(CUPSD_LOG_WARN,
+                   "No JobPrivateValues defined in policy %s "
+                   "- using defaults.", pol->name);
+    cupsdAddString(&(pol->job_attrs), "job-name");
+    cupsdAddString(&(pol->job_attrs), "job-originating-host-name");
+    cupsdAddString(&(pol->job_attrs), "job-originating-user-name");
+  }
+
+  if (!pol->sub_access)
+  {
+    cupsdLogMessage(CUPSD_LOG_WARN,
+                   "No SubscriptionPrivateAccess defined in policy %s "
+                   "- using defaults.", pol->name);
+    cupsdAddString(&(pol->sub_access), "@OWNER");
+    cupsdAddString(&(pol->sub_access), "@SYSTEM");
+  }
+
+  if (!pol->sub_attrs)
+  {
+    cupsdLogMessage(CUPSD_LOG_WARN,
+                   "No SubscriptionPrivateValues defined in policy %s "
+                   "- using defaults.", pol->name);
+    cupsdAddString(&(pol->sub_attrs), "notify-events");
+    cupsdAddString(&(pol->sub_attrs), "notify-pull-method");
+    cupsdAddString(&(pol->sub_attrs), "notify-recipient-uri");
+    cupsdAddString(&(pol->sub_attrs), "notify-subscriber-user-name");
+    cupsdAddString(&(pol->sub_attrs), "notify-user-data");
+  }
 }
 
 
 /*
- * End of "$Id: conf.c 6930 2007-09-08 00:28:06Z mike $".
+ * End of "$Id: conf.c 9352 2010-11-06 04:55:26Z mike $".
  */