From 49d8745278805ede5c41bae3c299e14ba40457bf Mon Sep 17 00:00:00 2001 From: msweet Date: Wed, 10 Sep 2008 22:30:50 +0000 Subject: [PATCH] Merge changes from CUPS 1.4svn-r7932. git-svn-id: svn+ssh://src.apple.com/svn/cups/easysw/current@957 a1ca3aef-8c08-0410-bb20-df032aa958be --- CHANGES-1.3.txt | 7 + CHANGES.txt | 12 +- Makefile | 8 + backend/Dependencies | 22 +-- backend/Makefile | 4 + config-scripts/cups-defaults.m4 | 8 + config-scripts/cups-network.m4 | 6 +- config-scripts/cups-scripting.m4 | 11 +- config.h.in | 21 +++ cups/Dependencies | 18 ++- cups/globals.h | 1 + cups/http-addr.c | 51 ++++++- cups/http-addrlist.c | 36 ++++- desktop/cups.desktop.in | 58 +++---- doc/Makefile | 2 +- doc/help/ref-cupsd-conf.html.in | 81 +++++++++- locale/translate.c | 12 +- man/Makefile | 8 +- man/{accept.man => cupsaccept.man} | 4 +- man/cupsd.conf.man.in | 20 ++- man/lpstat.man | 12 +- notifier/Dependencies | 3 + notifier/Makefile | 12 +- notifier/dbus.c | 6 +- packaging/cups.list.in | 12 +- scheduler/client.c | 10 +- scheduler/conf.c | 238 ++++++++++++++++++++++------- scheduler/conf.h | 19 ++- scheduler/cupsd.h | 2 +- scheduler/dirsvc.c | 100 +++++++----- scheduler/ipp.c | 9 +- scheduler/listen.c | 41 ++++- scheduler/log.c | 22 ++- scheduler/main.c | 35 ++++- scheduler/server.c | 7 +- scheduler/sysman.c | 33 ++-- scheduler/sysman.h | 2 +- systemv/Makefile | 13 +- systemv/accept.c | 4 +- systemv/lpstat.c | 9 +- 40 files changed, 752 insertions(+), 227 deletions(-) rename man/{accept.man => cupsaccept.man} (94%) diff --git a/CHANGES-1.3.txt b/CHANGES-1.3.txt index c03e5fba2..cb1f5832b 100644 --- a/CHANGES-1.3.txt +++ b/CHANGES-1.3.txt @@ -4,6 +4,13 @@ CHANGES-1.3.txt CHANGES IN CUPS V1.3.9 - Documentation updates (STR #2904) + - The scheduler did not send the server-started, + server-restarted, or server-stopped events (STR #2927) + - The scheduler no longer enforces configuration file + permissions on symlinked files (STR #2937) + - CUPS now reinitializes the DNS resolver on failures + (STR #2920) + - The CUPS desktop menu item was broken (STR #2924) - The PPD parser was too strict about missing keyword values in "relaxed" mode. - The PostScript filter incorrectly mirrored landscape diff --git a/CHANGES.txt b/CHANGES.txt index 789220f8f..5a8431195 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,8 +1,18 @@ -CHANGES.txt - 2008-09-03 +CHANGES.txt - 2008-09-10 ------------------------ CHANGES IN CUPS V1.4b1 + - Renamed the accept and reject commands to cupsaccept and + cupsreject; the old names are still available (STR #2936) + - The locale/translate utility needed an update to work with + Google (STR #2882) + - The lpstat command now supports a -H option to display the + default server (STR #2833) + - The scheduler now supports a FatalErrors directive to control + which errors should cause the scheduler to exit (STR #2536) + - The scheduler now uses the php-cgi program if it is available + (STR #2923) - The scheduler now supports a DefaultPaperSize directive (STR #2848) - The scheduler now passes the job-originating-host-name diff --git a/Makefile b/Makefile index 8cdcb4d28..8fe7685b9 100644 --- a/Makefile +++ b/Makefile @@ -15,6 +15,14 @@ include Makedefs + +# +# Don't run top-level build targets in parallel... +# + +.NOTPARALLEL: + + # # Directories to make... # diff --git a/backend/Dependencies b/backend/Dependencies index ecd5b130f..9051be05c 100644 --- a/backend/Dependencies +++ b/backend/Dependencies @@ -12,12 +12,12 @@ lpd.o: ../cups/backend.h ../cups/sidechannel.h ../cups/ppd-private.h lpd.o: ../cups/cups.h ../cups/ppd.h ../cups/array.h ../cups/file.h lpd.o: ../cups/language.h ../cups/debug.h ../cups/i18n.h ../cups/transcode.h lpd.o: ../cups/snmp-private.h ../cups/string.h -mdns.o: backend-private.h ../cups/backend.h ../cups/versioning.h -mdns.o: ../cups/sidechannel.h ../cups/ppd-private.h ../cups/cups.h -mdns.o: ../cups/ipp.h ../cups/http.h ../cups/ppd.h ../cups/array.h -mdns.o: ../cups/file.h ../cups/language.h ../cups/debug.h ../cups/i18n.h -mdns.o: ../cups/transcode.h ../cups/snmp-private.h ../cups/string.h -mdns.o: ../config.h ../cups/array.h +dnssd.o: backend-private.h ../cups/backend.h ../cups/versioning.h +dnssd.o: ../cups/sidechannel.h ../cups/ppd-private.h ../cups/cups.h +dnssd.o: ../cups/ipp.h ../cups/http.h ../cups/ppd.h ../cups/array.h +dnssd.o: ../cups/file.h ../cups/language.h ../cups/debug.h ../cups/i18n.h +dnssd.o: ../cups/transcode.h ../cups/snmp-private.h ../cups/string.h +dnssd.o: ../config.h ../cups/array.h pap.o: ../config.h ../cups/cups.h ../cups/ipp.h ../cups/http.h pap.o: ../cups/versioning.h ../cups/ppd.h ../cups/array.h ../cups/file.h pap.o: ../cups/language.h ../cups/backend.h ../cups/sidechannel.h @@ -68,7 +68,9 @@ testsupplies.o: ../cups/ipp.h ../cups/http.h ../cups/ppd.h ../cups/array.h testsupplies.o: ../cups/file.h ../cups/language.h ../cups/debug.h testsupplies.o: ../cups/i18n.h ../cups/transcode.h ../cups/snmp-private.h testsupplies.o: ../cups/string.h ../config.h -usb.o: ../cups/backend.h ../cups/versioning.h ../cups/cups.h ../cups/ipp.h -usb.o: ../cups/http.h ../cups/ppd.h ../cups/array.h ../cups/file.h -usb.o: ../cups/language.h ../cups/string.h ../config.h ../cups/i18n.h -usb.o: ../cups/transcode.h +usb.o: backend-private.h ../cups/backend.h ../cups/versioning.h +usb.o: ../cups/sidechannel.h ../cups/ppd-private.h ../cups/cups.h +usb.o: ../cups/ipp.h ../cups/http.h ../cups/ppd.h ../cups/array.h +usb.o: ../cups/file.h ../cups/language.h ../cups/debug.h ../cups/i18n.h +usb.o: ../cups/transcode.h ../cups/snmp-private.h ../cups/string.h +usb.o: ../config.h diff --git a/backend/Makefile b/backend/Makefile index 79868f83b..11ebdbd48 100644 --- a/backend/Makefile +++ b/backend/Makefile @@ -91,6 +91,10 @@ install-exec: done $(RM) $(SERVERBIN)/backend/http $(LN) ipp $(SERVERBIN)/backend/http + if test "x$(DNSSD_BACKEND)" != x; then \ + $(RM) $(SERVERBIN)/backend/mdns; \ + $(LN) $(DNSSD_BACKEND) $(SERVERBIN)/backend/mdns; \ + fi if test "x$(SYMROOT)" != "x"; then \ $(INSTALL_DIR) $(SYMROOT); \ for file in $(TARGETS); do \ diff --git a/config-scripts/cups-defaults.m4 b/config-scripts/cups-defaults.m4 index bdc22ebb0..b3ce77047 100644 --- a/config-scripts/cups-defaults.m4 +++ b/config-scripts/cups-defaults.m4 @@ -39,6 +39,14 @@ AC_ARG_WITH(log_file_perm, [ --with-log-file-perm set default LogFilePerm va AC_SUBST(CUPS_LOG_FILE_PERM) AC_DEFINE_UNQUOTED(CUPS_DEFAULT_LOG_FILE_PERM, 0$CUPS_LOG_FILE_PERM) +dnl Default FatalErrors +AC_ARG_WITH(fatal_errors, [ --with-fatal-errors set default FatalErrors value, default=config], + CUPS_FATAL_ERRORS="$withval", + CUPS_FATAL_ERRORS="config") +AC_SUBST(CUPS_FATAL_ERRORS) +AC_DEFINE_UNQUOTED(CUPS_DEFAULT_FATAL_ERRORS, "$CUPS_FATAL_ERRORS") + + dnl Default LogLevel AC_ARG_WITH(log_level, [ --with-log-level set default LogLevel value, default=warn], CUPS_LOG_LEVEL="$withval", diff --git a/config-scripts/cups-network.m4 b/config-scripts/cups-network.m4 index f36318575..9a88aa8f0 100644 --- a/config-scripts/cups-network.m4 +++ b/config-scripts/cups-network.m4 @@ -3,7 +3,7 @@ dnl "$Id: cups-network.m4 7127 2007-12-17 18:05:32Z mike $" dnl dnl Networking stuff for the Common UNIX Printing System (CUPS). dnl -dnl Copyright 2007 by Apple Inc. +dnl Copyright 2007-2008 by Apple Inc. dnl Copyright 1997-2005 by Easy Software Products, all rights reserved. dnl dnl These coded instructions, statements, and computer programs are the @@ -13,11 +13,15 @@ dnl which should have been included with this file. If this file is dnl file is missing or damaged, see the license at "http://www.cups.org/". dnl +AC_CHECK_HEADER(resolv.h,AC_DEFINE(HAVE_RESOLV_H)) AC_SEARCH_LIBS(socket, socket) AC_SEARCH_LIBS(gethostbyaddr, nsl) AC_SEARCH_LIBS(getifaddrs, nsl, AC_DEFINE(HAVE_GETIFADDRS)) AC_SEARCH_LIBS(hstrerror, nsl socket resolv, AC_DEFINE(HAVE_HSTRERROR)) AC_SEARCH_LIBS(rresvport_af, nsl, AC_DEFINE(HAVE_RRESVPORT_AF)) +AC_SEARCH_LIBS(__res_init, resolv bind, AC_DEFINE(HAVE_RES_INIT), + AC_SEARCH_LIBS(res_9_init, resolv bind, AC_DEFINE(HAVE_RES_INIT), + AC_SEARCH_LIBS(res_init, resolv bind, AC_DEFINE(HAVE_RES_INIT)))) # Tru64 5.1b leaks file descriptors with these functions; disable until # we can come up with a test for this... diff --git a/config-scripts/cups-scripting.m4 b/config-scripts/cups-scripting.m4 index 71a6707e9..f514221e2 100644 --- a/config-scripts/cups-scripting.m4 +++ b/config-scripts/cups-scripting.m4 @@ -3,7 +3,7 @@ dnl "$Id: cups-scripting.m4 6649 2007-07-11 21:46:42Z mike $" dnl dnl Scripting configuration stuff for the Common UNIX Printing System (CUPS). dnl -dnl Copyright 2007 by Apple Inc. +dnl Copyright 2007-2008 by Apple Inc. dnl Copyright 1997-2006 by Easy Software Products, all rights reserved. dnl dnl These coded instructions, statements, and computer programs are the @@ -51,8 +51,13 @@ AC_ARG_WITH(php, [ --with-php set PHP interpreter for web interfac CUPS_PHP="") if test "x$CUPS_PHP" = x; then - AC_PATH_PROG(PHP,php) - CUPS_PHP="$PHP" + AC_PATH_PROG(PHPCGI,php-cgi) + if test "x$PHPCGI" = x; then + AC_PATH_PROG(PHP,php) + CUPS_PHP="$PHP" + else + CUPS_PHP="$PHPCGI" + fi fi AC_DEFINE_UNQUOTED(CUPS_PHP, "$CUPS_PHP") diff --git a/config.h.in b/config.h.in index 39a8d63f3..5199ee4f3 100644 --- a/config.h.in +++ b/config.h.in @@ -50,6 +50,13 @@ #define CUPS_DEFAULT_ACCESS_LOG_LEVEL "actions" +/* + * Default fatal error settings... + */ + +#define CUPS_DEFAULT_FATAL_ERRORS "config" + + /* * Default browsing settings... */ @@ -393,6 +400,20 @@ #undef HAVE_HSTRERROR +/* + * Do we have res_init()? + */ + +#undef HAVE_RES_INIT + + +/* + * Do we have + */ + +#undef HAVE_RESOLV_H + + /* * Do we have the header file? */ diff --git a/cups/Dependencies b/cups/Dependencies index 7a32226fb..b1336d501 100644 --- a/cups/Dependencies +++ b/cups/Dependencies @@ -46,8 +46,8 @@ globals.o: i18n.h transcode.h http.o: http-private.h ../config.h http.h versioning.h md5.h ipp-private.h http.o: ipp.h globals.h string.h cups.h ppd.h array.h file.h language.h http.o: i18n.h transcode.h debug.h -http-addr.o: globals.h string.h ../config.h http-private.h http.h -http-addr.o: versioning.h md5.h ipp-private.h ipp.h cups.h ppd.h array.h +http-addr.o: http-private.h ../config.h http.h versioning.h md5.h +http-addr.o: ipp-private.h ipp.h globals.h string.h cups.h ppd.h array.h http-addr.o: file.h language.h i18n.h transcode.h debug.h http-addrlist.o: http-private.h ../config.h http.h versioning.h md5.h http-addrlist.o: ipp-private.h ipp.h globals.h string.h cups.h ppd.h array.h @@ -109,6 +109,8 @@ testadmin.o: adminutil.h cups.h ipp.h http.h versioning.h ppd.h array.h testadmin.o: file.h language.h string.h ../config.h testarray.o: ../cups/string.h ../config.h string.h array.h versioning.h dir.h testarray.o: debug.h +testconflicts.o: cups.h ipp.h http.h versioning.h ppd.h array.h file.h +testconflicts.o: language.h string.h ../config.h testcups.o: cups.h ipp.h http.h versioning.h ppd.h array.h file.h language.h testfile.o: string.h ../config.h file.h versioning.h debug.h testhttp.o: http-private.h ../config.h http.h versioning.h md5.h @@ -172,8 +174,8 @@ globals.32.o: globals.c i18n.h transcode.h http.32.o: http.c http-private.h ../config.h http.h versioning.h md5.h ipp-private.h http.32.o: http.c ipp.h globals.h string.h cups.h ppd.h array.h file.h language.h http.32.o: http.c i18n.h transcode.h debug.h -http-addr.32.o: http-addr.c globals.h string.h ../config.h http-private.h http.h -http-addr.32.o: http-addr.c versioning.h md5.h ipp-private.h ipp.h cups.h ppd.h array.h +http-addr.32.o: http-addr.c http-private.h ../config.h http.h versioning.h md5.h +http-addr.32.o: http-addr.c ipp-private.h ipp.h globals.h string.h cups.h ppd.h array.h http-addr.32.o: http-addr.c file.h language.h i18n.h transcode.h debug.h http-addrlist.32.o: http-addrlist.c http-private.h ../config.h http.h versioning.h md5.h http-addrlist.32.o: http-addrlist.c ipp-private.h ipp.h globals.h string.h cups.h ppd.h array.h @@ -235,6 +237,8 @@ testadmin.32.o: testadmin.c adminutil.h cups.h ipp.h http.h versioning.h ppd.h testadmin.32.o: testadmin.c file.h language.h string.h ../config.h testarray.32.o: testarray.c ../cups/string.h ../config.h string.h array.h versioning.h dir.h testarray.32.o: testarray.c debug.h +testconflicts.32.o: testconflicts.c cups.h ipp.h http.h versioning.h ppd.h array.h file.h +testconflicts.32.o: testconflicts.c language.h string.h ../config.h testcups.32.o: testcups.c cups.h ipp.h http.h versioning.h ppd.h array.h file.h language.h testfile.32.o: testfile.c string.h ../config.h file.h versioning.h debug.h testhttp.32.o: testhttp.c http-private.h ../config.h http.h versioning.h md5.h @@ -298,8 +302,8 @@ globals.64.o: globals.c i18n.h transcode.h http.64.o: http.c http-private.h ../config.h http.h versioning.h md5.h ipp-private.h http.64.o: http.c ipp.h globals.h string.h cups.h ppd.h array.h file.h language.h http.64.o: http.c i18n.h transcode.h debug.h -http-addr.64.o: http-addr.c globals.h string.h ../config.h http-private.h http.h -http-addr.64.o: http-addr.c versioning.h md5.h ipp-private.h ipp.h cups.h ppd.h array.h +http-addr.64.o: http-addr.c http-private.h ../config.h http.h versioning.h md5.h +http-addr.64.o: http-addr.c ipp-private.h ipp.h globals.h string.h cups.h ppd.h array.h http-addr.64.o: http-addr.c file.h language.h i18n.h transcode.h debug.h http-addrlist.64.o: http-addrlist.c http-private.h ../config.h http.h versioning.h md5.h http-addrlist.64.o: http-addrlist.c ipp-private.h ipp.h globals.h string.h cups.h ppd.h array.h @@ -361,6 +365,8 @@ testadmin.64.o: testadmin.c adminutil.h cups.h ipp.h http.h versioning.h ppd.h testadmin.64.o: testadmin.c file.h language.h string.h ../config.h testarray.64.o: testarray.c ../cups/string.h ../config.h string.h array.h versioning.h dir.h testarray.64.o: testarray.c debug.h +testconflicts.64.o: testconflicts.c cups.h ipp.h http.h versioning.h ppd.h array.h file.h +testconflicts.64.o: testconflicts.c language.h string.h ../config.h testcups.64.o: testcups.c cups.h ipp.h http.h versioning.h ppd.h array.h file.h language.h testfile.64.o: testfile.c string.h ../config.h file.h versioning.h debug.h testhttp.64.o: testhttp.c http-private.h ../config.h http.h versioning.h md5.h diff --git a/cups/globals.h b/cups/globals.h index f2ae63b97..d58099548 100644 --- a/cups/globals.h +++ b/cups/globals.h @@ -81,6 +81,7 @@ typedef struct _cups_globals_s /**** CUPS global state data ****/ # ifdef HAVE_GETADDRINFO char hostname[1024]; /* Hostname */ # endif /* HAVE_GETADDRINFO */ + int need_res_init; /* Need to reinitialize resolver? */ /* ipp.c */ ipp_uchar_t ipp_date[11]; /* RFC-1903 date/time data */ diff --git a/cups/http-addr.c b/cups/http-addr.c index 0bc71f6fa..55d701d64 100644 --- a/cups/http-addr.c +++ b/cups/http-addr.c @@ -29,10 +29,14 @@ * Include necessary headers... */ +#include "http-private.h" #include "globals.h" #include "debug.h" #include #include +#ifdef HAVE_RESOLV_H +# include +#endif /* HAVE_RESOLV_H */ /* @@ -176,6 +180,10 @@ httpAddrLookup( char *name, /* I - Host name buffer */ int namelen) /* I - Size of name buffer */ { + _cups_globals_t *cg = _cupsGlobals(); + /* Global data */ + + DEBUG_printf(("httpAddrLookup(addr=%p, name=%p, namelen=%d)\n", addr, name, namelen)); @@ -193,9 +201,33 @@ httpAddrLookup( #ifdef AF_LOCAL if (addr->addr.sa_family == AF_LOCAL) + { strlcpy(name, addr->un.sun_path, namelen); - else + return (name); + } #endif /* AF_LOCAL */ + +#ifdef HAVE_RES_INIT + /* + * STR #2920: Initialize resolver after failure in cups-polld + * + * If the previous lookup failed, re-initialize the resolver to prevent + * temporary network errors from persisting. This *should* be handled by + * the resolver libraries, but apparently the glibc folks do not agree. + * + * We set a flag at the end of this function if we encounter an error that + * requires reinitialization of the resolver functions. We then call + * res_init() if the flag is set on the next call here or in httpAddrLookup(). + */ + + if (cg->need_res_init) + { + res_init(); + + cg->need_res_init = 0; + } +#endif /* HAVE_RES_INIT */ + #ifdef HAVE_GETNAMEINFO { /* @@ -206,9 +238,16 @@ httpAddrLookup( * do... */ - if (getnameinfo(&addr->addr, httpAddrLength(addr), name, namelen, - NULL, 0, 0)) + int error = getnameinfo(&addr->addr, httpAddrLength(addr), name, namelen, + NULL, 0, 0); + + if (error) + { + if (error == EAI_FAIL) + cg->need_res_init = 1; + return (httpAddrString(addr, name, namelen)); + } } #else { @@ -230,8 +269,10 @@ httpAddrLookup( * No hostname, so return the raw address... */ - httpAddrString(addr, name, namelen); - return (NULL); + if (h_errno == NO_RECOVERY) + cg->need_res_init = 1; + + return (httpAddrString(addr, name, namelen)); } strlcpy(name, host->h_name, namelen); diff --git a/cups/http-addrlist.c b/cups/http-addrlist.c index d5685312e..52b5aeca9 100644 --- a/cups/http-addrlist.c +++ b/cups/http-addrlist.c @@ -28,6 +28,9 @@ #include "debug.h" #include #include +#ifdef HAVE_RESOLV_H +# include +#endif /* HAVE_RESOLV_H */ /* @@ -201,6 +204,8 @@ httpAddrGetList(const char *hostname, /* I - Hostname, IP address, or NULL for p http_addrlist_t *first, /* First address in list */ *addr, /* Current address in list */ *temp; /* New address */ + _cups_globals_t *cg = _cupsGlobals(); + /* Global data */ #ifdef DEBUG @@ -217,6 +222,28 @@ httpAddrGetList(const char *hostname, /* I - Hostname, IP address, or NULL for p family == AF_INET ? "INET" : "???", service); #endif /* DEBUG */ +#ifdef HAVE_RES_INIT + /* + * STR #2920: Initialize resolver after failure in cups-polld + * + * If the previous lookup failed, re-initialize the resolver to prevent + * temporary network errors from persisting. This *should* be handled by + * the resolver libraries, but apparently the glibc folks do not agree. + * + * We set a flag at the end of this function if we encounter an error that + * requires reinitialization of the resolver functions. We then call + * res_init() if the flag is set on the next call here or in httpAddrLookup(). + */ + + if (cg->need_res_init) + { + res_init(); + + cg->need_res_init = 0; + } +#endif /* HAVE_RES_INIT */ + + /* * Lookup the address the best way we can... */ @@ -246,6 +273,8 @@ httpAddrGetList(const char *hostname, /* I - Hostname, IP address, or NULL for p char ipv6[1024], /* IPv6 address */ *ipv6zone; /* Pointer to zone separator */ int ipv6len; /* Length of IPv6 address */ + int error; /* getaddrinfo() error */ + /* * Lookup the address as needed... @@ -297,7 +326,7 @@ httpAddrGetList(const char *hostname, /* I - Hostname, IP address, or NULL for p } } - if (!getaddrinfo(hostname, service, &hints, &results)) + if ((error = getaddrinfo(hostname, service, &hints, &results)) == 0) { /* * Copy the results to our own address list structure... @@ -343,6 +372,9 @@ httpAddrGetList(const char *hostname, /* I - Hostname, IP address, or NULL for p freeaddrinfo(results); } + else if (error == EAI_FAIL) + cg->need_res_init = 1; + #else if (hostname) { @@ -459,6 +491,8 @@ httpAddrGetList(const char *hostname, /* I - Hostname, IP address, or NULL for p addr = temp; } } + else if (h_errno == NO_RECOVERY) + cg->need_res_init = 1; } #endif /* HAVE_GETADDRINFO */ } diff --git a/desktop/cups.desktop.in b/desktop/cups.desktop.in index d5e2612f7..c92a8a0af 100644 --- a/desktop/cups.desktop.in +++ b/desktop/cups.desktop.in @@ -1,41 +1,33 @@ [Desktop Entry] -Categories=Application;System;X-Red-Hat-Base; -Encoding=UTF-8 +Categories=System;Printing;HardwareSettings;X-Red-Hat-Base; Exec=@CUPS_HTMLVIEW@ http://localhost:631/ -GenericName= Icon=cups -MimeType= -Path= StartupNotify=false Terminal=false -TerminalOptions= Type=Application -X-DCOP-ServiceType= -X-KDE-SubstituteUID=false -X-KDE-Username= Name=Manage Printing Comment=CUPS Web Interface -Name[de]=Druckerverwaltung -Comment[de]=CUPS Webinterface -Name[en_US]=Manage Printing -Comment[en_US]=CUPS Web Interface -Name[es]=Administrar impresión -Comment[es]=Interfaz Web de CUPS -Name[et]=Trükkimise haldur -Comment[et]=CUPS-i veebiliides -Name[fr]=Gestionnaire d'impression -Comment[fr]=Interface Web de CUPS -Name[he]=נהל הדפסות -Comment[he]=ממשק דפדפן של CUPS -Name[id]=Manajemen Pencetakan -Comment[id]=Antarmuka Web CUPS -Name[it]=Gestione stampa -Comment[it]=Interfaccia web di CUPS -Name[ja]=印刷の管理 -Comment[ja]=CUPS Web インタフェース -Name[pl]=Zarządzanie drukowaniem -Comment[pl]=Interfejs WWW CUPS -Name[zh]=打印机管理 -Comment[zh]=CUPS网页界面 -Name[zh_TW]=印表管理 -Comment[zh_TW]=CUPS 網頁介面 +Name[de.UTF-8]=Druckerverwaltung +Comment[de.UTF-8]=CUPS Webinterface +Name[en_US.UTF-8]=Manage Printing +Comment[en_US.UTF-8]=CUPS Web Interface +Name[es.UTF-8]=Administrar impresión +Comment[es.UTF-8]=Interfaz Web de CUPS +Name[et.UTF-8]=Trükkimise haldur +Comment[et.UTF-8]=CUPS-i veebiliides +Name[fr.UTF-8]=Gestionnaire d'impression +Comment[fr.UTF-8]=Interface Web de CUPS +Name[he.UTF-8]=נהל הדפסות +Comment[he.UTF-8]=ממשק דפדפן של CUPS +Name[id.UTF-8]=Manajemen Pencetakan +Comment[id.UTF-8]=Antarmuka Web CUPS +Name[it.UTF-8]=Gestione stampa +Comment[it.UTF-8]=Interfaccia web di CUPS +Name[ja.UTF-8]=印刷の管理 +Comment[ja.UTF-8]=CUPS Web インタフェース +Name[pl.UTF-8]=Zarządzanie drukowaniem +Comment[pl.UTF-8]=Interfejs WWW CUPS +Name[zh.UTF-8]=打印机管理 +Comment[zh.UTF-8]=CUPS网页界面 +Name[zh_TW.UTF-8]=印表管理 +Comment[zh_TW.UTF-8]=CUPS 網頁介面 diff --git a/doc/Makefile b/doc/Makefile index 4c461f75f..25b10104f 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -59,7 +59,7 @@ HELPFILES = \ help/glossary.html \ help/kerberos.html \ help/license.html \ - help/man-accept.html \ + help/man-cupsaccept.html \ help/man-backend.html \ help/man-cancel.html \ help/man-classes.conf.html \ diff --git a/doc/help/ref-cupsd-conf.html.in b/doc/help/ref-cupsd-conf.html.in index 9d5ca0e5b..1020744a7 100644 --- a/doc/help/ref-cupsd-conf.html.in +++ b/doc/help/ref-cupsd-conf.html.in @@ -975,6 +975,26 @@ language localization file exists for it. The default language is "en" for English.

