[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#721917: Patches fixing sysvinit issues on Debian/Hurd



Package: sysvinit
Version: 2.88dsf-43
Severity: wishlist
Tags: patch
Usertags: hurd

Dear maintainer :)

This is a patch series fixing sysvinit issues on Debian/Hurd *without*
actually switching to sysvinit as init system on Debian/Hurd as this
requires a rebuilt hurd package with recently implemented
functionality.

Thanks,
Justus
From 66a3c62db00e01ff894c7d63bf9182e1a4f2700c Mon Sep 17 00:00:00 2001
From: Justus Winter <4winter@informatik.uni-hamburg.de>
Date: Mon, 8 Jul 2013 11:41:33 +0200
Subject: [PATCH 1/6] initscripts: hurd has a proper tmpfs now, remove
 workaround

---
 debian/changelog                                   |    7 +++++++
 debian/src/initscripts/lib/init/mount-functions.sh |    1 -
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/debian/changelog b/debian/changelog
index bbd42d0..573add9 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+sysvinit (2.88dsf-44) UNRELEASED; urgency=low
+
+  [ Justus Winter ]
+  * mount-functions.sh: Hurd has a tmpfs translator now, remove workaround.
+
+ -- Justus Winter <4winter@informatik.uni-hamburg.de>  Thu, 05 Sep 2013 15:10:39 +0200
+
 sysvinit (2.88dsf-43) unstable; urgency=low
 
   [ Roger Leigh ]
diff --git a/debian/src/initscripts/lib/init/mount-functions.sh b/debian/src/initscripts/lib/init/mount-functions.sh
index 9fd369b..5126780 100644
--- a/debian/src/initscripts/lib/init/mount-functions.sh
+++ b/debian/src/initscripts/lib/init/mount-functions.sh
@@ -190,7 +190,6 @@ domount () {
 	elif [ "$PRIFSTYPE" = tmpfs ]; then
 		# always accept tmpfs, to mount /run before /proc
 		case "$KERNEL" in
-			GNU)	FSTYPE=none ;; # for now
 			*)	FSTYPE=$PRIFSTYPE ;;
 		esac
 	elif grep -E -qs "$PRIFSTYPE\$" /proc/filesystems; then
-- 
1.7.10.4

From b9b81e6c1f2fa67ccb90b5341728b2da02d476d6 Mon Sep 17 00:00:00 2001
From: Justus Winter <4winter@informatik.uni-hamburg.de>
Date: Mon, 8 Jul 2013 12:40:09 +0200
Subject: [PATCH 2/6] initscripts: add -ocompatible to procfs mounts on Hurd

---
 debian/changelog                                   |    1 +
 debian/src/initscripts/lib/init/mount-functions.sh |    3 ++-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/debian/changelog b/debian/changelog
index 573add9..29257ab 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,6 +2,7 @@ sysvinit (2.88dsf-44) UNRELEASED; urgency=low
 
   [ Justus Winter ]
   * mount-functions.sh: Hurd has a tmpfs translator now, remove workaround.
+  * mount-functions.sh: Add -ocompatible to procfs mounts on Hurd.
 
  -- Justus Winter <4winter@informatik.uni-hamburg.de>  Thu, 05 Sep 2013 15:10:39 +0200
 
diff --git a/debian/src/initscripts/lib/init/mount-functions.sh b/debian/src/initscripts/lib/init/mount-functions.sh
index 5126780..8bb3031 100644
--- a/debian/src/initscripts/lib/init/mount-functions.sh
+++ b/debian/src/initscripts/lib/init/mount-functions.sh
@@ -176,7 +176,8 @@ domount () {
 
 	if [ "$PRIFSTYPE" = proc ]; then
 		case "$KERNEL" in
-			Linux|GNU) FSTYPE=proc ;;
+			Linux)     FSTYPE=proc ;;
+			GNU)       FSTYPE=proc; FS_OPTS="-ocompatible" ;;
 			*FreeBSD)  FSTYPE=linprocfs ;;
 			*)         FSTYPE=procfs ;;
 		esac
