]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - scheduler/conf.c
File cleanup.
[thirdparty/cups.git] / scheduler / conf.c
index 8ae27c83751aa5a35385ca44f96b94e911ff0458..4320ce660af97fd6456e4444595f571fc1e6d617 100644 (file)
@@ -3,7 +3,7 @@
  *
  *   Configuration routines for the Common UNIX Printing System (CUPS).
  *
- *   Copyright 1997-2005 by Easy Software Products, all rights reserved.
+ *   Copyright 1997-2006 by Easy Software Products, all rights reserved.
  *
  *   These coded instructions, statements, and computer programs are the
  *   property of Easy Software Products and are protected by Federal
  * Contents:
  *
  *   cupsdReadConfiguration() - Read the cupsd.conf file.
+ *   check_permissions()      - Fix the mode and ownership of a file or
+ *                              directory.
  *   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_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.
- *   CDSAGetServerCerts()     - Convert a keychain name into the CFArrayRef
- *                              required by SSLSetCertificate.
  */
 
 /*
 #include <sys/utsname.h>
 #include <cups/dir.h>
 
-#ifdef HAVE_CDSASSL
-#  include <Security/SecureTransport.h>
-#  include <Security/SecIdentitySearch.h>
-#endif /* HAVE_CDSASSL */
-
 #ifdef HAVE_VSYSLOG
 #  include <syslog.h>
 #endif /* HAVE_VSYSLOG */
@@ -92,6 +89,12 @@ static cupsd_var_t   variables[] =
   { "AccessLog",               &AccessLog,             CUPSD_VARTYPE_STRING },
   { "AutoPurgeJobs",           &JobAutoPurge,          CUPSD_VARTYPE_BOOLEAN },
   { "BrowseInterval",          &BrowseInterval,        CUPSD_VARTYPE_INTEGER },
+#ifdef HAVE_LDAP
+  { "BrowseLDAPBindDN",                &BrowseLDAPBindDN,      CUPSD_VARTYPE_STRING },
+  { "BrowseLDAPDN",            &BrowseLDAPDN,          CUPSD_VARTYPE_STRING },
+  { "BrowseLDAPPassword",      &BrowseLDAPPassword,    CUPSD_VARTYPE_STRING },
+  { "BrowseLDAPServer",                &BrowseLDAPServer,      CUPSD_VARTYPE_STRING },
+#endif /* HAVE_LDAP */
   { "BrowseLocalOptions",      &BrowseLocalOptions,    CUPSD_VARTYPE_STRING },
   { "BrowsePort",              &BrowsePort,            CUPSD_VARTYPE_INTEGER },
   { "BrowseRemoteOptions",     &BrowseRemoteOptions,   CUPSD_VARTYPE_STRING },
@@ -105,11 +108,11 @@ static cupsd_var_t        variables[] =
   { "DataDir",                 &DataDir,               CUPSD_VARTYPE_STRING },
   { "DefaultCharset",          &DefaultCharset,        CUPSD_VARTYPE_STRING },
   { "DefaultLanguage",         &DefaultLanguage,       CUPSD_VARTYPE_STRING },
+  { "DefaultLeaseDuration",    &DefaultLeaseDuration,  CUPSD_VARTYPE_INTEGER },
   { "DefaultPolicy",           &DefaultPolicy,         CUPSD_VARTYPE_STRING },
+  { "DefaultShared",           &DefaultShared,         CUPSD_VARTYPE_BOOLEAN },
   { "DocumentRoot",            &DocumentRoot,          CUPSD_VARTYPE_STRING },
   { "ErrorLog",                        &ErrorLog,              CUPSD_VARTYPE_STRING },
-  { "FaxRetryLimit",           &FaxRetryLimit,         CUPSD_VARTYPE_INTEGER },
-  { "FaxRetryInterval",                &FaxRetryInterval,      CUPSD_VARTYPE_INTEGER },
   { "FileDevice",              &FileDevice,            CUPSD_VARTYPE_BOOLEAN },
   { "FilterLimit",             &FilterLimit,           CUPSD_VARTYPE_INTEGER },
   { "FilterNice",              &FilterNice,            CUPSD_VARTYPE_INTEGER },
@@ -117,6 +120,8 @@ static cupsd_var_t  variables[] =
   { "HideImplicitMembers",     &HideImplicitMembers,   CUPSD_VARTYPE_BOOLEAN },
   { "ImplicitClasses",         &ImplicitClasses,       CUPSD_VARTYPE_BOOLEAN },
   { "ImplicitAnyClasses",      &ImplicitAnyClasses,    CUPSD_VARTYPE_BOOLEAN },
+  { "JobRetryLimit",           &JobRetryLimit,         CUPSD_VARTYPE_INTEGER },
+  { "JobRetryInterval",                &JobRetryInterval,      CUPSD_VARTYPE_INTEGER },
   { "KeepAliveTimeout",                &KeepAliveTimeout,      CUPSD_VARTYPE_INTEGER },
   { "KeepAlive",               &KeepAlive,             CUPSD_VARTYPE_BOOLEAN },
   { "LimitRequestBody",                &MaxRequestSize,        CUPSD_VARTYPE_INTEGER },
@@ -126,12 +131,18 @@ static cupsd_var_t        variables[] =
   { "MaxClients",              &MaxClients,            CUPSD_VARTYPE_INTEGER },
   { "MaxClientsPerHost",       &MaxClientsPerHost,     CUPSD_VARTYPE_INTEGER },
   { "MaxCopies",               &MaxCopies,             CUPSD_VARTYPE_INTEGER },
+  { "MaxEvents",               &MaxEvents,             CUPSD_VARTYPE_INTEGER },
   { "MaxJobs",                 &MaxJobs,               CUPSD_VARTYPE_INTEGER },
   { "MaxJobsPerPrinter",       &MaxJobsPerPrinter,     CUPSD_VARTYPE_INTEGER },
   { "MaxJobsPerUser",          &MaxJobsPerUser,        CUPSD_VARTYPE_INTEGER },
+  { "MaxLeaseDuration",                &MaxLeaseDuration,      CUPSD_VARTYPE_INTEGER },
   { "MaxLogSize",              &MaxLogSize,            CUPSD_VARTYPE_INTEGER },
   { "MaxPrinterHistory",       &MaxPrinterHistory,     CUPSD_VARTYPE_INTEGER },
   { "MaxRequestSize",          &MaxRequestSize,        CUPSD_VARTYPE_INTEGER },
+  { "MaxSubscriptions",                &MaxSubscriptions,      CUPSD_VARTYPE_INTEGER },
+  { "MaxSubscriptionsPerJob",  &MaxSubscriptionsPerJob,        CUPSD_VARTYPE_INTEGER },
+  { "MaxSubscriptionsPerPrinter",&MaxSubscriptionsPerPrinter,  CUPSD_VARTYPE_INTEGER },
+  { "MaxSubscriptionsPerUser", &MaxSubscriptionsPerUser,       CUPSD_VARTYPE_INTEGER },
   { "PageLog",                 &PageLog,               CUPSD_VARTYPE_STRING },
   { "PreserveJobFiles",                &JobFiles,              CUPSD_VARTYPE_BOOLEAN },
   { "PreserveJobHistory",      &JobHistory,            CUPSD_VARTYPE_BOOLEAN },
@@ -141,7 +152,6 @@ static cupsd_var_t  variables[] =
   { "RemoteRoot",              &RemoteRoot,            CUPSD_VARTYPE_STRING },
   { "RequestRoot",             &RequestRoot,           CUPSD_VARTYPE_STRING },
   { "RIPCache",                        &RIPCache,              CUPSD_VARTYPE_STRING },
-  { "RunAsUser",               &RunAsUser,             CUPSD_VARTYPE_BOOLEAN },
   { "RootCertDuration",                &RootCertDuration,      CUPSD_VARTYPE_INTEGER },
   { "ServerAdmin",             &ServerAdmin,           CUPSD_VARTYPE_STRING },
   { "ServerBin",               &ServerBin,             CUPSD_VARTYPE_STRING },
@@ -151,11 +161,16 @@ static cupsd_var_t        variables[] =
   { "ServerKey",               &ServerKey,             CUPSD_VARTYPE_STRING },
 #  endif /* HAVE_LIBSSL || HAVE_GNUTLS */
 #endif /* HAVE_SSL */
+#ifdef HAVE_LAUNCHD
+  { "LaunchdTimeout",          &LaunchdTimeout,        CUPSD_VARTYPE_INTEGER },
+  { "LaunchdConf",             &LaunchdConf,           CUPSD_VARTYPE_STRING },
+#endif /* HAVE_LAUNCHD */
   { "ServerName",              &ServerName,            CUPSD_VARTYPE_STRING },
   { "ServerRoot",              &ServerRoot,            CUPSD_VARTYPE_STRING },
   { "StateDir",                        &StateDir,              CUPSD_VARTYPE_STRING },
   { "TempDir",                 &TempDir,               CUPSD_VARTYPE_STRING },
-  { "Timeout",                 &Timeout,               CUPSD_VARTYPE_INTEGER }
+  { "Timeout",                 &Timeout,               CUPSD_VARTYPE_INTEGER },
+  { "UseNetworkDefault",       &UseNetworkDefault,     CUPSD_VARTYPE_BOOLEAN }
 };
 #define NUM_VARS       (sizeof(variables) / sizeof(variables[0]))
 
@@ -169,23 +184,24 @@ static unsigned           zeros[4] =
                          0x00000000, 0x00000000, 0x00000000, 0x00000000
                        };
 
-#ifdef HAVE_CDSASSL
-CFArrayRef CDSAGetServerCerts();
-#endif /* HAVE_CDSASSL */
-
 
 /*
  * Local functions...
  */
-
-static int     get_address(const char *value, unsigned defaddress, int defport,
-                           int deffamily, http_addr_t *address);
-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     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 int             check_permissions(const char *filename,
+                                         const char *suffix, int mode,
+                                         int user, int group, int is_dir,
+                                         int create_dir);
+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_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);
 
 
 /*
@@ -200,19 +216,14 @@ cupsdReadConfiguration(void)
   int          status;                 /* Return status */
   char         temp[1024],             /* Temporary buffer */
                *slash;                 /* Directory separator */
