]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - scheduler/conf.c
Import changes from CUPS 1.4svn-r8704.
[thirdparty/cups.git] / scheduler / conf.c
index 1269555a758afc9c10bd6752f8e9e5154713d92a..ee6b0a9a0be3af011791cc31dac45ce015b57e18 100644 (file)
@@ -1,9 +1,9 @@
 /*
- * "$Id: conf.c 7694 2008-06-26 00:23:20Z mike $"
+ * "$Id: conf.c 7952 2008-09-17 00:56:20Z mike $"
  *
  *   Configuration routines for the Common UNIX Printing System (CUPS).
  *
- *   Copyright 2007-2008 by Apple Inc.
+ *   Copyright 2007-2009 by Apple Inc.
  *   Copyright 1997-2007 by Easy Software Products, all rights reserved.
  *
  *   These coded instructions, statements, and computer programs are the
  *
  * 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.
 #include <sys/utsname.h>
 #include <syslog.h>
 
+#ifdef HAVE_LIBPAPER
+#  include <paper.h>
+#endif /* HAVE_LIBPAPER */
+
 
 /*
  * Possibly missing network definitions...
@@ -95,6 +101,7 @@ static const cupsd_var_t     variables[] =
   { "BrowseRemoteOptions",     &BrowseRemoteOptions,   CUPSD_VARTYPE_STRING },
   { "BrowseShortNames",                &BrowseShortNames,      CUPSD_VARTYPE_BOOLEAN },
   { "BrowseTimeout",           &BrowseTimeout,         CUPSD_VARTYPE_INTEGER },
+  { "BrowseWebIF",             &BrowseWebIF,           CUPSD_VARTYPE_BOOLEAN },
   { "Browsing",                        &Browsing,              CUPSD_VARTYPE_BOOLEAN },
   { "CacheDir",                        &CacheDir,              CUPSD_VARTYPE_STRING },
   { "Classification",          &Classification,        CUPSD_VARTYPE_STRING },
@@ -115,12 +122,10 @@ 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 },
@@ -131,6 +136,7 @@ static const cupsd_var_t    variables[] =
 #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 },
@@ -149,6 +155,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 },
@@ -195,6 +202,7 @@ 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);
@@ -208,6 +216,30 @@ static int         read_location(cups_file_t *fp, char *name, int linenum);
 static int             read_policy(cups_file_t *fp, char *name, int linenum);
 
 
+/*
+ * '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);
+}
+
+
 /*
  * 'cupsdCheckPermissions()' - Fix the mode and ownership of a file or directory.
  */
@@ -263,7 +295,8 @@ cupsdCheckPermissions(
         return (-1);
       }
 
-      dir_created = 1;
+      dir_created      = 1;
+      fileinfo.st_mode = mode | S_IFDIR;
     }
     else
       return (create_dir ? -1 : 1);
@@ -358,6 +391,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.
  */
@@ -376,6 +428,7 @@ cupsdReadConfiguration(void)
   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 */
@@ -424,12 +477,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);
@@ -447,12 +506,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;
 
@@ -542,47 +601,53 @@ cupsdReadConfiguration(void)
   * Numeric options...
   */
 
