]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - scheduler/conf.c
Merge changes from CUPS 1.4svn-r7696.
[thirdparty/cups.git] / scheduler / conf.c
index 9a2188b62c26d3a5c312c53db2416d50df49f5d2..955dc2df1eb4aba02e12d4f7c60cc5532861e1fd 100644 (file)
@@ -1,9 +1,9 @@
 /*
- * "$Id: conf.c 6746 2007-07-30 16:47:10Z mike $"
+ * "$Id: conf.c 7694 2008-06-26 00:23:20Z mike $"
  *
  *   Configuration routines for the Common UNIX Printing System (CUPS).
  *
- *   Copyright 2007 by Apple Inc.
+ *   Copyright 2007-2008 by Apple Inc.
  *   Copyright 1997-2007 by Easy Software Products, all rights reserved.
  *
  *   These coded instructions, statements, and computer programs are the
@@ -56,7 +56,8 @@ typedef enum
 {
   CUPSD_VARTYPE_INTEGER,               /* Integer option */
   CUPSD_VARTYPE_STRING,                        /* String option */
-  CUPSD_VARTYPE_BOOLEAN                        /* Boolean option */
+  CUPSD_VARTYPE_BOOLEAN,               /* Boolean option */
+  CUPSD_VARTYPE_PATHNAME               /* File/directory name option */
 } cupsd_vartype_t;
 
 typedef struct
@@ -71,7 +72,7 @@ typedef struct
  * Local globals...
  */
 
-static cupsd_var_t     variables[] =
+static const cupsd_var_t       variables[] =
 {
   { "AccessLog",               &AccessLog,             CUPSD_VARTYPE_STRING },
 #ifdef __APPLE__
@@ -81,7 +82,7 @@ static cupsd_var_t    variables[] =
   { "BrowseInterval",          &BrowseInterval,        CUPSD_VARTYPE_INTEGER },
 #ifdef HAVE_LDAP
   { "BrowseLDAPBindDN",                &BrowseLDAPBindDN,      CUPSD_VARTYPE_STRING },
-  { "BrowseLDAPCACertFile",    &BrowseLDAPCACertFile,  CUPSD_VARTYPE_STRING },
+  { "BrowseLDAPCACertFile",    &BrowseLDAPCACertFile,  CUPSD_VARTYPE_PATHNAME },
   { "BrowseLDAPDN",            &BrowseLDAPDN,          CUPSD_VARTYPE_STRING },
   { "BrowseLDAPPassword",      &BrowseLDAPPassword,    CUPSD_VARTYPE_STRING },
   { "BrowseLDAPServer",                &BrowseLDAPServer,      CUPSD_VARTYPE_STRING },
@@ -102,6 +103,7 @@ static cupsd_var_t  variables[] =
   { "DefaultLeaseDuration",    &DefaultLeaseDuration,  CUPSD_VARTYPE_INTEGER },
   { "DefaultPolicy",           &DefaultPolicy,         CUPSD_VARTYPE_STRING },
   { "DefaultShared",           &DefaultShared,         CUPSD_VARTYPE_BOOLEAN },
+  { "DirtyCleanInterval",      &DirtyCleanInterval,    CUPSD_VARTYPE_INTEGER },
   { "DocumentRoot",            &DocumentRoot,          CUPSD_VARTYPE_STRING },
   { "ErrorLog",                        &ErrorLog,              CUPSD_VARTYPE_STRING },
   { "ErrorPolicy",             &ErrorPolicy,           CUPSD_VARTYPE_STRING },
@@ -112,6 +114,7 @@ static cupsd_var_t  variables[] =
 #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 },
   { "JobRetryLimit",           &JobRetryLimit,         CUPSD_VARTYPE_INTEGER },
@@ -125,6 +128,7 @@ static cupsd_var_t  variables[] =
   { "LimitRequestBody",                &MaxRequestSize,        CUPSD_VARTYPE_INTEGER },
   { "ListenBackLog",           &ListenBackLog,         CUPSD_VARTYPE_INTEGER },
   { "LogFilePerm",             &LogFilePerm,           CUPSD_VARTYPE_INTEGER },
+  { "LPDConfigFile",           &LPDConfigFile,         CUPSD_VARTYPE_STRING },
   { "MaxActiveJobs",           &MaxActiveJobs,         CUPSD_VARTYPE_INTEGER },
   { "MaxClients",              &MaxClients,            CUPSD_VARTYPE_INTEGER },
   { "MaxClientsPerHost",       &MaxClientsPerHost,     CUPSD_VARTYPE_INTEGER },
@@ -142,6 +146,7 @@ static cupsd_var_t  variables[] =
   { "MaxSubscriptionsPerPrinter",&MaxSubscriptionsPerPrinter,  CUPSD_VARTYPE_INTEGER },
   { "MaxSubscriptionsPerUser", &MaxSubscriptionsPerUser,       CUPSD_VARTYPE_INTEGER },
   { "PageLog",                 &PageLog,               CUPSD_VARTYPE_STRING },
+  { "PageLogFormat",           &PageLogFormat,         CUPSD_VARTYPE_STRING },
   { "PreserveJobFiles",                &JobFiles,              CUPSD_VARTYPE_BOOLEAN },
   { "PreserveJobHistory",      &JobHistory,            CUPSD_VARTYPE_BOOLEAN },
   { "Printcap",                        &Printcap,              CUPSD_VARTYPE_STRING },
@@ -152,31 +157,32 @@ static cupsd_var_t        variables[] =
   { "RIPCache",                        &RIPCache,              CUPSD_VARTYPE_STRING },
   { "RootCertDuration",                &RootCertDuration,      CUPSD_VARTYPE_INTEGER },
   { "ServerAdmin",             &ServerAdmin,           CUPSD_VARTYPE_STRING },
-  { "ServerBin",               &ServerBin,             CUPSD_VARTYPE_STRING },
+  { "ServerBin",               &ServerBin,             CUPSD_VARTYPE_PATHNAME },
 #ifdef HAVE_SSL
-  { "ServerCertificate",       &ServerCertificate,     CUPSD_VARTYPE_STRING },
+  { "ServerCertificate",       &ServerCertificate,     CUPSD_VARTYPE_PATHNAME },
 #  if defined(HAVE_LIBSSL) || defined(HAVE_GNUTLS)
-  { "ServerKey",               &ServerKey,             CUPSD_VARTYPE_STRING },
+  { "ServerKey",               &ServerKey,             CUPSD_VARTYPE_PATHNAME },
 #  endif /* HAVE_LIBSSL || HAVE_GNUTLS */
 #endif /* HAVE_SSL */
   { "ServerName",              &ServerName,            CUPSD_VARTYPE_STRING },
-  { "ServerRoot",              &ServerRoot,            CUPSD_VARTYPE_STRING },
+  { "ServerRoot",              &ServerRoot,            CUPSD_VARTYPE_PATHNAME },
+  { "SMBConfigFile",           &SMBConfigFile,         CUPSD_VARTYPE_STRING },
   { "StateDir",                        &StateDir,              CUPSD_VARTYPE_STRING },
 #ifdef HAVE_AUTHORIZATION_H
   { "SystemGroupAuthKey",      &SystemGroupAuthKey,    CUPSD_VARTYPE_STRING },
 #endif /* HAVE_AUTHORIZATION_H */
-  { "TempDir",                 &TempDir,               CUPSD_VARTYPE_STRING },
+  { "TempDir",                 &TempDir,               CUPSD_VARTYPE_PATHNAME },
   { "Timeout",                 &Timeout,               CUPSD_VARTYPE_INTEGER },
   { "UseNetworkDefault",       &UseNetworkDefault,     CUPSD_VARTYPE_BOOLEAN }
 };
 #define NUM_VARS       (sizeof(variables) / sizeof(variables[0]))
 
 