+

CUPS 1.4DefaultPaperSize

+ +

Examples

+ +
+DefaultPaperSize Letter
+DefaultPaperSize A4
+DefaultPaperSize Auto
+DefaultPaperSize None
+
+ +

Description

+ +

The DefaultPaperSize directive specifies the default paper +size to use when creating new printers. The default is Auto +which uses a paper size appropriate for the system default locale. A value +of None tells the scheduler to not set the default paper +size.

+ +

CUPS 1.2DefaultPolicy

Examples

@@ -1058,7 +1078,7 @@ HREF="#Limit">Limit section.

Examples

-DirtyCleanInterval 60
+DirtyCleanInterval 30
 DirtyCleanInterval 0
 
@@ -1066,7 +1086,7 @@ DirtyCleanInterval 0

The DirtyCleanInterval directive specifies the number of seconds to wait before updating configuration and state files for printers, -classes, subscriptions, and jobs. The default is 60 seconds.

+classes, subscriptions, and jobs. The default is 30 seconds.

DocumentRoot

@@ -1177,6 +1197,57 @@ printer.

+ +

CUPS 1.4FatalErrors

+ +

Examples

+ +
+FatalErrors none
+FatalErrors all
+FatalErrors browse
+FatalErrors config
+FatalErrors listen
+FatalErrors log
+FatalErrors permissions
+FatalErrors all -permissions
+FatalErrors config permissions log
+
+ +