-  AccessLogLevel        = CUPSD_ACCESSLOG_ACTIONS;
-  ConfigFilePerm        = CUPS_DEFAULT_CONFIG_FILE_PERM;
-  FatalErrors           = parse_fatal_errors(CUPS_DEFAULT_FATAL_ERRORS);
-  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    = DEFAULT_KEEPALIVE;
-  JobRetryLimit         = 5;
-  JobRetryInterval      = 300;
-  FileDevice            = FALSE;
-  FilterLevel           = 0;
-  FilterLimit           = 0;
-  FilterNice            = 0;
-  HostNameLookups       = FALSE;
-  ImplicitClasses       = CUPS_DEFAULT_IMPLICIT_CLASSES;
-  ImplicitAnyClasses    = FALSE;
-  HideImplicitMembers   = TRUE;
-  KeepAlive             = TRUE;
-  KeepAliveTimeout      = DEFAULT_KEEPALIVE;
-  ListenBackLog         = SOMAXCONN;
-  LogFilePerm           = CUPS_DEFAULT_LOG_FILE_PERM;
-  LogLevel              = CUPSD_LOG_WARN;
-  MaxClients            = 100;
-  MaxClientsPerHost     = 0;
-  MaxLogSize            = 1024 * 1024;
-  MaxPrinterHistory     = 10;
-  MaxRequestSize        = 0;
-  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;
-  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        = 10;
+  MaxRequestSize           = 0;
+  MultipleOperationTimeout = DEFAULT_TIMEOUT;
+  ReloadTimeout                   = DEFAULT_KEEPALIVE;
+  RootCertDuration         = 300;
+  Timeout                  = DEFAULT_TIMEOUT;
+  NumSystemGroups          = 0;
+
+  BrowseInterval           = DEFAULT_INTERVAL;
+  BrowsePort               = ippPort();
+  BrowseLocalProtocols     = parse_protocols(CUPS_DEFAULT_BROWSE_LOCAL_PROTOCOLS);
+  BrowseRemoteProtocols    = parse_protocols(CUPS_DEFAULT_BROWSE_REMOTE_PROTOCOLS);
+  BrowseShortNames         = CUPS_DEFAULT_BROWSE_SHORT_NAMES;
+  BrowseTimeout            = DEFAULT_TIMEOUT;
+  BrowseWebIF              = FALSE;
+  Browsing                 = CUPS_DEFAULT_BROWSING;
+  DefaultShared            = CUPS_DEFAULT_DEFAULT_SHARED;
 
   cupsdSetString(&LPDConfigFile, CUPS_DEFAULT_LPD_CONFIG_FILE);
   cupsdSetString(&SMBConfigFile, CUPS_DEFAULT_SMB_CONFIG_FILE);
@@ -650,14 +715,87 @@ cupsdReadConfiguration(void)
 
   RunUser = getuid();
 
+  cupsdLogMessage(CUPSD_LOG_INFO, "Remote access is %s.",
+                  RemotePort ? "enabled" : "disabled");
+
  /*
   * 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...
   */
