From: jlovell Date: Fri, 27 Jan 2006 21:43:41 +0000 (+0000) Subject: Load cups into easysw/current. X-Git-Tag: release-1.6.3~253 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=09ec001812911f8890dad0f164ab9098e22208cf;p=thirdparty%2Fcups.git Load cups into easysw/current. git-svn-id: svn+ssh://src.apple.com/svn/cups/easysw/current@35 a1ca3aef-8c08-0410-bb20-df032aa958be --- diff --git a/Makedefs.in b/Makedefs.in index 7177bcbbcd..4c6ccb6764 100644 --- a/Makedefs.in +++ b/Makedefs.in @@ -1,5 +1,5 @@ # -# "$Id: Makedefs.in 4999 2006-01-26 23:36:22Z mike $" +# "$Id: Makedefs.in 5008 2006-01-27 19:30:34Z mike $" # # Common makefile definitions for the Common UNIX Printing System (CUPS). # @@ -47,6 +47,7 @@ STRIP = @STRIP@ # INSTALL_BIN = $(LIBTOOL) $(INSTALL) -m 755 -s +INSTALL_CONFIG = $(INSTALL) -m @CUPS_CONFIG_FILE_PERM@ INSTALL_DATA = $(INSTALL) -m 644 INSTALL_DIR = $(INSTALL) -d INSTALL_LIB = $(LIBTOOL) $(INSTALL) -m 755 @@ -54,11 +55,19 @@ INSTALL_MAN = $(INSTALL) -m 644 INSTALL_SCRIPT = $(INSTALL) -m 755 # -# Default user and group for the scheduler... +# Default user, group, and system groups for the scheduler... # CUPS_USER = @CUPS_USER@ CUPS_GROUP = @CUPS_GROUP@ +CUPS_SYSTEM_GROUPS = @CUPS_SYSTEM_GROUPS@ + +# +# Default permissions... +# + +CUPS_CONFIG_FILE_PERM = @CUPS_CONFIG_FILE_PERM@ +CUPS_LOG_FILE_PERM = @CUPS_LOG_FILE_PERM@ # # Libraries... @@ -93,6 +102,7 @@ BACKLIBS = @BACKLIBS@ CFLAGS = -I.. $(RC_CFLAGS) $(SSLFLAGS) @CPPFLAGS@ @CFLAGS@ \ @LARGEFILE@ $(OPTIONS) COMMONLIBS = @LIBS@ +CUPSDLIBS = @CUPSDLIBS@ CXXFLAGS = -I.. $(RC_CFLAGS) $(SSLFLAGS) @CPPFLAGS@ @CXXFLAGS@ \ @LARGEFILE@ $(OPTIONS) CXXLIBS = @CXXLIBS@ @@ -195,5 +205,5 @@ PAMFILE = @PAMFILE@ # -# End of "$Id: Makedefs.in 4999 2006-01-26 23:36:22Z mike $" +# End of "$Id: Makedefs.in 5008 2006-01-27 19:30:34Z mike $" # diff --git a/Makefile b/Makefile index 2c99a07f71..9cfaec9bba 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ # -# "$Id: Makefile 4971 2006-01-24 14:33:18Z mike $" +# "$Id: Makefile 5003 2006-01-27 02:33:36Z mike $" # # Top-level Makefile for the Common UNIX Printing System (CUPS). # @@ -28,7 +28,7 @@ include Makedefs # Directories to make... # -DIRS = cups backend berkeley cgi-bin filter man pdftops \ +DIRS = cups backend berkeley cgi-bin filter locale man pdftops \ notifier scheduler systemv # @@ -80,8 +80,6 @@ install: installhdrs (cd doc; $(MAKE) $(MFLAGS) install) echo Installing in fonts... (cd fonts; $(MAKE) $(MFLAGS) install) - echo Installing in locale... - (cd locale; $(MAKE) $(MFLAGS) install) echo Installing in ppd... (cd ppd; $(MAKE) $(MFLAGS) install) echo Installing in templates... @@ -167,5 +165,5 @@ tardist: epm $(EPMFLAGS) -f tardist cups packaging/cups.list # -# End of "$Id: Makefile 4971 2006-01-24 14:33:18Z mike $". +# End of "$Id: Makefile 5003 2006-01-27 02:33:36Z mike $". # diff --git a/conf/Makefile b/conf/Makefile index 6846938069..cf2f88a8a2 100644 --- a/conf/Makefile +++ b/conf/Makefile @@ -1,5 +1,5 @@ # -# "$Id: Makefile 4972 2006-01-24 14:48:12Z mike $" +# "$Id: Makefile 5008 2006-01-27 19:30:34Z mike $" # # Configuration file makefile for the Common UNIX Printing System (CUPS). # @@ -54,17 +54,17 @@ install: all $(INSTALL_DIR) $(SERVERROOT) for file in $(KEEP); do \ if test -r $(SERVERROOT)/$$file ; then \ - $(INSTALL_DATA) $$file $(SERVERROOT)/$$file.N ; \ + $(INSTALL_CONFIG) $$file $(SERVERROOT)/$$file.N ; \ else \ - $(INSTALL_DATA) $$file $(SERVERROOT) ; \ + $(INSTALL_CONFIG) $$file $(SERVERROOT) ; \ fi ; \ done - $(INSTALL_DATA) cupsd.conf $(SERVERROOT)/cupsd.conf.default + $(INSTALL_CONFIG) cupsd.conf $(SERVERROOT)/cupsd.conf.default for file in $(REPLACE); do \ if test -r $(SERVERROOT)/$$file ; then \ $(MV) $(SERVERROOT)/$$file $(SERVERROOT)/$$file.O ; \ fi ; \ - $(INSTALL_DATA) $$file $(SERVERROOT) ; \ + $(INSTALL_CONFIG) $$file $(SERVERROOT) ; \ done -if test x$(PAMDIR) != x$(BUILDROOT); then \ $(INSTALL_DIR) $(PAMDIR); \ @@ -77,5 +77,5 @@ install: all # -# End of "$Id: Makefile 4972 2006-01-24 14:48:12Z mike $". +# End of "$Id: Makefile 5008 2006-01-27 19:30:34Z mike $". # diff --git a/config-scripts/cups-common.m4 b/config-scripts/cups-common.m4 index cc001bf747..18d0bfff12 100644 --- a/config-scripts/cups-common.m4 +++ b/config-scripts/cups-common.m4 @@ -1,5 +1,5 @@ dnl -dnl "$Id: cups-common.m4 4999 2006-01-26 23:36:22Z mike $" +dnl "$Id: cups-common.m4 5007 2006-01-27 18:25:42Z mike $" dnl dnl Common configuration stuff for the Common UNIX Printing System (CUPS). dnl @@ -187,6 +187,7 @@ dnl Extra platform-specific libraries... case $uname in Darwin*) BACKLIBS="-framework IOKit" + CUPSDLIBS="-framework IOKit -framework SystemConfiguration" LIBS="-framework CoreFoundation $LIBS" dnl Check for CFLocaleCreateCanonicalLocaleIdentifierFromString... @@ -214,10 +215,12 @@ case $uname in ;; *) BACKLIBS="" + CUPSDLIBS="" ;; esac AC_SUBST(BACKLIBS) +AC_SUBST(CUPSDLIBS) dnl New default port definition for IPP... AC_ARG_WITH(ipp-port, [ --with-ipp-port set default port number for IPP ], @@ -228,5 +231,5 @@ AC_SUBST(DEFAULT_IPP_PORT) AC_DEFINE_UNQUOTED(CUPS_DEFAULT_IPP_PORT,$DEFAULT_IPP_PORT) dnl -dnl End of "$Id: cups-common.m4 4999 2006-01-26 23:36:22Z mike $". +dnl End of "$Id: cups-common.m4 5007 2006-01-27 18:25:42Z mike $". dnl diff --git a/config-scripts/cups-defaults.m4 b/config-scripts/cups-defaults.m4 new file mode 100644 index 0000000000..26bfae8c71 --- /dev/null +++ b/config-scripts/cups-defaults.m4 @@ -0,0 +1,105 @@ +dnl +dnl "$Id$" +dnl +dnl Default cupsd configuration settings for the Common UNIX Printing System +dnl (CUPS). +dnl +dnl Copyright 2006 by Easy Software Products, all rights reserved. +dnl +dnl These coded instructions, statements, and computer programs are the +dnl property of Easy Software Products and are protected by Federal +dnl copyright law. Distribution and use rights are outlined in the file +dnl "LICENSE.txt" which should have been included with this file. If this +dnl file is missing or damaged please contact Easy Software Products +dnl at: +dnl +dnl Attn: CUPS Licensing Information +dnl Easy Software Products +dnl 44141 Airport View Drive, Suite 204 +dnl Hollywood, Maryland 20636 USA +dnl +dnl Voice: (301) 373-9600 +dnl EMail: cups-info@cups.org +dnl WWW: http://www.cups.org +dnl + +dnl Default ConfigFilePerm +AC_ARG_WITH(config_perm, [ --with-config-file-perm set default ConfigFilePerm value, default=0640], + CUPS_CONFIG_FILE_PERM="$withval", + CUPS_CONFIG_FILE_PERM="0640") +AC_SUBST(CUPS_CONFIG_FILE_PERM) +AC_DEFINE_UNQUOTED(CUPS_DEFAULT_CONFIG_FILE_PERM, $CUPS_CONFIG_FILE_PERM) + +dnl Default LogFilePerm +AC_ARG_WITH(log_perm, [ --with-log-file-perm set default LogFilePerm value, default=0644], + CUPS_LOG_FILE_PERM="$withval", + CUPS_LOG_FILE_PERM="0644") +AC_SUBST(CUPS_LOG_FILE_PERM) +AC_DEFINE_UNQUOTED(CUPS_DEFAULT_LOG_FILE_PERM, $CUPS_LOG_FILE_PERM) + +dnl Default Browsing +AC_ARG_ENABLE(browsing, [ --enable-browsing enable Browsing by default, default=yes]) +if test "x$enable_browsing" = xno; then + CUPS_BROWSING="No" + AC_DEFINE_UNQUOTED(CUPS_DEFAULT_BROWSING, 0) +else + CUPS_BROWSING="Yes" + AC_DEFINE_UNQUOTED(CUPS_DEFAULT_BROWSING, 1) +fi +AC_SUBST(CUPS_BROWSING) + +dnl Default BrowseLocalProtocols +AC_ARG_WITH(browse_local, [ --with-local-protocols set default BrowseLocalProtocols, default="CUPS"], + CUPS_BROWSE_LOCAL_PROTOCOLS="$withval", + CUPS_BROWSE_LOCAL_PROTOCOLS="CUPS") +AC_SUBST(CUPS_BROWSE_LOCAL_PROTOCOLS) +AC_DEFINE_UNQUOTED(CUPS_DEFAULT_BROWSE_LOCAL_PROTOCOLS, + "$CUPS_BROWSE_LOCAL_PROTOCOLS") + +dnl Default BrowseRemoteProtocols +AC_ARG_WITH(browse_remote, [ --with-remote-protocols set default BrowseRemoteProtocols, default="CUPS"], + CUPS_BROWSE_REMOTE_PROTOCOLS="$withval", + CUPS_BROWSE_REMOTE_PROTOCOLS="CUPS") +AC_SUBST(CUPS_BROWSE_REMOTE_PROTOCOLS) +AC_DEFINE_UNQUOTED(CUPS_DEFAULT_BROWSE_REMOTE_PROTOCOLS, + "$CUPS_BROWSE_REMOTE_PROTOCOLS") + +dnl Default BrowseShortNames +AC_ARG_ENABLE(browse_short, [ --enable-browse-short-names + enable BrowseShortNames by default, default=yes]) +if test "x$enable_browse_short" = xno; then + CUPS_BROWSE_SHORT_NAMES="No" + AC_DEFINE_UNQUOTED(CUPS_DEFAULT_BROWSE_SHORT_NAMES, 0) +else + CUPS_BROWSE_SHORT_NAMES="Yes" + AC_DEFINE_UNQUOTED(CUPS_DEFAULT_BROWSE_SHORT_NAMES, 1) +fi +AC_SUBST(CUPS_BROWSE_SHORT_NAMES) + +dnl Default DefaultShared +AC_ARG_ENABLE(default_shared, [ --enable-default-shared enable DefaultShared by default, default=yes]) +if test "x$enable_default_shared" = xno; then + CUPS_DEFAULT_SHARED="No" + AC_DEFINE_UNQUOTED(CUPS_DEFAULT_DEFAULT_SHARED, 0) +else + CUPS_DEFAULT_SHARED="Yes" + AC_DEFINE_UNQUOTED(CUPS_DEFAULT_DEFAULT_SHARED, 1) +fi +AC_SUBST(CUPS_DEFAULT_SHARED) + +dnl Default ImplicitClasses +AC_ARG_ENABLE(implicit, [ --enable-implicit-classes + enable ImplicitClasses by default, default=yes]) +if test "x$enable_implicit" = xno; then + CUPS_IMPLICIT_CLASSES="No" + AC_DEFINE_UNQUOTED(CUPS_DEFAULT_IMPLICIT_CLASSES, 0) +else + CUPS_IMPLICIT_CLASSES="Yes" + AC_DEFINE_UNQUOTED(CUPS_DEFAULT_IMPLICIT_CLASSES, 1) +fi +AC_SUBST(CUPS_IMPLICIT_CLASSES) + + +dnl +dnl End of "$Id$". +dnl diff --git a/config-scripts/cups-sharedlibs.m4 b/config-scripts/cups-sharedlibs.m4 index 8e015a5d7e..afaab9cf50 100644 --- a/config-scripts/cups-sharedlibs.m4 +++ b/config-scripts/cups-sharedlibs.m4 @@ -1,5 +1,5 @@ dnl -dnl "$Id: cups-sharedlibs.m4 4800 2005-10-18 18:06:20Z mike $" +dnl "$Id: cups-sharedlibs.m4 5007 2006-01-27 18:25:42Z mike $" dnl dnl Shared library support for the Common UNIX Printing System (CUPS). dnl @@ -57,7 +57,7 @@ if test x$enable_shared != xno; then LIBCUPS="libcups.2.dylib" LIBCUPSIMAGE="libcupsimage.2.dylib" DSO="\$(CC)" - DSOFLAGS="$DSOFLAGS \$(RC_CFLAGS) -dynamiclib -lc" + DSOFLAGS="$DSOFLAGS \$(RC_CFLAGS) -dynamiclib -single_module -lc" ;; AIX*) LIBCUPS="libcups_s.a" @@ -152,5 +152,5 @@ AC_SUBST(IMGLIBS) AC_SUBST(EXPORT_LDFLAGS) dnl -dnl End of "$Id: cups-sharedlibs.m4 4800 2005-10-18 18:06:20Z mike $". +dnl End of "$Id: cups-sharedlibs.m4 5007 2006-01-27 18:25:42Z mike $". dnl diff --git a/config.h.in b/config.h.in index efc0e2f200..a6f0f49047 100644 --- a/config.h.in +++ b/config.h.in @@ -1,11 +1,11 @@ /* - * "$Id: config.h.in 4979 2006-01-25 17:47:43Z mike $" + * "$Id: config.h.in 5008 2006-01-27 19:30:34Z mike $" * * Configuration file for the Common UNIX Printing System (CUPS). * * @configure_input@ * - * Copyright 1997-2005 by Easy Software Products. + * Copyright 1997-2006 by Easy Software Products. * * These coded instructions, statements, and computer programs are the * property of Easy Software Products and are protected by Federal @@ -36,11 +36,32 @@ /* - * Default user and group... + * Default user and groups... */ #define CUPS_DEFAULT_USER "lp" #define CUPS_DEFAULT_GROUP "sys" +#define CUPS_DEFAULT_SYSTEM_GROUPS "sys root system" + + +/* + * Default file permissions... + */ + +#define CUPS_DEFAULT_CONFIG_FILE_PERM 0640 +#define CUPS_DEFAULT_LOG_FILE_PERM 0644 + + +/* + * Default browsing settings... + */ + +#define CUPS_DEFAULT_BROWSING 1 +#define CUPS_DEFAULT_BROWSE_LOCAL_PROTOCOLS "CUPS" +#define CUPS_DEFAULT_BROWSE_REMOTE_PROTOCOLS "CUPS" +#define CUPS_DEFAULT_BROWSE_SHORT_NAMES 1 +#define CUPS_DEFAULT_DEFAULT_SHARED 1 +#define CUPS_DEFAULT_IMPLICIT_CLASSES 1 /* @@ -382,5 +403,5 @@ #endif /* !_CUPS_CONFIG_H_ */ /* - * End of "$Id: config.h.in 4979 2006-01-25 17:47:43Z mike $". + * End of "$Id: config.h.in 5008 2006-01-27 19:30:34Z mike $". */ diff --git a/configure.in b/configure.in index 0135039a2b..58dff5694f 100644 --- a/configure.in +++ b/configure.in @@ -1,5 +1,5 @@ dnl -dnl "$Id: configure.in 4971 2006-01-24 14:33:18Z mike $" +dnl "$Id: configure.in 5008 2006-01-27 19:30:34Z mike $" dnl dnl Configuration script for the Common UNIX Printing System (CUPS). dnl @@ -26,6 +26,7 @@ AC_INIT(cups/cups.h) sinclude(config-scripts/cups-opsys.m4) sinclude(config-scripts/cups-common.m4) +sinclude(config-scripts/cups-defaults.m4) sinclude(config-scripts/cups-directories.m4) sinclude(config-scripts/cups-manpages.m4) @@ -48,10 +49,11 @@ sinclude(config-scripts/cups-scripting.m4) AC_OUTPUT(Makedefs packaging/cups.list init/cups.sh cups-config conf/cupsd.conf conf/pam.std doc/index.html - doc/help/standard.html templates/edit-config.tmpl) + doc/help/standard.html templates/edit-config.tmpl + templates/header.tmpl) chmod +x cups-config dnl -dnl End of "$Id: configure.in 4971 2006-01-24 14:33:18Z mike $". +dnl End of "$Id: configure.in 5008 2006-01-27 19:30:34Z mike $". dnl diff --git a/doc/help/standard.html.in b/doc/help/standard.html.in index cbfa9d328e..5003acec90 100644 --- a/doc/help/standard.html.in +++ b/doc/help/standard.html.in @@ -19,7 +19,7 @@ by Easy Software Products, the creator of CUPS.

