]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - scheduler/conf.c
Load cups into easysw/current.
[thirdparty/cups.git] / scheduler / conf.c
index f76d86c91571ea39091b6f07576e17a5a9499585..cc8c782b40cd9f47c4531a2a9d36204ad062d1e6 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: conf.c 5116 2006-02-16 12:52:32Z mike $"
+ * "$Id: conf.c 5167 2006-02-25 02:11:44Z mike $"
  *
  *   Configuration routines for the Common UNIX Printing System (CUPS).
  *
@@ -89,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 },
@@ -216,6 +222,9 @@ cupsdReadConfiguration(void)
   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 */
+
 
  /*
   * Save the old root paths...
@@ -309,10 +318,7 @@ cupsdReadConfiguration(void)
 
   cupsdSetString(&RIPCache, "8m");
 
-  if (getenv("TMPDIR") == NULL)
-    cupsdSetString(&TempDir, CUPS_REQUESTS "/tmp");
-  else
-    cupsdSetString(&TempDir, getenv("TMPDIR"));
+  cupsdSetString(&TempDir, NULL);
 
  /*
   * Find the default user...
@@ -395,6 +401,13 @@ cupsdReadConfiguration(void)
   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;
@@ -615,6 +628,41 @@ cupsdReadConfiguration(void)
   check_permissions(ServerRoot, "printers.conf", 0600, RunUser, Group, 0, 0);
   check_permissions(ServerRoot, "passwd.md5", 0600, User, Group, 0, 0);
 
+ /*
+  * Update TempDir to the default if it hasn't been set already...
+  */
+
+  if (!TempDir)
+  {
+    if ((tmpdir = getenv("TMPDIR")) != NULL)
+    {
+     /*
+      * TMPDIR is defined, see if it is OK for us to use...
+      */
+
+      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);
+
+      if (!TempDir)
+        cupsdLogMessage(CUPSD_LOG_INFO, "Using default TempDir of %s/tmp...",
+                       RequestRoot);
+    }
+
+    if (!TempDir)
+      cupsdSetStringf(&TempDir, "%s/tmp", RequestRoot);
+  }
+
  /*
   * Make sure the request and temporary directories have the right
   * permissions...
@@ -3169,5 +3217,5 @@ read_policy(cups_file_t *fp,              /* I - Configuration file */
 
 
 /*
- * End of "$Id: conf.c 5116 2006-02-16 12:52:32Z mike $".
+ * End of "$Id: conf.c 5167 2006-02-25 02:11:44Z mike $".
  */