Description

+ +

The FatalErrors directive determines whether certain kinds of +errors are fatal. The following kinds of errors are currently recognized:

+ +
    + +
  • none - No errors are fatal
  • + +
  • all - All of the errors below are fatal
  • + +
  • browse - Browsing initialization errors are fatal, + for example failed binding to the CUPS browse port or failed connections + to LDAP servers
  • + +
  • config - Configuration file syntax errors are + fatal
  • + +
  • listen - Listen or Port errors are fatal, except for + IPv6 failures on the loopback or "any" addresses
  • + +
  • log - Log file creation or write errors are fatal
  • + +
  • permissions - Bad startup file permissions are + fatal, for example shared SSL certificate and key files with world- + read permissions
  • + +
+ +

Multiple errors can be listed, and the form "-kind" can be used with +all to remove specific kinds of errors. The default setting is +@CUPS_FATAL_ERRORS@.

+ +

CUPS 1.1.18FileDevice

Examples

@@ -1473,7 +1544,7 @@ KeepAliveTimeout 30

The KeepAliveTimeout directive controls how long a persistent HTTP connection will remain open after the last -request. The default is 60 seconds.

+request. The default is 30 seconds.

CUPS 1.1.7Limit (Location)

@@ -2414,14 +2485,14 @@ There is no default program.

 ReloadTimeout 0
-ReloadTimeout 60
+ReloadTimeout 30
 

Description

The ReloadTimeout directive specifies the number of seconds the scheduler will wait for active jobs to complete -before doing a restart. The default is 60 seconds.

+before doing a restart. The default is 30 seconds.

CUPS 1.1.3RemoteRoot

