From 6dc6691067234a6e7695304c14ed4b503f7088e0 Mon Sep 17 00:00:00 2001 From: mike Date: Fri, 27 Jan 2006 19:30:34 +0000 Subject: [PATCH] Add configure options to set the default values of various cupsd.conf settings. Fix the OSX test package script to update the web interface files before doing the install into the package directory - that way the revision number appears. Generate template/header.tmpl so that the version number is shown correctly on all pages. In cupsdStartBrowsing(), decouple the socket creation from the socket "broadcast" and "close on exec" options, since launchd will be providing the BrowseSocket for us on MacOS X. git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@5008 7a7537e8-13f0-0310-91df-b6672ffda945 --- Makedefs.in | 11 ++- conf/Makefile | 8 +- config-scripts/cups-defaults.m4 | 105 ++++++++++++++++++++++ config.h.in | 25 +++++- configure.in | 4 +- doc/help/standard.html.in | 46 +++++++++- scheduler/conf.c | 16 ++-- scheduler/dirsvc.c | 76 ++++++++-------- templates/{header.tmpl => header.tmpl.in} | 2 +- tools/testosx | 10 ++- 10 files changed, 242 insertions(+), 61 deletions(-) create mode 100644 config-scripts/cups-defaults.m4 rename templates/{header.tmpl => header.tmpl.in} (98%) diff --git a/Makedefs.in b/Makedefs.in index a945ad8db..0deab99d8 100644 --- a/Makedefs.in +++ b/Makedefs.in @@ -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... diff --git a/conf/Makefile b/conf/Makefile index e66b09e2b..d1796f918 100644 --- a/conf/Makefile +++ b/conf/Makefile @@ -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); \ diff --git a/config-scripts/cups-defaults.m4 b/config-scripts/cups-defaults.m4 new file mode 100644 index 000000000..26bfae8c7 --- /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.h.in b/config.h.in index 7faf778ce..e75436acb 100644 --- a/config.h.in +++ b/config.h.in @@ -5,7 +5,7 @@ * * @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 /* diff --git a/configure.in b/configure.in index 2eab599eb..264e678ef 100644 --- a/configure.in +++ b/configure.in @@ -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,7 +49,8 @@ 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 diff --git a/doc/help/standard.html.in b/doc/help/standard.html.in index cbfa9d328..5003acec9 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/scheduler/conf.c b/scheduler/conf.c index d9b42011d..89124846f 100644 --- a/scheduler/conf.c +++ b/scheduler/conf.c @@ -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); diff --git a/scheduler/dirsvc.c b/scheduler/dirsvc.c index e86e7003c..00fd870c4 100644 --- a/scheduler/dirsvc.c +++ b/scheduler/dirsvc.c @@ -1702,59 +1702,61 @@ cupsdStartBrowsing(void) if (!Browsing || !(BrowseLocalProtocols | BrowseRemoteProtocols)) return; - if (((BrowseLocalProtocols | BrowseRemoteProtocols) & BROWSE_CUPS) && - BrowseSocket < 0) + 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 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 7f5ab2375..bba6e90c2 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 d96e9f472..8729d53cf 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 -- 2.39.2