summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDidier Raboud <odyx@debian.org>2014-10-23 18:25:31 +0200
committerDidier Raboud <odyx@debian.org>2014-10-23 18:25:43 +0200
commitaaccc3689a6b2cfa95602dcb5ea969ce6e0af06b (patch)
tree29fe5062d42a6ac6c91883856e442cc5c36aa9b8
parent0924759faf088676d7a138c09783a4483691f4a3 (diff)
downloadcups-aaccc3689a6b2cfa95602dcb5ea969ce6e0af06b.tar.gz
Default back to not socket-activating CUPS
- Drop patch to let CUPS write the systemd.socket configuration files - Replace preinst generation of the same configuration file, delete them on upgrade - Drop the symlink enforcing the automatic configuration Closes: #747073 Git-Dch: Full
-rw-r--r--debian/cups-daemon.links1
-rw-r--r--debian/cups-daemon.preinst44
-rw-r--r--debian/patches/cupsd-write-systemd-Port.patch281
-rw-r--r--debian/patches/series1
4 files changed, 6 insertions, 321 deletions
diff --git a/debian/cups-daemon.links b/debian/cups-daemon.links
index be96c8d1..7b1aaff6 100644
--- a/debian/cups-daemon.links
+++ b/debian/cups-daemon.links
@@ -1,2 +1 @@
-etc/cups/cupsd-systemd-listen.conf etc/systemd/system/cups.socket.d/cupsd-listen.conf
/usr/share/doc/libcups2/README.Debian.gz /usr/share/doc/cups-daemon/README.Debian.gz
diff --git a/debian/cups-daemon.preinst b/debian/cups-daemon.preinst
index 63087f06..7280bd4c 100644
--- a/debian/cups-daemon.preinst
+++ b/debian/cups-daemon.preinst
@@ -10,45 +10,13 @@ install|upgrade)
mv /etc/cups/cupsd.conf /etc/cups/cupsd.conf.conffile-bak
fi
- # If file doesn't exist, has two conflicting stanzas or has a "listen-to-all" while cupsd.conf says it should 'listen-to-localhost'
- if [ ! -f /etc/cups/cupsd-systemd-listen.conf ] || \
- ( grep -q '^ListenStream=0.0.0.0:' /etc/cups/cupsd-systemd-listen.conf 2>/dev/null && \
- grep -q '^ListenStream=127.0.0.1:' /etc/cups/cupsd-systemd-listen.conf 2>/dev/null ) ||
- ( grep -q '^ListenStream=0.0.0.0:' /etc/cups/cupsd-systemd-listen.conf 2>/dev/null && \
- grep -q '^\s*Listen localhost:' /etc/cups/cupsd.conf 2>/dev/null );\
- then
- mkdir -p /etc/cups
- cat >/etc/cups/cupsd-systemd-listen.conf <<EOF
-[Socket]
-# This file was generated by CUPS and _WILL_ be deleted or overwritten by it!
-# It has to be kept in sync with the Port and Listen stanzas in /etc/cups/cupsd.conf
-# It is by default symlinked as cups-listen.conf in the
-# /etc/systemd/system/cups.socket.d/ directory. Remove the symlink
-# and write your own file there if you don't want this. See systemd.socket(5).
-EOF
- if [ -e /etc/cups/cupsd.conf ]; then
- if grep -q '^\s*Port' /etc/cups/cupsd.conf 2>/dev/null; then
- localport=`grep '^\s*Port' /etc/cups/cupsd.conf | head -n1 | sed -e 's/.*Port \([[:digit:]]*\)$/\1/'`
- cat >>/etc/cups/cupsd-systemd-listen.conf <<EOF
-# Matches 'Port $localport' from cupsd.conf
-ListenStream=0.0.0.0:$localport
-ListenStream=[::]:$localport
-EOF
- elif grep -q '^\s*Listen localhost:' /etc/cups/cupsd.conf 2>/dev/null; then
- localport=`grep '^\s*Listen localhost:' /etc/cups/cupsd.conf | head -n1 | sed -e 's/.*localhost\:\([[:digit:]]*\)$/\1/'`
- cat >>/etc/cups/cupsd-systemd-listen.conf <<EOF
-# Matches 'Listen localhost:$localport' from cupsd.conf
-ListenStream=127.0.0.1:$localport
-ListenStream=[::1]:$localport
-EOF
+ if dpkg --compare-versions "$2" le "1.7.5-7~"; then
+ # Delete cupsd-systemd-listen configuration files once used to socket-activate CUPS
+ for csl in cupsd-systemd-listen.conf cupsd-systemd-listen.conf.0; do
+ if [ -e /etc/cups/$csl ]; then
+ rm -f /etc/cups/$csl
fi
- else
- cat >>/etc/cups/cupsd-systemd-listen.conf <<EOF
-# Matches the default 'Listen localhost:631' from cupsd.conf.default
-ListenStream=127.0.0.1:631
-ListenStream=[::1]:631
-EOF
- fi
+ done
fi
esac
diff --git a/debian/patches/cupsd-write-systemd-Port.patch b/debian/patches/cupsd-write-systemd-Port.patch
deleted file mode 100644
index 8e9e5010..00000000
--- a/debian/patches/cupsd-write-systemd-Port.patch
+++ /dev/null
@@ -1,281 +0,0 @@
-Description: When using the webinterface to widen or shrink the range of
- IPs that cupsd will listen to, also write systemd-compatible socket
- unit configuration.
- .
- When this file is written by the scheduler, also reload the systemd
- daemon and let systemd restart the cups.socket. This makes sure that
- systemd is always the owner of the ports and enables socket activation
- through all the ports that cupsd listens to.
- .
- This is enabled throught the cupsd-listen.conf symlink to
- /etc/cups/cupsd-systemd-listen.conf in the
- /etc/systemd/system/cups.socket.d/ directory.
-Author: Didier Raboud <odyx@debian.org>
-Bug-Debian: https://bugs.debian.org/740382
-Last-Update: 2014-03-05
---- a/cups/adminutil.c
-+++ b/cups/adminutil.c
-@@ -1209,6 +1209,8 @@
- cups_option_t *cupsd_settings, /* New settings */
- *setting; /* Current setting */
- _cups_globals_t *cg = _cupsGlobals(); /* Global data */
-+ char tempfiled[1024]; /* Temporary new cupsd-systemd-listen.conf */
-+ cups_file_t *systemdlistenconf; /* cupsd-systemd-listen.conf file */
-
-
- /*
-@@ -1403,6 +1405,23 @@
- }
-
- /*
-+ * Create a temporary file for the new cupsd-systemd-listen.conf...
-+ */
-+ if ((systemdlistenconf = cupsTempFile2(tempfiled, sizeof(tempfiled))) == NULL)
-+ {
-+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, NULL, 0);
-+ return (0);
-+ }
-+
-+ cupsFilePuts(systemdlistenconf,"[Socket]\n");
-+ cupsFilePuts(systemdlistenconf,"# This file was generated by CUPS and _WILL_ be deleted or overwritten by it!\n");
-+ cupsFilePuts(systemdlistenconf,"# It has to be kept in sync with the Port and Listen stanzas in /etc/cups/cupsd.conf\n");
-+ cupsFilePuts(systemdlistenconf,"# It is by default symlinked as cups-listen.conf in the\n");
-+ cupsFilePuts(systemdlistenconf,"# /etc/systemd/system/cups.socket.d/ directory. Remove the symlink\n");
-+ cupsFilePuts(systemdlistenconf,"# and write your own file there if you don't want this. See systemd.socket(5).\n");
-+
-+
-+ /*
- * Copy the old file to the new, making changes along the way...
- */
-
-@@ -1448,12 +1467,24 @@
- {
- cupsFilePuts(temp, "# Allow remote access\n");
- cupsFilePrintf(temp, "Port %d\n", server_port);
-+
-+ /* Let systemd's socket configuration listen on all port numbers */
-+ cupsFilePuts(systemdlistenconf, "# Allow remote access\n");
-+ cupsFilePrintf(systemdlistenconf, "# Matches 'Port %d' from cupsd.conf.\n",ippPort());
-+ cupsFilePrintf(systemdlistenconf, "ListenStream=0.0.0.0:%d\n", server_port);
-+ cupsFilePrintf(systemdlistenconf, "ListenStream=[::]:%d\n", server_port);
- }
- else
- {
- cupsFilePuts(temp, "# Only listen for connections from the local "
- "machine.\n");
- cupsFilePrintf(temp, "Listen localhost:%d\n", server_port);
-+
-+ /* Let systemd's socket configuration listen only on local IP addresses */
-+ cupsFilePuts(systemdlistenconf, "# Only listen for connections from the local machine.\n");
-+ cupsFilePrintf(systemdlistenconf, "# Matches 'Listen localhost:%d' from cupsd.conf.\n",ippPort());
-+ cupsFilePrintf(systemdlistenconf, "ListenStream=127.0.0.1:%d\n", server_port);
-+ cupsFilePrintf(systemdlistenconf, "ListenStream=[::1]:%d\n", server_port);
- }
-
- #ifdef CUPS_DEFAULT_DOMAINSOCKET
-@@ -1805,12 +1836,24 @@
- {
- cupsFilePuts(temp, "# Allow remote access\n");
- cupsFilePrintf(temp, "Port %d\n", ippPort());
-+
-+ /* Let systemd's socket configuration listen on all port numbers */
-+ cupsFilePuts(systemdlistenconf, "# Allow remote access\n");
-+ cupsFilePrintf(systemdlistenconf, "# Matches 'Port %d' from cupsd.conf.\n",ippPort());
-+ cupsFilePrintf(systemdlistenconf, "ListenStream=0.0.0.0:%d\n", ippPort());
-+ cupsFilePrintf(systemdlistenconf, "ListenStream=[::]:%d\n", ippPort());
- }
- else
- {
- cupsFilePuts(temp,
- "# Only listen for connections from the local machine.\n");
- cupsFilePrintf(temp, "Listen localhost:%d\n", ippPort());
-+
-+ /* Let systemd's socket configuration listen only on local IP addresses */
-+ cupsFilePuts(systemdlistenconf, "# Only listen for connections from the local machine.\n");
-+ cupsFilePrintf(systemdlistenconf, "# Matches 'Listen localhost:%d' from cupsd.conf.\n",ippPort());
-+ cupsFilePrintf(systemdlistenconf, "ListenStream=127.0.0.1:%d\n", ippPort());
-+ cupsFilePrintf(systemdlistenconf, "ListenStream=[::1]:%d\n", ippPort());
- }
-
- #ifdef CUPS_DEFAULT_DOMAINSOCKET
-@@ -1947,6 +1990,16 @@
-
- cupsFileClose(cupsd);
- cupsFileClose(temp);
-+ cupsFileClose(systemdlistenconf);
-+
-+ /*
-+ * Upload the systemd configuration file to the server...
-+ */
-+
-+ status = cupsPutFile(http, "/admin/conf/cupsd-systemd-listen.conf", tempfiled);
-+
-+ if (status == HTTP_STATUS_CREATED)
-+ {
-
- /*
- * Upload the configuration file to the server...
-@@ -2015,6 +2068,7 @@
- else
- cupsFreeOptions(cupsd_num_settings, cupsd_settings);
-
-+ }
- /*
- * Remote our temp files and return...
- */
-@@ -2023,6 +2077,7 @@
- unlink(cupsdconf);
-
- unlink(tempfile);
-+ unlink(tempfiled);
-
- return (status == HTTP_STATUS_CREATED);
- }
---- a/scheduler/client.c
-+++ b/scheduler/client.c
-@@ -1741,10 +1741,10 @@
- * Validate the resource name...
- */
-
-- if (strcmp(con->uri, "/admin/conf/cupsd.conf"))
-+ if (strcmp(con->uri, "/admin/conf/cupsd.conf") && strcmp(con->uri, "/admin/conf/cupsd-systemd-listen.conf"))
- {
- /*
-- * PUT can only be done to the cupsd.conf file...
-+ * PUT can only be done to the cupsd.conf and cupsd-systemd-listen.conf files...
- */
-
- cupsdLogMessage(CUPSD_LOG_ERROR,
-@@ -3510,6 +3510,7 @@
- *out; /* Output file */
- char buffer[16384]; /* Copy buffer */
- ssize_t bytes; /* Number of bytes */
-+ char *conffile; /* Configuration file */
-
-
- /*
-@@ -3524,17 +3525,30 @@
- }
-
- /*
-+ * Determine which configuration file we're writing
-+ */
-+
-+ if (strcmp(con->uri, "/admin/conf/cupsd.conf") == 0)
-+ {
-+ conffile = ConfigurationFile;
-+ }
-+ else if(strcmp(con->uri, "/admin/conf/cupsd-systemd-listen.conf") == 0)
-+ {
-+ conffile = SystemdConfigurationFile;
-+ }
-+
-+ /*
- * Open the new config file...
- */
-
-- if ((out = cupsdCreateConfFile(ConfigurationFile, ConfigFilePerm)) == NULL)
-+ if ((out = cupsdCreateConfFile(conffile, ConfigFilePerm)) == NULL)
- {
- cupsFileClose(in);
- return (HTTP_SERVER_ERROR);
- }
-
- cupsdLogMessage(CUPSD_LOG_INFO, "Installing config file \"%s\"...",
-- ConfigurationFile);
-+ conffile);
-
- /*
- * Copy from the request to the new config file...
-@@ -3545,12 +3559,12 @@
- {
- cupsdLogMessage(CUPSD_LOG_ERROR,
- "Unable to copy to config file \"%s\": %s",
-- ConfigurationFile, strerror(errno));
-+ conffile, strerror(errno));
-
- cupsFileClose(in);
- cupsFileClose(out);
-
-- snprintf(filename, sizeof(filename), "%s.N", ConfigurationFile);
-+ snprintf(filename, sizeof(filename), "%s.N", conffile);
- cupsdUnlinkOrRemoveFile(filename);
-
- return (HTTP_SERVER_ERROR);
-@@ -3562,7 +3576,7 @@
-
- cupsFileClose(in);
-
-- if (cupsdCloseCreatedConfFile(out, ConfigurationFile))
-+ if (cupsdCloseCreatedConfFile(out, conffile))
- return (HTTP_SERVER_ERROR);
-
- /*
-@@ -3576,8 +3590,15 @@
- * Set the NeedReload flag...
- */
-
-- NeedReload = RELOAD_CUPSD;
-- ReloadTime = time(NULL);
-+ if(conffile == ConfigurationFile)
-+ {
-+ NeedReload = RELOAD_CUPSD;
-+ ReloadTime = time(NULL);
-+ }
-+ else if(conffile == SystemdConfigurationFile)
-+ {
-+ NeedSystemdReload = 1;
-+ }
-
- /*
- * Return that the file was created successfully...
---- a/scheduler/conf.h
-+++ b/scheduler/conf.h
-@@ -100,6 +100,8 @@
- /* cupsd.conf file to use */
- *CupsFilesFile VALUE(NULL),
- /* cups-files.conf file to use */
-+ *SystemdConfigurationFile VALUE(NULL),
-+ /* cupsd-systemd-listen.conf file to use */
- *ServerName VALUE(NULL),
- /* FQDN for server */
- *ServerAdmin VALUE(NULL),
---- a/scheduler/main.c
-+++ b/scheduler/main.c
-@@ -340,6 +340,9 @@
- if (!ConfigurationFile)
- cupsdSetString(&ConfigurationFile, CUPS_SERVERROOT "/cupsd.conf");
-
-+ if (!SystemdConfigurationFile)
-+ cupsdSetString(&SystemdConfigurationFile, CUPS_SERVERROOT "/cupsd-systemd-listen.conf");
-+
- if (!CupsFilesFile)
- {
- char *filename, /* Copy of cupsd.conf filename */
-@@ -804,6 +807,15 @@
-
- #ifdef HAVE_SYSTEMD
- /*
-+ * If systemd is the init system, reload the systemd configuration
-+ */
-+ if (NeedSystemdReload) {
-+ cupsdLogMessage(CUPSD_LOG_DEBUG, "cupsd changed the systemd sockets, reload systemd and restart cups.socket");
-+ system("test -d /run/systemd/system -a -x /bin/systemctl && /bin/systemctl --system daemon-reload && /bin/systemctl restart cups.socket");
-+ NeedSystemdReload = 0;
-+ }
-+
-+ /*
- * If we were started by systemd get the listen sockets file
- * descriptors...
- */
---- a/scheduler/cupsd.h
-+++ b/scheduler/cupsd.h
-@@ -155,6 +155,8 @@
- /* Time of reload request... */
- VAR int NeedReload VALUE(RELOAD_ALL),
- /* Need to load configuration? */
-+ NeedSystemdReload VALUE(0),
-+ /* Need to reload systemd? */
- DoingShutdown VALUE(0);
- /* Shutting down the scheduler? */
- VAR void *DefaultProfile VALUE(0);
diff --git a/debian/patches/series b/debian/patches/series
index 37f68781..b84ad8a6 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -56,7 +56,6 @@ cupsd-set-default-for-SyncOnClose-to-Yes.patch
man-cups-lpd-drop-dangling-references.patch
cupsd-idleexittimeout-systemd.patch
cupsd-idleexittimeout-upstart.patch
-cupsd-write-systemd-Port.patch
lppasswd-manpage-mention-dpkg-statoverride.patch
debianize_cups-config.patch