diff --git a/locale/translate.c b/locale/translate.c index 6cd767e01..74a5153dc 100644 --- a/locale/translate.c +++ b/locale/translate.c @@ -293,16 +293,16 @@ translate_messages(cups_array_t *cat, /* I - Message catalog */ *bufptr = '\0'; /* - * Find the first textarea element - that will have the translation data... + * Find the div containing translation */ - if ((bufptr = strstr(buffer, "")) == NULL) + if ((bufend = strstr(bufptr, "")) == NULL) { /* * textarea doesn't close, abort! */ - puts("/TEXTAREA SHORT DATA!"); + puts("/DIV SHORT DATA!"); ret = 0; break; } diff --git a/man/Makefile b/man/Makefile index 1e2bb0100..0f686af4f 100644 --- a/man/Makefile +++ b/man/Makefile @@ -53,7 +53,7 @@ MAN7 = backend.$(MAN7EXT) \ filter.$(MAN7EXT) \ rastertoescpx.$(MAN7EXT) \ rastertopclx.$(MAN7EXT) -MAN8 = accept.$(MAN8EXT) \ +MAN8 = cupsaccept.$(MAN8EXT) \ cupsaddsmb.$(MAN8EXT) \ cupsctl.$(MAN8EXT) \ cupsfilter.$(MAN8EXT) \ @@ -129,7 +129,7 @@ install: all install-data install-headers install-libs install-exec # Install data files... # -install-data: +install-data: all $(INSTALL_DIR) -m 755 $(MANDIR)/man1 for file in $(MAN1); do \ echo Installing $$file in $(MANDIR)/man1...; \ @@ -150,8 +150,8 @@ install-data: echo Installing $$file in $(AMANDIR)/man$(MAN8DIR)...; \ $(INSTALL_MAN) $$file $(AMANDIR)/man$(MAN8DIR); \ done - $(RM) $(AMANDIR)/man$(MAN8DIR)/reject.$(MAN8EXT) - $(LN) accept.$(MAN8EXT) $(AMANDIR)/man$(MAN8DIR)/reject.$(MAN8EXT) + $(RM) $(AMANDIR)/man$(MAN8DIR)/cupsreject.$(MAN8EXT) + $(LN) cupsaccept.$(MAN8EXT) $(AMANDIR)/man$(MAN8DIR)/cupsreject.$(MAN8EXT) $(RM) $(AMANDIR)/man$(MAN8DIR)/cupsdisable.$(MAN8EXT) $(LN) cupsenable.$(MAN8EXT) $(AMANDIR)/man$(MAN8DIR)/cupsdisable.$(MAN8EXT) diff --git a/man/accept.man b/man/cupsaccept.man similarity index 94% rename from man/accept.man rename to man/cupsaccept.man index 477d125e9..36457e351 100644 --- a/man/accept.man +++ b/man/cupsaccept.man @@ -1,5 +1,5 @@ .\" -.\" "$Id: accept.man 7600 2008-05-20 21:06:23Z mike $" +.\" "$Id$" .\" .\" accept/reject man page for the Common UNIX Printing System (CUPS). .\" @@ -75,5 +75,5 @@ http://localhost:631/help .SH COPYRIGHT Copyright 2007 by Apple Inc. .\" -.\" End of "$Id: accept.man 7600 2008-05-20 21:06:23Z mike $". +.\" End of "$Id$". .\" diff --git a/man/cupsd.conf.man.in b/man/cupsd.conf.man.in index 4421c1df4..b3137f74f 100644 --- a/man/cupsd.conf.man.in +++ b/man/cupsd.conf.man.in @@ -12,7 +12,7 @@ .\" which should have been included with this file. If this file is .\" file is missing or damaged, see the license at "http://www.cups.org/". .\" -.TH cupsd.conf 5 "Common UNIX Printing System" "16 June 2008" "Apple Inc." +.TH cupsd.conf 5 "Common UNIX Printing System" "8 September 2008" "Apple Inc." .SH NAME cupsd.conf \- server configuration file for cups .SH DESCRIPTION @@ -254,6 +254,15 @@ DefaultLanguage locale .br Specifies the default language to use for text and web content. .TP 5 +DefaultPaperSize Auto +.TP 5 +DefaultPaperSize None +.TP 5 +DefaultPaperSize sizename +.br +Specifies the default paper size for new print queues. "Auto" uses a locale- +specific default, while "None" specifies there is no default paper size. +.TP 5 DefaultPolicy policy-name .br Specifies the default access policy to use. @@ -303,6 +312,15 @@ ErrorLog syslog .br Specifies the error log filename. .TP 5 +FatalErrors none +.TP 5 +FatalErrors all -kind [... -kind] +.TP 5 +FatalErrors kind [... kind] +.br +Specifies which errors are fatal, causing the scheduler to exit. "Kind" is +"browse", "config", "listen", "log", or "permissions". +.TP 5 FileDevice Yes .TP 5 FileDevice No diff --git a/man/lpstat.man b/man/lpstat.man index 47294c5a5..e0bb5935d 100644 --- a/man/lpstat.man +++ b/man/lpstat.man @@ -3,7 +3,7 @@ .\" .\" lpstat man page for the Common UNIX Printing System (CUPS). .\" -.\" Copyright 2007 by Apple Inc. +.\" Copyright 2007-2008 by Apple Inc. .\" Copyright 1997-2006 by Easy Software Products. .\" .\" These coded instructions, statements, and computer programs are the @@ -12,12 +12,12 @@ .\" which should have been included with this file. If this file is .\" file is missing or damaged, see the license at "http://www.cups.org/". .\" -.TH lpstat 1 "Common UNIX Printing System" "23 March 2006" "Apple Inc." +.TH lpstat 1 "Common UNIX Printing System" "10 September 2008" "Apple Inc." .SH NAME lpstat \- print cups status information .SH SYNOPSIS .B lpstat -[ -E ] [ -U +[ -E ] [ -H ] [ -U .I username ] [ -h .I hostname[:port] @@ -47,6 +47,10 @@ The \fIlpstat\fR command supports the following options: .br Forces encryption when connecting to the server. .TP 5 +-H +.br +Shows the server hostname and port. +.TP 5 -R .br Shows the ranking of print jobs. @@ -133,7 +137,7 @@ The Solaris "-f", "-P", and "-S" options are silently ignored. .br http://localhost:631/help .SH COPYRIGHT -Copyright 2007 by Apple Inc. +Copyright 2007-2008 by Apple Inc. .\" .\" End of "$Id: lpstat.man 7600 2008-05-20 21:06:23Z mike $". .\" diff --git a/notifier/Dependencies b/notifier/Dependencies index a27cdfea4..8f5cfed1d 100644 --- a/notifier/Dependencies +++ b/notifier/Dependencies @@ -1,5 +1,8 @@ # DO NOT DELETE THIS LINE -- make depend depends on it. +dbus.o: ../cups/cups.h ../cups/ipp.h ../cups/http.h ../cups/versioning.h +dbus.o: ../cups/ppd.h ../cups/array.h ../cups/file.h ../cups/language.h +dbus.o: ../cups/string.h ../config.h mailto.o: ../cups/cups.h ../cups/ipp.h ../cups/http.h ../cups/versioning.h mailto.o: ../cups/ppd.h ../cups/array.h ../cups/file.h ../cups/language.h mailto.o: ../cups/i18n.h ../cups/transcode.h ../cups/string.h ../config.h diff --git a/notifier/Makefile b/notifier/Makefile index 2c80380a6..1f63c8497 100644 --- a/notifier/Makefile +++ b/notifier/Makefile @@ -64,10 +64,6 @@ install: all install-data install-headers install-libs install-exec install-data: $(INSTALL_DIR) -m 775 $(CACHEDIR)/rss -chgrp $(CUPS_GROUP) $(CACHEDIR)/rss - if test "x$(SYMROOT)" != "x"; then \ - $(INSTALL_DIR) $(SYMROOT); \ - cp $(NOTIFIERS) $(SYMROOT); \ - fi # @@ -80,6 +76,10 @@ install-exec: for file in $(NOTIFIERS); do \ $(INSTALL_BIN) $$file $(SERVERBIN)/notifier; \ done + if test "x$(SYMROOT)" != "x"; then \ + $(INSTALL_DIR) $(SYMROOT); \ + cp $(NOTIFIERS) $(SYMROOT); \ + fi # @@ -125,10 +125,6 @@ dbus: dbus.o ../cups/$(LIBCUPS) echo Linking $@... $(CC) $(LDFLAGS) -o dbus dbus.o $(DBUS_NOTIFIERLIBS) $(LIBS) -dbus.o: dbus.h -dbus.h: dbus-notifier.xml - dbus-binding-tool --mode=glib-server $< >$@ - # # mailto diff --git a/notifier/dbus.c b/notifier/dbus.c index 1f1c43a21..4b51b6258 100644 --- a/notifier/dbus.c +++ b/notifier/dbus.c @@ -16,6 +16,8 @@ * * Contents: * + * main() - Read events and send DBUS notifications. + * acquire_lock() - Acquire a lock so we only have a single notifier running. */ /* @@ -154,7 +156,7 @@ enum * Local functions... */ -static int acquire_lock(int *fd); +static int acquire_lock(int *fd, char *lockfile, size_t locksize); /* @@ -201,7 +203,7 @@ main(int argc, /* I - Number of command-line args */ return (1); } - if (strcmp(argv[1], "dbus:")) + if (strncmp(argv[1], "dbus:", 5)) { fprintf(stderr, "ERROR: Bad URI \"%s\"!\n", argv[1]); return (1); diff --git a/packaging/cups.list.in b/packaging/cups.list.in index da364d11d..d90871539 100644 --- a/packaging/cups.list.in +++ b/packaging/cups.list.in @@ -327,16 +327,18 @@ f 0755 root sys $SERVERBIN/daemon/cups-lpd scheduler/cups-lpd d 0755 root sys $BINDIR - l 0755 root sys $BINDIR/enable $SBINDIR/accept l 0755 root sys $LIBDIR/accept $SBINDIR/accept -d 0755 root sys $SBINDIR - -l 0755 root sys $SBINDIR/cupsdisable accept -l 0755 root sys $SBINDIR/cupsenable accept l 0755 root sys $BINDIR/disable $SBINDIR/accept d 0755 root sys $LIBDIR - l 0755 root sys $LIBDIR/lpadmin $SBINDIR/lpadmin l 0755 root sys $LIBDIR/reject accept +d 0755 root sys $SBINDIR - f 0755 root sys $SBINDIR/accept systemv/accept +l 0755 root sys $SBINDIR/cupsaccept accept f 0755 root sys $SBINDIR/cupsaddsmb systemv/cupsaddsmb f 0755 root sys $SBINDIR/cupsctl systemv/cupsctl +l 0755 root sys $SBINDIR/cupsdisable accept +l 0755 root sys $SBINDIR/cupsenable accept +l 0755 root sys $SBINDIR/cupsreject accept f 0755 root sys $SBINDIR/lpadmin systemv/lpadmin f 0755 root sys $SBINDIR/lpc berkeley/lpc f 0755 root sys $SBINDIR/lpinfo systemv/lpinfo @@ -732,8 +734,8 @@ f 0644 root sys $MANDIR/man7/filter.$MAN7EXT man/filter.$MAN7EXT f 0644 root sys $MANDIR/man7/rastertoescpx.$MAN7EXT man/rastertoescpx.$MAN7EXT f 0644 root sys $MANDIR/man7/rastertopclx.$MAN7EXT man/rastertopclx.$MAN7EXT -f 0644 root sys $AMANDIR/man$MAN8DIR/accept.$MAN8EXT man/accept.$MAN8EXT -l 0644 root sys $AMANDIR/man$MAN8DIR/reject.$MAN8EXT accept.$MAN8EXT +f 0644 root sys $AMANDIR/man$MAN8DIR/cupsaccept.$MAN8EXT man/cupsaccept.$MAN8EXT +l 0644 root sys $AMANDIR/man$MAN8DIR/cupsreject.$MAN8EXT cupsaccept.$MAN8EXT f 0644 root sys $AMANDIR/man$MAN8DIR/cupsaddsmb.$MAN8EXT man/cupsaddsmb.$MAN8EXT f 0644 root sys $AMANDIR/man$MAN8DIR/cupsctl.$MAN8EXT man/cupsctl.$MAN8EXT f 0644 root sys $AMANDIR/man$MAN8DIR/cupsfilter.$MAN8EXT man/cupsfilter.$MAN8EXT diff --git a/scheduler/client.c b/scheduler/client.c index a4e249790..3e3845e05 100644 --- a/scheduler/client.c +++ b/scheduler/client.c @@ -524,7 +524,8 @@ cupsdCloseAllClients(void) for (con = (cupsd_client_t *)cupsArrayFirst(Clients); con; con = (cupsd_client_t *)cupsArrayNext(Clients)) - cupsdCloseClient(con); + if (cupsdCloseClient(con)) + cupsdCloseClient(con); } @@ -1034,8 +1035,11 @@ cupsdReadClient(cupsd_client_t *con) /* I - Client to read from */ con->http.status = HTTP_OK; - cupsArrayAdd(ActiveClients, con); - cupsdSetBusyState(); + if (!cupsArrayFind(ActiveClients, con)) + { + cupsArrayAdd(ActiveClients, con); + cupsdSetBusyState(); + } case HTTP_OPTIONS : case HTTP_DELETE : diff --git a/scheduler/conf.c b/scheduler/conf.c index 51eecb22b..1269555a7 100644 --- a/scheduler/conf.c +++ b/scheduler/conf.c @@ -21,6 +21,7 @@ * get_addr_and_mask() - Get an IP address and netmask. * parse_aaa() - Parse authentication, authorization, and * access control lines. + * parse_fatal_errors() - Parse FatalErrors values in a string. * parse_groups() - Parse system group names in a string. * parse_protocols() - Parse browse protocols in a string. * read_configuration() - Read a configuration file. @@ -199,6 +200,7 @@ static int get_addr_and_mask(const char *value, unsigned *ip, unsigned *mask); static int parse_aaa(cupsd_location_t *loc, char *line, char *value, int linenum); +static int parse_fatal_errors(const char *s); static int parse_groups(const char *s); static int parse_protocols(const char *s); static int read_configuration(cups_file_t *fp); @@ -223,6 +225,7 @@ cupsdCheckPermissions( int dir_created = 0; /* Did we create a directory? */ char pathname[1024]; /* File name with prefix */ struct stat fileinfo; /* Stat buffer */ + int is_symlink; /* Is "filename" a symlink? */ /* @@ -239,7 +242,7 @@ cupsdCheckPermissions( * See if we can stat the file/directory... */ - if (stat(filename, &fileinfo)) + if (lstat(filename, &fileinfo)) { if (errno == ENOENT && create_dir) { @@ -266,8 +269,18 @@ cupsdCheckPermissions( return (create_dir ? -1 : 1); } + if ((is_symlink = S_ISLNK(fileinfo.st_mode)) != 0) + { + if (stat(filename, &fileinfo)) + { + cupsdLogMessage(CUPSD_LOG_ERROR, "\"%s\" is a bad symlink - %s", + filename, strerror(errno)); + return (-1); + } + } + /* - * Make sure it's a regular file... + * Make sure it's a regular file or a directory as needed... */ if (!dir_created && !is_dir && !S_ISREG(fileinfo.st_mode)) @@ -286,6 +299,13 @@ cupsdCheckPermissions( return (-1); } + /* + * If the filename is a symlink, do not change permissions (STR #2937)... + */ + + if (is_symlink) + return (0); + /* * Fix owner, group, and mode as needed... */ @@ -524,11 +544,12 @@ cupsdReadConfiguration(void) AccessLogLevel = CUPSD_ACCESSLOG_ACTIONS; ConfigFilePerm = CUPS_DEFAULT_CONFIG_FILE_PERM; + FatalErrors = parse_fatal_errors(CUPS_DEFAULT_FATAL_ERRORS); DefaultAuthType = CUPSD_AUTH_BASIC; #ifdef HAVE_SSL DefaultEncryption = HTTP_ENCRYPT_REQUIRED; #endif /* HAVE_SSL */ - DirtyCleanInterval = 60; + DirtyCleanInterval = DEFAULT_KEEPALIVE; JobRetryLimit = 5; JobRetryInterval = 300; FileDevice = FALSE; @@ -549,7 +570,7 @@ cupsdReadConfiguration(void) MaxLogSize = 1024 * 1024; MaxPrinterHistory = 10; MaxRequestSize = 0; - ReloadTimeout = 60; + ReloadTimeout = DEFAULT_KEEPALIVE; RootCertDuration = 300; Timeout = DEFAULT_TIMEOUT; NumSystemGroups = 0; @@ -737,7 +758,8 @@ cupsdReadConfiguration(void) */ cupsdLogMessage(CUPSD_LOG_EMERG, - "No valid Listen or Port lines were found in the configuration file!"); + "No valid Listen or Port lines were found in the " + "configuration file!"); /* * Commit suicide... @@ -775,21 +797,20 @@ cupsdReadConfiguration(void) if (ServerCertificate[0] != '/') cupsdSetStringf(&ServerCertificate, "%s/%s", ServerRoot, ServerCertificate); - if (!strncmp(ServerRoot, ServerCertificate, strlen(ServerRoot))) - { - chown(ServerCertificate, RunUser, Group); - chmod(ServerCertificate, 0600); - } + if (!strncmp(ServerRoot, ServerCertificate, strlen(ServerRoot)) && + cupsdCheckPermissions(ServerCertificate, NULL, 0600, RunUser, Group, + 0, 0) < 0 && + (FatalErrors & CUPSD_FATAL_PERMISSIONS)) + return (0); # if defined(HAVE_LIBSSL) || defined(HAVE_GNUTLS) if (ServerKey[0] != '/') cupsdSetStringf(&ServerKey, "%s/%s", ServerRoot, ServerKey); - if (!strncmp(ServerRoot, ServerKey, strlen(ServerRoot))) - { - chown(ServerKey, RunUser, Group); - chmod(ServerKey, 0600); - } + if (!strncmp(ServerRoot, ServerKey, strlen(ServerRoot)) && + cupsdCheckPermissions(ServerKey, NULL, 0600, RunUser, Group, 0, 0) < 0 && + (FatalErrors & CUPSD_FATAL_PERMISSIONS)) + return (0); # endif /* HAVE_LIBSSL || HAVE_GNUTLS */ #endif /* HAVE_SSL */ @@ -800,30 +821,31 @@ cupsdReadConfiguration(void) 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, - SystemGroupIDs[0], 1, 1) < 0 || - cupsdCheckPermissions(ServerRoot, NULL, 0755, RunUser, - Group, 1, 0) < 0 || - cupsdCheckPermissions(ServerRoot, "ppd", 0755, RunUser, - Group, 1, 1) < 0 || - cupsdCheckPermissions(ServerRoot, "ssl", 0700, RunUser, - Group, 1, 0) < 0 || - cupsdCheckPermissions(ServerRoot, "cupsd.conf", ConfigFilePerm, RunUser, - Group, 0, 0) < 0 || - cupsdCheckPermissions(ServerRoot, "classes.conf", 0600, RunUser, - Group, 0, 0) < 0 || - cupsdCheckPermissions(ServerRoot, "printers.conf", 0600, RunUser, - Group, 0, 0) < 0 || - cupsdCheckPermissions(ServerRoot, "passwd.md5", 0600, User, - Group, 0, 0) < 0) + 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, + SystemGroupIDs[0], 1, 1) < 0 || + cupsdCheckPermissions(ServerRoot, NULL, 0755, RunUser, + Group, 1, 0) < 0 || + cupsdCheckPermissions(ServerRoot, "ppd", 0755, RunUser, + Group, 1, 1) < 0 || + cupsdCheckPermissions(ServerRoot, "ssl", 0700, RunUser, + Group, 1, 0) < 0 || + cupsdCheckPermissions(ServerRoot, "cupsd.conf", ConfigFilePerm, RunUser, + Group, 0, 0) < 0 || + cupsdCheckPermissions(ServerRoot, "classes.conf", 0600, RunUser, + Group, 0, 0) < 0 || + cupsdCheckPermissions(ServerRoot, "printers.conf", 0600, RunUser, + Group, 0, 0) < 0 || + cupsdCheckPermissions(ServerRoot, "passwd.md5", 0600, User, + Group, 0, 0) < 0) && + (FatalErrors & CUPSD_FATAL_PERMISSIONS)) return (0); /* @@ -873,7 +895,8 @@ cupsdReadConfiguration(void) * is under the spool directory or does not exist... */ - if (cupsdCheckPermissions(TempDir, NULL, 01770, RunUser, Group, 1, 1) < 0) + if (cupsdCheckPermissions(TempDir, NULL, 01770, RunUser, Group, 1, 1) < 0 && + (FatalErrors & CUPSD_FATAL_PERMISSIONS)) return (0); } @@ -932,8 +955,10 @@ cupsdReadConfiguration(void) if (MaxClients > (MaxFDs / 3) || MaxClients <= 0) { if (MaxClients > 0) - cupsdLogMessage(CUPSD_LOG_INFO, "MaxClients limited to 1/3 (%d) of the file descriptor limit (%d)...", - MaxFDs / 3, MaxFDs); + cupsdLogMessage(CUPSD_LOG_INFO, + "MaxClients limited to 1/3 (%d) of the file descriptor " + "limit (%d)...", + MaxFDs / 3, MaxFDs); MaxClients = MaxFDs / 3; } @@ -1170,7 +1195,8 @@ cupsdReadConfiguration(void) cupsdLogMessage(CUPSD_LOG_EMERG, "Unable to load MIME database from \"%s\" or \"%s\"!", mimedir, ServerRoot); - exit(errno); + if (FatalErrors & CUPSD_FATAL_CONFIG) + return (0); } cupsdLogMessage(CUPSD_LOG_INFO, @@ -1966,6 +1992,86 @@ parse_aaa(cupsd_location_t *loc, /* I - Location */ } +/* + * 'parse_fatal_errors()' - Parse FatalErrors values in a string. + */ + +static int /* O - FatalErrors bits */ +parse_fatal_errors(const char *s) /* I - FatalErrors string */ +{ + int fatal; /* FatalErrors bits */ + char value[1024], /* Value string */ + *valstart, /* Pointer into value */ + *valend; /* End of value */ + + + /* + * Empty FatalErrors line yields NULL pointer... + */ + + if (!s) + return (CUPSD_FATAL_NONE); + + /* + * Loop through the value string,... + */ + + strlcpy(value, s, sizeof(value)); + + fatal = CUPSD_FATAL_NONE; + + for (valstart = value; *valstart;) + { + /* + * Get the current space/comma-delimited kind name... + */ + + for (valend = valstart; *valend; valend ++) + if (isspace(*valend & 255) || *valend == ',') + break; + + if (*valend) + *valend++ = '\0'; + + /* + * Add the error to the bitmask... + */ + + if (!strcasecmp(valstart, "all")) + fatal = CUPSD_FATAL_ALL; + else if (!strcasecmp(valstart, "browse")) + fatal |= CUPSD_FATAL_BROWSE; + else if (!strcasecmp(valstart, "-browse")) + fatal &= ~CUPSD_FATAL_BROWSE; + else if (!strcasecmp(valstart, "config")) + fatal |= CUPSD_FATAL_CONFIG; + else if (!strcasecmp(valstart, "-config")) + fatal &= ~CUPSD_FATAL_CONFIG; + else if (!strcasecmp(valstart, "listen")) + fatal |= CUPSD_FATAL_LISTEN; + else if (!strcasecmp(valstart, "-listen")) + fatal &= ~CUPSD_FATAL_LISTEN; + else if (!strcasecmp(valstart, "log")) + fatal |= CUPSD_FATAL_LOG; + else if (!strcasecmp(valstart, "-log")) + fatal &= ~CUPSD_FATAL_LOG; + else if (!strcasecmp(valstart, "permissions")) + fatal |= CUPSD_FATAL_PERMISSIONS; + else if (!strcasecmp(valstart, "-permissions")) + fatal &= ~CUPSD_FATAL_PERMISSIONS; + else if (strcasecmp(valstart, "none")) + cupsdLogMessage(CUPSD_LOG_ERROR, + "Unknown FatalErrors kind \"%s\" ignored!", valstart); + + for (valstart = valend; *valstart; valstart ++) + if (!isspace(*valstart & 255) || *valstart != ',') + break; + } + + return (fatal); +} + + /* * 'parse_groups()' - Parse system group names in a string. */ @@ -2200,6 +2306,8 @@ read_configuration(cups_file_t *fp) /* I - File to read from */ if (linenum == 0) return (0); } + else if (!strcasecmp(line, "FatalErrors")) + FatalErrors = parse_fatal_errors(value); else if (!strcasecmp(line, "FaxRetryInterval") && value) { JobRetryInterval = atoi(value); @@ -2246,6 +2354,25 @@ read_configuration(cups_file_t *fp) /* I - File to read from */ for (addr = addrlist; addr; addr = addr->next) { + /* + * See if this address is already present... + */ + + for (lis = (cupsd_listener_t *)cupsArrayFirst(Listeners); + lis; + lis = (cupsd_listener_t *)cupsArrayNext(Listeners)) + if (httpAddrEqual(&(addr->addr), &(lis->address)) && + _httpAddrPort(&(addr->addr)) == _httpAddrPort(&(lis->address))) + break; + + if (lis) + { + httpAddrString(&lis->address, temp, sizeof(temp)); + cupsdLogMessage(CUPSD_LOG_WARN, + "Duplicate listen address \"%s\" ignored!", temp); + continue; + } + /* * Allocate another listener... */ @@ -2799,7 +2926,8 @@ read_configuration(cups_file_t *fp) /* I - File to read from */ cupsdLogMessage(CUPSD_LOG_WARN, "Unknown default authorization type %s on line %d.", value, linenum); - return (0); + if (FatalErrors & CUPSD_FATAL_CONFIG) + return (0); } } #ifdef HAVE_SSL @@ -2820,7 +2948,8 @@ read_configuration(cups_file_t *fp) /* I - File to read from */ cupsdLogMessage(CUPSD_LOG_WARN, "Unknown default encryption %s on line %d.", value, linenum); - return (0); + if (FatalErrors & CUPSD_FATAL_CONFIG) + return (0); } } #endif /* HAVE_SSL */ @@ -3223,7 +3352,8 @@ read_location(cups_file_t *fp, /* I - Configuration file */ if (!value) { cupsdLogMessage(CUPSD_LOG_ERROR, "Syntax error on line %d.", linenum); - return (0); + if (FatalErrors & CUPSD_FATAL_CONFIG) + return (0); } if ((loc = cupsdCopyLocation(&parent)) == NULL) @@ -3271,7 +3401,8 @@ read_location(cups_file_t *fp, /* I - Configuration file */ cupsdLogMessage(CUPSD_LOG_ERROR, "Unknown Location directive %s on line %d.", line, linenum); - return (0); + if (FatalErrors & CUPSD_FATAL_CONFIG) + return (0); } } @@ -3279,7 +3410,7 @@ read_location(cups_file_t *fp, /* I - Configuration file */ "Unexpected end-of-file at line %d while reading location!", linenum); - return (0); + return ((FatalErrors & CUPSD_FATAL_CONFIG) ? 0 : linenum); } @@ -3361,7 +3492,8 @@ read_policy(cups_file_t *fp, /* I - Configuration file */ if (!value) { cupsdLogMessage(CUPSD_LOG_ERROR, "Syntax error on line %d.", linenum); - return (0); + if (FatalErrors & CUPSD_FATAL_CONFIG) + return (0); } /* @@ -3435,7 +3567,8 @@ read_policy(cups_file_t *fp, /* I - Configuration file */ cupsdLogMessage(CUPSD_LOG_ERROR, "Missing directive before %s on line %d.", line, linenum); - return (0); + if (FatalErrors & CUPSD_FATAL_CONFIG) + return (0); } else if (!parse_aaa(op, line, value, linenum)) { @@ -3448,7 +3581,8 @@ read_policy(cups_file_t *fp, /* I - Configuration file */ "Unknown Policy directive %s on line %d.", line, linenum); - return (0); + if (FatalErrors & CUPSD_FATAL_CONFIG) + return (0); } } @@ -3456,7 +3590,7 @@ read_policy(cups_file_t *fp, /* I - Configuration file */ "Unexpected end-of-file at line %d while reading policy \"%s\"!", linenum, policy); - return (0); + return ((FatalErrors & CUPSD_FATAL_CONFIG) ? 0 : linenum); } diff --git a/scheduler/conf.h b/scheduler/conf.h index 1b3765bd4..e80a24ea9 100644 --- a/scheduler/conf.h +++ b/scheduler/conf.h @@ -45,6 +45,19 @@ typedef enum } cupsd_accesslog_t; +/* + * FatalErrors flags... + */ + +#define CUPSD_FATAL_NONE 0 /* No errors are fatal */ +#define CUPSD_FATAL_BROWSE 1 /* Browse bind errors are fatal */ +#define CUPSD_FATAL_CONFIG 2 /* Config file syntax errors are fatal */ +#define CUPSD_FATAL_LISTEN 4 /* Listen/Port bind errors are fatal */ +#define CUPSD_FATAL_LOG 8 /* Log file errors are fatal */ +#define CUPSD_FATAL_PERMISSIONS 16 /* File permission errors are fatal */ +#define CUPSD_FATAL_ALL ~0 /* All errors are fatal */ + + /* * Printcap formats... */ @@ -132,6 +145,8 @@ VAR int AccessLogLevel VALUE(CUPSD_ACCESSLOG_ACTIONS), /* Allow overrides? */ ConfigFilePerm VALUE(0640), /* Permissions for config files */ + FatalErrors VALUE(CUPSD_FATAL_CONFIG), + /* Which errors are fatal? */ LogFilePerm VALUE(0644), /* Permissions for log files */ LogLevel VALUE(CUPSD_LOG_WARN), @@ -170,7 +185,7 @@ VAR int AccessLogLevel VALUE(CUPSD_ACCESSLOG_ACTIONS), /* Current filter level */ FilterNice VALUE(0), /* Nice value for filters */ - ReloadTimeout VALUE(0), + ReloadTimeout VALUE(DEFAULT_KEEPALIVE), /* Timeout before reload from SIGHUP */ RootCertDuration VALUE(300), /* Root certificate update interval */ @@ -205,7 +220,7 @@ VAR char *ServerKey VALUE(NULL); #endif /* HAVE_SSL */ #ifdef HAVE_LAUNCHD -VAR int LaunchdTimeout VALUE(DEFAULT_TIMEOUT); +VAR int LaunchdTimeout VALUE(DEFAULT_KEEPALIVE); /* Time after which an idle cupsd will exit */ VAR char *LaunchdConf VALUE(NULL); /* launchd(8) configuration file */ diff --git a/scheduler/cupsd.h b/scheduler/cupsd.h index b4304ce83..5b1a4d645 100644 --- a/scheduler/cupsd.h +++ b/scheduler/cupsd.h @@ -92,7 +92,7 @@ extern const char *cups_hstrerror(int); #define DEFAULT_HISTORY 1 /* Preserve job history? */ #define DEFAULT_FILES 0 /* Preserve job files? */ #define DEFAULT_TIMEOUT 300 /* Timeout during requests/updates */ -#define DEFAULT_KEEPALIVE 60 /* Timeout between requests */ +#define DEFAULT_KEEPALIVE 30 /* Timeout between requests */ #define DEFAULT_INTERVAL 30 /* Interval between browse updates */ #define DEFAULT_CHARSET "utf-8" /* Default charset */ diff --git a/scheduler/dirsvc.c b/scheduler/dirsvc.c index e7e2b6e1f..82ed30515 100644 --- a/scheduler/dirsvc.c +++ b/scheduler/dirsvc.c @@ -1422,9 +1422,14 @@ cupsdStartBrowsing(void) strerror(errno)); BrowseLocalProtocols &= ~BROWSE_CUPS; BrowseRemoteProtocols &= ~BROWSE_CUPS; - return; + + if (FatalErrors & CUPSD_FATAL_BROWSE) + cupsdEndProcess(getpid(), 0); } + } + if (BrowseSocket >= 0) + { /* * Bind the socket to browse port... */ @@ -1449,50 +1454,60 @@ cupsdStartBrowsing(void) BrowseSocket = -1; BrowseLocalProtocols &= ~BROWSE_CUPS; BrowseRemoteProtocols &= ~BROWSE_CUPS; - return; + + if (FatalErrors & CUPSD_FATAL_BROWSE) + cupsdEndProcess(getpid(), 0); } } - /* - * Set the "broadcast" flag... - */ - - val = 1; - if (setsockopt(BrowseSocket, SOL_SOCKET, SO_BROADCAST, &val, sizeof(val))) + if (BrowseSocket >= 0) { - cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to set broadcast mode - %s.", - strerror(errno)); + /* + * Set the "broadcast" flag... + */ + + val = 1; + if (setsockopt(BrowseSocket, SOL_SOCKET, SO_BROADCAST, &val, sizeof(val))) + { + cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to set broadcast mode - %s.", + strerror(errno)); #ifdef WIN32 - closesocket(BrowseSocket); + closesocket(BrowseSocket); #else - close(BrowseSocket); + close(BrowseSocket); #endif /* WIN32 */ - BrowseSocket = -1; - BrowseLocalProtocols &= ~BROWSE_CUPS; - BrowseRemoteProtocols &= ~BROWSE_CUPS; - return; - } + BrowseSocket = -1; + BrowseLocalProtocols &= ~BROWSE_CUPS; + BrowseRemoteProtocols &= ~BROWSE_CUPS; - /* - * Close the socket on exec... - */ + if (FatalErrors & CUPSD_FATAL_BROWSE) + cupsdEndProcess(getpid(), 0); + } + } - fcntl(BrowseSocket, F_SETFD, fcntl(BrowseSocket, F_GETFD) | FD_CLOEXEC); + if (BrowseSocket >= 0) + { + /* + * Close the socket on exec... + */ - /* - * Finally, add the socket to the input selection set as needed... - */ + fcntl(BrowseSocket, F_SETFD, fcntl(BrowseSocket, F_GETFD) | FD_CLOEXEC); - if (BrowseRemoteProtocols & BROWSE_CUPS) - { /* - * We only listen if we want remote printers... + * Finally, add the socket to the input selection set as needed... */ - cupsdAddSelect(BrowseSocket, (cupsd_selfunc_t)update_cups_browse, - NULL, NULL); + if (BrowseRemoteProtocols & BROWSE_CUPS) + { + /* + * We only listen if we want remote printers... + */ + + cupsdAddSelect(BrowseSocket, (cupsd_selfunc_t)update_cups_browse, + NULL, NULL); + } } } else @@ -1511,8 +1526,13 @@ cupsdStartBrowsing(void) if ((error = DNSServiceCreateConnection(&DNSSDRef)) != kDNSServiceErr_NoError) + { cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to create master DNS-SD reference: %d", error); + + if (FatalErrors & CUPSD_FATAL_BROWSE) + cupsdEndProcess(getpid(), 0); + } else { /* @@ -1579,6 +1599,10 @@ cupsdStartBrowsing(void) "Unable to open an SLP handle; disabling SLP browsing!"); BrowseLocalProtocols &= ~BROWSE_SLP; BrowseRemoteProtocols &= ~BROWSE_SLP; + BrowseSLPHandle = NULL; + + if (FatalErrors & CUPSD_FATAL_BROWSE) + cupsdEndProcess(getpid(), 0); } BrowseSLPRefresh = 0; @@ -1596,11 +1620,19 @@ cupsdStartBrowsing(void) "Need to set BrowseLDAPDN to use LDAP browsing!"); BrowseLocalProtocols &= ~BROWSE_LDAP; BrowseRemoteProtocols &= ~BROWSE_LDAP; + + if (FatalErrors & CUPSD_FATAL_BROWSE) + cupsdEndProcess(getpid(), 0); } else { - /* Open LDAP handle... */ - BrowseLDAPHandle = ldap_connect(); + /* + * Open LDAP handle... + */ + + if ((BrowseLDAPHandle = ldap_connect()) == NULL && + (FatalErrors & CUPSD_FATAL_BROWSE)) + cupsdEndProcess(getpid(), 0); } BrowseLDAPRefresh = 0; @@ -2321,7 +2353,7 @@ dnssdBuildTxtRecord( } keyvalue[i ][0] = "air"; - keyvalue[i++][1] = air; + keyvalue[i++][1] = air_str; } /* @@ -2573,7 +2605,7 @@ dnssdRegisterPrinter(cupsd_printer_t *p)/* I - Printer */ * Register IPP and (optionally) LPD... */ - ipp_len = 0; /* anti-compiler-warning-code */ + ipp_len = 0; /* anti-compiler-warning-code */ ipp_txt = dnssdBuildTxtRecord(&ipp_len, p, 0); if (!p->ipp_ref) @@ -2654,7 +2686,7 @@ dnssdRegisterPrinter(cupsd_printer_t *p)/* I - Printer */ if (BrowseLocalProtocols & BROWSE_LPD) { - printer_len = 0; /* anti-compiler-warning-code */ + printer_len = 0; /* anti-compiler-warning-code */ printer_txt = dnssdBuildTxtRecord(&printer_len, p, 1); if (!p->printer_ref) diff --git a/scheduler/ipp.c b/scheduler/ipp.c index 11fa79bd5..075ee2407 100644 --- a/scheduler/ipp.c +++ b/scheduler/ipp.c @@ -9558,11 +9558,7 @@ send_document(cupsd_client_t *con, /* I - Client connection */ else filetype = mimeType(MimeDatabase, super, type); - jformat = ippFindAttribute(job->attrs, "document-format", IPP_TAG_MIMETYPE); - - if (filetype && - (!jformat || - (!strcmp(super, "application") && !strcmp(type, "octet-stream")))) + if (filetype) { /* * Replace the document-format attribute value with the auto-typed or @@ -9572,7 +9568,8 @@ send_document(cupsd_client_t *con, /* I - Client connection */ snprintf(mimetype, sizeof(mimetype), "%s/%s", filetype->super, filetype->type); - if (jformat) + if ((jformat = ippFindAttribute(job->attrs, "document-format", + IPP_TAG_MIMETYPE)) != NULL) { _cupsStrFree(jformat->values[0].string.text); diff --git a/scheduler/listen.c b/scheduler/listen.c index 361ff677c..69fb7fc3c 100644 --- a/scheduler/listen.c +++ b/scheduler/listen.c @@ -4,7 +4,7 @@ * Server listening routines for the Common UNIX Printing System (CUPS) * scheduler. * - * Copyright 2007 by Apple Inc. + * Copyright 2007-2008 by Apple Inc. * Copyright 1997-2006 by Easy Software Products, all rights reserved. * * These coded instructions, statements, and computer programs are the @@ -150,10 +150,15 @@ cupsdStartListening(void) httpAddrFreeList(ServerAddrs); if ((ServerAddrs = httpAddrGetList(ServerName, AF_UNSPEC, NULL)) == NULL) + { cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to find IP address for server name \"%s\"!", ServerName); + if (FatalErrors & CUPSD_FATAL_LISTEN) + cupsdEndProcess(getpid(), 0); + } + /* * Setup socket listeners... */ @@ -194,6 +199,20 @@ cupsdStartListening(void) cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to open listen socket for address %s:%d - %s.", s, p, strerror(errno)); + +#ifdef AF_INET6 + /* + * IPv6 is often disabled while DNS returns IPv6 addresses... + */ + + if (lis->address.addr.sa_family != AF_INET6 && + (FatalErrors & CUPSD_FATAL_LISTEN)) + cupsdEndProcess(getpid(), 0); +#else + if (FatalErrors & CUPSD_FATAL_LISTEN) + cupsdEndProcess(getpid(), 0); +#endif /* AF_INET6 */ + continue; } @@ -278,6 +297,10 @@ cupsdStartListening(void) s, p, strerror(errno)); close(lis->fd); lis->fd = -1; + + if (FatalErrors & CUPSD_FATAL_LISTEN) + cupsdEndProcess(getpid(), 0); + continue; } @@ -290,7 +313,14 @@ cupsdStartListening(void) cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to listen for clients on address %s:%d - %s.", s, p, strerror(errno)); - exit(errno); + + close(lis->fd); + lis->fd = -1; + + if (FatalErrors & CUPSD_FATAL_LISTEN) + cupsdEndProcess(getpid(), 0); + + continue; } } @@ -339,11 +369,8 @@ cupsdStartListening(void) "No Listen or Port lines were found to allow access via " "localhost!"); - /* - * Commit suicide... - */ - - cupsdEndProcess(getpid(), 0); + if (FatalErrors & (CUPSD_FATAL_CONFIG | CUPSD_FATAL_LISTEN)) + cupsdEndProcess(getpid(), 0); } /* diff --git a/scheduler/log.c b/scheduler/log.c index dc2e23297..a0123bf8a 100644 --- a/scheduler/log.c +++ b/scheduler/log.c @@ -807,7 +807,20 @@ check_log_file(cups_file_t **lf, /* IO - Log file */ if (!strncmp(filename, CUPS_LOGDIR, strlen(CUPS_LOGDIR))) { - cupsdCheckPermissions(CUPS_LOGDIR, NULL, 0755, RunUser, Group, 1, -1); + /* + * Try updating the permissions of the containing log directory, using + * the log file permissions as a basis... + */ + + int log_dir_perm = 0300 | LogFilePerm; + /* LogFilePerm + owner write/search */ + if (log_dir_perm & 0040) + log_dir_perm |= 0010; /* Add group search */ + if (log_dir_perm & 0004) + log_dir_perm |= 0001; /* Add other search */ + + cupsdCheckPermissions(CUPS_LOGDIR, NULL, log_dir_perm, RunUser, Group, + 1, -1); *lf = cupsFileOpen(filename, "a"); } @@ -816,6 +829,10 @@ check_log_file(cups_file_t **lf, /* IO - Log file */ { syslog(LOG_ERR, "Unable to open log file \"%s\" - %s", filename, strerror(errno)); + + if (FatalErrors & CUPSD_FATAL_LOG) + cupsdEndProcess(getpid(), 0); + return (0); } } @@ -855,6 +872,9 @@ check_log_file(cups_file_t **lf, /* IO - Log file */ syslog(LOG_ERR, "Unable to open log file \"%s\" - %s", filename, strerror(errno)); + if (FatalErrors & CUPSD_FATAL_LOG) + cupsdEndProcess(getpid(), 0); + return (0); } diff --git a/scheduler/main.c b/scheduler/main.c index 417d98ef5..be77cb0ab 100644 --- a/scheduler/main.c +++ b/scheduler/main.c @@ -654,6 +654,23 @@ main(int argc, /* I - Number of command-line args */ cupsdStartSystemMonitor(); #endif /* __APPLE__ */ + /* + * Send server-started event... + */ + +#ifdef HAVE_LAUNCHD + if (Launchd) + cupsdAddEvent(CUPSD_EVENT_SERVER_STARTED, NULL, NULL, + "Scheduler started via launchd."); + else +#endif /* HAVE_LAUNCHD */ + if (fg) + cupsdAddEvent(CUPSD_EVENT_SERVER_STARTED, NULL, NULL, + "Scheduler started in foreground."); + else + cupsdAddEvent(CUPSD_EVENT_SERVER_STARTED, NULL, NULL, + "Scheduler started in background."); + /* * Start any pending print jobs... */ @@ -762,6 +779,13 @@ main(int argc, /* I - Number of command-line args */ */ cupsdStartServer(); + + /* + * Send a server-restarted event... + */ + + cupsdAddEvent(CUPSD_EVENT_SERVER_RESTARTED, NULL, NULL, + "Scheduler restarted."); } } @@ -867,10 +891,7 @@ main(int argc, /* I - Number of command-line args */ */ if (DirtyCleanTime && current_time >= DirtyCleanTime) - { cupsdCleanDirty(); - cupsdSetBusyState(); - } #ifndef __APPLE__ /* @@ -1101,10 +1122,18 @@ main(int argc, /* I - Number of command-line args */ */ if (stop_scheduler) + { cupsdLogMessage(CUPSD_LOG_INFO, "Scheduler shutting down normally."); + cupsdAddEvent(CUPSD_EVENT_SERVER_STOPPED, NULL, NULL, + "Scheduler shutting down normally."); + } else + { cupsdLogMessage(CUPSD_LOG_ERROR, "Scheduler shutting down due to program error."); + cupsdAddEvent(CUPSD_EVENT_SERVER_STOPPED, NULL, NULL, + "Scheduler shutting down due to program error."); + } /* * Close all network clients... diff --git a/scheduler/server.c b/scheduler/server.c index d44e4ee73..650b3b16d 100644 --- a/scheduler/server.c +++ b/scheduler/server.c @@ -111,10 +111,11 @@ cupsdStartServer(void) * Mark that the server has started and printers and jobs may be changed... */ - LastEvent = CUPSD_EVENT_PRINTER_CHANGED | CUPSD_EVENT_JOB_STATE_CHANGED | - CUPSD_EVENT_SERVER_STARTED; + LastEvent = CUPSD_EVENT_PRINTER_CHANGED | CUPSD_EVENT_JOB_STATE_CHANGED | + CUPSD_EVENT_SERVER_STARTED; + started = 1; - started = 1; + cupsdSetBusyState(); } diff --git a/scheduler/sysman.c b/scheduler/sysman.c index cffb285a7..8933d083e 100644 --- a/scheduler/sysman.c +++ b/scheduler/sysman.c @@ -93,6 +93,8 @@ cupsdCleanDirty(void) DirtyFiles = CUPSD_DIRTY_NONE; DirtyCleanTime = 0; + + cupsdSetBusyState(); } @@ -103,6 +105,9 @@ cupsdCleanDirty(void) void cupsdMarkDirty(int what) /* I - What file(s) are dirty? */ { + if (what == CUPSD_DIRTY_PRINTCAP && !Printcap) + return; + DirtyFiles |= what; if (!DirtyCleanTime) @@ -121,22 +126,28 @@ cupsdSetBusyState(void) { int newbusy; /* New busy state */ static int busy = 0; /* Current busy state */ - - - newbusy = DirtyCleanTime || - cupsArrayCount(PrintingJobs) || - cupsArrayCount(ActiveClients); + static const char * const busy_text[] = + { /* Text for busy states */ + "Not busy", + "Dirty files", + "Printing jobs", + "Printing jobs and dirty files", + "Active clients", + "Active clients and dirty files", + "Active clients and printing jobs", + "Active clients, printing jobs, and dirty files" + }; + + + newbusy = (DirtyCleanTime ? 1 : 0) | + (cupsArrayCount(PrintingJobs) ? 2 : 0) | + (cupsArrayCount(ActiveClients) ? 4 : 0); if (newbusy != busy) { busy = newbusy; - if (busy) - cupsdLogMessage(CUPSD_LOG_DEBUG2, - "cupsdSetBusyState: Server no longer busy..."); - else - cupsdLogMessage(CUPSD_LOG_DEBUG2, - "cupsdSetBusyState: Server is now busy..."); + cupsdLogMessage(CUPSD_LOG_DEBUG, "cupsdSetBusyState: %s", busy_text[busy]); } } diff --git a/scheduler/sysman.h b/scheduler/sysman.h index 282f7b5bc..97b9dd2c3 100644 --- a/scheduler/sysman.h +++ b/scheduler/sysman.h @@ -31,7 +31,7 @@ VAR int DirtyFiles VALUE(CUPSD_DIRTY_NONE), /* What files are dirty? */ - DirtyCleanInterval VALUE(60); + DirtyCleanInterval VALUE(DEFAULT_KEEPALIVE); /* How often do we write dirty files? */ VAR time_t DirtyCleanTime VALUE(0); /* When to clean dirty files next */ diff --git a/systemv/Makefile b/systemv/Makefile index 8d95c1fc1..cfa4c7e7f 100644 --- a/systemv/Makefile +++ b/systemv/Makefile @@ -48,7 +48,8 @@ unittests: # clean: - $(RM) $(OBJS) $(TARGETS) cupsdisable cupsenable reject + $(RM) $(OBJS) $(TARGETS) + $(RM) cupsaccept cupsdisable cupsenable cupsreject reject # @@ -91,10 +92,14 @@ install-exec: $(INSTALL_BIN) cancel $(BINDIR) $(INSTALL_BIN) cupstestdsc $(BINDIR) $(INSTALL_BIN) cupstestppd $(BINDIR) + $(RM) $(SBINDIR)/cupsaccept + $(LN) accept $(SBINDIR)/cupsaccept $(RM) $(SBINDIR)/cupsdisable $(LN) accept $(SBINDIR)/cupsdisable $(RM) $(SBINDIR)/cupsenable $(LN) accept $(SBINDIR)/cupsenable + $(RM) $(SBINDIR)/cupsreject + $(LN) accept $(SBINDIR)/cupsreject $(INSTALL_BIN) lp $(BINDIR) $(INSTALL_BIN) lpoptions $(BINDIR) $(INSTALL_BIN) lpstat $(BINDIR) @@ -136,8 +141,10 @@ uninstall: -$(RMDIR) $(BINDIR) $(RM) $(SBINDIR)/accept $(RM) $(SBINDIR)/cupsaddsmb + $(RM) $(SBINDIR)/cupsaccept $(RM) $(SBINDIR)/cupsdisable $(RM) $(SBINDIR)/cupsenable + $(RM) $(SBINDIR)/cupsreject $(RM) $(SBINDIR)/lpadmin $(RM) $(SBINDIR)/lpinfo $(RM) $(SBINDIR)/lpmove @@ -152,10 +159,12 @@ uninstall: accept: accept.o ../cups/$(LIBCUPS) echo Linking $@... $(CC) $(LDFLAGS) -o accept accept.o $(LIBS) - $(RM) reject cupsenable cupsdisable + $(RM) cupsaccept cupsenable cupsdisable cupsreject reject $(LN) accept reject + $(LN) accept cupsaccept $(LN) accept cupsenable $(LN) accept cupsdisable + $(LN) accept cupsreject # diff --git a/systemv/accept.c b/systemv/accept.c index 20e3af373..6d8ba2619 100644 --- a/systemv/accept.c +++ b/systemv/accept.c @@ -62,9 +62,9 @@ main(int argc, /* I - Number of command-line arguments */ cancel = 0; - if (!strcmp(command, "accept")) + if (!strcmp(command, "cupsaccept") || !strcmp(command, "accept")) op = CUPS_ACCEPT_JOBS; - else if (!strcmp(command, "reject")) + else if (!strcmp(command, "cupsreject") || !strcmp(command, "reject")) op = CUPS_REJECT_JOBS; else if (!strcmp(command, "cupsdisable") || !strcmp(command, "disable")) op = IPP_PAUSE_PRINTER; diff --git a/systemv/lpstat.c b/systemv/lpstat.c index ba63ae2c6..35b76226e 100644 --- a/systemv/lpstat.c +++ b/systemv/lpstat.c @@ -3,7 +3,7 @@ * * "lpstat" command for the Common UNIX Printing System (CUPS). * - * Copyright 2007 by Apple Inc. + * Copyright 2007-2008 by Apple Inc. * Copyright 1997-2006 by Easy Software Products. * * These coded instructions, statements, and computer programs are the @@ -112,6 +112,13 @@ main(int argc, /* I - Number of command-line arguments */ #endif /* HAVE_SSL */ break; + case 'H' : /* Show server and port */ + if (cupsServer()[0] == '/') + _cupsLangPrintf(stdout, "%s\n", cupsServer()); + else + _cupsLangPrintf(stdout, "%s:%d\n", cupsServer(), ippPort()); + break; + case 'P' : /* Show paper types */ op = 'P'; break; -- 2.39.2