@@ -1146,6 +1284,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))
   {
@@ -1162,7 +1301,6 @@ cupsdReadConfiguration(void)
 
     cupsdDeleteAllSubscriptions();
     cupsdFreeAllJobs();
-    cupsdDeleteAllClasses();
     cupsdDeleteAllPrinters();
 
     DefaultPrinter = NULL;
@@ -1270,10 +1408,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...
     */
@@ -1687,92 +1831,113 @@ parse_aaa(cupsd_location_t *loc,       /* I - Location */
     * Deny [From] host/ip...
     */
 
-    if (!strncasecmp(value, "from", 4))
+    while (*value)
     {
-     /*
-      * Strip leading "from"...
-      */
+      if (!strncasecmp(value, "from", 4))
+      {
+       /*
+       * Strip leading "from"...
+       */
 
-      value += 4;
+       value += 4;
 
-      while (isspace(*value & 255))
-       value ++;
-    }
+       while (isspace(*value & 255))
+         value ++;
 
-   /*
-    * Figure out what form the allow/deny address takes:
-    *
-    *    All
-    *    None
-    *    *.domain.com
-    *    .domain.com
-    *    host.domain.com
-    *    nnn.*
-    *    nnn.nnn.*
-    *    nnn.nnn.nnn.*
-    *    nnn.nnn.nnn.nnn
-    *    nnn.nnn.nnn.nnn/mm
-    *    nnn.nnn.nnn.nnn/mmm.mmm.mmm.mmm
-    */
+        if (!*value)
+         break;
+      }
 
-    if (!strcasecmp(value, "all"))
-    {
      /*
-      * All hosts...
+      * Find the end of the value...
       */
 
-      if (!strcasecmp(line, "Allow"))
-       cupsdAllowIP(loc, zeros, zeros);
-      else
-       cupsdDenyIP(loc, zeros, zeros);
-    }
-    else if (!strcasecmp(value, "none"))
-    {
+      for (valptr = value; *valptr && !isspace(*valptr & 255); valptr ++);
+
+      while (isspace(*valptr & 255))
+        *valptr++ = '\0';
+
      /*
-      * No hosts...
+      * Figure out what form the allow/deny address takes:
+      *
+      *    All
+      *    None
+      *    *.domain.com
+      *    .domain.com
+      *    host.domain.com
+      *    nnn.*
+      *    nnn.nnn.*
+      *    nnn.nnn.nnn.*
+      *    nnn.nnn.nnn.nnn
+      *    nnn.nnn.nnn.nnn/mm
+      *    nnn.nnn.nnn.nnn/mmm.mmm.mmm.mmm
       */
 
-      if (!strcasecmp(line, "Allow"))
-       cupsdAllowIP(loc, ones, zeros);
-      else
-       cupsdDenyIP(loc, ones, zeros);
-    }
+      if (!strcasecmp(value, "all"))
+      {
+       /*
+       * All hosts...
+       */
+
+       if (!strcasecmp(line, "Allow"))
+         cupsdAllowIP(loc, zeros, zeros);
+       else
+         cupsdDenyIP(loc, zeros, zeros);
+      }
+      else if (!strcasecmp(value, "none"))
+      {
+       /*
+       * No hosts...
+       */
+
+       if (!strcasecmp(line, "Allow"))
+         cupsdAllowIP(loc, ones, zeros);
+       else
+         cupsdDenyIP(loc, ones, zeros);
+      }
 #ifdef AF_INET6
-    else if (value[0] == '*' || value[0] == '.' || 
-             (!isdigit(value[0] & 255) && value[0] != '['))
+      else if (value[0] == '*' || value[0] == '.' || 
+              (!isdigit(value[0] & 255) && value[0] != '['))
 #else
-    else if (value[0] == '*' || value[0] == '.' || !isdigit(value[0] & 255))
+      else if (value[0] == '*' || value[0] == '.' || !isdigit(value[0] & 255))
 #endif /* AF_INET6 */
-    {
-     /*
-      * Host or domain name...
-      */
+      {
+       /*
+       * Host or domain name...
+       */
 
-      if (value[0] == '*')
-       value ++;
+       if (value[0] == '*')
+         value ++;
 
-      if (!strcasecmp(line, "Allow"))
-       cupsdAllowHost(loc, value);
+       if (!strcasecmp(line, "Allow"))
+         cupsdAllowHost(loc, value);
+       else
+         cupsdDenyHost(loc, value);
+      }
       else
-       cupsdDenyHost(loc, value);
-    }
-    else
-    {
-     /*
-      * One of many IP address forms...
-      */
-
-      if (!get_addr_and_mask(value, ip, mask))
       {
-        cupsdLogMessage(CUPSD_LOG_ERROR, "Bad netmask value %s on line %d.",
-                       value, linenum);
-        return (0);
+       /*
+       * One of many IP address forms...
+       */
+
+       if (!get_addr_and_mask(value, ip, mask))
+       {
+         cupsdLogMessage(CUPSD_LOG_ERROR, "Bad netmask value %s on line %d.",
+                         value, linenum);
+         return (0);
+       }
+
+       if (!strcasecmp(line, "Allow"))
+         cupsdAllowIP(loc, ip, mask);
+       else
+         cupsdDenyIP(loc, ip, mask);
       }
 
-      if (!strcasecmp(line, "Allow"))
-       cupsdAllowIP(loc, ip, mask);
-      else
-       cupsdDenyIP(loc, ip, mask);
+     /*
+      * Advance to next value...
+      */
+
+      value = valptr;
     }
   }
   else if (!strcasecmp(line, "AuthType"))
@@ -2425,6 +2590,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);
+       }
       }
 
      /*
@@ -2576,92 +2751,113 @@ read_configuration(cups_file_t *fp)    /* I - File to read from */
                        "Unable to initialize browse access control list!");
       else
       {
-       if (!strncasecmp(value, "from ", 5))
+       while (*value)
        {
-        /*
-          * Strip leading "from"...
-         */
+         if (!strncasecmp(value, "from", 4))
+         {
+          /*
+           * Strip leading "from"...
+           */
 
-         value += 5;
+           value += 4;
 
-         while (isspace(*value))
-           value ++;
-       }
+           while (isspace(*value & 255))
+             value ++;
 
-       /*
-       * Figure out what form the allow/deny address takes:
-       *
-       *    All
-       *    None
-       *    *.domain.com
-       *    .domain.com
-       *    host.domain.com
-       *    nnn.*
-       *    nnn.nnn.*
-       *    nnn.nnn.nnn.*
-       *    nnn.nnn.nnn.nnn
-       *    nnn.nnn.nnn.nnn/mm
-       *    nnn.nnn.nnn.nnn/mmm.mmm.mmm.mmm
-       */
+           if (!*value)
+             break;
+         }
 
-       if (!strcasecmp(value, "all"))
-       {
         /*
-          * All hosts...
+         * Find the end of the value...
          */
 
-          if (!strcasecmp(line, "BrowseAllow"))
-           cupsdAllowIP(location, zeros, zeros);
-         else
-           cupsdDenyIP(location, zeros, zeros);
-       }
-       else if (!strcasecmp(value, "none"))
-       {
+         for (valueptr = value; *valueptr && !isspace(*valueptr & 255); valueptr ++);
+
+         while (isspace(*valueptr & 255))
+           *valueptr++ = '\0';
+
         /*
-          * No hosts...
+         * Figure out what form the allow/deny address takes:
+         *
+         *    All
+         *    None
+         *    *.domain.com
+         *    .domain.com
+         *    host.domain.com
+         *    nnn.*
+         *    nnn.nnn.*
+         *    nnn.nnn.nnn.*
+         *    nnn.nnn.nnn.nnn
+         *    nnn.nnn.nnn.nnn/mm
+         *    nnn.nnn.nnn.nnn/mmm.mmm.mmm.mmm
          */
 
-          if (!strcasecmp(line, "BrowseAllow"))
-           cupsdAllowIP(location, ones, zeros);
-         else
-           cupsdDenyIP(location, ones, zeros);
-       }
+         if (!strcasecmp(value, "all"))
+         {
+          /*
+           * All hosts...
+           */
+
+           if (!strcasecmp(line, "BrowseAllow"))
+             cupsdAllowIP(location, zeros, zeros);
+           else
+             cupsdDenyIP(location, zeros, zeros);
+         }
+         else if (!strcasecmp(value, "none"))
+         {
+          /*
+           * No hosts...
+           */
+
+           if (!strcasecmp(line, "BrowseAllow"))
+             cupsdAllowIP(location, ones, zeros);
+           else
+             cupsdDenyIP(location, ones, zeros);
+         }
 #ifdef AF_INET6
-       else if (value[0] == '*' || value[0] == '.' || 
-                (!isdigit(value[0] & 255) && value[0] != '['))
+         else if (value[0] == '*' || value[0] == '.' || 
+                  (!isdigit(value[0] & 255) && value[0] != '['))
 #else
-       else if (value[0] == '*' || value[0] == '.' || !isdigit(value[0] & 255))
+         else if (value[0] == '*' || value[0] == '.' || !isdigit(value[0] & 255))
 #endif /* AF_INET6 */
-       {
-        /*
-          * Host or domain name...
-         */
+         {
+          /*
+           * Host or domain name...
+           */
 
-         if (value[0] == '*')
-           value ++;
+           if (value[0] == '*')
+             value ++;
 
-          if (!strcasecmp(line, "BrowseAllow"))
-           cupsdAllowHost(location, value);
+           if (!strcasecmp(line, "BrowseAllow"))
+             cupsdAllowHost(location, value);
+           else
+             cupsdDenyHost(location, value);
+         }
          else
-           cupsdDenyHost(location, value);
-       }
-       else
-       {
-        /*
-          * One of many IP address forms...
-         */
-
-          if (!get_addr_and_mask(value, ip, mask))
          {
-            cupsdLogMessage(CUPSD_LOG_ERROR, "Bad netmask value %s on line %d.",
-                           value, linenum);
-           break;
+          /*
+           * One of many IP address forms...
+           */
+
+           if (!get_addr_and_mask(value, ip, mask))
+           {
+             cupsdLogMessage(CUPSD_LOG_ERROR, "Bad netmask value %s on line %d.",
+                             value, linenum);
+             break;
+           }
+
+           if (!strcasecmp(line, "BrowseAllow"))
+             cupsdAllowIP(location, ip, mask);
+           else
+             cupsdDenyIP(location, ip, mask);
          }
 
-          if (!strcasecmp(line, "BrowseAllow"))
-           cupsdAllowIP(location, ip, mask);
-         else
-           cupsdDenyIP(location, ip, mask);
+        /*
+         * Advance to next value...
+         */
+
+         value = valueptr;
        }
       }
     }
