summaryrefslogtreecommitdiff
path: root/scheduler/main.c
diff options
context:
space:
mode:
authorDidier Raboud <odyx@debian.org>2013-03-19 11:05:58 +0100
committerDidier Raboud <odyx@debian.org>2013-03-19 11:05:58 +0100
commitea5667a811b20e235ce1975e763469edd1f7f0de (patch)
treea02b8034aba8666f06fdbc971905ca760b1c3aa7 /scheduler/main.c
parent6fd17d1b328ea9230585f7ad1e3c478343157220 (diff)
downloadcups-ea5667a811b20e235ce1975e763469edd1f7f0de.tar.gz
Imported Upstream version 1.6.2upstream/1.6.2
Diffstat (limited to 'scheduler/main.c')
-rw-r--r--scheduler/main.c108
1 files changed, 72 insertions, 36 deletions
diff --git a/scheduler/main.c b/scheduler/main.c
index d3b43a05..58776fea 100644
--- a/scheduler/main.c
+++ b/scheduler/main.c
@@ -1,5 +1,5 @@
/*
- * "$Id: main.c 10431 2012-04-23 19:19:19Z mike $"
+ * "$Id: main.c 10777 2012-12-17 22:18:10Z mike $"
*
* Main loop for the CUPS scheduler.
*
@@ -65,10 +65,15 @@
#if defined(HAVE_MALLOC_H) && defined(HAVE_MALLINFO)
# include <malloc.h>
#endif /* HAVE_MALLOC_H && HAVE_MALLINFO */
+
#ifdef HAVE_NOTIFY_H
# include <notify.h>
#endif /* HAVE_NOTIFY_H */
+#ifdef HAVE_SYS_PARAM_H
+# include <sys/param.h>
+#endif /* HAVE_SYS_PARAM_H */
+
/*
* Local functions...
@@ -207,7 +212,6 @@ main(int argc, /* I - Number of command-line args */
char *current; /* Current directory */
-
/*
* Allocate a buffer for the current working directory to
* reduce run-time stack usage; this approximates the
@@ -271,6 +275,29 @@ main(int argc, /* I - Number of command-line args */
UseProfiles = 0;
break;
+ case 's' : /* Set cups-files.conf location */
+ i ++;
+ if (i >= argc)
+ {
+ _cupsLangPuts(stderr, _("cupsd: Expected cups-files.conf "
+ "filename after \"-s\" option."));
+ usage(1);
+ }
+
+ if (argv[i][0] != '/')
+ {
+ /*
+ * Relative filename not allowed...
+ */
+
+ _cupsLangPuts(stderr, _("cupsd: Relative cups-files.conf "
+ "filename not allowed."));
+ usage(1);
+ }
+
+ cupsdSetString(&CupsFilesFile, argv[i]);
+ break;
+
#ifdef __APPLE__
case 'S' : /* Disable system management functions */
fputs("cupsd: -S (disable system management) for internal "
@@ -298,7 +325,39 @@ main(int argc, /* I - Number of command-line args */
}
if (!ConfigurationFile)
+ {
cupsdSetString(&ConfigurationFile, CUPS_SERVERROOT "/cupsd.conf");
+ cupsdSetString(&CupsFilesFile, CUPS_SERVERROOT "/cups-files.conf");
+ }
+
+ if (!CupsFilesFile)
+ {
+ char *filename, /* Copy of cupsd.conf filename */
+ *slash; /* Final slash in cupsd.conf filename */
+ size_t len; /* Size of buffer */
+
+ len = strlen(ConfigurationFile) + 15;
+ if ((filename = malloc(len)) == NULL)
+ {
+ _cupsLangPrintf(stderr,
+ _("cupsd: Unable to get path to "
+ "cups-files.conf file."));
+ return (1);
+ }
+
+ strlcpy(filename, ConfigurationFile, len);
+ if ((slash = strrchr(filename, '/')) == NULL)
+ {
+ _cupsLangPrintf(stderr,
+ _("cupsd: Unable to get path to "
+ "cups-files.conf file."));
+ return (1);
+ }
+
+ strlcpy(slash, "/cups-files.conf", len - (slash - filename));
+ cupsdSetString(&CupsFilesFile, filename);
+ free(filename);
+ }
/*
* If the user hasn't specified "-f", run in the background...
@@ -365,15 +424,15 @@ main(int argc, /* I - Number of command-line args */
}
}
-#ifdef __OpenBSD__
+#if defined(__OpenBSD__) && OpenBSD < 201211
/*
* Call _thread_sys_closefrom() so the child process doesn't reset the
* parent's file descriptors to be blocking. This is a workaround for a
- * limitation of userland libpthread on OpenBSD.
+ * limitation of userland libpthread on older versions of OpenBSD.
*/
_thread_sys_closefrom(0);
-#endif /* __OpenBSD__ */
+#endif /* __OpenBSD__ && OpenBSD < 201211 */
/*
* Since CoreFoundation and DBUS both create fork-unsafe data on execution of
@@ -483,17 +542,11 @@ main(int argc, /* I - Number of command-line args */
*/
if (!cupsdReadConfiguration())
- {
- if (TestConfigFile)
- printf("%s contains errors\n", ConfigurationFile);
- else
- syslog(LOG_LPR, "Unable to read configuration file \'%s\' - exiting!",
- ConfigurationFile);
return (1);
- }
else if (TestConfigFile)
{
- printf("%s is OK\n", ConfigurationFile);
+ printf("\"%s\" is OK.\n", CupsFilesFile);
+ printf("\"%s\" is OK.\n", ConfigurationFile);
return (0);
}
@@ -781,9 +834,9 @@ main(int argc, /* I - Number of command-line args */
* Got an error from select!
*/
-#ifdef HAVE_DNSSD
+#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI)
cupsd_printer_t *p; /* Current printer */
-#endif /* HAVE_DNSSD */
+#endif /* HAVE_DNSSD || HAVE_AVAHI */
if (errno == EINTR) /* Just interrupted by a signal */
@@ -824,13 +877,13 @@ main(int argc, /* I - Number of command-line args */
job->print_pipes[0], job->print_pipes[1],
job->back_pipes[0], job->back_pipes[1]);
-#ifdef HAVE_DNSSD
+#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI)
for (p = (cupsd_printer_t *)cupsArrayFirst(Printers);
p;
p = (cupsd_printer_t *)cupsArrayNext(Printers))
cupsdLogMessage(CUPSD_LOG_EMERG, "printer[%s] reg_name=\"%s\"", p->name,
p->reg_name ? p->reg_name : "(null)");
-#endif /* HAVE_DNSSD */
+#endif /* HAVE_DNSSD || HAVE_AVAHI */
break;
}
@@ -922,7 +975,7 @@ main(int argc, /* I - Number of command-line args */
*/
cupsdDeleteCert(0);
- cupsdAddCert(0, "root", NULL);
+ cupsdAddCert(0, "root", cupsdDefaultAuthType());
}
#endif /* !HAVE_AUTHORIZATION_H */
@@ -1114,23 +1167,6 @@ main(int argc, /* I - Number of command-line args */
cupsdStopSystemMonitor();
#endif /* __APPLE__ */
-#ifdef HAVE_GSSAPI
- /*
- * Free the scheduler's Kerberos context...
- */
-
-# ifdef __APPLE__
- /*
- * If the weak-linked GSSAPI/Kerberos library is not present, don't try
- * to use it...
- */
-
- if (krb5_init_context != NULL)
-# endif /* __APPLE__ */
- if (KerberosContext)
- krb5_free_context(KerberosContext);
-#endif /* HAVE_GSSAPI */
-
#ifdef __sgi
/*
* Remove the fake IRIX lpsched lock file, but only if the existing
@@ -2030,5 +2066,5 @@ usage(int status) /* O - Exit status */
/*
- * End of "$Id: main.c 10431 2012-04-23 19:19:19Z mike $".
+ * End of "$Id: main.c 10777 2012-12-17 22:18:10Z mike $".
*/