-static unsigned                ones[4] =
+static const unsigned  ones[4] =
                        {
                          0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff
                        };
-static unsigned                zeros[4] =
+static const unsigned  zeros[4] =
                        {
                          0x00000000, 0x00000000, 0x00000000, 0x00000000
                        };
@@ -340,6 +346,7 @@ cupsdReadConfiguration(void)
   cups_file_t  *fp;                    /* Configuration file */
   int          status;                 /* Return status */
   char         temp[1024],             /* Temporary buffer */
+               mimedir[1024],          /* MIME directory */
                *slash;                 /* Directory separator */
   cups_lang_t  *language;              /* Language */
   struct passwd        *user;                  /* Default user */
@@ -348,6 +355,7 @@ cupsdReadConfiguration(void)
                *old_requestroot;       /* Old RequestRoot */
   const char   *tmpdir;                /* TMPDIR environment variable */
   struct stat  tmpinfo;                /* Temporary directory info */
+  cupsd_policy_t *p;                   /* Policy */
 
 
  /*
@@ -383,7 +391,7 @@ cupsdReadConfiguration(void)
   if (NumRelays > 0)
   {
     for (i = 0; i < NumRelays; i ++)
-      if (Relays[i].from.type == AUTH_NAME)
+      if (Relays[i].from.type == CUPSD_AUTH_NAME)
        free(Relays[i].from.mask.name.name);
 
     free(Relays);
@@ -407,11 +415,14 @@ cupsdReadConfiguration(void)
   cupsdSetString(&AccessLog, CUPS_LOGDIR "/access_log");
   cupsdSetString(&ErrorLog, CUPS_LOGDIR "/error_log");
   cupsdSetString(&PageLog, CUPS_LOGDIR "/page_log");
+  cupsdSetString(&PageLogFormat,
+                 "%p %j %u %T %P %C %{job-billing} "
+                "%{job-originating-host-name} %{job-name} %{media} %{sides}");
   cupsdSetString(&Printcap, CUPS_DEFAULT_PRINTCAP);
   cupsdSetString(&PrintcapGUI, "/usr/bin/glpoptions");
   cupsdSetString(&FontPath, CUPS_FONTPATH);
   cupsdSetString(&RemoteRoot, "remroot");
-  cupsdSetString(&ServerHeader, "CUPS/1.2");
+  cupsdSetString(&ServerHeader, "CUPS/1.4");
   cupsdSetString(&StateDir, CUPS_STATEDIR);
 #ifdef HAVE_GSSAPI
   cupsdSetString(&GSSServiceName, CUPS_DEFAULT_GSSSERVICENAME);
@@ -507,10 +518,11 @@ cupsdReadConfiguration(void)
   */
 
   ConfigFilePerm        = CUPS_DEFAULT_CONFIG_FILE_PERM;
-  DefaultAuthType       = AUTH_BASIC;
+  DefaultAuthType       = CUPSD_AUTH_BASIC;
 #ifdef HAVE_SSL
   DefaultEncryption     = HTTP_ENCRYPT_REQUIRED;
 #endif /* HAVE_SSL */
+  DirtyCleanInterval    = 60;
   JobRetryLimit         = 5;
   JobRetryInterval      = 300;
   FileDevice            = FALSE;
@@ -545,6 +557,9 @@ cupsdReadConfiguration(void)
   Browsing              = CUPS_DEFAULT_BROWSING;
   DefaultShared         = CUPS_DEFAULT_DEFAULT_SHARED;
 
+  cupsdSetString(&LPDConfigFile, CUPS_DEFAULT_LPD_CONFIG_FILE);
+  cupsdSetString(&SMBConfigFile, CUPS_DEFAULT_SMB_CONFIG_FILE);
+
   cupsdClearString(&BrowseLocalOptions);
   cupsdClearString(&BrowseRemoteOptions);
 
@@ -775,10 +790,14 @@ cupsdReadConfiguration(void)
   * writable by the user and group in the cupsd.conf file...
   */
 