@@ -2953,19 +3149,6 @@ read_configuration(cups_file_t *fp)      /* I - File to read from */
       }
     }
 #endif /* HAVE_SSL */
-#ifdef HAVE_GSSAPI
-    else if (!strcasecmp(line, "Krb5Keytab") && value)
-    {
-      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") && value)
     {
      /*
@@ -3105,6 +3288,20 @@ read_configuration(cups_file_t *fp)      /* I - File to read from */
         cupsdLogMessage(CUPSD_LOG_WARN, "Unknown LogLevel %s on line %d.",
                        value, linenum);
     }
+    else if (!strcasecmp(line, "LogTimeFormat") && value)
+    {
+     /*
+      * Amount of logging to do to error log...
+      */
+
+      if (!strcasecmp(value, "standard"))
+        LogTimeFormat = CUPSD_TIME_STANDARD;
+      else if (!strcasecmp(value, "usecs"))
+        LogTimeFormat = CUPSD_TIME_USECS;
+      else
+        cupsdLogMessage(CUPSD_LOG_WARN, "Unknown LogTimeFormat %s on line %d.",
+                       value, linenum);
+    }
     else if (!strcasecmp(line, "PrintcapFormat") && value)
     {
      /*
@@ -3113,6 +3310,8 @@ read_configuration(cups_file_t *fp)       /* I - File to read from */
 
       if (!strcasecmp(value, "bsd"))
         PrintcapFormat = PRINTCAP_BSD;
+      else if (!strcasecmp(value, "plist"))
+        PrintcapFormat = PRINTCAP_PLIST;
       else if (!strcasecmp(value, "solaris"))
         PrintcapFormat = PRINTCAP_SOLARIS;
       else
@@ -3174,6 +3373,13 @@ read_configuration(cups_file_t *fp)      /* I - File to read from */
            break;
       }
     }
