]> git.proxmox.com Git - systemd.git/commitdiff
Make the SysV compat tools try both /run/initctl and /dev/initctl
authorMichael Biebl <biebl@debian.org>
Tue, 24 Jun 2014 10:40:42 +0000 (12:40 +0200)
committerMichael Biebl <biebl@debian.org>
Tue, 24 Jun 2014 10:46:27 +0000 (12:46 +0200)
This makes them usable under sysvinit as PID 1 without requiring any
symlinks.

debian/changelog
debian/patches/Add-run-initctl-support-to-SysV-compat-tools.patch [new file with mode: 0644]
debian/patches/series
debian/systemd-sysv.postinst [deleted file]
debian/systemd.postinst

index 595b7b05382796b21d297d3b80b1ff334f240b3d..9907761d68bb99847c11ac27c660f8be9a510498 100644 (file)
@@ -24,6 +24,8 @@ systemd (204-11) UNRELEASED; urgency=medium
   * Use Conflicts instead of Breaks against sysvinit-core. This avoids
     /sbin/init going missing when switching from systemd-sysv to sysvinit.
     While at it, add a Replaces: upstart. (Closes: #751589)
+  * Make the SysV compat tools try both /run/initctl and /dev/initctl. This
+    makes them usable under sysvinit as PID 1 without requiring any symlinks.
 
   [ Michael Stapelberg ]
   * Clarify that “systemd” does not influence init whereas “systemd-sysv” does
diff --git a/debian/patches/Add-run-initctl-support-to-SysV-compat-tools.patch b/debian/patches/Add-run-initctl-support-to-SysV-compat-tools.patch
new file mode 100644 (file)
index 0000000..0983e43
--- /dev/null
@@ -0,0 +1,47 @@
+From: Michael Biebl <biebl@debian.org>
+Date: Tue, 24 Jun 2014 12:35:25 +0200
+Subject: Add /run/initctl support to SysV compat tools
+
+sysvinit in Debian uses /run/initctl as FIFO to communicate with PID 1.
+Make the SysV compat tools in systemd-sysv try both /run/initctl and the
+traditional /dev/initctl. This makes them usable when running sysvinit
+as PID 1.
+---
+ src/systemctl/systemctl.c | 17 +++++++++++------
+ 1 file changed, 11 insertions(+), 6 deletions(-)
+
+diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
+index 3147c4a..61d181b 100644
+--- a/src/systemctl/systemctl.c
++++ b/src/systemctl/systemctl.c
+@@ -5589,19 +5589,24 @@ static int talk_initctl(void) {
+         request.cmd = INIT_CMD_RUNLVL;
+         request.runlevel = rl;
+-        fd = open(INIT_FIFO, O_WRONLY|O_NDELAY|O_CLOEXEC|O_NOCTTY);
++        /* Try /run/initctl first since that is what sysvinit in Debian uses */
++        fd = open("/run/initctl", O_WRONLY|O_NDELAY|O_CLOEXEC|O_NOCTTY);
+         if (fd < 0) {
+-                if (errno == ENOENT)
+-                        return 0;
++                /* Fall back to /dev/initctl */
++                fd = open(INIT_FIFO, O_WRONLY|O_NDELAY|O_CLOEXEC|O_NOCTTY);
++                if (fd < 0) {
++                        if (errno == ENOENT)
++                                return 0;
+-                log_error("Failed to open "INIT_FIFO": %m");
+-                return -errno;
++                        log_error("Failed to open initctl FIFO: %m");
++                        return -errno;
++                }
+         }
+         errno = 0;
+         r = loop_write(fd, &request, sizeof(request), false) != sizeof(request);
+         if (r) {
+-                log_error("Failed to write to "INIT_FIFO": %m");
++                log_error("Failed to write to initctl FIFO: %m");
+                 return errno > 0 ? -errno : -EIO;
+         }
index 758d4826b08b568ee038169c987fa2e100855b6b..7cedf651c465465ef699828858c97323cb42d8e3 100644 (file)
@@ -57,3 +57,4 @@ rules-drivers-always-call-kmod-even-when-a-driver-is.patch
 Advertise-hibernation-only-if-there-s-enough-free-sw.patch
 journal-handle-multiline-syslog-messages.patch
 libudev-fix-memleak-when-enumerating-childs.patch
+Add-run-initctl-support-to-SysV-compat-tools.patch
diff --git a/debian/systemd-sysv.postinst b/debian/systemd-sysv.postinst
deleted file mode 100644 (file)
index 04e68f8..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/bin/sh
-
-set -e
-
-# We are installing systemd-sysv but systemd is not running.
-# This most likely means we are upgrading from another init, possibly a newer
-# sysvinit version which created the initctl socket at /run/initctl.
-# systemd's sysv tools expect the socket at /dev/initctl, so create the compat
-# symlink ourselves.
-if [ ! -d /run/systemd/system ] ; then
-    if [ ! -p /dev/initctl ] && [ -p /run/initctl ] ; then
-        ln -sf /run/initctl /dev/initctl
-    fi
-fi
-
-#DEBHELPER#
index 098ef9b0dde96963678d6d9f92bce118f03e1f3f..727aef8720c74e5eafbe21db319772dac37dd1fb 100644 (file)
@@ -80,11 +80,6 @@ if dpkg --compare-versions "$2" lt "204-8"; then
     fi
 fi
 
-# Create /run/initctl → /dev/initctl compat symlink on upgrades
-if [ -d /run/systemd/system ]; then
-    _systemctl restart systemd-initctl.socket || true
-fi
-
 if dpkg --compare-versions "$2" lt "40-1"; then
     # /lib/init/rw has been replaced by /run, so try to remove it on upgrades
     # http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=643699
@@ -92,11 +87,6 @@ if dpkg --compare-versions "$2" lt "40-1"; then
     if [ -d /lib/init/rw ]; then
         rmdir --ignore-fail-on-non-empty /lib/init/rw || true
     fi
-
-    # Create /run/initctl → /dev/initctl compat symlink on upgrades
-    if [ -d /run/systemd/system ]; then
-        ln -sf /dev/initctl /run/initctl
-    fi
 fi
 
 systemd-machine-id-setup