-  char         type[MIME_MAX_SUPER + MIME_MAX_TYPE];
-                                       /* MIME type name */
   cups_lang_t  *language;              /* Language */
   struct passwd        *user;                  /* Default user */
   struct group *group;                 /* Default group */
   char         *old_serverroot,        /* Old ServerRoot */
                *old_requestroot;       /* Old RequestRoot */
+  const char   *tmpdir;                /* TMPDIR environment variable */
+  struct stat  tmpinfo;                /* Temporary directory info */
 
- /*
-  * Shutdown the server...
-  */
-
-  cupsdStopServer();
 
  /*
   * Save the old root paths...
@@ -254,21 +265,7 @@ cupsdReadConfiguration(void)
     NumRelays = 0;
   }
 
-  if (NumListeners > 0)
-  {
-#ifdef HAVE_DOMAINSOCKETS
-    int                        i;              /* Looping var */
-    cupsd_listener_t   *lis;           /* Current listening socket */
-
-    for (i = NumListeners, lis = Listeners; i > 0; i --, lis ++)
-      if (lis->address.sin_family == AF_LOCAL)
-       cupsdClearString((char **)&lis->address.sin_addr);
-#endif /* HAVE_DOMAINSOCKETS */
-
-    free(Listeners);
-
-    NumListeners = 0;
-  }
+  cupsdDeleteAllListeners();
 
  /*
   * String options...
@@ -288,7 +285,7 @@ cupsdReadConfiguration(void)
   cupsdSetString(&PrintcapGUI, "/usr/bin/glpoptions");
   cupsdSetString(&FontPath, CUPS_FONTPATH);
   cupsdSetString(&RemoteRoot, "remroot");
-  cupsdSetString(&ServerHeader, "CUPS/1.1");
+  cupsdSetString(&ServerHeader, "CUPS/1.2");
   cupsdSetString(&StateDir, CUPS_STATEDIR);
 
   strlcpy(temp, ConfigurationFile, sizeof(temp));
@@ -302,7 +299,7 @@ cupsdReadConfiguration(void)
 
 #ifdef HAVE_SSL
 #  ifdef HAVE_CDSASSL
-  cupsdSetString(&ServerCertificate, "/var/root/Library/Keychains/CUPS");
+  cupsdSetString(&ServerCertificate, "/Library/Keychains/System.keychain");
 #  else
   cupsdSetString(&ServerCertificate, "ssl/server.crt");
   cupsdSetString(&ServerKey, "ssl/server.key");
@@ -316,50 +313,11 @@ cupsdReadConfiguration(void)
   else
     cupsdSetString(&DefaultLanguage, language->language);
 
-  cupsdSetString(&DefaultCharset, cupsEncodingName(language->encoding));
+  cupsdSetString(&DefaultCharset, _cupsEncodingName(language->encoding));
 
   cupsdSetString(&RIPCache, "8m");
 
-  if (getenv("TMPDIR") == NULL)
-    cupsdSetString(&TempDir, CUPS_REQUESTS "/tmp");
-  else
-    cupsdSetString(&TempDir, getenv("TMPDIR"));
-
- /*
-  * Find the default system group: "sys", "system", or "root"...
-  */
-
-  group = getgrnam(CUPS_DEFAULT_GROUP);
-  endgrent();
-
-  NumSystemGroups = 0;
-
-  if (group != NULL)
-  {
-   /*
-    * Found the group, use it!
-    */
-
-    cupsdSetString(&SystemGroups[0], CUPS_DEFAULT_GROUP);
-
-    SystemGroupIDs[0] = group->gr_gid;
-  }
-  else
-  {
-   /*
-    * Find the group associated with GID 0...
-    */
-
-    group = getgrgid(0);
-    endgrent();
-
-    if (group != NULL)
-      cupsdSetString(&SystemGroups[0], group->gr_name);
-    else
-      cupsdSetString(&SystemGroups[0], "unknown");
-
-    SystemGroupIDs[0] = 0;
-  }
+  cupsdSetString(&TempDir, NULL);
 
  /*
   * Find the default user...
@@ -402,44 +360,55 @@ cupsdReadConfiguration(void)
   * Numeric options...
   */
 
-  ConfigFilePerm      = 0640;
-  DefaultAuthType     = AUTH_BASIC;
-  FaxRetryLimit       = 5;
-  FaxRetryInterval    = 300;
-  FileDevice          = FALSE;
-  FilterLevel         = 0;
-  FilterLimit         = 0;
-  FilterNice          = 0;
-  HostNameLookups     = FALSE;
-  ImplicitClasses     = TRUE;
-  ImplicitAnyClasses  = FALSE;
-  HideImplicitMembers = TRUE;
-  KeepAlive           = TRUE;
-  KeepAliveTimeout    = DEFAULT_KEEPALIVE;
-  ListenBackLog       = SOMAXCONN;
-  LogFilePerm         = 0644;
-  LogLevel            = CUPSD_LOG_ERROR;
-  MaxClients          = 100;
-  MaxClientsPerHost   = 0;
-  MaxLogSize          = 1024 * 1024;
-  MaxPrinterHistory   = 10;
-  MaxRequestSize      = 0;
-  ReloadTimeout              = 60;
-  RootCertDuration    = 300;
-  RunAsUser           = FALSE;
-  Timeout             = DEFAULT_TIMEOUT;
+  ConfigFilePerm        = CUPS_DEFAULT_CONFIG_FILE_PERM;
+  DefaultAuthType       = AUTH_BASIC;
+#ifdef HAVE_SSL
+  DefaultEncryption     = HTTP_ENCRYPT_REQUIRED;
+#endif /* HAVE_SSL */
+  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  = BROWSE_CUPS;
-  BrowseRemoteProtocols = BROWSE_CUPS;
-  BrowseShortNames      = TRUE;
+  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              = TRUE;
+  Browsing              = CUPS_DEFAULT_BROWSING;
+  DefaultShared         = CUPS_DEFAULT_DEFAULT_SHARED;
 
   cupsdClearString(&BrowseLocalOptions);
   cupsdClearString(&BrowseRemoteOptions);
 
+#ifdef HAVE_LDAP
+  cupsdClearString(&BrowseLDAPBindDN);
+  cupsdClearString(&BrowseLDAPDN);
+  cupsdClearString(&BrowseLDAPPassword);
+  cupsdClearString(&BrowseLDAPServer);
+#endif /* HAVE_LDAP */
+
   JobHistory          = DEFAULT_HISTORY;
   JobFiles            = DEFAULT_FILES;
   JobAutoPurge        = 0;
@@ -449,8 +418,21 @@ cupsdReadConfiguration(void)
   MaxJobsPerPrinter   = 0;
   MaxCopies           = 100;
 
+  cupsdDeleteAllPolicies();
   cupsdClearString(&DefaultPolicy);
 
+  MaxSubscriptions           = 100;
+  MaxSubscriptionsPerJob     = 0;
+  MaxSubscriptionsPerPrinter = 0;
+  MaxSubscriptionsPerUser    = 0;
+  DefaultLeaseDuration       = 86400;
+  MaxLeaseDuration           = 0;
+
+#ifdef HAVE_LAUNCHD
+  LaunchdTimeout = DEFAULT_TIMEOUT + 10;
+  cupsdSetString(&LaunchdConf, CUPS_DEFAULT_LAUNCHD_CONF);
+#endif /* HAVE_LAUNCHD */
+
  /*
   * Read the configuration file...
   */
@@ -465,17 +447,32 @@ cupsdReadConfiguration(void)
   if (!status)
     return (0);
 
-  if (RunAsUser)
-    RunUser = User;
-  else
-    RunUser = getuid();
+  RunUser = getuid();
 
  /*
   * Use the default system group if none was supplied in cupsd.conf...
   */
 
   if (NumSystemGroups == 0)
-    NumSystemGroups ++;
+  {
+    if (!parse_groups(CUPS_DEFAULT_SYSTEM_GROUPS))
+    {
+     /*
+      * Find the group associated with GID 0...
+      */
+
+      group = getgrgid(0);
+      endgrent();
+
+      if (group != NULL)
+       cupsdSetString(&SystemGroups[0], group->gr_name);
+      else
+       cupsdSetString(&SystemGroups[0], "unknown");
+
+      SystemGroupIDs[0] = 0;
+      NumSystemGroups   = 1;
+    }
+  }
 
  /*
   * Get the access control list for browsing...
@@ -545,7 +542,7 @@ cupsdReadConfiguration(void)
   * as an error and exit!
   */
 