+    else if (!strcasecmp(line, "ServerAlias") && value)
+    {
+      if (!ServerAlias)
+        ServerAlias = cupsArrayNew(NULL, NULL);
+
+      cupsdAddAlias(ServerAlias, value);
+    }
     else if (!strcasecmp(line, "SetEnv") && value)
     {
      /*
@@ -3198,6 +3404,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
     {
      /*
@@ -3354,6 +3577,8 @@ read_location(cups_file_t *fp,            /* I - Configuration file */
         cupsdLogMessage(CUPSD_LOG_ERROR, "Syntax error on line %d.", linenum);
         if (FatalErrors & CUPSD_FATAL_CONFIG)
          return (0);
+        else
+         continue;
       }
       
       if ((loc = cupsdCopyLocation(&parent)) == NULL)
@@ -3494,6 +3719,8 @@ read_policy(cups_file_t *fp,              /* I - Configuration file */
         cupsdLogMessage(CUPSD_LOG_ERROR, "Syntax error on line %d.", linenum);
         if (FatalErrors & CUPSD_FATAL_CONFIG)
          return (0);
+        else
+         continue;
       }
       
      /*
@@ -3595,5 +3822,5 @@ read_policy(cups_file_t *fp,              /* I - Configuration file */
 
 
 /*
- * End of "$Id: conf.c 7694 2008-06-26 00:23:20Z mike $".
+ * End of "$Id: conf.c 7952 2008-09-17 00:56:20Z mike $".
  */