-- 
1.7.10.4

From b177429374e6c460d734124ddfeb45e6d39655ff Mon Sep 17 00:00:00 2001
From: Justus Winter <4winter@informatik.uni-hamburg.de>
Date: Mon, 8 Jul 2013 12:48:42 +0200
Subject: [PATCH 3/6] initscripts: use pidof -s /sbin/init for robustness

pidof -s returns the first matching process. Since readdir(2) on
procfs returns the processes in ascending order, this returns the
first process. This is more robust if there is more than one
/sbin/init process.

Currently on Hurd there are two /sbin/init processes. Clearly this
needs some investigation. But as far as I can tell this could also
happen if INITDEBUG is defined as /sbin/init then forks a child that
can be ptrace(2)d on a vanilla Linux kernel.
---
 debian/changelog                              |    1 +
 debian/src/initscripts/etc/init.d/mountall.sh |    2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/debian/changelog b/debian/changelog
index 29257ab..49afbed 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -3,6 +3,7 @@ sysvinit (2.88dsf-44) UNRELEASED; urgency=low
   [ Justus Winter ]
   * mount-functions.sh: Hurd has a tmpfs translator now, remove workaround.
   * mount-functions.sh: Add -ocompatible to procfs mounts on Hurd.
+  * mountall.sh: Use pidof -s /sbin/init for robustness.
 
  -- Justus Winter <4winter@informatik.uni-hamburg.de>  Thu, 05 Sep 2013 15:10:39 +0200
 