-  if (NumListeners == 0)
+  if (cupsArrayCount(Listeners) == 0)
   {
    /*
     * No listeners!
@@ -590,15 +587,21 @@ cupsdReadConfiguration(void)
   if (ServerCertificate[0] != '/')
     cupsdSetStringf(&ServerCertificate, "%s/%s", ServerRoot, ServerCertificate);
 
-#  if defined(HAVE_LIBSSL) || defined(HAVE_GNUTLS)
-  chown(ServerCertificate, RunUser, Group);
-  chmod(ServerCertificate, ConfigFilePerm);
+  if (!strncmp(ServerRoot, ServerCertificate, strlen(ServerRoot)))
+  {
+    chown(ServerCertificate, RunUser, Group);
+    chmod(ServerCertificate, 0600);
+  }
 
+#  if defined(HAVE_LIBSSL) || defined(HAVE_GNUTLS)
   if (ServerKey[0] != '/')
     cupsdSetStringf(&ServerKey, "%s/%s", ServerRoot, ServerKey);
 
-  chown(ServerKey, RunUser, Group);
-  chmod(ServerKey, ConfigFilePerm);
+  if (!strncmp(ServerRoot, ServerKey, strlen(ServerRoot)))
+  {
+    chown(ServerKey, RunUser, Group);
+    chmod(ServerKey, 0600);
+  }
 #  endif /* HAVE_LIBSSL || HAVE_GNUTLS */
 #endif /* HAVE_SSL */
 
@@ -607,65 +610,63 @@ cupsdReadConfiguration(void)
   * writable by the user and group in the cupsd.conf file...
   */
 
-  chown(CacheDir, RunUser, Group);
-  chmod(CacheDir, 0775);
-
-  snprintf(temp, sizeof(temp), "%s/ppd", CacheDir);
-  if (access(temp, 0))
-    mkdir(temp, 0755);
-  chown(temp, RunUser, Group);
-  chmod(temp, 0755);
-
-  chown(StateDir, RunUser, Group);
-  chmod(StateDir, 0775);
-
-  snprintf(temp, sizeof(temp), "%s/certs", StateDir);
-  if (access(temp, 0))
-    mkdir(temp, 0510);
-  chown(temp, User, SystemGroupIDs[0]);
-  if (RunUser)
-    chmod(temp, 0710);
-  else
-    chmod(temp, 0510);
+  check_permissions(CacheDir, NULL, 0775, RunUser, Group, 1, 1);
+/*  check_permissions(CacheDir, "ppd", 0755, RunUser, Group, 1, 1);*/
 
-  chown(ServerRoot, RunUser, Group);
-  chmod(ServerRoot, 0755);
+  check_permissions(StateDir, NULL, 0755, RunUser, Group, 1, 1);
+  check_permissions(StateDir, "certs", RunUser ? 0711 : 0511, User,
+                    SystemGroupIDs[0], 1, 1);
 
-  snprintf(temp, sizeof(temp), "%s/ppd", ServerRoot);
-  if (access(temp, 0))
-    mkdir(temp, 0755);
-  chown(temp, RunUser, Group);
-  chmod(temp, 0755);
+  check_permissions(ServerRoot, NULL, 0755, RunUser, Group, 1, 0);
+  check_permissions(ServerRoot, "ppd", 0755, RunUser, Group, 1, 1);
+  check_permissions(ServerRoot, "ssl", 0700, RunUser, Group, 1, 0);
+  check_permissions(ServerRoot, "cupsd.conf", ConfigFilePerm, RunUser, Group,
+                    0, 0);
+  check_permissions(ServerRoot, "classes.conf", 0600, RunUser, Group, 0, 0);
+  check_permissions(ServerRoot, "printers.conf", 0600, RunUser, Group, 0, 0);
+  check_permissions(ServerRoot, "passwd.md5", 0600, User, Group, 0, 0);
 
-  snprintf(temp, sizeof(temp), "%s/ssl", ServerRoot);
-  if (access(temp, 0))
-    mkdir(temp, 0700);
-  chown(temp, RunUser, Group);
-  chmod(temp, 0700);
+ /*
+  * Update TempDir to the default if it hasn't been set already...
+  */
 
-  snprintf(temp, sizeof(temp), "%s/cupsd.conf", ServerRoot);
-  chown(temp, RunUser, Group);
-  chmod(temp, ConfigFilePerm);
+  if (!TempDir)
+  {
+    if ((tmpdir = getenv("TMPDIR")) != NULL)
+    {
+     /*
+      * TMPDIR is defined, see if it is OK for us to use...
+      */
 
-  snprintf(temp, sizeof(temp), "%s/classes.conf", ServerRoot);
-  chown(temp, RunUser, Group);
-  chmod(temp, 0600);
+      if (stat(tmpdir, &tmpinfo))
+        cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to access TMPDIR (%s): %s",
+                       tmpdir, strerror(errno));
+      else if (!S_ISDIR(tmpinfo.st_mode))
+        cupsdLogMessage(CUPSD_LOG_ERROR, "TMPDIR (%s) is not a directory!",
+                       tmpdir);
+      else if ((tmpinfo.st_uid != User || !(tmpinfo.st_mode & S_IWUSR)) &&
+               (tmpinfo.st_gid != Group || !(tmpinfo.st_mode & S_IWGRP)) &&
+              !(tmpinfo.st_mode & S_IWOTH))
+        cupsdLogMessage(CUPSD_LOG_ERROR,
+                       "TMPDIR (%s) has the wrong permissions!", tmpdir);
+      else
+        cupsdSetString(&TempDir, tmpdir);
 
-  snprintf(temp, sizeof(temp), "%s/printers.conf", ServerRoot);
-  chown(temp, RunUser, Group);
-  chmod(temp, 0600);
+      if (!TempDir)
+        cupsdLogMessage(CUPSD_LOG_INFO, "Using default TempDir of %s/tmp...",
+                       RequestRoot);
+    }
 
-  snprintf(temp, sizeof(temp), "%s/passwd.md5", ServerRoot);
-  chown(temp, User, Group);
-  chmod(temp, 0600);
+    if (!TempDir)
+      cupsdSetStringf(&TempDir, "%s/tmp", RequestRoot);
+  }
 
  /*
   * Make sure the request and temporary directories have the right
   * permissions...
   */
 
-  chown(RequestRoot, RunUser, Group);
-  chmod(RequestRoot, 0710);
+  check_permissions(RequestRoot, NULL, 0710, RunUser, Group, 1, 1);
 
   if (!strncmp(TempDir, RequestRoot, strlen(RequestRoot)) ||
       access(TempDir, 0))
@@ -675,11 +676,7 @@ cupsdReadConfiguration(void)
     * is under the spool directory or does not exist...
     */
 
-    if (access(TempDir, 0))
-      mkdir(TempDir, 01770);
-
-    chown(TempDir, RunUser, Group);
-    chmod(TempDir, 01770);
+    check_permissions(TempDir, NULL, 01770, RunUser, Group, 1, 1);
   }
 
   if (!strncmp(TempDir, RequestRoot, strlen(RequestRoot)))
@@ -738,16 +735,8 @@ cupsdReadConfiguration(void)
     MaxClients = MaxFDs / 3;
   }
 
-  if ((Clients = calloc(sizeof(cupsd_client_t), MaxClients)) == NULL)
-  {
-    cupsdLogMessage(CUPSD_LOG_ERROR,
-                    "cupsdReadConfiguration: Unable to allocate memory for %d clients: %s",
-                    MaxClients, strerror(errno));
-    exit(1);
-  }
-  else
-    cupsdLogMessage(CUPSD_LOG_INFO, "Configured for up to %d clients.",
-                    MaxClients);
+  cupsdLogMessage(CUPSD_LOG_INFO, "Configured for up to %d clients.",
+                  MaxClients);
 
  /*
   * Check the MaxActiveJobs setting; limit to 1/3 the available
@@ -901,6 +890,13 @@ cupsdReadConfiguration(void)
     }
   }
 
+  cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdReadConfiguration: NumPolicies=%d",
+                  NumPolicies);
+  for (i = 0; i < NumPolicies; i ++)
+    cupsdLogMessage(CUPSD_LOG_DEBUG2,
+                    "cupsdReadConfiguration: Policies[%d]=\"%s\"", i,
+                    Policies[i]->name);
+
  /*
   * If we are doing a full reload or the server root has changed, flush
   * the jobs, printers, etc. and start from scratch...
@@ -910,12 +906,18 @@ cupsdReadConfiguration(void)
       !old_serverroot || !ServerRoot || strcmp(old_serverroot, ServerRoot) ||
       !old_requestroot || !RequestRoot || strcmp(old_requestroot, RequestRoot))
   {
+    mime_type_t        *type;                  /* Current type */
+    char       mimetype[MIME_MAX_SUPER + MIME_MAX_TYPE];
+                                       /* MIME type name */
+
+
     cupsdLogMessage(CUPSD_LOG_INFO, "Full reload is required.");
 
    /*
     * Free all memory...
     */
 
+    cupsdDeleteAllSubscriptions();
     cupsdFreeAllJobs();
     cupsdDeleteAllClasses();
     cupsdDeleteAllPrinters();
@@ -928,7 +930,7 @@ cupsdReadConfiguration(void)
     if (NumMimeTypes)
     {
       for (i = 0; i < NumMimeTypes; i ++)
-       free((void *)MimeTypes[i]);
+       _cups_sp_free(MimeTypes[i]);
 
       free(MimeTypes);
     }
@@ -950,29 +952,52 @@ cupsdReadConfiguration(void)
 
     cupsdLogMessage(CUPSD_LOG_INFO,
                     "Loaded MIME database from \'%s\': %d types, %d filters...",
-                    ServerRoot, MimeDatabase->num_types, MimeDatabase->num_filters);
+                    ServerRoot, mimeNumTypes(MimeDatabase),
+                   mimeNumFilters(MimeDatabase));
 
    /*
     * Create a list of MIME types for the document-format-supported
     * attribute...
     */
 
-    NumMimeTypes = MimeDatabase->num_types;
+    NumMimeTypes = mimeNumTypes(MimeDatabase);
     if (!mimeType(MimeDatabase, "application", "octet-stream"))
       NumMimeTypes ++;
 
     MimeTypes = calloc(NumMimeTypes, sizeof(const char *));
 
-    for (i = 0; i < MimeDatabase->num_types; i ++)
+    for (i = 0, type = mimeFirstType(MimeDatabase);
+         type;
+        i ++, type = mimeNextType(MimeDatabase))
     {
-      snprintf(type, sizeof(type), "%s/%s", MimeDatabase->types[i]->super,
-               MimeDatabase->types[i]->type);
+      snprintf(mimetype, sizeof(mimetype), "%s/%s", type->super, type->type);
 
-      MimeTypes[i] = strdup(type);
+      MimeTypes[i] = _cups_sp_alloc(mimetype);
     }
 
     if (i < NumMimeTypes)