+  snprintf(temp, sizeof(temp), "%s/rss", CacheDir);
+
   if (cupsdCheckPermissions(RequestRoot, NULL, 0710, RunUser,
                            Group, 1, 1) < 0 ||
       cupsdCheckPermissions(CacheDir, NULL, 0775, RunUser,
                            Group, 1, 1) < 0 ||
+      cupsdCheckPermissions(temp, NULL, 0775, RunUser,
+                           Group, 1, 1) < 0 ||
       cupsdCheckPermissions(StateDir, NULL, 0755, RunUser,
                            Group, 1, 1) < 0 ||
       cupsdCheckPermissions(StateDir, "certs", RunUser ? 0711 : 0511, User,
@@ -929,7 +948,6 @@ cupsdReadConfiguration(void)
 
   if (!DefaultPolicyPtr)
   {
-    cupsd_policy_t     *p;             /* New policy */
     cupsd_location_t   *po;            /* New policy operation */
 
 
@@ -957,12 +975,12 @@ cupsdReadConfiguration(void)
                      "Renew-Subscription Cancel-Subscription "
                      "Get-Notifications Reprocess-Job Cancel-Current-Job "
                      "Suspend-Current-Job Resume-Job CUPS-Move-Job "
-                     "CUPS-Authenticate-Job>");
+                     "CUPS-Authenticate-Job CUPS-Get-Document>");
       cupsdLogMessage(CUPSD_LOG_INFO, "Order Deny,Allow");
 
       po = cupsdAddPolicyOp(p, NULL, IPP_SEND_DOCUMENT);
-      po->order_type = AUTH_ALLOW;
-      po->level      = AUTH_USER;
+      po->order_type = CUPSD_AUTH_ALLOW;
+      po->level      = CUPSD_AUTH_USER;
 
       cupsdAddName(po, "@OWNER");
       cupsdAddName(po, "@SYSTEM");
@@ -985,6 +1003,7 @@ cupsdReadConfiguration(void)
       cupsdAddPolicyOp(p, po, IPP_RESUME_JOB);
       cupsdAddPolicyOp(p, po, CUPS_MOVE_JOB);
       cupsdAddPolicyOp(p, po, CUPS_AUTHENTICATE_JOB);
+      cupsdAddPolicyOp(p, po, CUPS_GET_DOCUMENT);
 
       cupsdLogMessage(CUPSD_LOG_INFO, "</Limit>");
 
@@ -1002,9 +1021,9 @@ cupsdReadConfiguration(void)
       cupsdLogMessage(CUPSD_LOG_INFO, "AuthType Default");
 
       po = cupsdAddPolicyOp(p, NULL, IPP_PAUSE_PRINTER);
-      po->order_type = AUTH_ALLOW;
-      po->type       = AUTH_DEFAULT;
-      po->level      = AUTH_USER;
+      po->order_type = CUPSD_AUTH_ALLOW;
+      po->type       = CUPSD_AUTH_DEFAULT;
+      po->level      = CUPSD_AUTH_USER;
 
       cupsdAddName(po, "@SYSTEM");
       cupsdLogMessage(CUPSD_LOG_INFO, "Require user @SYSTEM");
@@ -1037,7 +1056,7 @@ cupsdReadConfiguration(void)
       cupsdLogMessage(CUPSD_LOG_INFO, "Order Deny,Allow");
 
       po = cupsdAddPolicyOp(p, NULL, IPP_ANY_OPERATION);
-      po->order_type = AUTH_ALLOW;
+      po->order_type = CUPSD_AUTH_ALLOW;
 
       cupsdLogMessage(CUPSD_LOG_INFO, "</Limit>");
       cupsdLogMessage(CUPSD_LOG_INFO, "</Policy>");
@@ -1045,11 +1064,12 @@ cupsdReadConfiguration(void)
   }
 
   cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdReadConfiguration: NumPolicies=%d",
-                  NumPolicies);
-  for (i = 0; i < NumPolicies; i ++)
+                  cupsArrayCount(Policies));
+  for (i = 0, p = (cupsd_policy_t *)cupsArrayFirst(Policies);
+       p;
+       i ++, p = (cupsd_policy_t *)cupsArrayNext(Policies))
     cupsdLogMessage(CUPSD_LOG_DEBUG2,
-                    "cupsdReadConfiguration: Policies[%d]=\"%s\"", i,
-                    Policies[i]->name);
+                    "cupsdReadConfiguration: Policies[%d]=\"%s\"", i, p->name);
 
  /*
   * If we are doing a full reload or the server root has changed, flush
@@ -1094,20 +1114,25 @@ cupsdReadConfiguration(void)
     */
 
     snprintf(temp, sizeof(temp), "%s/filter", ServerBin);
+    snprintf(mimedir, sizeof(mimedir), "%s/mime", DataDir);
 
-    MimeDatabase = mimeLoad(ServerRoot, temp);
+    MimeDatabase = mimeLoadTypes(NULL, mimedir);
+    MimeDatabase = mimeLoadTypes(MimeDatabase, ServerRoot);
+    MimeDatabase = mimeLoadFilters(MimeDatabase, mimedir, temp);
+    MimeDatabase = mimeLoadFilters(MimeDatabase, ServerRoot, temp);
 
     if (!MimeDatabase)
     {
       cupsdLogMessage(CUPSD_LOG_EMERG,
-                      "Unable to load MIME database from \'%s\'!", ServerRoot);
+                      "Unable to load MIME database from \"%s\" or \"%s\"!",
+                     mimedir, ServerRoot);
       exit(errno);
     }
 
     cupsdLogMessage(CUPSD_LOG_INFO,
-                    "Loaded MIME database from \'%s\': %d types, %d filters...",
-                    ServerRoot, mimeNumTypes(MimeDatabase),
-                   mimeNumFilters(MimeDatabase));
+                    "Loaded MIME database from \"%s\" and \"%s\": %d types, "
+                   "%d filters...", mimedir, ServerRoot,
+                   mimeNumTypes(MimeDatabase), mimeNumFilters(MimeDatabase));
 
    /*
     * Create a list of MIME types for the document-format-supported
@@ -1118,19 +1143,27 @@ cupsdReadConfiguration(void)
     if (!mimeType(MimeDatabase, "application", "octet-stream"))
       NumMimeTypes ++;
 
-    MimeTypes = calloc(NumMimeTypes, sizeof(const char *));
-
-    for (i = 0, type = mimeFirstType(MimeDatabase);
-         type;
-        i ++, type = mimeNextType(MimeDatabase))
+    if ((MimeTypes = calloc(NumMimeTypes, sizeof(const char *))) == NULL)
     {
-      snprintf(mimetype, sizeof(mimetype), "%s/%s", type->super, type->type);
-
-      MimeTypes[i] = _cupsStrAlloc(mimetype);
+      cupsdLogMessage(CUPSD_LOG_ERROR,
+                      "Unable to allocate memory for %d MIME types!",
+                     NumMimeTypes);
+      NumMimeTypes = 0;
     }
+    else
+    {
+      for (i = 0, type = mimeFirstType(MimeDatabase);
+          type;
+          i ++, type = mimeNextType(MimeDatabase))
+      {
+       snprintf(mimetype, sizeof(mimetype), "%s/%s", type->super, type->type);
 
-    if (i < NumMimeTypes)
-      MimeTypes[i] = _cupsStrAlloc("application/octet-stream");
+       MimeTypes[i] = _cupsStrAlloc(mimetype);
+      }
+
+      if (i < NumMimeTypes)
+       MimeTypes[i] = _cupsStrAlloc("application/octet-stream");
+    }
 
     if (LogLevel == CUPSD_LOG_DEBUG2)
     {
@@ -1167,7 +1200,7 @@ cupsdReadConfiguration(void)
     cupsdLoadAllPrinters();
     cupsdLoadAllClasses();
     cupsdLoadRemoteCache();
-    cupsdWritePrintcap();
+    cupsdMarkDirty(CUPSD_DIRTY_PRINTCAP);
 
     cupsdCreateCommonData();
 
@@ -1198,7 +1231,7 @@ cupsdReadConfiguration(void)
     */
 
     cupsdUpdatePrinters();
-    cupsdWritePrintcap();
+    cupsdMarkDirty(CUPSD_DIRTY_PRINTCAP);
 
     cupsdLogMessage(CUPSD_LOG_INFO, "Partial reload complete.");
   }
@@ -1567,9 +1600,9 @@ parse_aaa(cupsd_location_t *loc,  /* I - Location */
     */
 
     if (!strncasecmp(value, "deny", 4))
-      loc->order_type = AUTH_ALLOW;
+      loc->order_type = CUPSD_AUTH_ALLOW;
     else if (!strncasecmp(value, "allow", 5))
-      loc->order_type = AUTH_DENY;
+      loc->order_type = CUPSD_AUTH_DENY;
     else
     {
       cupsdLogMessage(CUPSD_LOG_ERROR, "Unknown Order value %s on line %d.",
@@ -1680,44 +1713,44 @@ parse_aaa(cupsd_location_t *loc,        /* I - Location */
 
     if (!strcasecmp(value, "none"))
     {
-      loc->type  = AUTH_NONE;
-      loc->level = AUTH_ANON;
+      loc->type  = CUPSD_AUTH_NONE;
+      loc->level = CUPSD_AUTH_ANON;
     }
     else if (!strcasecmp(value, "basic"))
     {
-      loc->type = AUTH_BASIC;
+      loc->type = CUPSD_AUTH_BASIC;
 
-      if (loc->level == AUTH_ANON)
-       loc->level = AUTH_USER;
+      if (loc->level == CUPSD_AUTH_ANON)
+       loc->level = CUPSD_AUTH_USER;
     }
     else if (!strcasecmp(value, "digest"))
     {
-      loc->type = AUTH_DIGEST;
+      loc->type = CUPSD_AUTH_DIGEST;
 
-      if (loc->level == AUTH_ANON)
-       loc->level = AUTH_USER;
+      if (loc->level == CUPSD_AUTH_ANON)
+       loc->level = CUPSD_AUTH_USER;
     }
     else if (!strcasecmp(value, "basicdigest"))
     {
-      loc->type = AUTH_BASICDIGEST;
+      loc->type = CUPSD_AUTH_BASICDIGEST;
 
-      if (loc->level == AUTH_ANON)
-       loc->level = AUTH_USER;
+      if (loc->level == CUPSD_AUTH_ANON)
+       loc->level = CUPSD_AUTH_USER;
     }
     else if (!strcasecmp(value, "default"))
     {
-      loc->type = AUTH_DEFAULT;
+      loc->type = CUPSD_AUTH_DEFAULT;
 
-      if (loc->level == AUTH_ANON)
-       loc->level = AUTH_USER;
+      if (loc->level == CUPSD_AUTH_ANON)
+       loc->level = CUPSD_AUTH_USER;
     }
 #ifdef HAVE_GSSAPI
     else if (!strcasecmp(value, "negotiate"))
     {
-      loc->type = AUTH_NEGOTIATE;
+      loc->type = CUPSD_AUTH_NEGOTIATE;
 
-      if (loc->level == AUTH_ANON)
-       loc->level = AUTH_USER;
+      if (loc->level == CUPSD_AUTH_ANON)
+       loc->level = CUPSD_AUTH_USER;
     }
 #endif /* HAVE_GSSAPI */
     else
@@ -1736,8 +1769,8 @@ parse_aaa(cupsd_location_t *loc,  /* I - Location */
 
     if (!strcasecmp(value, "anonymous"))
     {
-      loc->type  = AUTH_NONE;
-      loc->level = AUTH_ANON;
+      loc->type  = CUPSD_AUTH_NONE;
+      loc->level = CUPSD_AUTH_ANON;
 
       cupsdLogMessage(CUPSD_LOG_WARN,
                       "\"AuthClass %s\" is deprecated; consider removing "
@@ -1746,7 +1779,7 @@ parse_aaa(cupsd_location_t *loc,  /* I - Location */
     }
     else if (!strcasecmp(value, "user"))
     {
-      loc->level = AUTH_USER;
+      loc->level = CUPSD_AUTH_USER;
 
       cupsdLogMessage(CUPSD_LOG_WARN,
                       "\"AuthClass %s\" is deprecated; consider using "
@@ -1755,7 +1788,7 @@ parse_aaa(cupsd_location_t *loc,  /* I - Location */
     }
     else if (!strcasecmp(value, "group"))
     {
-      loc->level = AUTH_GROUP;
+      loc->level = CUPSD_AUTH_GROUP;
 
       cupsdLogMessage(CUPSD_LOG_WARN,
                       "\"AuthClass %s\" is deprecated; consider using "
@@ -1764,7 +1797,7 @@ parse_aaa(cupsd_location_t *loc,  /* I - Location */
     }
     else if (!strcasecmp(value, "system"))
     {
-      loc->level = AUTH_GROUP;
+      loc->level = CUPSD_AUTH_GROUP;
 
       cupsdAddName(loc, "@SYSTEM");
 
@@ -1809,9 +1842,9 @@ parse_aaa(cupsd_location_t *loc,  /* I - Location */
 
     if (!strcasecmp(value, "valid-user") ||
         !strcasecmp(value, "user"))
-      loc->level = AUTH_USER;
+      loc->level = CUPSD_AUTH_USER;
     else if (!strcasecmp(value, "group"))
-      loc->level = AUTH_GROUP;
+      loc->level = CUPSD_AUTH_GROUP;
     else
     {
       cupsdLogMessage(CUPSD_LOG_WARN, "Unknown Require type %s on line %d.",
@@ -1872,9 +1905,9 @@ parse_aaa(cupsd_location_t *loc,  /* I - Location */
   else if (!strcasecmp(line, "Satisfy"))
   {
     if (!strcasecmp(value, "all"))
-      loc->satisfy = AUTH_SATISFY_ALL;
+      loc->satisfy = CUPSD_AUTH_SATISFY_ALL;
     else if (!strcasecmp(value, "any"))
-      loc->satisfy = AUTH_SATISFY_ANY;
+      loc->satisfy = CUPSD_AUTH_SATISFY_ANY;
     else
     {
       cupsdLogMessage(CUPSD_LOG_WARN, "Unknown Satisfy value %s on line %d.",
@@ -2015,12 +2048,19 @@ parse_protocols(const char *s)          /* I - Space-delimited protocols */
       protocols |= BROWSE_SLP;
     else if (!strcasecmp(valstart, "ldap"))
       protocols |= BROWSE_LDAP;
-    else if (!strcasecmp(valstart, "dnssd") || !strcasecmp(valstart, "bonjour"))
+    else if (!strcasecmp(valstart, "dnssd") ||
+             !strcasecmp(valstart, "dns-sd") ||
+             !strcasecmp(valstart, "bonjour"))
       protocols |= BROWSE_DNSSD;
+    else if (!strcasecmp(valstart, "lpd"))
+      protocols |= BROWSE_LPD;
+    else if (!strcasecmp(valstart, "smb"))
+      protocols |= BROWSE_SMB;
     else if (!strcasecmp(valstart, "all"))
       protocols |= BROWSE_ALL;
     else if (strcasecmp(valstart, "none"))
-      return (-1);
+      cupsdLogMessage(CUPSD_LOG_ERROR,
+                      "Unknown browse protocol \"%s\" ignored!", valstart);
 
     for (valstart = valend; *valstart; valstart ++)
       if (!isspace(*valstart & 255) || *valstart != ',')
@@ -2050,7 +2090,7 @@ read_configuration(cups_file_t *fp)       /* I - File to read from */
                        *value,         /* Pointer to value */
                        *valueptr;      /* Pointer into value */
   int                  valuelen;       /* Length of value */
-  cupsd_var_t          *var;           /* Current variable */
+  cupsd_var_t const    *var;           /* Current variable */
   http_addrlist_t      *addrlist,      /* Address list */
                        *addr;          /* Current address */
   unsigned             ip[4],          /* Address value */
@@ -2075,7 +2115,7 @@ read_configuration(cups_file_t *fp)       /* I - File to read from */
     * Decode the directive...
     */
 
-    if (!strcasecmp(line, "Include"))
+    if (!strcasecmp(line, "Include") && value)
     {
      /*
       * Include filename
@@ -2096,72 +2136,39 @@ read_configuration(cups_file_t *fp)     /* I - File to read from */
        cupsFileClose(incfile);
       }
     }
-    else if (!strcasecmp(line, "<Location"))
+    else if (!strcasecmp(line, "<Location") && value)
     {
      /*
       * <Location path>
       */
 
-      if (value)
-      {
-       linenum = read_location(fp, value, linenum);
-       if (linenum == 0)
-         return (0);
-      }
-      else
-      {
-        cupsdLogMessage(CUPSD_LOG_ERROR, "Syntax error on line %d.",
-                  linenum);
-        return (0);
-      }
+      linenum = read_location(fp, value, linenum);
+      if (linenum == 0)
+       return (0);
     }
-    else if (!strcasecmp(line, "<Policy"))
+    else if (!strcasecmp(line, "<Policy") && value)
     {
      /*
       * <Policy name>
       */
 
-      if (value)
-      {
-       linenum = read_policy(fp, value, linenum);
-       if (linenum == 0)
-         return (0);
-      }
-      else
-      {
-        cupsdLogMessage(CUPSD_LOG_ERROR, "Syntax error on line %d.", linenum);
-        return (0);
-      }
+      linenum = read_policy(fp, value, linenum);
+      if (linenum == 0)
+       return (0);
     }
-    else if (!strcasecmp(line, "FaxRetryInterval"))
+    else if (!strcasecmp(line, "FaxRetryInterval") && value)
     {
-      if (value)
-      {
-        JobRetryInterval = atoi(value);
-       cupsdLogMessage(CUPSD_LOG_WARN,
-                       "FaxRetryInterval is deprecated; use "
-                       "JobRetryInterval on line %d.", linenum);
-      }
-      else
-      {
-        cupsdLogMessage(CUPSD_LOG_ERROR, "Syntax error on line %d.", linenum);
-        return (0);
-      }
+      JobRetryInterval = atoi(value);
+      cupsdLogMessage(CUPSD_LOG_WARN,
+                     "FaxRetryInterval is deprecated; use "
+                     "JobRetryInterval on line %d.", linenum);
     }
-    else if (!strcasecmp(line, "FaxRetryLimit"))
+    else if (!strcasecmp(line, "FaxRetryLimit") && value)
     {
-      if (value)
-      {
-        JobRetryLimit = atoi(value);
-       cupsdLogMessage(CUPSD_LOG_WARN,
-                       "FaxRetryLimit is deprecated; use "
-                       "JobRetryLimit on line %d.", linenum);
-      }
-      else
-      {
-        cupsdLogMessage(CUPSD_LOG_ERROR, "Syntax error on line %d.", linenum);
-        return (0);
-      }
+      JobRetryLimit = atoi(value);
+      cupsdLogMessage(CUPSD_LOG_WARN,
+                     "FaxRetryLimit is deprecated; use "
+                     "JobRetryLimit on line %d.", linenum);
     }
     else if (!strcasecmp(line, "Port") || !strcasecmp(line, "Listen")
 #ifdef HAVE_SSL
@@ -2255,7 +2262,7 @@ read_configuration(cups_file_t *fp)       /* I - File to read from */
 
       httpAddrFreeList(addrlist);
     }
-    else if (!strcasecmp(line, "BrowseAddress"))
+    else if (!strcasecmp(line, "BrowseAddress") && value)
     {
      /*
       * Add a browse address to the list...
@@ -2336,7 +2343,7 @@ read_configuration(cups_file_t *fp)       /* I - File to read from */
         cupsdLogMessage(CUPSD_LOG_ERROR, "Bad BrowseAddress %s at line %d.",
                        value, linenum);
     }
-    else if (!strcasecmp(line, "BrowseOrder"))
+    else if (!strcasecmp(line, "BrowseOrder") && value)
     {
      /*
       * "BrowseOrder Deny,Allow" or "BrowseOrder Allow,Deny"...
@@ -2349,9 +2356,9 @@ read_configuration(cups_file_t *fp)       /* I - File to read from */
         cupsdLogMessage(CUPSD_LOG_ERROR,
                        "Unable to initialize browse access control list!");
       else if (!strncasecmp(value, "deny", 4))
-        location->order_type = AUTH_ALLOW;
+        location->order_type = CUPSD_AUTH_ALLOW;
       else if (!strncasecmp(value, "allow", 5))
-        location->order_type = AUTH_DENY;
+        location->order_type = CUPSD_AUTH_DENY;
       else
         cupsdLogMessage(CUPSD_LOG_ERROR,
                        "Unknown BrowseOrder value %s on line %d.",
@@ -2382,8 +2389,8 @@ read_configuration(cups_file_t *fp)       /* I - File to read from */
       if (strcasecmp(line, "BrowseRemoteProtocols"))
         BrowseLocalProtocols = protocols;
     }
-    else if (!strcasecmp(line, "BrowseAllow") ||
-             !strcasecmp(line, "BrowseDeny"))
+    else if ((!strcasecmp(line, "BrowseAllow") ||
+              !strcasecmp(line, "BrowseDeny")) && value)
     {
      /*
       * BrowseAllow [From] host/ip...
@@ -2487,7 +2494,7 @@ read_configuration(cups_file_t *fp)       /* I - File to read from */
        }
       }
     }
-    else if (!strcasecmp(line, "BrowseRelay"))
+    else if (!strcasecmp(line, "BrowseRelay") && value)
     {
      /*
       * BrowseRelay [from] source [to] destination
@@ -2555,8 +2562,16 @@ read_configuration(cups_file_t *fp)      /* I - File to read from */
        if ((ptr = strchr(temp, ' ')) != NULL)
          *ptr = '\0';
 
-        relay->from.type             = AUTH_NAME;
-       relay->from.mask.name.name   = strdup(temp);
+        relay->from.type = CUPSD_AUTH_NAME;
+
+       if ((relay->from.mask.name.name = strdup(temp)) == NULL)
+       {
+         cupsdLogMessage(CUPSD_LOG_ERROR,
+                         "Unable to allocate BrowseRelay name at line %d - %s.",
+                         linenum, strerror(errno));
+         continue;
+       }
+
        relay->from.mask.name.length = strlen(temp);
       }
       else
@@ -2572,7 +2587,7 @@ read_configuration(cups_file_t *fp)       /* I - File to read from */
          break;
        }
 
-        relay->from.type = AUTH_IP;
+        relay->from.type = CUPSD_AUTH_IP;
        memcpy(relay->from.mask.ip.address, ip,
               sizeof(relay->from.mask.ip.address));
        memcpy(relay->from.mask.ip.netmask, mask,
@@ -2622,7 +2637,7 @@ read_configuration(cups_file_t *fp)       /* I - File to read from */
   
          httpAddrString(&(relay->to), temp, sizeof(temp));
   
-         if (relay->from.type == AUTH_IP)
+         if (relay->from.type == CUPSD_AUTH_IP)
            snprintf(temp2, sizeof(temp2), "%u.%u.%u.%u/%u.%u.%u.%u",
                     relay->from.mask.ip.address[0] >> 24,
                     (relay->from.mask.ip.address[0] >> 16) & 255,
@@ -2648,14 +2663,14 @@ read_configuration(cups_file_t *fp)     /* I - File to read from */
       }
       else
       {
-        if (relay->from.type == AUTH_NAME)
+        if (relay->from.type == CUPSD_AUTH_NAME)
          free(relay->from.mask.name.name);
 
         cupsdLogMessage(CUPSD_LOG_ERROR, "Bad relay address %s at line %d.",
                        value, linenum);
       }
     }
-    else if (!strcasecmp(line, "BrowsePoll"))
+    else if (!strcasecmp(line, "BrowsePoll") && value)
     {
      /*
       * BrowsePoll address[:port]
@@ -2717,23 +2732,23 @@ read_configuration(cups_file_t *fp)     /* I - File to read from */
       cupsdLogMessage(CUPSD_LOG_INFO, "Polling %s:%d", pollp->hostname,
                      pollp->port);
     }
-    else if (!strcasecmp(line, "DefaultAuthType"))
+    else if (!strcasecmp(line, "DefaultAuthType") && value)
     {
      /*
       * DefaultAuthType {basic,digest,basicdigest,negotiate}
       */
 
       if (!strcasecmp(value, "none"))
-       DefaultAuthType = AUTH_NONE;
+       DefaultAuthType = CUPSD_AUTH_NONE;
       else if (!strcasecmp(value, "basic"))
-       DefaultAuthType = AUTH_BASIC;
+       DefaultAuthType = CUPSD_AUTH_BASIC;
       else if (!strcasecmp(value, "digest"))
-       DefaultAuthType = AUTH_DIGEST;
+       DefaultAuthType = CUPSD_AUTH_DIGEST;
       else if (!strcasecmp(value, "basicdigest"))
-       DefaultAuthType = AUTH_BASICDIGEST;
+       DefaultAuthType = CUPSD_AUTH_BASICDIGEST;
 #ifdef HAVE_GSSAPI
       else if (!strcasecmp(value, "negotiate"))
-        DefaultAuthType = AUTH_NEGOTIATE;
+        DefaultAuthType = CUPSD_AUTH_NEGOTIATE;
 #endif /* HAVE_GSSAPI */
       else
       {
@@ -2766,7 +2781,7 @@ read_configuration(cups_file_t *fp)       /* I - File to read from */
     }
 #endif /* HAVE_SSL */
 #ifdef HAVE_GSSAPI
-    else if (!strcasecmp(line, "Krb5Keytab"))
+    else if (!strcasecmp(line, "Krb5Keytab") && value)
     {
       cupsdSetStringf(&Krb5Keytab, "KRB5_KTNAME=%s", value);
       putenv(Krb5Keytab);
@@ -2778,13 +2793,13 @@ read_configuration(cups_file_t *fp)     /* I - File to read from */
 #  endif /* HAVE_GSSKRB5_REGISTER_ACCEPTOR_IDENTITY */
     }
 #endif /* HAVE_GSSAPI */
-    else if (!strcasecmp(line, "User"))
+    else if (!strcasecmp(line, "User") && value)
     {
      /*
       * User ID to run as...
       */
 
-      if (value && isdigit(value[0] & 255))
+      if (isdigit(value[0] & 255))
       {
         int uid = atoi(value);
 
@@ -2797,7 +2812,7 @@ read_configuration(cups_file_t *fp)       /* I - File to read from */
         else
          User = atoi(value);
       }
-      else if (value)
+      else
       {
         struct passwd *p;      /* Password information */
 
@@ -2820,12 +2835,8 @@ read_configuration(cups_file_t *fp)      /* I - File to read from */
                          "Unknown User \"%s\" on line %d, ignoring!",
                          value, linenum);
       }
-      else
-       cupsdLogMessage(CUPSD_LOG_ERROR,
-                       "User directive on line %d missing the username!",
-                       linenum);
     }
-    else if (!strcasecmp(line, "Group"))
+    else if (!strcasecmp(line, "Group") && value)
     {
      /*
       * Group ID to run as...
@@ -2846,7 +2857,7 @@ read_configuration(cups_file_t *fp)       /* I - File to read from */
                          value, linenum);
       }
     }
-    else if (!strcasecmp(line, "SystemGroup"))
+    else if (!strcasecmp(line, "SystemGroup") && value)
     {
      /*
       * SystemGroup (admin) group(s)...
@@ -2857,15 +2868,17 @@ read_configuration(cups_file_t *fp)     /* I - File to read from */
                        "Unknown SystemGroup \"%s\" on line %d, ignoring!",
                        value, linenum);
     }
-    else if (!strcasecmp(line, "HostNameLookups"))
+    else if (!strcasecmp(line, "HostNameLookups") && value)
     {
      /*
       * Do hostname lookups?
       */
 
-      if (!strcasecmp(value, "off"))
+      if (!strcasecmp(value, "off") || !strcasecmp(value, "no") ||
+          !strcasecmp(value, "false"))
         HostNameLookups = 0;
-      else if (!strcasecmp(value, "on"))
+      else if (!strcasecmp(value, "on") || !strcasecmp(value, "yes") ||
+          !strcasecmp(value, "true"))
         HostNameLookups = 1;
       else if (!strcasecmp(value, "double"))
         HostNameLookups = 2;
@@ -2873,7 +2886,7 @@ read_configuration(cups_file_t *fp)       /* I - File to read from */
        cupsdLogMessage(CUPSD_LOG_WARN, "Unknown HostNameLookups %s on line %d.",
                        value, linenum);
     }
-    else if (!strcasecmp(line, "LogLevel"))
+    else if (!strcasecmp(line, "LogLevel") && value)
     {
      /*
       * Amount of logging to do...
@@ -2903,7 +2916,7 @@ read_configuration(cups_file_t *fp)       /* I - File to read from */
         cupsdLogMessage(CUPSD_LOG_WARN, "Unknown LogLevel %s on line %d.",
                        value, linenum);
     }
-    else if (!strcasecmp(line, "PrintcapFormat"))
+    else if (!strcasecmp(line, "PrintcapFormat") && value)
     {
      /*
       * Format of printcap file?
@@ -2917,7 +2930,7 @@ read_configuration(cups_file_t *fp)       /* I - File to read from */
        cupsdLogMessage(CUPSD_LOG_WARN, "Unknown PrintcapFormat %s on line %d.",
                        value, linenum);
     }
-    else if (!strcasecmp(line, "ServerTokens"))
+    else if (!strcasecmp(line, "ServerTokens") && value)
     {
      /*
       * Set the string used for the Server header...
@@ -2933,7 +2946,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.2");
+       cupsdSetString(&ServerHeader, "CUPS/1.4");
       else if (!strcasecmp(value, "Minimal"))
        cupsdSetString(&ServerHeader, CUPS_MINIMAL);
       else if (!strcasecmp(value, "OS"))
@@ -2947,7 +2960,7 @@ read_configuration(cups_file_t *fp)       /* I - File to read from */
        cupsdLogMessage(CUPSD_LOG_WARN, "Unknown ServerTokens %s on line %d.",
                         value, linenum);
     }
-    else if (!strcasecmp(line, "PassEnv"))
+    else if (!strcasecmp(line, "PassEnv") && value)
     {
      /*
       * PassEnv variable [... variable]
@@ -2972,7 +2985,7 @@ read_configuration(cups_file_t *fp)       /* I - File to read from */
            break;
       }
     }
-    else if (!strcasecmp(line, "SetEnv"))
+    else if (!strcasecmp(line, "SetEnv") && value)
     {
      /*
       * SetEnv variable value
@@ -3012,8 +3025,12 @@ read_configuration(cups_file_t *fp)      /* I - File to read from */
         * Unknown directive!  Output an error message and continue...
        */
 
-        cupsdLogMessage(CUPSD_LOG_ERROR, "Unknown directive %s on line %d.",
-                       line, linenum);
+        if (!value)
+         cupsdLogMessage(CUPSD_LOG_ERROR, "Missing value for %s on line %d.",
+                         line, linenum);
+       else
+         cupsdLogMessage(CUPSD_LOG_ERROR, "Unknown directive %s on line %d.",
+                         line, linenum);
         continue;
       }
 
@@ -3076,6 +3093,28 @@ read_configuration(cups_file_t *fp)      /* I - File to read from */
                              value, linenum);
            break;
 
+       case CUPSD_VARTYPE_PATHNAME :
+            if (!value)
+           {
+             cupsdLogMessage(CUPSD_LOG_ERROR,
+                             "Missing pathname value for %s on line %d!",
+                             line, linenum);
+              break;
+           }
+
+           if (value[0] == '/')
+             strlcpy(temp, value, sizeof(temp));
+           else
+             snprintf(temp, sizeof(temp), "%s/%s", ServerRoot, value);
+
+            if (access(temp, 0))
+           {
+             cupsdLogMessage(CUPSD_LOG_ERROR,
+                             "File or directory for \"%s %s\" on line %d "
+                             "does not exist!", line, value, linenum);
+              break;
+           }
+
        case CUPSD_VARTYPE_STRING :
            cupsdSetString((char **)var->ptr, value);
            break;
@@ -3107,7 +3146,7 @@ read_location(cups_file_t *fp,            /* I - Configuration file */
   if ((parent = cupsdAddLocation(location)) == NULL)
     return (0);
 
-  parent->limit = AUTH_LIMIT_ALL;
+  parent->limit = CUPSD_AUTH_LIMIT_ALL;
   loc           = parent;
 
   while (cupsFileGetConf(fp, line, sizeof(line), &value, &linenum))
@@ -3139,19 +3178,19 @@ read_location(cups_file_t *fp,          /* I - Configuration file */
          *valptr++ = '\0';
 
         if (!strcmp(value, "ALL"))
-         loc->limit = AUTH_LIMIT_ALL;
+         loc->limit = CUPSD_AUTH_LIMIT_ALL;
        else if (!strcmp(value, "GET"))
-         loc->limit |= AUTH_LIMIT_GET;
+         loc->limit |= CUPSD_AUTH_LIMIT_GET;
        else if (!strcmp(value, "HEAD"))
-         loc->limit |= AUTH_LIMIT_HEAD;
+         loc->limit |= CUPSD_AUTH_LIMIT_HEAD;
        else if (!strcmp(value, "OPTIONS"))
-         loc->limit |= AUTH_LIMIT_OPTIONS;
+         loc->limit |= CUPSD_AUTH_LIMIT_OPTIONS;
        else if (!strcmp(value, "POST"))
-         loc->limit |= AUTH_LIMIT_POST;
+         loc->limit |= CUPSD_AUTH_LIMIT_POST;
        else if (!strcmp(value, "PUT"))
-         loc->limit |= AUTH_LIMIT_PUT;
+         loc->limit |= CUPSD_AUTH_LIMIT_PUT;
        else if (!strcmp(value, "TRACE"))
-         loc->limit |= AUTH_LIMIT_TRACE;
+         loc->limit |= CUPSD_AUTH_LIMIT_TRACE;
        else
          cupsdLogMessage(CUPSD_LOG_WARN, "Unknown request type %s on line %d!",
                          value, linenum);
@@ -3160,11 +3199,12 @@ read_location(cups_file_t *fp,          /* I - Configuration file */
       }
 
       if (!strcasecmp(line, "<LimitExcept"))
-        loc->limit = AUTH_LIMIT_ALL ^ loc->limit;
+        loc->limit = CUPSD_AUTH_LIMIT_ALL ^ loc->limit;
 
       parent->limit &= ~loc->limit;
     }
-    else if (!strcasecmp(line, "</Limit>"))
+    else if (!strcasecmp(line, "</Limit>") ||
+             !strcasecmp(line, "</LimitExcept>"))
       loc = parent;
     else if (!parse_aaa(loc, line, value, linenum))
     {
@@ -3230,6 +3270,30 @@ read_policy(cups_file_t *fp,             /* I - Configuration file */
                        "Missing </Limit> before </Policy> on line %d!",
                        linenum);
 
+     /*
+      * Verify that we have an explicit policy for CUPS-Get-Document
+      * (ensures that upgrades do not introduce new security issues...)
+      */
+
+      if ((op = cupsdFindPolicyOp(pol, CUPS_GET_DOCUMENT)) == NULL ||
+          op->op == IPP_ANY_OPERATION)
+      {
+        if ((op = cupsdFindPolicyOp(pol, IPP_SEND_DOCUMENT)) != NULL &&
+            op->op != IPP_ANY_OPERATION)
+       {
+        /*
+         * Add a new limit for CUPS-Get-Document using the Send-Document
+         * limit as a template...
+         */
+
+          cupsdLogMessage(CUPSD_LOG_WARN,
+                         "No limit for CUPS-Get-Document defined in policy %s "
+                         "- using Send-Document's policy", pol->name);
+
+          cupsdAddPolicyOp(pol, op, CUPS_GET_DOCUMENT);
+       }
+      }
+
       return (linenum);
     }
     else if (!strcasecmp(line, "<Limit") && !op)
@@ -3337,5 +3401,5 @@ read_policy(cups_file_t *fp,              /* I - Configuration file */
 
 
 /*
- * End of "$Id: conf.c 6746 2007-07-30 16:47:10Z mike $".
+ * End of "$Id: conf.c 7694 2008-06-26 00:23:20Z mike $".
  */