diff --git a/debian/src/initscripts/etc/init.d/mountall.sh b/debian/src/initscripts/etc/init.d/mountall.sh
index 5f913cd..392eeec 100755
--- a/debian/src/initscripts/etc/init.d/mountall.sh
+++ b/debian/src/initscripts/etc/init.d/mountall.sh
@@ -55,7 +55,7 @@ do_start() {
 		mknod -m 600 "$INITCTL" p
 
 		# Reopen control channel.
-		PID="$(pidof /sbin/init || echo 1)"
+		PID="$(pidof -s /sbin/init || echo 1)"
 		[ -n "$PID" ] && kill -s USR1 "$PID"
 	fi
 
-- 
1.7.10.4

From 4a58b5c18367c9f6e6491ec5060f8b3375219609 Mon Sep 17 00:00:00 2001
From: Justus Winter <4winter@informatik.uni-hamburg.de>
Date: Mon, 8 Jul 2013 18:35:44 +0200
Subject: [PATCH 4/6] initscripts: Only run rootcheck on Linux

Neither kFreeBSD nor Hurd have /dev/root and the device ids used here
are specific to Linux. Note that fsck is still run, rootcheck refers
to the check whether the root device in /etc/fstab matches the actual
device.
---
 debian/changelog                               |    2 ++
 debian/src/initscripts/etc/init.d/checkroot.sh |    6 +++++-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/debian/changelog b/debian/changelog
index 49afbed..f8b8da1 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -4,6 +4,8 @@ sysvinit (2.88dsf-44) UNRELEASED; urgency=low
   * mount-functions.sh: Hurd has a tmpfs translator now, remove workaround.
   * mount-functions.sh: Add -ocompatible to procfs mounts on Hurd.
   * mountall.sh: Use pidof -s /sbin/init for robustness.
+  * checkroot.sh: Only run rootcheck on Linux. Neither kFreeBSD nor Hurd
+    have /dev/root and the device ids used here are specific to Linux.
 
  -- Justus Winter <4winter@informatik.uni-hamburg.de>  Thu, 05 Sep 2013 15:10:39 +0200
 
diff --git a/debian/src/initscripts/etc/init.d/checkroot.sh b/debian/src/initscripts/etc/init.d/checkroot.sh
index 05a3c96..61afa70 100755
--- a/debian/src/initscripts/etc/init.d/checkroot.sh
+++ b/debian/src/initscripts/etc/init.d/checkroot.sh
@@ -84,7 +84,11 @@ do_start () {
 	# If not we try to use the /dev/root alias device, and if that
 	# fails we create a temporary node in /run.
 	#
-	if [ "$rootcheck" = yes ]
+	# Do this only on Linux. Neither kFreeBSD nor Hurd have
+	# /dev/root and the device ids used here are specific to
+	# Linux.
+	KERNEL="$(uname)"
+	if [ "$rootcheck" = yes ] && [ "$KERNEL" = Linux ]
 	then
 		ddev="$(mountpoint -qx $rootdev)"
 		rdev="$(mountpoint -d /)"
-- 
1.7.10.4

From 75639b8760da7636518e9a3b255368545ca1bc1a Mon Sep 17 00:00:00 2001
From: Justus Winter <4winter@informatik.uni-hamburg.de>
Date: Mon, 8 Jul 2013 15:56:46 +0200
Subject: [PATCH 5/6] killall5.c: Use sysconf(_SC_SYMLOOP_MAX) instead of
 MAXSYMLINKS.

If sysconf returns an error, fall back to MAXSYMLINKS on platforms
that define it.

Fixes build on Hurd.
---
 debian/changelog |    2 ++
 src/killall5.c   |   15 ++++++++++++++-
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/debian/changelog b/debian/changelog
index f8b8da1..83cd26c 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -6,6 +6,8 @@ sysvinit (2.88dsf-44) UNRELEASED; urgency=low
   * mountall.sh: Use pidof -s /sbin/init for robustness.
   * checkroot.sh: Only run rootcheck on Linux. Neither kFreeBSD nor Hurd
     have /dev/root and the device ids used here are specific to Linux.
+  * killall5.c: Use sysconf(_SC_SYMLOOP_MAX) instead of MAXSYMLINKS.
+    Fixes build on Hurd.
 
  -- Justus Winter <4winter@informatik.uni-hamburg.de>  Thu, 05 Sep 2013 15:10:39 +0200
 
diff --git a/src/killall5.c b/src/killall5.c
index 5937d98..2c9bb4f 100644
--- a/src/killall5.c
+++ b/src/killall5.c
@@ -367,13 +367,26 @@ out:
 }
 
 /*
+ *     Get the maximal number of symlinks to follow.
+ */
+static int maxsymlinks(void)
+{
+	int v = sysconf(_SC_SYMLOOP_MAX);
+#ifdef MAXSYMLINKS
+	if (v == -1)
+		return MAXSYMLINKS;
+#endif
+	return v;
+}
+
+/*
  *     Check path is located on a network based partition.
  */
 int check4nfs(const char * path, char * real)
 {
 	char buf[PATH_MAX+1];
 	const char *curr;
-	int deep = MAXSYMLINKS;
+	int deep = maxsymlinks();
 
 	if (!nlist) return 0;
 
-- 
1.7.10.4

From bb1362bd0487d76f5b4951161bf6134c2cf35160 Mon Sep 17 00:00:00 2001
From: Justus Winter <4winter@informatik.uni-hamburg.de>
Date: Mon, 8 Jul 2013 19:00:04 +0200
Subject: [PATCH 6/6] sysvinit: Fix getty path in /etc/inittab on Hurd.

This is essentially the same as
89f6476d8979174f395a1bf784486254464c349d but fixes the existing
/etc/inittab file in the postinstall script.
---
 debian/changelog          |    1 +
 debian/sysvinit.config    |   43 +++++++++++++++++++++++++++++++++++++++++++
 debian/sysvinit.postinst  |   13 +++++++++++++
 debian/sysvinit.templates |   15 +++++++++++++++
 4 files changed, 72 insertions(+)
 create mode 100755 debian/sysvinit.config
 create mode 100644 debian/sysvinit.templates

diff --git a/debian/changelog b/debian/changelog
index 83cd26c..ac37127 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -8,6 +8,7 @@ sysvinit (2.88dsf-44) UNRELEASED; urgency=low
     have /dev/root and the device ids used here are specific to Linux.
   * killall5.c: Use sysconf(_SC_SYMLOOP_MAX) instead of MAXSYMLINKS.
     Fixes build on Hurd.
+  * sysvinit.postinst: Fix file name of gettys in /etc/inittab on Hurd.
 
  -- Justus Winter <4winter@informatik.uni-hamburg.de>  Thu, 05 Sep 2013 15:10:39 +0200
 
diff --git a/debian/sysvinit.config b/debian/sysvinit.config
new file mode 100755
index 0000000..ce34f63
--- /dev/null
+++ b/debian/sysvinit.config
@@ -0,0 +1,43 @@
+#!/bin/sh
+# config script for sysvinit
+#
+# see: dh_installdeb(1)
+
+set -e
+
+. /usr/share/debconf/confmodule
+
+# summary of how this script can be called:
+#	 * <config> `configure' <installed-version>
+#	 * <config> `reconfigure' <installed-version>
+# for details, see http://www.debian.org/doc/debian-policy/ or
+# the debian-policy package
+
+case "$1" in
+    configure|reconfigure)
+
+	if [ "$(uname)" = GNU ]; then
+	    db_set sysvinit/hurd-fix-inittab "true"
+	    if echo '3e3693078d18d4696c83a76531433cd4  /etc/inittab' \
+		| md5sum --status --check -; then
+		    # The file is unmodified, update it silently.
+		    :
+	    elif fgrep -q '/libexec/getty' /etc/inittab; then
+		    db_input low sysvinit/hurd-fix-inittab || true
+		    db_go
+	    fi
+	fi
+    ;;
+
+    *)
+	echo "config script called with unknown argument \`$1'" >&2
+	exit 1
+    ;;
+esac
+
+# dh_installdeb will replace this with shell code automatically
+# generated by other debhelper scripts.
+
+#DEBHELPER#
+
+exit 0
diff --git a/debian/sysvinit.postinst b/debian/sysvinit.postinst
index 1750412..d78fe86 100755
--- a/debian/sysvinit.postinst
+++ b/debian/sysvinit.postinst
@@ -5,6 +5,9 @@
 
 set -e
 
