/*
- * "$Id: main.c 6689 2007-07-18 23:52:15Z mike $"
+ * "$Id: main.c 6914 2007-09-05 21:05:04Z mike $"
*
* Scheduler main loop for the Common UNIX Printing System (CUPS).
*
#endif /* HAVE_LAUNCHD */
+#ifdef HAVE_GETEUID
+ /*
+ * Check for setuid invocation, which we do not support!
+ */
+
+ if (getuid() != geteuid())
+ {
+ fputs("cupsd: Cannot run as a setuid program!\n", stderr);
+ return (1);
+ }
+#endif /* HAVE_GETEUID */
+
/*
* Check for command-line arguments...
*/
fg = 1;
break;
+ case 't' : /* Test the cupsd.conf file... */
+ TestConfigFile = 1;
+ fg = 1;
+ break;
+
default : /* Unknown option */
_cupsLangPrintf(stderr, _("cupsd: Unknown option \"%c\" - "
"aborting!\n"), *opt);
if (!cupsdReadConfiguration())
{
- syslog(LOG_LPR, "Unable to read configuration file \'%s\' - exiting!",
- ConfigurationFile);
+ 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);
+ return (0);
+ }
if (!strncmp(TempDir, RequestRoot, strlen(RequestRoot)))
{
PSQUpdateQuotaProc = dlsym(PSQLibRef, PSQLibFuncName);
#endif /* __APPLE__ && HAVE_DLFCN_H */
+#ifdef HAVE_GSSAPI
+# 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__ */
+
+ /*
+ * Setup a Kerberos context for the scheduler to use...
+ */
+
+ if (krb5_init_context(&KerberosContext))
+ cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to initialize Kerberos context");
+#endif /* HAVE_GSSAPI */
+
/*
* Startup the server...
*/
}
#endif /* HAVE_LAUNCHD */
+ /*
+ * Resume listening for new connections as needed...
+ */
+
+ if (ListeningPaused && ListeningPaused <= current_time &&
+ cupsArrayCount(Clients) < MaxClients)
+ cupsdResumeListening();
+
/*
* Expire subscriptions and unload completed jobs as needed...
*/
"Scheduler shutting down due to program error.");
/*
- * Close all network clients and stop all jobs...
+ * Close all network clients...
*/
cupsdStopServer();
+#ifdef HAVE_LAUNCHD
+ /*
+ * Update the launchd KeepAlive file as needed...
+ */
+
+ if (Launchd)
+ launchd_checkout();
+#endif /* HAVE_LAUNCHD */
+
+ /*
+ * Stop all jobs...
+ */
+
cupsdFreeAllJobs();
#ifdef __APPLE__
+ /*
+ * Stop monitoring system event monitoring...
+ */
+
cupsdStopSystemMonitor();
#endif /* __APPLE__ */
-#ifdef HAVE_LAUNCHD
+#ifdef HAVE_GSSAPI
/*
- * Update the launchd KeepAlive file as needed...
+ * Free the scheduler's Kerberos context...
*/
- if (Launchd)
- launchd_checkout();
-#endif /* HAVE_LAUNCHD */
+# 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__ */
+ krb5_free_context(KerberosContext);
+#endif /* HAVE_GSSAPI */
#ifdef __APPLE__
#ifdef HAVE_DLFCN_H
timeout = now + 86400; /* 86400 == 1 day */
why = "do nothing";
+ /*
+ * Check whether we are accepting new connections...
+ */
+
+ if (ListeningPaused > 0 && cupsArrayCount(Clients) < MaxClients &&
+ ListeningPaused < timeout)
+ {
+ if (ListeningPaused <= now)
+ timeout = now;
+ else
+ timeout = ListeningPaused;
+
+ why = "resume listening";
+ }
+
/*
* Check the activity and close old clients...
*/
/*
- * End of "$Id: main.c 6689 2007-07-18 23:52:15Z mike $".
+ * End of "$Id: main.c 6914 2007-09-05 21:05:04Z mike $".
*/