-

cupsd Configuration

+

cupsd Configuration

cupsd(8) is configured by default to show printers shared by other systems and only allow local access to @@ -31,8 +31,49 @@ Basic authentication with membership in the group (@CUPS_DEFAULT_DOMAINSOCKET@) or "localhost" (127.0.0.1).

+

Settings

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
DirectiveValue
Browsing@CUPS_BROWSING@
BrowseLocalProtocols@CUPS_BROWSE_LOCAL_PROTOCOLS@
BrowseRemoteProtocols@CUPS_BROWSE_REMOTE_PROTOCOLS@
BrowseShortNames@CUPS_BROWSE_SHORT_NAMES@
ConfigFilePerm@CUPS_CONFIG_FILE_PERM@
DefaultShared@CUPS_DEFAULT_SHARED@
ImplicitClasses@CUPS_IMPLICIT_CLASSES@
LogFilePerm@CUPS_LOG_FILE_PERM@
-

Directories

+ +

Directories

@@ -123,6 +164,5 @@ Basic authentication with membership in the group
- diff --git a/man/lp.man b/man/lp.man index f8faf3f826..2a823459be 100644 --- a/man/lp.man +++ b/man/lp.man @@ -1,5 +1,5 @@ .\" -.\" "$Id: lp.man 4948 2006-01-19 03:23:41Z mike $" +.\" "$Id: lp.man 5010 2006-01-27 19:53:55Z mike $" .\" .\" lp/cancel man page for the Common UNIX Printing System (CUPS). .\" @@ -98,6 +98,10 @@ The following options are recognized by \fBlp\fR: .br Forces encryption when connecting to the server. .TP 5 +\-U +.br +Specifies the username to use when connecting to the server. +.TP 5 \-c .br This option is provided for backwards-compatibility only. On @@ -120,8 +124,12 @@ of the CUPS_SERVER environment variable. Specifies an existing job to modify. .TP 5 \-m +.TP 5 +\-p +.TP 5 +\-w .br -Send email when the job is completed (not supported CUPS 1.1.) +Send email when the job is completed. .TP 5 \-n \fIcopies\fR .br @@ -167,15 +175,14 @@ Unlike the System V printing system, CUPS allows printer names to contain any printable character except SPACE and TAB. Also, printer and class names are \fBnot\fR case-sensitive. .LP -The "m" option is not functional in CUPS 1.1. -.LP The "q" option accepts a different range of values than the -Solaris lp command, matching the IPP job priority values (1-100) -instead of the Solaris values (0-39). +Solaris lp command, matching the IPP job priority values (1-100, 100 is +highest priority) instead of the Solaris values (0-39, 0 is highest +priority). .SH NOTES Administrators wishing to prevent unauthorized cancellation of -jobs via the \fI-u\fR option should password-protect the /jobs -location in \fIcupsd.conf(5)\fR. +jobs via the \fI-u\fR option should require authentication for +Cancel-Jobs operations in \fIcupsd.conf(5)\fR. .SH SEE ALSO lpstat(1), .br @@ -183,5 +190,5 @@ http://localhost:631/help .SH COPYRIGHT Copyright 1993-2006 by Easy Software Products, All Rights Reserved. .\" -.\" End of "$Id: lp.man 4948 2006-01-19 03:23:41Z mike $". +.\" End of "$Id: lp.man 5010 2006-01-27 19:53:55Z mike $". .\" diff --git a/man/lprm.man b/man/lprm.man index 92d05b5e65..0ca5fec10f 100644 --- a/man/lprm.man +++ b/man/lprm.man @@ -1,5 +1,5 @@ .\" -.\" "$Id: lprm.man 4948 2006-01-19 03:23:41Z mike $" +.\" "$Id: lprm.man 5010 2006-01-27 19:53:55Z mike $" .\" .\" lprm man page for the Common UNIX Printing System (CUPS). .\" @@ -21,7 +21,7 @@ .\" EMail: cups-info@cups.org .\" WWW: http://www.cups.org .\" -.TH lprm 1 "Common UNIX Printing System" "18 January 2006" "Easy Software Products" +.TH lprm 1 "Common UNIX Printing System" "27 January 2006" "Easy Software Products" .SH NAME lprm \- cancel print jobs .SH SYNOPSIS @@ -32,7 +32,7 @@ lprm \- cancel print jobs .I hostname[:port] ] [ -P .I destination -] [ - ] [ +] [ - ] [ .I job ID(s) ] .SH DESCRIPTION @@ -44,6 +44,10 @@ cancelled. You can specify one or more job ID numbers to cancel those jobs, or use the \fI\-\fR option to cancel all jobs. .LP The \fI-E\fR option forces encryption when connecting to the server. +.LP +The \fI-U\fR option specifies the username to use when connecting to the server. +.LP +The \fI-h\fR option an alternate server to use. .SH COMPATIBILITY The CUPS version of \fIlprm\fR is compatible with the standard Berkeley \fIlprm\fR command. @@ -54,5 +58,5 @@ http://localhost:631/help .SH COPYRIGHT Copyright 1993-2006 by Easy Software Products, All Rights Reserved. .\" -.\" End of "$Id: lprm.man 4948 2006-01-19 03:23:41Z mike $". +.\" End of "$Id: lprm.man 5010 2006-01-27 19:53:55Z mike $". .\" diff --git a/packaging/cups.spec.in b/packaging/cups.spec.in index 21cbb1fe85..d551315cb1 100644 --- a/packaging/cups.spec.in +++ b/packaging/cups.spec.in @@ -226,12 +226,11 @@ rm -rf $RPM_BUILD_ROOT /usr/share/man/man8/reject.8.gz %dir /var/cache/cups -%dir /var/cache/cups/ppd %dir /var/log/cups %dir /var/run/cups %attr(0711,lp,root) %dir /var/run/cups/certs -%attr(0700,lp,root) %dir /var/spool/cups -%attr(1700,lp,root) %dir /var/spool/cups/tmp +%attr(0710,lp,root) %dir /var/spool/cups +%attr(1770,lp,root) %dir /var/spool/cups/tmp %files devel %defattr(-,root,root) @@ -243,7 +242,7 @@ rm -rf $RPM_BUILD_ROOT /usr/bin/cups-config %dir /usr/include/cups /usr/include/cups/* -/usr/lib/*.a +#/usr/lib/*.a /usr/lib/*.so %dir /usr/share/doc/cups/help diff --git a/scheduler/Makefile b/scheduler/Makefile index 66adc3015f..e5f61fcd5a 100644 --- a/scheduler/Makefile +++ b/scheduler/Makefile @@ -1,5 +1,5 @@ # -# "$Id: Makefile 5000 2006-01-26 23:38:43Z mike $" +# "$Id: Makefile 5007 2006-01-27 18:25:42Z mike $" # # Scheduler Makefile for the Common UNIX Printing System (CUPS). # @@ -45,7 +45,8 @@ CUPSDOBJS = \ quotas.o \ server.o \ statbuf.o \ - subscriptions.o + subscriptions.o \ + sysman.o MIMEOBJS = \ filter.o \ mime.o \ @@ -146,14 +147,14 @@ install: all cupsd: $(CUPSDOBJS) libmime.a ../cups/$(LIBCUPS) echo Linking $@... $(CC) $(LDFLAGS) -o cupsd $(CUPSDOBJS) libmime.a \ - $(LIBZ) $(SSLLIBS) $(LIBSLP) $(PAMLIBS) $(LIBS) \ - $(LIBPAPER) $(LIBMALLOC) + $(LIBZ) $(SSLLIBS) $(LIBSLP) $(PAMLIBS) \ + $(LIBPAPER) $(LIBMALLOC) $(CUPSDLIBS) $(LIBS) cupsd-static: $(CUPSDOBJS) libmime.a ../cups/libcups.a echo Linking $@... $(CC) $(LDFLAGS) -o cupsd-static $(CUPSDOBJS) libmime.a \ $(LIBZ) $(SSLLIBS) $(LIBSLP) $(PAMLIBS) ../cups/libcups.a \ - $(COMMONLIBS) $(LIBZ) $(LIBPAPER) $(LIBMALLOC) + $(COMMONLIBS) $(LIBZ) $(LIBPAPER) $(LIBMALLOC) $(CUPSDLIBS) # @@ -239,5 +240,5 @@ include Dependencies # -# End of "$Id: Makefile 5000 2006-01-26 23:38:43Z mike $". +# End of "$Id: Makefile 5007 2006-01-27 18:25:42Z mike $". # diff --git a/scheduler/conf.c b/scheduler/conf.c index aab53c63aa..1849d64363 100644 --- a/scheduler/conf.c +++ b/scheduler/conf.c @@ -1,5 +1,5 @@ /* - * "$Id: conf.c 5001 2006-01-26 23:39:23Z mike $" + * "$Id: conf.c 5008 2006-01-27 19:30:34Z mike $" * * Configuration routines for the Common UNIX Printing System (CUPS). * @@ -392,7 +392,7 @@ cupsdReadConfiguration(void) * Numeric options... */ - ConfigFilePerm = 0640; /* TODO: Add configure option */ + ConfigFilePerm = CUPS_DEFAULT_CONFIG_FILE_PERM; DefaultAuthType = AUTH_BASIC; JobRetryLimit = 5; JobRetryInterval = 300; @@ -401,13 +401,13 @@ cupsdReadConfiguration(void) FilterLimit = 0; FilterNice = 0; HostNameLookups = FALSE; - ImplicitClasses = TRUE; + ImplicitClasses = CUPS_DEFAULT_IMPLICIT_CLASSES; ImplicitAnyClasses = FALSE; HideImplicitMembers = TRUE; KeepAlive = TRUE; KeepAliveTimeout = DEFAULT_KEEPALIVE; ListenBackLog = SOMAXCONN; - LogFilePerm = 0644; + LogFilePerm = CUPS_DEFAULT_LOG_FILE_PERM; LogLevel = CUPSD_LOG_ERROR; MaxClients = 100; MaxClientsPerHost = 0; @@ -421,12 +421,12 @@ cupsdReadConfiguration(void) BrowseInterval = DEFAULT_INTERVAL; BrowsePort = ippPort(); - BrowseLocalProtocols = BROWSE_CUPS; - BrowseRemoteProtocols = BROWSE_CUPS; - BrowseShortNames = TRUE; + BrowseLocalProtocols = BROWSE_CUPS; /* TODO: Use configure option */ + BrowseRemoteProtocols = BROWSE_CUPS; /* TODO: Use configure option */ + BrowseShortNames = CUPS_DEFAULT_BROWSE_SHORT_NAMES; BrowseTimeout = DEFAULT_TIMEOUT; - Browsing = TRUE; - DefaultShared = TRUE; /* TODO: Add configure option */ + Browsing = CUPS_DEFAULT_BROWSING; + DefaultShared = CUPS_DEFAULT_DEFAULT_SHARED; cupsdClearString(&BrowseLocalOptions); cupsdClearString(&BrowseRemoteOptions); @@ -3122,5 +3122,5 @@ read_policy(cups_file_t *fp, /* I - Configuration file */ /* - * End of "$Id: conf.c 5001 2006-01-26 23:39:23Z mike $". + * End of "$Id: conf.c 5008 2006-01-27 19:30:34Z mike $". */ diff --git a/scheduler/cupsd.h b/scheduler/cupsd.h index 1152838cdb..7380c3dcd5 100644 --- a/scheduler/cupsd.h +++ b/scheduler/cupsd.h @@ -1,5 +1,5 @@ /* - * "$Id: cupsd.h 4903 2006-01-10 20:02:46Z mike $" + * "$Id: cupsd.h 5007 2006-01-27 18:25:42Z mike $" * * Main header file for the Common UNIX Printing System (CUPS) scheduler. * @@ -121,6 +121,7 @@ extern const char *cups_hstrerror(int); * Other stuff for the scheduler... */ +#include "sysman.h" #include "statbuf.h" #include "cert.h" #include "auth.h" @@ -197,5 +198,5 @@ extern int cupsdStartProcess(const char *command, char *argv[], /* - * End of "$Id: cupsd.h 4903 2006-01-10 20:02:46Z mike $". + * End of "$Id: cupsd.h 5007 2006-01-27 18:25:42Z mike $". */ diff --git a/scheduler/dirsvc.c b/scheduler/dirsvc.c index c218a94ae9..893ca6145a 100644 --- a/scheduler/dirsvc.c +++ b/scheduler/dirsvc.c @@ -1,5 +1,5 @@ /* - * "$Id: dirsvc.c 4906 2006-01-10 20:53:28Z mike $" + * "$Id: dirsvc.c 5008 2006-01-27 19:30:34Z mike $" * * Directory services routines for the Common UNIX Printing System (CUPS). * @@ -1704,56 +1704,59 @@ cupsdStartBrowsing(void) if ((BrowseLocalProtocols | BrowseRemoteProtocols) & BROWSE_CUPS) { - /* - * Create the broadcast socket... - */ - - if ((BrowseSocket = socket(AF_INET, SOCK_DGRAM, 0)) < 0) + if (BrowseSocket < 0) { - cupsdLogMessage(CUPSD_LOG_ERROR, - "cupsdStartBrowsing: Unable to create broadcast socket - %s.", - strerror(errno)); - BrowseLocalProtocols &= ~BROWSE_CUPS; - BrowseRemoteProtocols &= ~BROWSE_CUPS; - return; - } + /* + * Create the broadcast socket... + */ - /* - * Set the "broadcast" flag... - */ + if ((BrowseSocket = socket(AF_INET, SOCK_DGRAM, 0)) < 0) + { + cupsdLogMessage(CUPSD_LOG_ERROR, + "cupsdStartBrowsing: Unable to create broadcast " + "socket - %s.", strerror(errno)); + BrowseLocalProtocols &= ~BROWSE_CUPS; + BrowseRemoteProtocols &= ~BROWSE_CUPS; + return; + } - val = 1; - if (setsockopt(BrowseSocket, SOL_SOCKET, SO_BROADCAST, &val, sizeof(val))) - { - cupsdLogMessage(CUPSD_LOG_ERROR, - "cupsdStartBrowsing: Unable to set broadcast mode - %s.", - strerror(errno)); + /* + * Bind the socket to browse port... + */ + + memset(&addr, 0, sizeof(addr)); + addr.sin_addr.s_addr = htonl(INADDR_ANY); + addr.sin_family = AF_INET; + addr.sin_port = htons(BrowsePort); + + if (bind(BrowseSocket, (struct sockaddr *)&addr, sizeof(addr))) + { + cupsdLogMessage(CUPSD_LOG_ERROR, + "cupsdStartBrowsing: Unable to bind broadcast " + "socket - %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; + return; + } } /* - * Bind the socket to browse port... + * Set the "broadcast" flag... */ - memset(&addr, 0, sizeof(addr)); - addr.sin_addr.s_addr = htonl(INADDR_ANY); - addr.sin_family = AF_INET; - addr.sin_port = htons(BrowsePort); - - if (bind(BrowseSocket, (struct sockaddr *)&addr, sizeof(addr))) + val = 1; + if (setsockopt(BrowseSocket, SOL_SOCKET, SO_BROADCAST, &val, sizeof(val))) { cupsdLogMessage(CUPSD_LOG_ERROR, - "cupsdStartBrowsing: Unable to bind broadcast socket - %s.", + "cupsdStartBrowsing: Unable to set broadcast mode - %s.", strerror(errno)); #ifdef WIN32 @@ -1924,27 +1927,25 @@ cupsdStopBrowsing(void) if (!Browsing || !(BrowseLocalProtocols | BrowseRemoteProtocols)) return; - if ((BrowseLocalProtocols | BrowseRemoteProtocols) & BROWSE_CUPS) + if (((BrowseLocalProtocols | BrowseRemoteProtocols) & BROWSE_CUPS) && + BrowseSocket >= 0) { /* * Close the socket and remove it from the input selection set. */ - if (BrowseSocket >= 0) - { #ifdef WIN32 - closesocket(BrowseSocket); + closesocket(BrowseSocket); #else - close(BrowseSocket); + close(BrowseSocket); #endif /* WIN32 */ - cupsdLogMessage(CUPSD_LOG_DEBUG2, - "cupsdStopBrowsing: Removing fd %d from InputSet...", - BrowseSocket); + cupsdLogMessage(CUPSD_LOG_DEBUG2, + "cupsdStopBrowsing: Removing fd %d from InputSet...", + BrowseSocket); - FD_CLR(BrowseSocket, InputSet); - BrowseSocket = -1; - } + FD_CLR(BrowseSocket, InputSet); + BrowseSocket = -1; } #ifdef HAVE_LIBSLP @@ -2052,6 +2053,13 @@ cupsdUpdateCUPSBrowse(void) packet[bytes] = '\0'; + /* + * If we're about to sleep, ignore incoming browse packets. + */ + + if (Sleeping) + return; + /* * Figure out where it came from... */ @@ -2631,5 +2639,5 @@ slp_url_callback( /* - * End of "$Id: dirsvc.c 4906 2006-01-10 20:53:28Z mike $". + * End of "$Id: dirsvc.c 5008 2006-01-27 19:30:34Z mike $". */ diff --git a/scheduler/job.c b/scheduler/job.c index 0921095baa..fe7ce5e307 100644 --- a/scheduler/job.c +++ b/scheduler/job.c @@ -1,5 +1,5 @@ /* - * "$Id: job.c 4992 2006-01-26 17:50:58Z mike $" + * "$Id: job.c 5007 2006-01-27 18:25:42Z mike $" * * Job management routines for the Common UNIX Printing System (CUPS). * @@ -291,7 +291,8 @@ cupsdCheckJobs(void) * Start pending jobs if the destination is available... */ - if (job->state->values[0].integer == IPP_JOB_PENDING && !NeedReload) + if (job->state->values[0].integer == IPP_JOB_PENDING && !NeedReload && + !Sleeping) { printer = cupsdFindDest(job->dest); pclass = NULL; @@ -2685,5 +2686,5 @@ set_hold_until(cupsd_job_t *job, /* I - Job to update */ /* - * End of "$Id: job.c 4992 2006-01-26 17:50:58Z mike $". + * End of "$Id: job.c 5007 2006-01-27 18:25:42Z mike $". */ diff --git a/scheduler/main.c b/scheduler/main.c index c34a6b4602..cb14f2b376 100644 --- a/scheduler/main.c +++ b/scheduler/main.c @@ -1,5 +1,5 @@ /* - * "$Id: main.c 4997 2006-01-26 21:43:54Z mike $" + * "$Id: main.c 5007 2006-01-27 18:25:42Z mike $" * * Scheduler main loop for the Common UNIX Printing System (CUPS). * @@ -153,11 +153,22 @@ main(int argc, /* I - Number of command-line arguments */ * Relative directory... */ - char current[1024]; /* Current directory */ + char *current; /* Current directory */ - getcwd(current, sizeof(current)); + /* + * Allocate a buffer for the current working directory to + * reduce run-time stack usage; this approximates the + * behavior of some implementations of getcwd() when they + * are passed a NULL pointer. + */ + + current = malloc(1024); + getcwd(current, 1024); + cupsdSetStringf(&ConfigurationFile, "%s/%s", current, argv[i]); + + free(current); } break; @@ -429,6 +440,12 @@ main(int argc, /* I - Number of command-line arguments */ kill(i, SIGUSR1); } + /* + * Start power management framework... + */ + + cupsdStartSystemMonitor(); + /* * If the administrator has configured the server to run as an unpriviledged * user, change to that user now... @@ -611,6 +628,11 @@ main(int argc, /* I - Number of command-line arguments */ cupsdLogMessage(CUPSD_LOG_EMERG, "CGIPipes[0] = %d", CGIPipes[0]); +#ifdef __APPLE__ + cupsdLogMessage(CUPSD_LOG_EMERG, "SysEventPipes[0] = %d", + SysEventPipes[0]); +#endif /* __APPLE__ */ + for (job = (cupsd_job_t *)cupsArrayFirst(ActiveJobs); job; job = (cupsd_job_t *)cupsArrayNext(ActiveJobs)) @@ -654,6 +676,15 @@ main(int argc, /* I - Number of command-line arguments */ if (CGIPipes[0] >= 0 && FD_ISSET(CGIPipes[0], input)) cupsdUpdateCGI(); + /* + * Handle system management events as needed... + */ + +#ifdef __APPLE__ + if (SysEventPipes[0] >= 0 && FD_ISSET(SysEventPipes[0], input)) + cupsdUpdateSystemMonitor(); +#endif /* __APPLE__ */ + /* * Update notifier messages as needed... */ @@ -893,6 +924,8 @@ main(int argc, /* I - Number of command-line arguments */ cupsdStopAllJobs(); + cupsdStopSystemMonitor(); + #ifdef __sgi /* * Remove the fake IRIX lpsched lock file, but only if the existing @@ -1551,5 +1584,5 @@ usage(void) /* - * End of "$Id: main.c 4997 2006-01-26 21:43:54Z mike $". + * End of "$Id: main.c 5007 2006-01-27 18:25:42Z mike $". */ diff --git a/scheduler/sysman.c b/scheduler/sysman.c new file mode 100644 index 0000000000..7718cb3850 --- /dev/null +++ b/scheduler/sysman.c @@ -0,0 +1,748 @@ +/* + * "$Id: sysman.c 5007 2006-01-27 18:25:42Z mike $" + * + * System management definitions for the Common UNIX Printing System (CUPS). + * + * Copyright 2006 by Easy Software Products. + * + * These coded instructions, statements, and computer programs are the + * property of Easy Software Products and are protected by Federal + * copyright law. Distribution and use rights are outlined in the file + * "LICENSE.txt" which should have been included with this file. If this + * file is missing or damaged please contact Easy Software Products + * at: + * + * Attn: CUPS Licensing Information + * Easy Software Products + * 44141 Airport View Drive, Suite 204 + * Hollywood, Maryland 20636 USA + * + * Voice: (301) 373-9600 + * EMail: cups-info@cups.org + * WWW: http://www.cups.org + * + * Contents: + * + * cupsdStartSystemMonitor() - Start monitoring for system change. + * cupsdStopSystemMonitor() - Stop monitoring for system change. + * cupsdUpdateSystemMonitor() - Update the current system state. + * sysEventThreadEntry() - A thread to receive power and computer + * name change notifications. + * sysEventPowerNotifier() - Handle power notification events. + * sysEventConfigurationNotifier() - Computer name changed notification + * callback. + * sysEventTimerNotifier() - Handle delayed event notifications. + */ + + +/* + * Include necessary headers... + */ + +#include "cupsd.h" + + +/* + * Power management is a new addition to CUPS. Right now it is only + * implemented on MacOS X, but essentially we use these three functions + * to let the OS know when it is OK to put the system to sleep, typically + * when we are not in the middle of printing a job. + * + * Once put to sleep, we invalidate all remote printers since it is + * common to wake up in a new location. + */ + +#ifndef __APPLE__ +/* + * 'cupsdStartSystemMonitor()' - Start monitoring for system change. + */ + +void +cupsdStartSystemMonitor(void) +{ +} + + +/* + * 'cupsdStopSystemMonitor()' - Stop monitoring for system change. + */ + +void +cupsdStopSystemMonitor(void) +{ +} + + +/* + * 'cupsdUpdateSystemMonitor()' - Update the current system state. + */ + +void +cupsdUpdateSystemMonitor(void) +{ +} +#endif /* !__APPLE__ */ + + +#ifdef __APPLE__ +/* + * This is the Apple-specific system event code. It works by creating + * a worker thread that waits for events from the OS and relays them + * to the main thread via a traditional pipe. + */ + +/* + * Include MacOS-specific headers... + */ + +# include +# include +# include +# include +# include + + +/* + * Constants... + */ + +#define SYSEVENT_CANSLEEP 0x1 /* Decide whether to allow sleep or not */ +#define SYSEVENT_WILLSLEEP 0x2 /* Computer will go to sleep */ +#define SYSEVENT_WOKE 0x4 /* Computer woke from sleep */ +#define SYSEVENT_NETCHANGED 0x8 /* Network changed */ +#define SYSEVENT_NAMECHANGED 0x10 /* Computer name changed */ + + +/* + * Structures... + */ + +typedef struct cupsd_sysevent_s /*** System event data ****/ +{ + unsigned char event; /* Event bit field */ + io_connect_t powerKernelPort; /* Power context data */ + long powerNotificationID; /* Power event data */ +} cupsd_sysevent_t; + + +typedef struct cupsd_thread_data_s /*** Thread context data ****/ +{ + cupsd_sysevent_t sysevent; /* System event */ + CFRunLoopTimerRef timerRef; /* Timer to delay some change * + * notifications */ +} cupsd_thread_data_t; + + +/* + * Local globals... + */ + +static pthread_t SysEventThread = NULL; + /* Thread to host a runloop */ +static pthread_mutex_t SysEventThreadMutex = { 0 }; + /* Coordinates access to shared gloabals */ +static pthread_cond_t SysEventThreadCond = { 0 }; + /* Thread initialization complete condition */ +static CFRunLoopRef SysEventRunloop = NULL; + /* The runloop. Access must be protected! */ +static CFStringRef ComputerNameKey = NULL, + /* Computer name key */ + NetworkGlobalKey = NULL, + /* Network global key */ + HostNamesKey = NULL, + /* Host name key */ + NetworkInterfaceKey = NULL; + /* Netowrk interface key */ + + +/* + * Local functions... + */ + +static void *sysEventThreadEntry(void); +static void sysEventPowerNotifier(void *context, io_service_t service, + natural_t messageType, + void *messageArgument); +static void sysEventConfigurationNotifier(SCDynamicStoreRef store, + CFArrayRef changedKeys, + void *context); +static void sysEventTimerNotifier(CFRunLoopTimerRef timer, void *context); +#endif /* __APPLE__ */ + + +/* + * 'cupsdStartSystemMonitor()' - Start monitoring for system change. + */ + +void +cupsdStartSystemMonitor(void) +{ + int flags; /* fcntl flags on pipe */ + + + if (cupsdOpenPipe(SysEventPipes)) + { + cupsdLogMessage(CUPSD_LOG_ERROR, "System event monitor pipe() failed - %s!", + strerror(errno)); + return; + } + + cupsdLogMessage(CUPSD_LOG_DEBUG2, + "cupsdStartSystemMonitor: Adding fd %d to InputSet...", + SysEventPipes[0]); + FD_SET(SysEventPipes[0], InputSet); + + /* + * Set non-blocking mode on the descriptor we will be receiving notification + * events on. + */ + + flags = fcntl(SysEventPipes[0], F_GETFL, 0); + fcntl(SysEventPipes[0], F_SETFL, flags | O_NONBLOCK); + + /* + * Start the thread that runs the runloop... + */ + + pthread_mutex_init(&SysEventThreadMutex, NULL); + pthread_cond_init(&SysEventThreadCond, NULL); + pthread_create(&SysEventThread, NULL, (void *(*)())sysEventThreadEntry, NULL); +} + + +/* + * 'cupsdStopSystemMonitor()' - Stop monitoring for system change. + */ + +void +cupsdStopSystemMonitor(void) +{ + CFRunLoopRef rl; /* The event handler runloop */ + + + if (SysEventThread) + { + /* + * Make sure the thread has completed it's initialization and + * stored it's runloop reference in the shared global. + */ + + pthread_mutex_lock(&SysEventThreadMutex); + + if (!SysEventRunloop) + pthread_cond_wait(&SysEventThreadCond, &SysEventThreadMutex); + + rl = SysEventRunloop; + SysEventRunloop = NULL; + + pthread_mutex_unlock(&SysEventThreadMutex); + + if (rl) + CFRunLoopStop(rl); + + pthread_join(SysEventThread, NULL); + pthread_mutex_destroy(&SysEventThreadMutex); + pthread_cond_destroy(&SysEventThreadCond); + } + + if (SysEventPipes[0] >= 0) + { + cupsdLogMessage(CUPSD_LOG_DEBUG2, + "cupsdStopSystemMonitor: Removing fd %d from InputSet...", + SysEventPipes[0]); + + FD_CLR(SysEventPipes[0], InputSet); + + cupsdClosePipe(SysEventPipes); + } +} + + +/* + * 'cupsdUpdateSystemMonitor()' - Update the current system state. + */ + +void +cupsdUpdateSystemMonitor(void) +{ + cupsd_sysevent_t sysevent; /* The system event */ + cupsd_printer_t *p; /* Printer information */ + + + /* + * Drain the event pipe... + */ + + while (read((int)SysEventPipes[0], &sysevent, sizeof(sysevent)) + == sizeof(sysevent)) + { + if (sysevent.event & SYSEVENT_CANSLEEP) + { + /* + * If there are any active printers cancel the sleep request... + */ + + for (p = (cupsd_printer_t *)cupsArrayFirst(Printers); + p; + p = (cupsd_printer_t *)cupsArrayNext(Printers)) + if (p->job) + break; + + if (p) + { + cupsdLogMessage(CUPSD_LOG_INFO, + "System sleep canceled because printer %s is active", + p->name); + IOCancelPowerChange(sysevent.powerKernelPort, + sysevent.powerNotificationID); + } + else + { + cupsdLogMessage(CUPSD_LOG_DEBUG, "System wants to sleep"); + IOAllowPowerChange(sysevent.powerKernelPort, + sysevent.powerNotificationID); + } + } + + if (sysevent.event & SYSEVENT_WILLSLEEP) + { + cupsdLogMessage(CUPSD_LOG_DEBUG, "System going to sleep"); + + Sleeping = 1; + + cupsdStopAllJobs(); + + for (p = (cupsd_printer_t *)cupsArrayFirst(Printers); + p; + p = (cupsd_printer_t *)cupsArrayNext(Printers)) + { + if (p->type & CUPS_PRINTER_REMOTE) + { + cupsdLogMessage(CUPSD_LOG_DEBUG, + "Deleting remote destination \"%s\"", p->name); + cupsArraySave(Printers); + cupsdDeletePrinter(p, 0); + cupsArrayRestore(Printers); + } + else + { + /* TODO: Possibly update when MDNS support is added? */ + cupsdLogMessage(CUPSD_LOG_DEBUG, + "Deregistering local printer \"%s\"", p->name); + cupsdSendBrowseDelete(p); + } + } + + IOAllowPowerChange(sysevent.powerKernelPort, + sysevent.powerNotificationID); + } + + if (sysevent.event & SYSEVENT_WOKE) + { + cupsdLogMessage(CUPSD_LOG_DEBUG, "System woke from sleep"); + IOAllowPowerChange(sysevent.powerKernelPort, + sysevent.powerNotificationID); + Sleeping = 0; + cupsdCheckJobs(); + } + + if (sysevent.event & SYSEVENT_NETCHANGED) + { + if (!Sleeping) + { + cupsdLogMessage(CUPSD_LOG_DEBUG, + "System network configuration changed"); + + /* + * Force an update of the list of network interfaces in 2 seconds. + */ + + NetIFTime = time(NULL) - 58; + + /* + * Resetting browse_time before calling cupsdSendBrowseList causes + * browse packets to be sent for local shared printers. + */ + + for (p = (cupsd_printer_t *)cupsArrayFirst(Printers); + p; + p = (cupsd_printer_t *)cupsArrayNext(Printers)) + p->browse_time = 0; + + cupsdSendBrowseList(); + } + else + cupsdLogMessage(CUPSD_LOG_DEBUG, + "System network configuration changed; " + "ignored while sleeping"); + } + + if (sysevent.event & SYSEVENT_NAMECHANGED) + { + if (!Sleeping) + { + cupsdLogMessage(CUPSD_LOG_DEBUG, "Computer name changed"); + + /* + * De-register the individual printers... + */ + + for (p = (cupsd_printer_t *)cupsArrayFirst(Printers); + p; + p = (cupsd_printer_t *)cupsArrayNext(Printers)) + cupsdSendBrowseDelete(p); + + /* + * Now re-register them... + * + * TODO: This might need updating for MDNS. + */ + + for (p = (cupsd_printer_t *)cupsArrayFirst(Printers); + p; + p = (cupsd_printer_t *)cupsArrayNext(Printers)) + p->browse_time = 0; + } + else + cupsdLogMessage(CUPSD_LOG_DEBUG, + "Computer name changed; ignored while sleeping"); + } + } +} + + +/* + * 'sysEventThreadEntry()' - A thread to receive power and computer name + * change notifications. + */ + +static void * /* O - Return status/value */ +sysEventThreadEntry(void) +{ + io_object_t powerNotifierObj; + /* Power notifier object */ + IONotificationPortRef powerNotifierPort; + /* Power notifier port */ + SCDynamicStoreRef store = NULL;/* System Config dynamic store */ + CFRunLoopSourceRef powerRLS = NULL,/* Power runloop source */ + storeRLS = NULL;/* System Config runloop source */ + CFStringRef key[3], /* System Config keys */ + pattern[1]; /* System Config patterns */ + CFArrayRef keys = NULL, /* System Config key array*/ + patterns = NULL;/* System Config pattern array */ + SCDynamicStoreContext storeContext; /* Dynamic store context */ + CFRunLoopTimerContext timerContext; /* Timer context */ + cupsd_thread_data_t threadData; /* Thread context data for the * + * runloop notifiers */ + + + /* + * Register for power state change notifications + */ + + bzero(&threadData, sizeof(threadData)); + + threadData.sysevent.powerKernelPort = + IORegisterForSystemPower(&threadData, &powerNotifierPort, + sysEventPowerNotifier, &powerNotifierObj); + + if (threadData.sysevent.powerKernelPort) + { + powerRLS = IONotificationPortGetRunLoopSource(powerNotifierPort); + CFRunLoopAddSource(CFRunLoopGetCurrent(), powerRLS, kCFRunLoopDefaultMode); + } + else + DEBUG_puts("sysEventThreadEntry: error registering for system power " + "notifications"); + + /* + * Register for system configuration change notifications + */ + + bzero(&storeContext, sizeof(storeContext)); + storeContext.info = &threadData; + + store = SCDynamicStoreCreate(NULL, CFSTR("cupsd"), + sysEventConfigurationNotifier, &storeContext); + + if (!ComputerNameKey) + ComputerNameKey = SCDynamicStoreKeyCreateComputerName(NULL); + + if (!NetworkGlobalKey) + NetworkGlobalKey = + SCDynamicStoreKeyCreateNetworkGlobalEntity(NULL, + kSCDynamicStoreDomainState, + kSCEntNetIPv4); + + if (!HostNamesKey) + HostNamesKey = SCDynamicStoreKeyCreateHostNames(NULL); + + if (!NetworkInterfaceKey) + NetworkInterfaceKey = + SCDynamicStoreKeyCreateNetworkInterfaceEntity(NULL, + kSCDynamicStoreDomainState, + kSCCompAnyRegex, + kSCEntNetIPv4); + + if (store && ComputerNameKey && NetworkGlobalKey && HostNamesKey && + NetworkInterfaceKey) + { + key[0] = ComputerNameKey; + key[1] = NetworkGlobalKey; + key[2] = HostNamesKey; + pattern[0] = NetworkInterfaceKey; + + keys = CFArrayCreate(NULL, (const void **)key, + sizeof(key) / sizeof(key[0]), + &kCFTypeArrayCallBacks); + patterns = CFArrayCreate(NULL, (const void **)pattern, + sizeof(pattern) / sizeof(pattern[0]), + &kCFTypeArrayCallBacks); + + if (keys && patterns && + SCDynamicStoreSetNotificationKeys(store, keys, patterns)) + { + if ((storeRLS = SCDynamicStoreCreateRunLoopSource(NULL, store, 0)) + != NULL) + { + CFRunLoopAddSource(CFRunLoopGetCurrent(), storeRLS, + kCFRunLoopDefaultMode); + } + else + DEBUG_printf(("sysEventThreadEntry: SCDynamicStoreCreateRunLoopSource " + "failed: %s\n", SCErrorString(SCError()))); + } + else + DEBUG_printf(("sysEventThreadEntry: SCDynamicStoreSetNotificationKeys " + "failed: %s\n", SCErrorString(SCError()))); + } + else + DEBUG_printf(("sysEventThreadEntry: SCDynamicStoreCreate failed: %s\n", + SCErrorString(SCError()))); + + if (keys) + CFRelease(keys); + + if (patterns) + CFRelease(patterns); + + /* + * Set up a timer to delay the wake change notifications. + * + * The initial time is set a decade or so into the future, we'll adjust + * this later. + */ + + bzero(&timerContext, sizeof(timerContext)); + timerContext.info = &threadData; + + threadData.timerRef = + CFRunLoopTimerCreate(NULL, + CFAbsoluteTimeGetCurrent() + (86400L * 365L * 10L), + 86400L * 365L * 10L, 0, 0, sysEventTimerNotifier, + &timerContext); + CFRunLoopAddTimer(CFRunLoopGetCurrent(), threadData.timerRef, + kCFRunLoopDefaultMode); + + /* + * Store our runloop in a global so the main thread can use it to stop us. + */ + + pthread_mutex_lock(&SysEventThreadMutex); + + SysEventRunloop = CFRunLoopGetCurrent(); + + pthread_cond_signal(&SysEventThreadCond); + pthread_mutex_unlock(&SysEventThreadMutex); + + /* + * Disappear into the runloop until it's stopped by the main thread. + */ + + CFRunLoopRun(); + + /* + * Clean up before exiting. + */ + + if (threadData.timerRef) + { + CFRunLoopRemoveTimer(CFRunLoopGetCurrent(), threadData.timerRef, + kCFRunLoopDefaultMode); + CFRelease(threadData.timerRef); + } + + if (threadData.sysevent.powerKernelPort) + { + CFRunLoopRemoveSource(CFRunLoopGetCurrent(), powerRLS, + kCFRunLoopDefaultMode); + IODeregisterForSystemPower(&powerNotifierObj); + IOServiceClose(threadData.sysevent.powerKernelPort); + IONotificationPortDestroy(powerNotifierPort); + } + + if (storeRLS) + { + CFRunLoopRemoveSource(CFRunLoopGetCurrent(), storeRLS, + kCFRunLoopDefaultMode); + CFRunLoopSourceInvalidate(storeRLS); + CFRelease(storeRLS); + } + + if (store) + CFRelease(store); + + pthread_exit(NULL); +} + + +/* + * 'sysEventPowerNotifier()' - Handle power notification events. + */ + +static void +sysEventPowerNotifier( + void *context, /* I - Thread context data */ + io_service_t service, /* I - Unused service info */ + natural_t messageType, /* I - Type of message */ + void *messageArgument) /* I - Message data */ +{ + int sendit = 1; /* Send event to main thread? * + * (0 = no, 1 = yes, 2 = delayed */ + cupsd_thread_data_t *threadData; /* Thread context data */ + + + threadData = (cupsd_thread_data_t *)context; + + (void)service; /* anti-compiler-warning-code */ + + switch (messageType) + { + case kIOMessageCanSystemPowerOff: + case kIOMessageCanSystemSleep: + threadData->sysevent.event |= SYSEVENT_CANSLEEP; + break; + + case kIOMessageSystemWillRestart: + case kIOMessageSystemWillPowerOff: + case kIOMessageSystemWillSleep: + threadData->sysevent.event |= SYSEVENT_WILLSLEEP; + break; + + case kIOMessageSystemHasPoweredOn: + /* + * Because powered on is followed by a net-changed event, delay + * before sending it. + */ + + sendit = 2; + threadData->sysevent.event |= SYSEVENT_WOKE; + break; + + case kIOMessageSystemWillNotPowerOff: + case kIOMessageSystemWillNotSleep: + case kIOMessageSystemWillPowerOn: + default: + sendit = 0; + break; + } + + if (sendit == 0) + IOAllowPowerChange(threadData->sysevent.powerKernelPort, + (long)messageArgument); + else + { + threadData->sysevent.powerNotificationID = (long)messageArgument; + + if (sendit == 1) + { + /* + * Send the event to the main thread now. + */ + + write(SysEventPipes[1], &threadData->sysevent, + sizeof(threadData->sysevent)); + threadData->sysevent.event = 0; + } + else + { + /* + * Send the event to the main thread after 1 to 2 seconds. + */ + + CFRunLoopTimerSetNextFireDate(threadData->timerRef, + CFAbsoluteTimeGetCurrent() + 2); + } + } +} + + +/* + * 'sysEventConfigurationNotifier()' - Computer name changed notification + * callback. + */ + +static void +sysEventConfigurationNotifier( + SCDynamicStoreRef store, /* I - System data (unused) */ + CFArrayRef changedKeys, /* I - Changed data */ + void *context) /* I - Thread context data */ +{ + cupsd_thread_data_t *threadData; /* Thread context data */ + + + threadData = (cupsd_thread_data_t *)context; + + (void)store; /* anti-compiler-warning-code */ + + CFRange range = CFRangeMake(0, CFArrayGetCount(changedKeys)); + + if (CFArrayContainsValue(changedKeys, range, ComputerNameKey)) + threadData->sysevent.event |= SYSEVENT_NAMECHANGED; + + if (CFArrayContainsValue(changedKeys, range, NetworkGlobalKey) || + CFArrayContainsValue(changedKeys, range, HostNamesKey) || + CFArrayContainsValue(changedKeys, range, NetworkInterfaceKey)) + threadData->sysevent.event |= SYSEVENT_NETCHANGED; + + /* + * Because we registered for several different kinds of change notifications + * this callback usually gets called several times in a row. We use a timer to + * de-bounce these so we only end up generating one event for the main thread. + */ + + CFRunLoopTimerSetNextFireDate(threadData->timerRef, + CFAbsoluteTimeGetCurrent() + 2); +} + + +/* + * 'sysEventTimerNotifier()' - Handle delayed event notifications. + */ + +static void +sysEventTimerNotifier( + CFRunLoopTimerRef timer, /* I - Timer information */ + void *context) /* I - Thread context data */ +{ + cupsd_thread_data_t *threadData; /* Thread context data */ + + + threadData = (cupsd_thread_data_t *)context; + + /* + * If an event is still pending send it to the main thread. + */ + + if (threadData->sysevent.event) + { + write(SysEventPipes[1], &threadData->sysevent, + sizeof(threadData->sysevent)); + threadData->sysevent.event = 0; + } +} + + +/* + * End of "$Id: sysman.c 5007 2006-01-27 18:25:42Z mike $". + */ diff --git a/scheduler/sysman.h b/scheduler/sysman.h new file mode 100644 index 0000000000..3119b134b2 --- /dev/null +++ b/scheduler/sysman.h @@ -0,0 +1,49 @@ +/* + * "$Id: sysman.h 5007 2006-01-27 18:25:42Z mike $" + * + * System management definitions for the Common UNIX Printing System (CUPS). + * + * Copyright 2006 by Easy Software Products. + * + * These coded instructions, statements, and computer programs are the + * property of Easy Software Products and are protected by Federal + * copyright law. Distribution and use rights are outlined in the file + * "LICENSE.txt" which should have been included with this file. If this + * file is missing or damaged please contact Easy Software Products + * at: + * + * Attn: CUPS Licensing Information + * Easy Software Products + * 44141 Airport View Drive, Suite 204 + * Hollywood, Maryland 20636 USA + * + * Voice: (301) 373-9600 + * EMail: cups-info@cups.org + * WWW: http://www.cups.org + */ + +/* + * Globals... + */ + +VAR int Sleeping VALUE(0); + /* Non-zero if machine is entering or * + * in a sleep state... */ +#ifdef __APPLE__ +VAR int SysEventPipes[2] VALUE2(-1,-1); + /* System event notification pipes */ +#endif /* __APPLE__ */ + + +/* + * Prototypes... + */ + +extern void cupsdStartSystemMonitor(void); +extern void cupsdStopSystemMonitor(void); +extern void cupsdUpdateSystemMonitor(void); + + +/* + * End of "$Id: sysman.h 5007 2006-01-27 18:25:42Z mike $". + */ diff --git a/templates/header.tmpl b/templates/header.tmpl.in similarity index 98% rename from templates/header.tmpl rename to templates/header.tmpl.in index 7f5ab2375f..bba6e90c20 100644 --- a/templates/header.tmpl +++ b/templates/header.tmpl.in @@ -2,7 +2,7 @@ - {title} - {cups_version} + {title} - @CUPS_VERSION@ diff --git a/tools/testosx b/tools/testosx index d96e9f472c..8729d53cf9 100755 --- a/tools/testosx +++ b/tools/testosx @@ -25,10 +25,6 @@ rm -rf $pkgdir mkdir -p $pkgdir/Package mkdir -p $pkgdir/Resources -# Install CUPS into the Package directory... -#make INSTALL=$topdir/install-sh BUILDROOT=$pkgdir/Package install -make BUILDROOT=$pkgdir/Package install - # Install resource files into the Resources directory... echo Installing resource files... cp packaging/LICENSE.rtf $pkgdir/Resources/ReadMe.rtf @@ -56,6 +52,12 @@ sed -e '1,$s/@CUPS_VERSION@/1.2svn-r'$rev'/g' \ packaging/cups-info.plist sed -e '1,$s/@CUPS_VERSION@/1.2svn-r'$rev'/g' \ doc/index.html +sed -e '1,$s/@CUPS_VERSION@/1.2svn-r'$rev'/g' \ + templates/header.tmpl + +# Install CUPS into the Package directory... +#make INSTALL=$topdir/install-sh BUILDROOT=$pkgdir/Package install +make BUILDROOT=$pkgdir/Package install # Figure out where PackageMaker is installled... if test -d /Developer/Applications/Utilities/PackageMaker.app; then