+# Source debconf library.
+. /usr/share/debconf/confmodule
+
 # Restart init, and migrate to /run/initctl if needed.
 do_restart() {
 	INITCTL=/run/initctl
@@ -83,6 +86,16 @@ rm -f /etc/ioctl.save
 if [ ! -f /etc/inittab ]
 then
 	cp -p /usr/share/sysvinit/inittab /etc/inittab
+elif [ "$(uname)" = GNU ] && fgrep -q '/libexec/getty' /etc/inittab; then
+	rm -f -- /etc/inittab.dpkg-new
+	sed -e '/^[^#]/ s|/libexec/getty|/sbin/getty|' \
+	    < /etc/inittab > /etc/inittab.dpkg-new
+
+	db_get sysvinit/hurd-fix-inittab
+	if [ "${RET}" = "true" ]; then
+		mv -- /etc/inittab /etc/inittab.dpkg-old
+		mv -- /etc/inittab.dpkg-new /etc/inittab
+	fi
 fi
 
 restart=yes
diff --git a/debian/sysvinit.templates b/debian/sysvinit.templates
new file mode 100644
index 0000000..935ae84
--- /dev/null
+++ b/debian/sysvinit.templates
@@ -0,0 +1,15 @@
+Template: sysvinit/hurd-fix-inittab
+Type: boolean
+_Description: Update getty file names in /etc/inittab?
+ Your /etc/inittab seems to use /libexec/getty as getty. The default
+ inittab has been changed, however your /etc/inittab has been
+ modified. Note that sysvinit has never been used to boot an Hurd
+ system, so any errors in that file would not have shown up.
+ .
+ Do you want me to change /etc/inittab to use /sbin/getty as getty?
+ .
+ If you choose yes, a backup will be stored in /etc/inittab.dpkg-old.
+ .
+ If you choose no, an updated inittab will be written to
+ /etc/inittab.dpkg-new. Please review the changes and update your
+ /etc/inittab accordingly.
-- 
1.7.10.4


Reply to: