]> 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 d9f9b052479cfb8079c3b96f0bef5c4ff55434d2..955dc2df1eb4aba02e12d4f7c60cc5532861e1fd 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: conf.c 6930 2007-09-08 00:28:06Z mike $"
+ * "$Id: conf.c 7694 2008-06-26 00:23:20Z mike $"
  *
  *   Configuration routines for the Common UNIX Printing System (CUPS).
  *
@@ -103,6 +103,7 @@ static const 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 },
@@ -113,6 +114,7 @@ static const 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 },
@@ -144,6 +146,7 @@ static const 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 },
@@ -343,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 */
@@ -411,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);
@@ -515,6 +522,7 @@ cupsdReadConfiguration(void)
 #ifdef HAVE_SSL
   DefaultEncryption     = HTTP_ENCRYPT_REQUIRED;
 #endif /* HAVE_SSL */
+  DirtyCleanInterval    = 60;
   JobRetryLimit         = 5;
   JobRetryInterval      = 300;
   FileDevice            = FALSE;
@@ -782,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,
@@ -1102,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
@@ -1183,7 +1200,7 @@ cupsdReadConfiguration(void)
     cupsdLoadAllPrinters();
     cupsdLoadAllClasses();
     cupsdLoadRemoteCache();
-    cupsdWritePrintcap();
+    cupsdMarkDirty(CUPSD_DIRTY_PRINTCAP);
 
     cupsdCreateCommonData();
 
@@ -1214,7 +1231,7 @@ cupsdReadConfiguration(void)
     */
 
     cupsdUpdatePrinters();
-    cupsdWritePrintcap();
+    cupsdMarkDirty(CUPSD_DIRTY_PRINTCAP);
 
     cupsdLogMessage(CUPSD_LOG_INFO, "Partial reload complete.");
   }
@@ -2098,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
@@ -2119,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
@@ -2278,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...
@@ -2359,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"...
@@ -2405,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...
@@ -2510,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
@@ -2686,7 +2670,7 @@ read_configuration(cups_file_t *fp)       /* I - File to read from */
                        value, linenum);
       }
     }
-    else if (!strcasecmp(line, "BrowsePoll"))
+    else if (!strcasecmp(line, "BrowsePoll") && value)
     {
      /*
       * BrowsePoll address[:port]
@@ -2748,7 +2732,7 @@ read_configuration(cups_file_t *fp)       /* I - File to read from */
       cupsdLogMessage(CUPSD_LOG_INFO, "Polling %s:%d", pollp->hostname,
                      pollp->port);
     }
-    else if (!strcasecmp(line, "DefaultAuthType"))
+    else if (!strcasecmp(line, "DefaultAuthType") && value)
     {
      /*
       * DefaultAuthType {basic,digest,basicdigest,negotiate}
@@ -2797,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);
@@ -2809,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);
 
@@ -2828,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 */
 
@@ -2851,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...
@@ -2877,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)...
@@ -2888,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;
@@ -2904,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...
@@ -2934,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?
@@ -2948,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...
@@ -2964,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"))
@@ -2978,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]
@@ -3003,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
@@ -3043,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;
       }
 
@@ -3108,7 +3094,15 @@ read_configuration(cups_file_t *fp)      /* I - File to read from */
            break;
 
        case CUPSD_VARTYPE_PATHNAME :
-            if (value[0] == '/')
+            if (!value)
+           {
+             cupsdLogMessage(CUPSD_LOG_ERROR,
+                             "Missing pathname value for %s on line %d!",
+                             line, linenum);
+              break;
+           }
+
+           if (value[0] == '/')
              strlcpy(temp, value, sizeof(temp));
            else
              snprintf(temp, sizeof(temp), "%s/%s", ServerRoot, value);
@@ -3407,5 +3401,5 @@ read_policy(cups_file_t *fp,              /* I - Configuration file */
 
 
 /*
- * End of "$Id: conf.c 6930 2007-09-08 00:28:06Z mike $".
+ * End of "$Id: conf.c 7694 2008-06-26 00:23:20Z mike $".
  */