-      MimeTypes[i] = strdup("application/octet-stream");
+      MimeTypes[i] = _cups_sp_alloc("application/octet-stream");
+
+    if (LogLevel == CUPSD_LOG_DEBUG2)
+    {
+      mime_filter_t    *filter;        /* Current filter */
+
+
+      for (type = mimeFirstType(MimeDatabase);
+           type;
+          type = mimeNextType(MimeDatabase))
+       cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdReadConfiguration: type %s/%s",
+                       type->super, type->type);
+
+      for (filter = mimeFirstFilter(MimeDatabase);
+           filter;
+          filter = mimeNextFilter(MimeDatabase))
+       cupsdLogMessage(CUPSD_LOG_DEBUG2,
+                       "cupsdReadConfiguration: filter %s/%s to %s/%s %d %s",
+                       filter->src->super, filter->src->type,
+                       filter->dst->super, filter->dst->type,
+                       filter->cost, filter->filter);
+    }
 
    /*
     * Load banners...
@@ -987,6 +1012,8 @@ cupsdReadConfiguration(void)
 
     cupsdLoadAllPrinters();
     cupsdLoadAllClasses();
+    cupsdLoadRemoteCache();
+    cupsdWritePrintcap();
 
     cupsdCreateCommonData();
 
@@ -996,12 +1023,29 @@ cupsdReadConfiguration(void)
 
     cupsdLoadAllJobs();
 
+   /*
+    * Load subscriptions...
+    */
+
+    cupsdLoadAllSubscriptions();
+
     cupsdLogMessage(CUPSD_LOG_INFO, "Full reload complete.");
   }
   else
   {
+   /*
+    * Not a full reload, so recreate the common printer attributes...
+    */
+
     cupsdCreateCommonData();
 
+   /*
+    * Update all printers as needed...
+    */
+
+    cupsdUpdatePrinters();
+    cupsdWritePrintcap();
+
     cupsdLogMessage(CUPSD_LOG_INFO, "Partial reload complete.");
   }
 
@@ -1014,171 +1058,191 @@ cupsdReadConfiguration(void)
   cupsdClearString(&old_serverroot);
   cupsdClearString(&old_requestroot);
 
- /*
-  * Startup the server and return...
-  */
-
-  cupsdStartServer();
-
   return (1);
 }
 
 
 /*
- * 'get_address()' - Get an address + port number from a line.
+ * 'check_permissions()' - Fix the mode and ownership of a file or directory.
  */
 
-static int                             /* O - 1 if address good, 0 if bad */
-get_address(const char  *value,                /* I - Value string */
-            unsigned    defaddress,    /* I - Default address */
-           int         defport,        /* I - Default port */
-           int         deffamily,      /* I - Default family */
-            http_addr_t *address)      /* O - Socket address */
+static int                             /* O - 0 on success, -1 on error */
+check_permissions(const char *filename,        /* I - File/directory name */
+                  const char *suffix,  /* I - Additional file/directory name */
+                  int        mode,     /* I - Permissions */
+                 int        user,      /* I - Owner */
+                 int        group,     /* I - Group */
+                 int        is_dir,    /* I - 1 = directory, 0 = file */
+                 int        create_dir)/* I - 1 = create directory, 0 = not */
 {
-  char                 hostname[256],  /* Hostname or IP */
-                       portname[256],  /* Port number or name */
-                       *ptr;           /* Pointer into hostname string */
-  struct hostent       *host;          /* Host address */
-  struct servent       *port;          /* Port number */  
+  int          dir_created = 0;        /* Did we create a directory? */
+  char         pathname[1024];         /* File name with prefix */
+  struct stat  fileinfo;               /* Stat buffer */
 
 
  /*
-  * Check for an empty value...
+  * Prepend the given root to the filename before testing it...
   */
 
-  if (!*value)
+  if (suffix)
   {
-    cupsdLogMessage(CUPSD_LOG_ERROR, "Bad (empty) address!");
-    return (0);
+    snprintf(pathname, sizeof(pathname), "%s/%s", filename, suffix);
+    filename = pathname;
   }
 
  /*
-  * Initialize the socket address to the defaults...
+  * See if we can stat the file/directory...
   */
 
-  memset(address, 0, sizeof(http_addr_t));
+  if (stat(filename, &fileinfo))
+  {
+    if (errno == ENOENT && create_dir)
+    {
+      cupsdLogMessage(CUPSD_LOG_ERROR, "Creating missing directory \"%s\"",
+                      filename);
 
-#ifdef AF_INET6
-  if (deffamily == AF_INET6)
+      if (mkdir(filename, mode))
+      {
+        cupsdLogMessage(CUPSD_LOG_ERROR,
+                       "Unable to create directory \"%s\" - %s", filename,
+                       strerror(errno));
+        return (-1);
+      }
+
+      dir_created = 1;
+    }
+    else
+      return (-1);
+  }
+
+ /*
+  * Make sure it's a regular file...
+  */
+
+  if (!dir_created && !is_dir && !S_ISREG(fileinfo.st_mode))
   {
-    address->ipv6.sin6_family            = AF_INET6;
-    address->ipv6.sin6_addr.s6_addr32[0] = htonl(defaddress);
-    address->ipv6.sin6_addr.s6_addr32[1] = htonl(defaddress);
-    address->ipv6.sin6_addr.s6_addr32[2] = htonl(defaddress);
-    address->ipv6.sin6_addr.s6_addr32[3] = htonl(defaddress);
-    address->ipv6.sin6_port              = htons(defport);
+    cupsdLogMessage(CUPSD_LOG_ERROR, "\"%s\" is not a regular file!", filename);
+    return (-1);
   }
-  else
-#endif /* AF_INET6 */
+
+  if (!dir_created && is_dir && !S_ISDIR(fileinfo.st_mode))
   {
-    address->ipv4.sin_family      = AF_INET;
-    address->ipv4.sin_addr.s_addr = htonl(defaddress);
-    address->ipv4.sin_port        = htons(defport);
+    cupsdLogMessage(CUPSD_LOG_ERROR, "\"%s\" is not a directory!", filename);
+    return (-1);
   }
 
-#ifdef AF_LOCAL
  /*
-  * If the address starts with a "/", it is a domain socket...
+  * Fix owner, group, and mode as needed...
   */
 
-  if (*value == '/')
+  if (dir_created || fileinfo.st_uid != user || fileinfo.st_gid != group)
   {
-    if (strlen(value) >= sizeof(address->un.sun_path))
+    cupsdLogMessage(CUPSD_LOG_WARN, "Repairing ownership of \"%s\"", filename);
+
+    if (chown(filename, user, group))
     {
-      cupsdLogMessage(CUPSD_LOG_ERROR, "Domain socket name \"%s\" too long!",
-                      value);
-      return (0);
+      cupsdLogMessage(CUPSD_LOG_ERROR,
+                      "Unable to change ownership of \"%s\" - %s", filename,
+                     strerror(errno));
+      return (-1);
     }
+  }
 
-    address->un.sun_family = AF_LOCAL;
-    strcpy(address->un.sun_path, value);
+  if (dir_created || (fileinfo.st_mode & 07777) != mode)
+  {
+    cupsdLogMessage(CUPSD_LOG_WARN, "Repairing access permissions of \"%s\"", filename);
 
-    return (1);
+    if (chmod(filename, mode))
+    {
+      cupsdLogMessage(CUPSD_LOG_ERROR,
+                      "Unable to change permissions of \"%s\" - %s", filename,
+                     strerror(errno));
+      return (-1);
+    }
   }
-#endif /* AF_LOCAL */
 
  /*
-  * Try to grab a hostname and port number...
+  * Everything is OK...
   */
 
-  strlcpy(hostname, value, sizeof(hostname));
+  return (0);
+}
 
-  if ((ptr = strrchr(hostname, ':')) != NULL)
-  {
-   /*
-    * Copy hostname and port separately...
-    */
 
-    *ptr++ = '\0';
+/*
+ * 'get_address()' - Get an address + port number from a line.
+ */
 
-    strlcpy(portname, ptr, sizeof(portname));
-  }
-  else if (isdigit(value[0] & 255))
-  {
-   /*
-    * Port number...
-    */
+static http_addrlist_t *               /* O - Pointer to list if address good, NULL if bad */
+get_address(const char  *value,                /* I - Value string */
+           int         defport)        /* I - Default port */
+{
+  char                 buffer[1024],   /* Hostname + port number buffer */
+                       defpname[255],  /* Default port name */
+                       *hostname,      /* Hostname or IP */
+                       *portname;      /* Port number or name */
+  http_addrlist_t      *addrlist;      /* Address list */
 
-    hostname[0] = '\0';
-    strlcpy(portname, value, sizeof(portname));
-  }
-  else
-  {
-   /*
-    * Hostname by itself...
-    */
 
-    portname[0] = '\0';
+ /*
+  * Check for an empty value...
+  */
+
+  if (!*value)
+  {
+    cupsdLogMessage(CUPSD_LOG_ERROR, "Bad (empty) address!");
+    return (NULL);
   }
 
  /*
-  * Decode the hostname and port number as needed...
+  * Grab a hostname and port number; if there is no colon and the port name
+  * is only digits, then we have a port number by itself...
   */
 
-  if (hostname[0] && strcmp(hostname, "*"))
-  {
-    if ((host = httpGetHostByName(hostname)) == NULL)
-    {
-      cupsdLogMessage(CUPSD_LOG_ERROR, "httpGetHostByName(\"%s\") failed - %s!",
-                      hostname, hstrerror(h_errno));
-      return (0);
-    }
+  strlcpy(buffer, value, sizeof(buffer));
 
-    httpAddrLoad(host, defport, 0, address);
+  if ((portname = strrchr(buffer, ':')) != NULL && !strchr(portname, ']'))
+  {
+    *portname++ = '\0';
+    hostname = buffer;
   }
-
-  if (portname[0] != '\0')
+  else
   {
-    if (isdigit(portname[0] & 255))
+    for (portname = buffer; isdigit(*portname & 255); portname ++);
+
+    if (*portname)
     {
-#ifdef AF_INET6
-      if (address->addr.sa_family == AF_INET6)
-        address->ipv6.sin6_port = htons(atoi(portname));
-      else
-#endif /* AF_INET6 */
-      address->ipv4.sin_port = htons(atoi(portname));
+     /*
+      * Use the default port...
+      */
+
+      sprintf(defpname, "%d", defport);
+      portname = defpname;
+      hostname = buffer;
     }
     else
     {
-      if ((port = getservbyname(portname, NULL)) == NULL)
-      {
-        cupsdLogMessage(CUPSD_LOG_ERROR, "getservbyname(\"%s\") failed - %s!",
-                       portname, strerror(errno));
-        return (0);
-      }
-      else
-      {
-#ifdef AF_INET6
-       if (address->addr.sa_family == AF_INET6)
-          address->ipv6.sin6_port = htons(port->s_port);
-       else
-#endif /* AF_INET6 */
-       address->ipv4.sin_port = htons(port->s_port);
-      }
+     /*
+      * The buffer contains just a port number...
+      */
+
+      portname = buffer;
+      hostname = NULL;
     }
   }
 
-  return (1);
+  if (hostname && !strcmp(hostname, "*"))
+    hostname = NULL;
+
+ /*
+  * Now lookup the address using httpAddrGetList()...
+  */
+
+  if ((addrlist = httpAddrGetList(hostname, AF_UNSPEC, portname)) == NULL)
+    cupsdLogMessage(CUPSD_LOG_ERROR, "Hostname lookup for \"%s\" failed!",
+                    hostname ? hostname : "(nil)");
+
+  return (addrlist);
 }
 
 
@@ -1191,18 +1255,33 @@ get_addr_and_mask(const char *value,    /* I - String from config file */
                   unsigned   *ip,      /* O - Address value */
                  unsigned   *mask)     /* O - Mask value */
 {
-  int          i,                      /* Looping var */
+  int          i, j,                   /* Looping vars */
                family,                 /* Address family */
                ipcount;                /* Count of fields in address */
+  unsigned     ipval;                  /* Value */
   const char   *maskval,               /* Pointer to start of mask value */
-               *ptr;                   /* Pointer into value */
-  static unsigned netmasks[4][4] =     /* Standard netmasks... */
+               *ptr,                   /* Pointer into value */
+               *ptr2;                  /* ... */
+  static unsigned netmasks[4][4] =     /* Standard IPv4 netmasks... */
   {
+    { 0xffffffff, 0xffffffff, 0xffffffff, 0xff000000 },
+    { 0xffffffff, 0xffffffff, 0xffffffff, 0xffff0000 },
+    { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffff00 },
+    { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
+  };
+#ifdef AF_INET6
+  static unsigned netmasks6[8][4] =    /* Standard IPv6 netmasks... */
+  {
+    { 0xffff0000, 0x00000000, 0x00000000, 0x00000000 },
     { 0xffffffff, 0x00000000, 0x00000000, 0x00000000 },
+    { 0xffffffff, 0xffff0000, 0x00000000, 0x00000000 },
     { 0xffffffff, 0xffffffff, 0x00000000, 0x00000000 },
+    { 0xffffffff, 0xffffffff, 0xffff0000, 0x00000000 },
     { 0xffffffff, 0xffffffff, 0xffffffff, 0x00000000 },
+    { 0xffffffff, 0xffffffff, 0xffffffff, 0xffff0000 },
     { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }
   };
+#endif /* AF_INET6 */
 
 
  /*
@@ -1229,16 +1308,34 @@ get_addr_and_mask(const char *value,    /* I - String from config file */
 
     family  = AF_INET6;
 
-    for (i = 0, ptr = value + 1; *ptr && i < 4; i ++)
+    for (i = 0, ptr = value + 1; *ptr && i < 8; i ++)
     {
       if (*ptr == ']')
         break;
-      else if (*ptr == ':')
-        ip[i] = 0;
+      else if (!strncmp(ptr, "::", 2))
+      {
+        for (ptr2 = strchr(ptr + 2, ':'), j = 0;
+            ptr2;
+            ptr2 = strchr(ptr2 + 1, ':'), j ++);
+
+        i = 7 - j;
+      }
+      else if (isxdigit(*ptr & 255))
+      {
+        ipval = strtoul(ptr, (char **)&ptr, 16);
+
+       if (ipval > 0xffff)
+         return (0);
+
+        if (i & 1)
+          ip[i] |= ipval;
+       else
+          ip[i] |= ipval << 16;
+      }
       else
-        ip[i] = strtoul(ptr, (char **)&ptr, 16);
+        return (0);
 
-      if (*ptr == ':' || *ptr == ']')
+      while (*ptr == ':')
         ptr ++;
     }
 
@@ -1270,22 +1367,40 @@ get_addr_and_mask(const char *value,    /* I - String from config file */
     memset(mask, 0, sizeof(unsigned) * 4);
 
 #ifdef AF_INET6
-    if (maskval[1] == '[')
+    if (*maskval == '[')
     {
      /*
       * Get hexadecimal mask value...
       */
 
-      for (i = 0, ptr = maskval + 1; *ptr && i < 4; i ++)
+      for (i = 0, ptr = maskval + 1; *ptr && i < 8; i ++)
       {
        if (*ptr == ']')
          break;
-       else if (*ptr == ':')
-          mask[i] = 0;
+       else if (!strncmp(ptr, "::", 2))
+       {
+          for (ptr2 = strchr(ptr + 2, ':'), j = 0;
+              ptr2;
+              ptr2 = strchr(ptr2 + 1, ':'), j ++);
+
+          i = 7 - j;
+       }
+       else if (isxdigit(*ptr & 255))
+       {
+          ipval = strtoul(ptr, (char **)&ptr, 16);
+
+         if (ipval > 0xffff)
+           return (0);
+
+          if (i & 1)
+            mask[i] |= ipval;
+         else
+            mask[i] |= ipval << 16;
+       }
        else
-          mask[i] = strtoul(ptr, (char **)&ptr, 16);
+          return (0);
 
-       if (*ptr == ':' || *ptr == ']')
+        while (*ptr == ':')
           ptr ++;
       }
 
@@ -1361,6 +1476,10 @@ get_addr_and_mask(const char *value,     /* I - String from config file */
       }
     }
   }
+#ifdef AF_INET6
+  else if (family == AF_INET6)
+    memcpy(mask, netmasks6[ipcount - 1], sizeof(unsigned) * 4);
+#endif /* AF_INET6 */
   else
     memcpy(mask, netmasks[ipcount - 1], sizeof(unsigned) * 4);
 
@@ -1583,16 +1702,40 @@ parse_aaa(cupsd_location_t *loc,        /* I - Location */
     {
       loc->type  = AUTH_NONE;
       loc->level = AUTH_ANON;
+
+      cupsdLogMessage(CUPSD_LOG_WARN,
+                      "\"AuthClass %s\" is deprecated; consider removing "
+                     "it from line %d.",
+                     value, linenum);
     }
     else if (!strcasecmp(value, "user"))
+    {
       loc->level = AUTH_USER;
+
+      cupsdLogMessage(CUPSD_LOG_WARN,
+                      "\"AuthClass %s\" is deprecated; consider using "
+                     "\"Require valid-user\" on line %d.",
+                     value, linenum);
+    }
     else if (!strcasecmp(value, "group"))
+    {
       loc->level = AUTH_GROUP;
+
+      cupsdLogMessage(CUPSD_LOG_WARN,
+                      "\"AuthClass %s\" is deprecated; consider using "
+                     "\"Require @groupname\" on line %d.",
+                     value, linenum);
+    }
     else if (!strcasecmp(value, "system"))
     {
       loc->level = AUTH_GROUP;
 
       cupsdAddName(loc, "@SYSTEM");
+
+      cupsdLogMessage(CUPSD_LOG_WARN,
+                      "\"AuthClass %s\" is deprecated; consider using "
+                     "\"Require @SYSTEM\" on line %d.",
+                     value, linenum);
     }
     else
     {
@@ -1603,7 +1746,14 @@ parse_aaa(cupsd_location_t *loc, /* I - Location */
     }
   }
   else if (!strcasecmp(line, "AuthGroupName"))
+  {
     cupsdAddName(loc, value);
+
+    cupsdLogMessage(CUPSD_LOG_WARN,
+                    "\"AuthGroupName %s\" directive is deprecated; consider "
+                   "using \"Require @%s\" on line %d.",
+                   value, value, linenum);
+  }
   else if (!strcasecmp(line, "Require"))
   {
    /*
@@ -1690,33 +1840,170 @@ parse_aaa(cupsd_location_t *loc,       /* I - Location */
 
 
 /*
- * 'read_configuration()' - Read a configuration file.
+ * 'parse_groups()' - Parse system group names in a string.
  */
 
 static int                             /* O - 1 on success, 0 on failure */
-read_configuration(cups_file_t *fp)    /* I - File to read from */
+parse_groups(const char *s)            /* I - Space-delimited groups */
 {
-  int                  i;              /* Looping var */
-  int                  linenum;        /* Current line number */
-  char                 line[HTTP_MAX_BUFFER],
-                                       /* 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 */
-  int                  valuelen;       /* Length of value */
-  cupsd_var_t          *var;           /* Current variable */
-  unsigned             ip[4],          /* Address value */
-                       mask[4];        /* Netmask value */
-  cupsd_dirsvc_relay_t *relay;         /* Relay data */
-  cupsd_dirsvc_poll_t  *poll;          /* Polling data */
-  http_addr_t          polladdr;       /* Polling address */
-  cupsd_location_t     *location;      /* Browse location */
-  cups_file_t          *incfile;       /* Include file */
-  char                 incname[1024];  /* Include filename */
-  struct group         *group;         /* Group */
+  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 == ',')
+         break;
+    }
+
+    if (*valend)
+      *valend++ = '\0';
+
+    group = getgrnam(valstart);
+    if (group)
+    {
+      cupsdSetString(SystemGroups + NumSystemGroups, valstart);
+      SystemGroupIDs[NumSystemGroups] = group->gr_gid;
+
+      NumSystemGroups ++;
+    }
+    else
+      status = 0;
+
+    endgrent();
+
+    valstart = valend;
+
+    while (*valstart == ',' || isspace(*valstart))
+      valstart ++;
+  }
+
+  return (status);
+}
+
+
+/*
+ * 'parse_protocols()' - Parse browse protocols in a string.
+ */
+
+static int                             /* O - Browse protocol bits */
+parse_protocols(const char *s)         /* I - Space-delimited protocols */
+{
+  int  protocols;                      /* Browse protocol bits */
+  char value[1024],                    /* Value string */
+       *valstart,                      /* Pointer into value */
+       *valend;                        /* End of value */
+
+
+ /*
+  * Loop through the value string,...
+  */
+
+  strlcpy(value, s, sizeof(value));
+
+  protocols = 0;
+
+  for (valstart = value; *valstart;)
+  {
+   /*
+    * Get the current space/comma-delimited protocol name...
+    */
+
+    for (valend = valstart; *valend; valend ++)
+      if (isspace(*valend & 255) || *valend == ',')
+       break;
+
+    if (*valend)
+      *valend++ = '\0';
+
+   /*
+    * Add the protocol to the bitmask...
+    */
+
+    if (!strcasecmp(valstart, "cups"))
+      protocols |= BROWSE_CUPS;
+    else if (!strcasecmp(valstart, "slp"))
+      protocols |= BROWSE_SLP;
+    else if (!strcasecmp(valstart, "ldap"))
+      protocols |= BROWSE_LDAP;
+    else if (!strcasecmp(valstart, "dnssd") || !strcasecmp(valstart, "bonjour"))
+      protocols |= BROWSE_DNSSD;
+    else if (!strcasecmp(valstart, "all"))
+      protocols |= BROWSE_ALL;
+    else
+      return (-1);
+
+    for (valstart = valend; *valstart; valstart ++)
+      if (!isspace(*valstart & 255) || *valstart != ',')
+       break;
+  }
+
+  return (protocols);
+}
+
+
+/*
+ * 'read_configuration()' - Read a configuration file.
+ */
+
+static int                             /* O - 1 on success, 0 on failure */
+read_configuration(cups_file_t *fp)    /* I - File to read from */
+{
+  int                  i;              /* Looping var */
+  int                  linenum;        /* Current line number */
+  char                 line[HTTP_MAX_BUFFER],
+                                       /* 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 */
+  int                  valuelen;       /* Length of value */
+  cupsd_var_t          *var;           /* Current variable */
+  http_addrlist_t      *addrlist,      /* Address list */
+                       *addr;          /* Current address */
+  unsigned             ip[4],          /* Address value */
+                       mask[4];        /* Netmask value */
+  cupsd_dirsvc_relay_t *relay;         /* Relay data */
+  cupsd_dirsvc_poll_t  *pollp;         /* Polling data */
+  cupsd_location_t     *location;      /* Browse location */
+  cups_file_t          *incfile;       /* Include file */
+  char                 incname[1024];  /* Include filename */
+  struct group         *group;         /* Group */
 
 
  /*
@@ -1789,90 +2076,106 @@ read_configuration(cups_file_t *fp)    /* I - File to read from */
         return (0);
       }
     }
-    else if (!strcasecmp(line, "Port") || !strcasecmp(line, "Listen"))
+    else if (!strcasecmp(line, "FaxRetryInterval"))
     {
-     /*
-      * Add a listening address to the list...
-      */
-
-      cupsd_listener_t *lis;           /* New listeners array */
-
-
-      if (NumListeners == 0)
-        lis = malloc(sizeof(cupsd_listener_t));
+      if (value)
+      {
+        JobRetryInterval = atoi(value);
+       cupsdLogMessage(CUPSD_LOG_WARN,
+                       "FaxRetryInterval is deprecated; use "
+                       "JobRetryInterval on line %d.", linenum);
+      }
       else
-        lis = realloc(Listeners, (NumListeners + 1) * sizeof(cupsd_listener_t));
-
-      if (!lis)
       {
-        cupsdLogMessage(CUPSD_LOG_ERROR,
-                       "Unable to allocate %s at line %d - %s.",
-                       line, linenum, strerror(errno));
-        continue;
+        cupsdLogMessage(CUPSD_LOG_ERROR, "Syntax error on line %d.", linenum);
+        return (0);
       }
-
-      Listeners = lis;
-      lis      += NumListeners;
-
-      memset(lis, 0, sizeof(cupsd_listener_t));
-
-#if defined(AF_INET6) && !defined(__OpenBSD__)
-      if (get_address(value, INADDR_ANY, IPP_PORT, AF_INET6, &(lis->address)))
-#else
-      if (get_address(value, INADDR_ANY, IPP_PORT, AF_INET, &(lis->address)))
-#endif /* AF_INET6  && !__OpenBSD__ */
+    }
+    else if (!strcasecmp(line, "FaxRetryLimit"))
+    {
+      if (value)
       {
-        httpAddrString(&(lis->address), temp, sizeof(temp));
-
-#ifdef AF_INET6
-        if (lis->address.addr.sa_family == AF_INET6)
-          cupsdLogMessage(CUPSD_LOG_INFO, "Listening to %s:%d (IPv6)", temp,
-                          ntohs(lis->address.ipv6.sin6_port));
-       else
-#endif /* AF_INET6 */
-#ifdef AF_LOCAL
-        if (lis->address.addr.sa_family == AF_LOCAL)
-          cupsdLogMessage(CUPSD_LOG_INFO, "Listening to %s (Domain)", temp);
-       else
-#endif /* AF_LOCAL */
-         cupsdLogMessage(CUPSD_LOG_INFO, "Listening to %s:%d (IPv4)", temp,
-                          ntohs(lis->address.ipv4.sin_port));
-
-       NumListeners ++;
+        JobRetryLimit = atoi(value);
+       cupsdLogMessage(CUPSD_LOG_WARN,
+                       "FaxRetryLimit is deprecated; use "
+                       "JobRetryLimit on line %d.", linenum);
       }
       else
-        cupsdLogMessage(CUPSD_LOG_ERROR, "Bad %s address %s at line %d.", line,
-                       value, linenum);
+      {
+        cupsdLogMessage(CUPSD_LOG_ERROR, "Syntax error on line %d.", linenum);
+        return (0);
+      }
     }
+    else if (!strcasecmp(line, "Port") || !strcasecmp(line, "Listen")
 #ifdef HAVE_SSL
-    else if (!strcasecmp(line, "SSLPort") || !strcasecmp(line, "SSLListen"))
+             || !strcasecmp(line, "SSLPort") || !strcasecmp(line, "SSLListen")
+#endif /* HAVE_SSL */
+            )
     {
      /*
-      * Add a listening address to the list...
+      * Add listening address(es) to the list...
       */
 
       cupsd_listener_t *lis;           /* New listeners array */
 
 
-      if (NumListeners == 0)
-        lis = malloc(sizeof(cupsd_listener_t));
-      else
-        lis = realloc(Listeners, (NumListeners + 1) * sizeof(cupsd_listener_t));
+     /*
+      * Get the address list...
+      */
 
-      if (!lis)
+      addrlist = get_address(value, IPP_PORT);
+
+      if (!addrlist)
       {
-        cupsdLogMessage(CUPSD_LOG_ERROR,
-                       "Unable to allocate %s at line %d - %s.",
-                       line, linenum, strerror(errno));
+        cupsdLogMessage(CUPSD_LOG_ERROR, "Bad %s address %s at line %d.", line,
+                       value, linenum);
         continue;
       }
 
-      Listeners = lis;
-      lis      += NumListeners;
+     /*
+      * Add each address...
+      */
 
-      if (get_address(value, INADDR_ANY, IPP_PORT, AF_INET, &(lis->address)))
+      for (addr = addrlist; addr; addr = addr->next)
       {
-        httpAddrString(&(lis->address), temp, sizeof(temp));
+       /*
+        * Allocate another listener...
+       */
+
+        if (!Listeners)
+         Listeners = cupsArrayNew(NULL, NULL);
+
+       if (!Listeners)
+       {
+          cupsdLogMessage(CUPSD_LOG_ERROR,
+                         "Unable to allocate %s at line %d - %s.",
+                         line, linenum, strerror(errno));
+          break;
+       }
+
+        if ((lis = calloc(1, sizeof(cupsd_listener_t))) == NULL)
+       {
+          cupsdLogMessage(CUPSD_LOG_ERROR,
+                         "Unable to allocate %s at line %d - %s.",
+                         line, linenum, strerror(errno));
+          break;
+       }
+
+        cupsArrayAdd(Listeners, lis);
+
+       /*
+        * Copy the current address and log it...
+       */
+
+       memcpy(&(lis->address), &(addr->addr), sizeof(lis->address));
+       lis->fd = -1;
+
+#ifdef HAVE_SSL
+        if (!strcasecmp(line, "SSLPort") || !strcasecmp(line, "SSLListen"))
+          lis->encryption = HTTP_ENCRYPT_ALWAYS;
+#endif /* HAVE_SSL */
+
+       httpAddrString(&lis->address, temp, sizeof(temp));
 
 #ifdef AF_INET6
         if (lis->address.addr.sa_family == AF_INET6)
@@ -1885,16 +2188,16 @@ read_configuration(cups_file_t *fp)     /* I - File to read from */
           cupsdLogMessage(CUPSD_LOG_INFO, "Listening to %s (Domain)", temp);
        else
 #endif /* AF_LOCAL */
-        cupsdLogMessage(CUPSD_LOG_INFO, "Listening to %s:%d (IPv4)", temp,
+       cupsdLogMessage(CUPSD_LOG_INFO, "Listening to %s:%d (IPv4)", temp,
                         ntohs(lis->address.ipv4.sin_port));
-        lis->encryption = HTTP_ENCRYPT_ALWAYS;
-       NumListeners ++;
       }
-      else
-        cupsdLogMessage(CUPSD_LOG_ERROR, "Bad %s address %s at line %d.", line,
-                       value, linenum);
+
+     /*
+      * Free the list...
+      */
+
+      httpAddrFreeList(addrlist);
     }
-#endif /* HAVE_SSL */
     else if (!strcasecmp(line, "BrowseAddress"))
     {
      /*
@@ -1945,21 +2248,32 @@ read_configuration(cups_file_t *fp)     /* I - File to read from */
 
        NumBrowsers ++;
       }
-      else if (get_address(value, INADDR_NONE, BrowsePort, AF_INET, &(dira->to)))
+      else if ((addrlist = get_address(value, BrowsePort)) != NULL)
       {
-        httpAddrString(&(dira->to), temp, sizeof(temp));
+       /*
+        * Only IPv4 addresses are supported...
+        */
 
-#ifdef AF_INET6
-        if (dira->to.addr.sa_family == AF_INET6)
-          cupsdLogMessage(CUPSD_LOG_INFO,
-                         "Sending browsing info to %s:%d (IPv6)", temp,
-                          ntohs(dira->to.ipv6.sin6_port));
+       for (addr = addrlist; addr; addr = addr->next)
+         if (addr->addr.addr.sa_family == AF_INET)
+           break;          
+
+       if (addr)
+       {
+         memcpy(&(dira->to), &(addrlist->addr), sizeof(dira->to));
+         httpAddrString(&(dira->to), temp, sizeof(temp));
+
+         cupsdLogMessage(CUPSD_LOG_INFO,
+                         "Sending browsing info to %s:%d (IPv4)",
+                         temp, ntohs(dira->to.ipv4.sin_port));
+  
+         NumBrowsers ++;
+       }
        else
-#endif /* AF_INET6 */
-        cupsdLogMessage(CUPSD_LOG_INFO, "Sending browsing info to %s:%d (IPv4)",
-                       temp, ntohs(dira->to.ipv4.sin_port));
+         cupsdLogMessage(CUPSD_LOG_ERROR, "Bad BrowseAddress %s at line %d.",
+                         value, linenum);
 
-       NumBrowsers ++;
+       httpAddrFreeList(addrlist);
       }
       else
         cupsdLogMessage(CUPSD_LOG_ERROR, "Bad BrowseAddress %s at line %d.",
@@ -1991,66 +2305,25 @@ read_configuration(cups_file_t *fp)     /* I - File to read from */
              !strcasecmp(line, "BrowseRemoteProtocols"))
     {
      /*
-      * "BrowseProtocol name [... name]"
+      * "BrowseProtocols name [... name]"
+      * "BrowseLocalProtocols name [... name]"
+      * "BrowseRemoteProtocols name [... name]"
       */
 
-      if (strcasecmp(line, "BrowseLocalProtocols"))
-        BrowseRemoteProtocols = 0;
-      if (strcasecmp(line, "BrowseRemoteProtocols"))
-        BrowseLocalProtocols = 0;
+      int protocols = parse_protocols(value);
 
-      for (; *value;)
+      if (protocols < 0)
       {
-        for (valuelen = 0; value[valuelen]; valuelen ++)
-         if (isspace(value[valuelen]) || value[valuelen] == ',')
-           break;
-
-        if (value[valuelen])
-        {
-         value[valuelen] = '\0';
-         valuelen ++;
-       }
-
-        if (!strcasecmp(value, "cups"))
-       {
-         if (strcasecmp(line, "BrowseLocalProtocols"))
-           BrowseRemoteProtocols |= BROWSE_CUPS;
-         if (strcasecmp(line, "BrowseRemoteProtocols"))
-           BrowseLocalProtocols |= BROWSE_CUPS;
-       }
-        else if (!strcasecmp(value, "slp"))
-       {
-         if (strcasecmp(line, "BrowseLocalProtocols"))
-           BrowseRemoteProtocols |= BROWSE_SLP;
-         if (strcasecmp(line, "BrowseRemoteProtocols"))
-           BrowseLocalProtocols |= BROWSE_SLP;
-       }
-        else if (!strcasecmp(value, "ldap"))
-       {
-         if (strcasecmp(line, "BrowseLocalProtocols"))
-           BrowseRemoteProtocols |= BROWSE_LDAP;
-         if (strcasecmp(line, "BrowseRemoteProtocols"))
-           BrowseLocalProtocols |= BROWSE_LDAP;
-       }
-        else if (!strcasecmp(value, "all"))
-       {
-         if (strcasecmp(line, "BrowseLocalProtocols"))
-           BrowseRemoteProtocols |= BROWSE_ALL;
-         if (strcasecmp(line, "BrowseRemoteProtocols"))
-           BrowseLocalProtocols |= BROWSE_ALL;
-       }
-       else
-       {
-         cupsdLogMessage(CUPSD_LOG_ERROR,
-                         "Unknown browse protocol \"%s\" on line %d.",
-                         value, linenum);
-          break;
-       }
-
-        for (value += valuelen; *value; value ++)
-         if (!isspace(*value) || *value != ',')
-           break;
+       cupsdLogMessage(CUPSD_LOG_ERROR,
+                       "Unknown browse protocol \"%s\" on line %d.",
+                       value, linenum);
+        break;
       }
+
+      if (strcasecmp(line, "BrowseLocalProtocols"))
+        BrowseRemoteProtocols = protocols;
+      if (strcasecmp(line, "BrowseRemoteProtocols"))
+        BrowseLocalProtocols = protocols;
     }
     else if (!strcasecmp(line, "BrowseAllow") ||
              !strcasecmp(line, "BrowseDeny"))
@@ -2266,33 +2539,45 @@ read_configuration(cups_file_t *fp)     /* I - File to read from */
       * Get "to" address and port...
       */
 
-      if (get_address(value, INADDR_BROADCAST, BrowsePort, AF_INET, &(relay->to)))
+      if ((addrlist = get_address(value, BrowsePort)) != NULL)
       {
-        httpAddrString(&(relay->to), temp, sizeof(temp));
-
-        if (relay->from.type == AUTH_IP)
-         snprintf(temp2, sizeof(temp2), "%u.%u.%u.%u/%u.%u.%u.%u",
-                  relay->from.mask.ip.address[0],
-                  relay->from.mask.ip.address[1],
-                  relay->from.mask.ip.address[2],
-                  relay->from.mask.ip.address[3],
-                  relay->from.mask.ip.netmask[0],
-                  relay->from.mask.ip.netmask[1],
-                  relay->from.mask.ip.netmask[2],
-                  relay->from.mask.ip.netmask[3]);
-       else
-         strlcpy(temp2, relay->from.mask.name.name, sizeof(temp2));
+       /*
+        * Only IPv4 addresses are supported...
+        */
 
-#ifdef AF_INET6
-        if (relay->to.addr.sa_family == AF_INET6)
-          cupsdLogMessage(CUPSD_LOG_INFO, "Relaying from %s to %s:%d (IPv6)",
-                         temp, temp2, ntohs(relay->to.ipv6.sin6_port));
+       for (addr = addrlist; addr; addr = addr->next)
+         if (addr->addr.addr.sa_family == AF_INET)
+           break;          
+
+       if (addr)
+       {
+         memcpy(&(relay->to), &(addrlist->addr), sizeof(relay->to));
+  
+         httpAddrString(&(relay->to), temp, sizeof(temp));
+  
+         if (relay->from.type == AUTH_IP)
+           snprintf(temp2, sizeof(temp2), "%u.%u.%u.%u/%u.%u.%u.%u",
+                    relay->from.mask.ip.address[0],
+                    relay->from.mask.ip.address[1],
+                    relay->from.mask.ip.address[2],
+                    relay->from.mask.ip.address[3],
+                    relay->from.mask.ip.netmask[0],
+                    relay->from.mask.ip.netmask[1],
+                    relay->from.mask.ip.netmask[2],
+                    relay->from.mask.ip.netmask[3]);
+         else
+           strlcpy(temp2, relay->from.mask.name.name, sizeof(temp2));
+  
+         cupsdLogMessage(CUPSD_LOG_INFO, "Relaying from %s to %s:%d (IPv4)",
+                         temp, temp2, ntohs(relay->to.ipv4.sin_port));
+  
+         NumRelays ++;
+       }
        else
-#endif /* AF_INET6 */
-        cupsdLogMessage(CUPSD_LOG_INFO, "Relaying from %s to %s:%d (IPv4)",
-                       temp, temp2, ntohs(relay->to.ipv4.sin_port));
+         cupsdLogMessage(CUPSD_LOG_ERROR, "Bad relay address %s at line %d.",
+                         value, linenum);
 
-       NumRelays ++;
+       httpAddrFreeList(addrlist);
       }
       else
       {
@@ -2309,12 +2594,43 @@ read_configuration(cups_file_t *fp)     /* I - File to read from */
       * BrowsePoll address[:port]
       */
 
+      char             *portname;      /* Port name */
+      int              portnum;        /* Port number */
+      struct servent   *service;       /* Service */
+
+
+     /*
+      * Extract the port name from the address...
+      */
+
+      if ((portname = strrchr(value, ':')) != NULL && !strchr(portname, ']'))
+      {
+        *portname++ = '\0';
+
+        if (isdigit(*portname & 255))
+         portnum = atoi(portname);
+       else if ((service = getservbyname(portname, NULL)) != NULL)
+         portnum = ntohs(service->s_port);
+       else
+       {
+         cupsdLogMessage(CUPSD_LOG_ERROR, "Lookup of service \"%s\" failed!",
+                         portname);
+          continue;
+       }
+      }
+      else
+        portnum = ippPort();
+
+     /*
+      * Add the poll entry...
+      */
+
       if (NumPolled == 0)
-        poll = malloc(sizeof(cupsd_dirsvc_poll_t));
+        pollp = malloc(sizeof(cupsd_dirsvc_poll_t));
       else
-        poll = realloc(Polled, (NumPolled + 1) * sizeof(cupsd_dirsvc_poll_t));
+        pollp = realloc(Polled, (NumPolled + 1) * sizeof(cupsd_dirsvc_poll_t));
 
-      if (!poll)
+      if (!pollp)
       {
         cupsdLogMessage(CUPSD_LOG_ERROR,
                        "Unable to allocate BrowsePoll at line %d - %s.",
@@ -2322,33 +2638,17 @@ read_configuration(cups_file_t *fp)     /* I - File to read from */
         continue;
       }
 
-      Polled = poll;
-      poll   += NumPolled;
-
-     /*
-      * Get poll address and port...
-      */
-
-      if (get_address(value, INADDR_NONE, ippPort(), AF_INET, &polladdr))
-      {
-       NumPolled ++;
-       memset(poll, 0, sizeof(cupsd_dirsvc_poll_t));
+      Polled = pollp;
+      pollp   += NumPolled;
 
-        httpAddrString(&polladdr, poll->hostname, sizeof(poll->hostname));
+      NumPolled ++;
+      memset(pollp, 0, sizeof(cupsd_dirsvc_poll_t));
 
-#ifdef AF_INET6
-        if (polladdr.addr.sa_family == AF_INET6)
-          poll->port = ntohs(polladdr.ipv6.sin6_port);
-       else
-#endif /* AF_INET6 */
-        poll->port = ntohs(polladdr.ipv4.sin_port);
+      strlcpy(pollp->hostname, value, sizeof(pollp->hostname));
+      pollp->port = portnum;
 
-        cupsdLogMessage(CUPSD_LOG_INFO, "Polling %s:%d", poll->hostname,
-                       poll->port);
-      }
-      else
-        cupsdLogMessage(CUPSD_LOG_ERROR, "Bad poll address %s at line %d.",
-                       value, linenum);
+      cupsdLogMessage(CUPSD_LOG_INFO, "Polling %s:%d", pollp->hostname,
+                     pollp->port);
     }
     else if (!strcasecmp(line, "DefaultAuthType"))
     {
@@ -2370,28 +2670,74 @@ read_configuration(cups_file_t *fp)     /* I - File to read from */
        return (0);
       }
     }
+#ifdef HAVE_SSL
+    else if (!strcasecmp(line, "DefaultEncryption"))
+    {
+     /*
+      * DefaultEncryption {Never,IfRequested,Required}
+      */
+
+      if (!value || !strcasecmp(value, "never"))
+       DefaultEncryption = HTTP_ENCRYPT_NEVER;
+      else if (!strcasecmp(value, "required"))
+       DefaultEncryption = HTTP_ENCRYPT_REQUIRED;
+      else if (!strcasecmp(value, "ifrequested"))
+       DefaultEncryption = HTTP_ENCRYPT_IF_REQUESTED;
+      else
+      {
+       cupsdLogMessage(CUPSD_LOG_WARN,
+                       "Unknown default encryption %s on line %d.",
+                       value, linenum);
+       return (0);
+      }
+    }
+#endif /* HAVE_SSL */
     else if (!strcasecmp(line, "User"))
     {
      /*
       * User ID to run as...
       */
 
-      if (isdigit(value[0]))
-        User = atoi(value);
-      else
+      if (value && isdigit(value[0] & 255))
+      {
+        int uid = atoi(value);
+
+       if (!uid)
+         cupsdLogMessage(CUPSD_LOG_ERROR,
+                         "Will not use User 0 as specified on line %d "
+                         "for security reasons.  You must use a non-"
+                         "privileged account instead.",
+                         linenum);
+        else
+         User = atoi(value);
+      }
+      else if (value)
       {
         struct passwd *p;      /* Password information */
 
         endpwent();
        p = getpwnam(value);
 
-       if (p != NULL)
-         User = p->pw_uid;
+       if (p)
+       {
+         if (!p->pw_uid)
+           cupsdLogMessage(CUPSD_LOG_ERROR,
+                           "Will not use User %s (UID=0) as specified on line "
+                           "%d for security reasons.  You must use a non-"
+                           "privileged account instead.",
+                           value, linenum);
+         else
+           User = p->pw_uid;
+       }
        else
          cupsdLogMessage(CUPSD_LOG_ERROR,
                          "Unknown User \"%s\" on line %d, ignoring!",
                          value, linenum);
       }
+      else
+       cupsdLogMessage(CUPSD_LOG_ERROR,
+                       "User directive on line %d missing the username!",
+                       linenum);
     }
     else if (!strcasecmp(line, "Group"))
     {
@@ -2417,64 +2763,13 @@ read_configuration(cups_file_t *fp)     /* I - File to read from */
     else if (!strcasecmp(line, "SystemGroup"))
     {
      /*
-      * System (admin) group(s)...
+      * SystemGroup (admin) group(s)...
       */
 
-      char     *valueptr,              /* Pointer into value */
-               quote;                  /* Quote character */
-
-
-      for (i = NumSystemGroups; *value && i < MAX_SYSTEM_GROUPS;)
-      {
-        if (*value == '\'' || *value == '\"')
-       {
-        /*
-         * Scan quoted name...
-         */
-
-         quote = *value++;
-
-         for (valueptr = value; *valueptr; valueptr ++)
-           if (*valueptr == quote)
-             break;
-       }
-       else
-       {
-        /*
-         * Scan space or comma-delimited name...
-         */
-
-          for (valueptr = value; *valueptr; valueptr ++)
-           if (isspace(*valueptr) || *valueptr == ',')
-             break;
-        }
-
-        if (*valueptr)
-          *valueptr++ = '\0';
-
-        group = getgrnam(value);
-        if (group)
-       {
-          cupsdSetString(SystemGroups + i, value);
-         SystemGroupIDs[i] = group->gr_gid;
-
-         i ++;
-       }
-       else
-         cupsdLogMessage(CUPSD_LOG_ERROR,
-                         "Unknown SystemGroup \"%s\" on line %d, ignoring!",
-                         value, linenum);
-
-        endgrent();
-
-        value = valueptr;
-
-        while (*value == ',' || isspace(*value))
-         value ++;
-      }
-
-      if (i)
-        NumSystemGroups = i;
+      if (!parse_groups(value))
+       cupsdLogMessage(CUPSD_LOG_ERROR,
+                       "Unknown SystemGroup \"%s\" on line %d, ignoring!",
+                       value, linenum);
     }
     else if (!strcasecmp(line, "HostNameLookups"))
     {
@@ -2552,7 +2847,7 @@ read_configuration(cups_file_t *fp)       /* I - File to read from */
       else if (!strcasecmp(value, "Major"))
        cupsdSetString(&ServerHeader, "CUPS/1");
       else if (!strcasecmp(value, "Minor"))
-       cupsdSetString(&ServerHeader, "CUPS/1.1");
+       cupsdSetString(&ServerHeader, "CUPS/1.2");
       else if (!strcasecmp(value, "Minimal"))
        cupsdSetString(&ServerHeader, CUPS_MINIMAL);
       else if (!strcasecmp(value, "OS"))
@@ -2566,6 +2861,55 @@ 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"))
+    {
+     /*
+      * PassEnv variable [... variable]
+      */
+
+      for (; *value;)
+      {
+        for (valuelen = 0; value[valuelen]; valuelen ++)
+         if (isspace(value[valuelen]) || value[valuelen] == ',')
+           break;
+
+        if (value[valuelen])
+        {
+         value[valuelen] = '\0';
+         valuelen ++;
+       }
+
+        cupsdSetEnv(value, NULL);
+
+        for (value += valuelen; *value; value ++)
+         if (!isspace(*value) || *value != ',')
+           break;
+      }
+    }
+    else if (!strcasecmp(line, "SetEnv"))
+    {
+     /*
+      * SetEnv variable value
+      */
+
+      for (valueptr = value; *valueptr && !isspace(*valueptr & 255); valueptr ++);
+
+      if (*valueptr)
+      {
+       /*
+        * Found a value...
+       */
+
+        while (isspace(*valueptr & 255))
+         *valueptr++ = '\0';
+
+        cupsdSetEnv(value, valueptr);
+      }
+      else
+        cupsdLogMessage(CUPSD_LOG_ERROR,
+                       "Missing value for SetEnv directive on line %d.",
+                       linenum);
+    }
     else
     {
      /*
@@ -2892,96 +3236,6 @@ read_policy(cups_file_t *fp,             /* I - Configuration file */
 }
 
 
-#ifdef HAVE_CDSASSL
-/*
- * 'CDSAGetServerCerts()' - Convert a keychain name into the CFArrayRef
- *                          required by SSLSetCertificate.
- *
- * For now we assumes that there is exactly one SecIdentity in the
- * keychain - i.e. there is exactly one matching cert/private key pair.
- * In the future we will search a keychain for a SecIdentity matching a
- * specific criteria.  We also skip the operation of adding additional
- * non-signing certs from the keychain to the CFArrayRef.
- *
- * To create a self-signed certificate for testing use the certtool.
- * Executing the following as root will do it:
- *
- *     certtool c c v k=CUPS
- */
-
-CFArrayRef
-CDSAGetServerCerts(void)
-{
-  OSStatus             err;            /* Error info */
-  SecKeychainRef       kcRef;          /* Keychain reference */
-  SecIdentitySearchRef srchRef;        /* Search reference */
-  SecIdentityRef       identity;       /* Identity */
-  CFArrayRef           ca;             /* Certificate array */
-
-
-  kcRef    = NULL;
-  srchRef  = NULL;
-  identity = NULL;
-  ca       = NULL;
-  err      = SecKeychainOpen(ServerCertificate, &kcRef);
-
-  if (err)
-    cupsdLogMessage(CUPSD_LOG_ERROR, "Cannot open keychain \"%s\", error %d.",
-                    ServerCertificate, err);
-  else
-  {
-   /*
-    * Search for "any" identity matching specified key use; 
-    * in this app, we expect there to be exactly one. 
-    */
-
-    err = SecIdentitySearchCreate(kcRef, CSSM_KEYUSE_SIGN, &srchRef);
-
-    if (err)
-      cupsdLogMessage(CUPSD_LOG_ERROR,
-                      "Cannot find signing key in keychain \"%s\", error %d",
-                      ServerCertificate, err);
-    else
-    {
-      err = SecIdentitySearchCopyNext(srchRef, &identity);
-
-      if (err)
-       cupsdLogMessage(CUPSD_LOG_ERROR,
-                       "Cannot find signing key in keychain \"%s\", error %d",
-                       ServerCertificate, err);
-      else
-      {
-       if (CFGetTypeID(identity) != SecIdentityGetTypeID())
-         cupsdLogMessage(CUPSD_LOG_ERROR,
-                         "SecIdentitySearchCopyNext CFTypeID failure!");
-       else
-       {
-        /* 
-         * Found one. Place it in a CFArray. 
-         * TBD: snag other (non-identity) certs from keychain and add them
-         * to array as well.
-         */
-
-         ca = CFArrayCreate(NULL, (const void **)&identity, 1, NULL);
-
-         if (ca == nil)
-           cupsdLogMessage(CUPSD_LOG_ERROR, "CFArrayCreate error");
-       }
-
-       /*CFRelease(identity);*/
-      }
-
-      /*CFRelease(srchRef);*/
-    }
-
-    /*CFRelease(kcRef);*/
-  }
-
-  return ca;
-}
-#endif /* HAVE_CDSASSL */
-
-
 /*
  * End of "$Id$".
  */