Package: initscripts
Version: 2.88dsf-13.1
Severity: normal
Tags: patch

Note: blocked by #620157 and will require versioned dependency on
base-files once it adds top-level /run.

/run is a new cross-distribution location for the storage of
transient writable files needed from system startup to shutdown, but
which do not require preserving across reboots.  This location is
a replacement for several existing locations in the filesystem
hierarchy:

/var/run (→ /run)
/var/lock (→ /run/lock)
/lib/init/rw (→ /run/init)
/dev/.* (→ /run/*)
/dev/shm/.* (→ /run/*)
writable files under /etc (→ /run/*)

Note files abusing /dev and /dev/shm are in contravention of the
FHS; this provides a location for them in the heierarchy.  It
also provides a location for distribution-specific solutions such
as Debian's /lib/init/rw.  /run will be a cross-distribution location
and is now also used by Fedora/SuSE and others will also be using it.
It's also been proposed to the FHS for standardisation.

https://lwn.net/Articles/436012/
http://thread.gmane.org/gmane.linux.redhat.fedora.devel/146976
http://bugs.freestandards.org/show_bug.cgi?id=718
http://lists.debian.org/debian-devel/2011/03/msg01118.html
http://lists.debian.org/debian-devel/2011/03/msg01119.html
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=620157

The attached patch contains a detailed changelog of the changes, so
I won't repeat it here verbatim.  Outstanding issues are marked
TODO, and may require further discussion to resolve them.

One issue is how best to handle the transition for wheezy.  The
patch takes the most conservative approach, modelled on the
/lib/init/rw approach.  /run is not used until a system reboot, at
which point /etc/init/rcS.d will handle setup.  I create a
compatibility bind mount from /run/init to /lib/init/rw.  I've
currently left out bind mounts/symlink of /var/run and /var/lock;
I'd link to get consensus on how best to handle migration before
doing this last small bit.

We could bind mount if a directory, and create symlinks if not,
or they do not exist (to handle new installs).  But, base-files
will also need to drop these locations from itself so we can
co-opt them.

We could take a less conservative approach and do the migration in
one shot, setting up bind mounts from the existing locations to
/run, which would allow other packages to simply have a versioned
dependency on initscripts to start using /run, rather than waiting
until after wheezy to rely upon it.  But this has a much greater
potential for pain and trouble.  But is certainly feasible on
Linux by doing the following:

  check for /lib/init/rw/.ramfs
    (not in a chroot or bootstrap env; OK to continue)
  bind mount /var/run on /run
    create /run/init and /run/lock
  bind mount /var/lock on /run/lock
  bind mount /lib/init/rw on /run/init

However, we only want to do this once only on initial upgrade;
we don't want to repeat this, or do it following a reboot, or
else things will get seriously screwy.  Note it also needs to
cope with /var/lock and /var/run being symlinks or separately
mounted filesystems; if separately mounted we can mount --move
them and replace with symlinks.


Regards,
Roger

-- System Information:
Debian Release: wheezy/sid
  APT prefers unstable
  APT policy: (550, 'unstable'), (400, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.38-1-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_GB.utf8, LC_CTYPE=en_GB.utf8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages initscripts depends on:
ii  coreutils                   8.5-1        GNU core utilities
ii  debianutils                 3.4.4        Miscellaneous utilities specific t
ii  libc6                       2.11.2-13    Embedded GNU C Library: Shared lib
ii  lsb-base                    3.2-27       Linux Standard Base 3.2 init scrip
ii  mount                       2.17.2-9.1   Tools for mounting and manipulatin
ii  sysv-rc                     2.88dsf-13.1 System-V-like runlevel change mech
ii  sysvinit-utils              2.88dsf-13.1 System-V-like utilities

Versions of packages initscripts recommends:
ii  e2fsprogs                     1.41.12-2  ext2/ext3/ext4 file system utiliti
ii  psmisc                        22.13-1    utilities that use the proc file s

initscripts suggests no packages.

-- no debconf information
diff -urN sysvinit-2.88dsf.original/debian/changelog sysvinit-2.88dsf/debian/changelog
--- sysvinit-2.88dsf.original/debian/changelog	2011-03-30 16:46:27.675265266 +0100
+++ sysvinit-2.88dsf/debian/changelog	2011-03-30 22:29:57.414026872 +0100
@@ -1,3 +1,68 @@
+sysvinit (2.88dsf-14) unstable; urgency=low
+
+  * Support for new top-level directory /run to replace /var/run,
+    /var/lock and /lib/init/rw as a place to store transient
+    writable data which should not be preserved across a system
+    reboot.  Summary:
+      /var/run → /run
+      /var/lock → /run/lock
+      /lib/init/rw → /run/init
+    These changes do not take effect until the system is rebooted as
+    is currently done for /lib/init/rw setup.  Following a reboot, the
+    old paths will continue to be available via bind mounts.  For
+    wheezy, packages must continue to use the existing paths because
+    /run is not guaranteed to be present.  In wheezy+1, all paths under
+    /run can be relied upon, and the old paths can be switched to be
+    symlinks (maybe only for clean installs?) or kept as bind mounts.
+    - initscripts.postinst: Trigger reboot to complete transition.
+    - debian/src/initscripts/doc/README.Debian:
+      Document new use of RUN_SIZE; LOCK_SIZE is no longer used.
+      Refer to /run/init rather than /lib/init/rw.
+    - debian/src/initscripts/etc/init.d/checkroot.sh:
+      Use /run/init in place of /lib/init/rw.
+    - debian/src/initscripts/etc/init.d/mountkernfs.sh:
+      Create /run/init, /run/init/sendsigs.omit.d and /run/lock.
+      Bind mount /run/init to /lib/init/rw for backward compatibility.
+      /run/lock has 01777 permissions to match /var/lock.
+      Drop mounting of /var/run and /var/lock.
+    - debian/src/initscripts/etc/init.d/mtab.sh:
+      Bind mount /run/init and drop mounting of /var/run and /var/lock.
+      TODO: Does this exactly match the mountkernfs behaviour?
+    - debian/src/initscripts/etc/init.d/sendsigs:
+      Support both old and new paths:
+        files: /run/sendsigs.omit /run/init/sendsigs.omit
+               /var/run/sendsigs.omit /lib/init/rw/sendsigs.omit
+        dirs: /run/init/sendsigs.omit.d/ /lib/init/rw/sendsigs.omit.d/
+      Support for both is required to allow clean shutdown of systems
+      both after an upgrade but before reboot (old paths) and after an
+      upgrade after reboot (new paths).
+    - debian/src/initscripts/etc/init.d/umountnfs.sh:
+      Ignore /run.  Continue to ignore /lib/init/rw in order to handle
+      clean shutdown.  Also continue to ignore /var/run and /var/lock
+      if mounted as tmpfs in order to cleanly shutdown.
+    - debian/src/initscripts/lib/init/mount-functions.sh:
+      Drop support for mounting /var/run and /var/lock as separate
+      tmpfs filesystems.  Symlink /var/run to /run and /var/lock to
+      /run/lock.
+    - debian/src/initscripts/Makefile: /lib/init/rw is created as a
+      symlink to /run.
+      TODO: Given that it's a directory and in use as a mountpoint on
+      upgrades, this probably won't work.  Maybe create as a symlink
+      for new installs only.  Since /lib might be read only, we can't
+      assume that we can change it at boot time.
+  * TODO: /run/lock and /var/lock have 01777 permissions, which means
+    there is a potential for any user to DoS the system by filling
+    either /var or /run.  We should investigate why this is the case.
+    Other distributions use a lock group and setgid binaries, but this
+    may cause its own problems.  We could always use a tiny tmps
+    mounted separately on /run/lock.
+  * TODO: Handling upgrades.  The above changes only take effect upon
+    rebooting the system, and do not set up /run on upgrade.  We could
+    use mount --bind/--move to move things around on upgrade to allow
+    a more immediate transition.
+
+ -- Roger Leigh <rle...@debian.org>  Wed, 30 Mar 2011 21:17:49 +0100
+
 sysvinit (2.88dsf-13.1) unstable; urgency=low
 
   * Non-maintainer upload.
diff -urN sysvinit-2.88dsf.original/debian/initscripts.postinst sysvinit-2.88dsf/debian/initscripts.postinst
--- sysvinit-2.88dsf.original/debian/initscripts.postinst	2011-03-30 16:46:27.675265266 +0100
+++ sysvinit-2.88dsf/debian/initscripts.postinst	2011-03-30 21:17:27.714566966 +0100
@@ -143,13 +143,13 @@
 fi
 
 #
-# When installing for the first time or upgrading from version before
-# 2.86.ds1-27, a reboot is needed to make the /lib/init/rw/ tmpfs
-# available.  Flag this using notify-reboot-required.  Not mounting it
-# here as it creates problem for debootstrap, vservers, pbuilder and
-# cowbuilder.
+# When installing for the first time or upgrading from a version
+# before or equal to 2.88dsf-14, a reboot is needed to make the /run
+# tmpfs available.  Flag this using notify-reboot-required.  Not
+# mounting it here as it creates problem for debootstrap, vservers,
+# pbuilder and cowbuilder.
 #
-if dpkg --compare-versions "$PREV_VER" lt "2.86.ds1-27" \
+if dpkg --compare-versions "$PREV_VER" le "2.88dsf-14" \
  && [ -x /usr/share/update-notifier/notify-reboot-required ]; then
 	/usr/share/update-notifier/notify-reboot-required
 fi
diff -urN sysvinit-2.88dsf.original/debian/src/initscripts/doc/README.Debian sysvinit-2.88dsf/debian/src/initscripts/doc/README.Debian
--- sysvinit-2.88dsf.original/debian/src/initscripts/doc/README.Debian	2011-03-30 16:46:27.675265266 +0100
+++ sysvinit-2.88dsf/debian/src/initscripts/doc/README.Debian	2011-03-30 21:24:29.643799146 +0100
@@ -4,29 +4,25 @@
 Tmpfs can be used as virtual memory filesystem. glibc 2.2 and above
 expects a tmpfs to be mounted at /dev/shm for POSIX shared memory,
 this is done automatically by /etc/init.d/mountdevsubfs.sh early in
-the boot process. You can limit tmpfs max size by setting the
-SHM_SIZE variable to a desired size in the /etc/default/tmpfs file
-to prevent tmpfs from using up all system memory.
-
-A tmpfs can also be mounted over /var/run/ and /var/lock/. This can
-be achieved by setting the RAMRUN and RAMLOCK variables to "yes" in
-the /etc/default/rcS file. A size limit for the tmpfs filesystem
-mounted over /var/run/ and /var/lock/ can be set via the RUN_SIZE
-and LOCK_SIZE variables in the /etc/default/tmpfs file.
+the boot process. You can limit tmpfs max size by setting the SHM_SIZE
+variable to a desired size in the /etc/default/tmpfs file to prevent
+tmpfs from using up all system memory.
+
+A size limit for the tmpfs filesystem mounted over /run can be set via
+the RUN_SIZE variable in the /etc/default/tmpfs file.
 
 If TMPFS_SIZE is set in /etc/default/tmpfs, it will be used as the
-default value for SHM_SIZE, RUN_SIZE and LOCK_SIZE. Otherwise, kernel
-defaults are used.
+default value for SHM_SIZE and RUN_SIZE. Otherwise, kernel defaults
+are used.
 
 
 sendsigs process omission interface
 -----------------------------------
 
-Since initscripts package version 2.86.ds1-48, /etc/init.d/sendsigs
-is able to omit processes from being killed by killall5(8). Process
-id's listed in /var/run/sendsigs.omit, /lib/init/rw/sendsigs.omit or
-any file in the /lib/init/rw/sendsigs.omit.d/ directory will be
-omitted by sendsigs.
+Since initscripts package version 2.86.ds1-48, /etc/init.d/sendsigs is
+able to omit processes from being killed by killall5(8). Process id's
+listed in /run/sendsigs.omit, /run/init/sendsigs.omit or any file in
+the /run/init/sendsigs.omit.d/ directory will be omitted by sendsigs.
 
 The recommended practise for adding a process id for omission is to
 create a file in /lib/init/rw/sendsigs.omit.d/<package name>
diff -urN sysvinit-2.88dsf.original/debian/src/initscripts/etc/default/tmpfs sysvinit-2.88dsf/debian/src/initscripts/etc/default/tmpfs
--- sysvinit-2.88dsf.original/debian/src/initscripts/etc/default/tmpfs	2011-03-30 16:46:27.679265316 +0100
+++ sysvinit-2.88dsf/debian/src/initscripts/etc/default/tmpfs	2011-03-30 20:29:06.406325953 +0100
@@ -1,6 +1,14 @@
+# TMPFS_SIZE sets the maximum size (in bytes) that tmpfs filesystems can use.
+#
+# The size will be rounded down to a multiple of the page size, 4096 bytes.
+TMPFS_SIZE=
+
 # SHM_SIZE sets the maximum size (in bytes) that the /dev/shm tmpfs can use.
 # If this is not set then the size defaults to the value of TMPFS_SIZE
 # if that is set; otherwise to the kernel's default.
-#
-# The size will be rounded down to a multiple of the page size, 4096 bytes.
 SHM_SIZE=
+
+# RUN_SIZE sets the maximum size (in bytes) that the /run tmpfs can use.
+# If this is not set then the size defaults to the value of TMPFS_SIZE
+# if that is set; otherwise to the kernel's default.
+RUN_SIZE=
diff -urN sysvinit-2.88dsf.original/debian/src/initscripts/etc/init.d/checkroot.sh sysvinit-2.88dsf/debian/src/initscripts/etc/init.d/checkroot.sh
--- sysvinit-2.88dsf.original/debian/src/initscripts/etc/init.d/checkroot.sh	2011-03-30 16:46:27.675265266 +0100
+++ sysvinit-2.88dsf/debian/src/initscripts/etc/init.d/checkroot.sh	2011-03-30 21:25:53.340835041 +0100
@@ -137,7 +137,7 @@
 	#
 	# Does the root device in /etc/fstab match with the actual device ?
 	# If not we try to use the /dev/root alias device, and if that
-	# fails we create a temporary node in /lib/init/rw.
+	# fails we create a temporary node in /run/init.
 	#
 	if [ "$rootcheck" = yes ]
 	then
@@ -150,11 +150,11 @@
 				rootdev=/dev/root
 			else
 				if \
-					rm -f /lib/init/rw/rootdev \
-					&& mknod -m 600 /lib/init/rw/rootdev b ${rdev%:*} ${rdev#*:} \
-					&& [ -e /lib/init/rw/rootdev ]
+					rm -f /run/init/rootdev \
+					&& mknod -m 600 /run/init/rootdev b ${rdev%:*} ${rdev#*:} \
+					&& [ -e /run/init/rootdev ]
 				then
-					rootdev=/lib/init/rw/rootdev
+					rootdev=/run/init/rootdev
 				else
 					rootfatal=yes
 				fi
@@ -169,7 +169,7 @@
 	then
 		log_failure_msg "The device node $rootdev for the root filesystem is missing or incorrect 
 or there is no entry for the root filesystem listed in /etc/fstab. 
-The system is also unable to create a temporary node in /lib/init/rw. 
+The system is also unable to create a temporary node in /run/init. 
 This means you have to fix the problem manually."
 		log_warning_msg "A maintenance shell will now be started. 
 CONTROL-D will terminate this shell and restart the system."
@@ -268,7 +268,7 @@
 		then
 			log_action_begin_msg "Checking root file system"
 			if [ "$roottype" = "ext2" -o "$roottype" = "ext3" -o "$roottype" = "ext4" ] && usplash_running; then
-			    PROGRESS_FILE=`mktemp -p /lib/init/rw` || PROGRESS_FILE=/lib/init/rw/checkroot_fsck
+			    PROGRESS_FILE=`mktemp -p /run/init` || PROGRESS_FILE=/run/init/checkroot_fsck
 			    set -m
 			    logsave -s $FSCK_LOGFILE fsck -C3 $force $fix -t $roottype $rootdev >/dev/console 2>&1 3>$PROGRESS_FILE &
 			    set +m
@@ -385,9 +385,9 @@
 	fi
 
 	#
-	# Remove /lib/init/rw/rootdev if we created it.
+	# Remove /run/init/rootdev if we created it.
 	#
-	rm -f /lib/init/rw/rootdev
+	rm -f /run/init/rootdev
 }
 
 do_status () {
diff -urN sysvinit-2.88dsf.original/debian/src/initscripts/etc/init.d/mountkernfs.sh sysvinit-2.88dsf/debian/src/initscripts/etc/init.d/mountkernfs.sh
--- sysvinit-2.88dsf.original/debian/src/initscripts/etc/init.d/mountkernfs.sh	2011-03-30 16:46:27.679265316 +0100
+++ sysvinit-2.88dsf/debian/src/initscripts/etc/init.d/mountkernfs.sh	2011-03-30 21:54:22.266746112 +0100
@@ -26,11 +26,24 @@
 	#
 	RW_OPT=
 	[ "${RW_SIZE:=$TMPFS_SIZE}" ] && RW_OPT=",size=$RW_SIZE"
-	domount tmpfs "" /lib/init/rw tmpfs -omode=0755,nosuid$RW_OPT
-	touch /lib/init/rw/.ramfs
+	domount tmpfs "" /run tmpfs -omode=0755,nosuid$RW_OPT
+	touch /run/.ramfs
+
+	# Make lock directory as the replacement for /var/lock
+	mkdir /run/lock
+	chmod 01777 /run/lock
+
+	# Make init directory as the replacement for /lib/init/rw
+	mkdir /run/init
 
 	# Make pidfile omit directory for sendsigs
-	mkdir /lib/init/rw/sendsigs.omit.d/
+	# TODO: Move to /run/sendsigs.omit.d?  Keeping it in /run/init
+	# keeps compatibility with the existing use of /lib/init/rw.
+	mkdir /run/init/sendsigs.omit.d/
+
+	# Create compatibility bind mount for /lib/init/rw from /run/init
+	[ -d /lib/init/rw ]
+	domount none /run/init /lib/init/rw -orw,bind
 
 	#
 	# Mount proc filesystem on /proc
diff -urN sysvinit-2.88dsf.original/debian/src/initscripts/etc/init.d/mtab.sh sysvinit-2.88dsf/debian/src/initscripts/etc/init.d/mtab.sh
--- sysvinit-2.88dsf.original/debian/src/initscripts/etc/init.d/mtab.sh	2011-03-30 16:46:27.679265316 +0100
+++ sysvinit-2.88dsf/debian/src/initscripts/etc/init.d/mtab.sh	2011-03-30 21:53:15.213884244 +0100
@@ -107,24 +107,14 @@
 
 	# S02mountkernfs.sh
 	RW_OPT=
-	[ "${RW_SIZE:=$TMPFS_SIZE}" ] && RW_OPT=",size=$RW_SIZE"
-	domtab tmpfs /lib/init/rw tmpfs -omode=0755,nosuid$RW_OPT
-
+	[ "${RW_SIZE:=$RUN_SIZE}" ] && RW_OPT=",size=$RW_SIZE"
+	domtab tmpfs /run tmpfs -omode=0755,nosuid$RW_OPT
+	domtab /run /lib/init/rw none -orw,bind
 	domtab proc /proc "proc" -onodev,noexec,nosuid
 	if grep -E -qs "sysfs\$" /proc/filesystems
 	then
 		domtab sysfs /sys sysfs -onodev,noexec,nosuid
 	fi
-	if [ yes = "$RAMRUN" ] ; then
-		RUN_OPT=
-		[ "${RUN_SIZE:=$TMPFS_SIZE}" ] && RUN_OPT=",size=$RUN_SIZE"
-		domtab tmpfs /var/run "varrun" -omode=0755,nosuid$RUN_OPT
-	fi
-	if [ yes = "$RAMLOCK" ] ; then
-		LOCK_OPT=
-		[ "${LOCK_SIZE:=$TMPFS_SIZE}" ] && LOCK_OPT=",size=$LOCK_SIZE"
-		domtab tmpfs /var/lock "varlock" -omode=1777,nodev,noexec,nosuid$LOCK_OPT
-	fi
 	if [ -d /proc/bus/usb ]
 	then
 		domtab usbfs /proc/bus/usb "procbususb"
diff -urN sysvinit-2.88dsf.original/debian/src/initscripts/etc/init.d/sendsigs sysvinit-2.88dsf/debian/src/initscripts/etc/init.d/sendsigs
--- sysvinit-2.88dsf.original/debian/src/initscripts/etc/init.d/sendsigs	2011-03-30 16:46:27.679265316 +0100
+++ sysvinit-2.88dsf/debian/src/initscripts/etc/init.d/sendsigs	2011-03-30 22:13:11.125172850 +0100
@@ -27,9 +27,7 @@
 do_stop () {
 	OMITPIDS=
 
-	# The /var/run/sendsigs.omit file is used to be compatible
-	# with Ubuntu.
-	for omitfile in /var/run/sendsigs.omit /lib/init/rw/sendsigs.omit; do
+	for omitfile in /run/sendsigs.omit /run/init/sendsigs.omit /var/run/sendsigs.omit /lib/init/rw/sendsigs.omit; do
 		if [ -e $omitfile ]; then
 			for pid in $(cat $omitfile); do
 				OMITPIDS="${OMITPIDS:+$OMITPIDS }-o $pid"
@@ -40,8 +38,8 @@
 	# Load sendsigs.omit.d/packagename files too, to make it
 	# possible for scripts that need to modify the list of pids at
 	# run time without race conditions.
-	if [ -d /lib/init/rw/sendsigs.omit.d/ ]; then
-		for pidfile in /lib/init/rw/sendsigs.omit.d/*; do
+	if [ -d /run/init/sendsigs.omit.d/ ]; then
+		for pidfile in /run/init/sendsigs.omit.d/*; do
 			[ -f "$pidfile" ] || continue
 			for pid in $(cat $pidfile); do
 				OMITPIDS="${OMITPIDS:+$OMITPIDS }-o $pid"
diff -urN sysvinit-2.88dsf.original/debian/src/initscripts/etc/init.d/#sendsigs# sysvinit-2.88dsf/debian/src/initscripts/etc/init.d/#sendsigs#
--- sysvinit-2.88dsf.original/debian/src/initscripts/etc/init.d/#sendsigs#	1970-01-01 01:00:00.000000000 +0100
+++ sysvinit-2.88dsf/debian/src/initscripts/etc/init.d/#sendsigs#	2011-03-30 22:16:10.755473396 +0100
@@ -0,0 +1,126 @@
+#! /bin/sh
+### BEGIN INIT INFO
+# Provides:          sendsigs
+# Required-Start:    
+# Required-Stop:     umountnfs
+# Default-Start:
+# Default-Stop:      0 6
+# Short-Description: Kill all remaining processes.
+# Description: 
+### END INIT INFO
+
+PATH=/sbin:/usr/sbin:/bin:/usr/bin
+
+. /lib/lsb/init-functions
+
+# Make it possible to see who the misbehaving processes are
+report_unkillable() {
+	if [ -x /usr/bin/pstree ] ; then
+		echo "Currently running processes (pstree):"
+		pstree
+	elif [ -x /bin/ps ] ; then
+		echo "Currently running processes (ps):"
+		ps -ef
+	fi
+}
+
+do_stop () {
+	OMITPIDS=
+
+	for omitfile in /run/sendsigs.omit /run/init/sendsigs.omit /var/run/sendsigs.omit /lib/init/rw/sendsigs.omit; do
+		if [ -e $omitfile ]; then
+			for pid in $(cat $omitfile); do
+				OMITPIDS="${OMITPIDS:+$OMITPIDS }-o $pid"
+			done
+		fi
+	done
+
+	# Load sendsigs.omit.d/packagename files too, to make it
+	# possible for scripts that need to modify the list of pids at
+	# run time without race conditions.
+	for omitdir in /run/init/sendsigs.omit.d/ /lib/init/rw/sendsigs.omit.d/; do
+
+	if [ -d $omitdir ]; then
+		for pidfile in $omitdir/*; do
+			[ -f "$pidfile" ] || continue
+			for pid in $(cat $pidfile); do
+				OMITPIDS="${OMITPIDS:+$OMITPIDS }-o $pid"
+			done
+		done
+	fi
+
+	# Upstart jobs have their own "stop on" clauses that sends
+	# SIGTERM/SIGKILL just like this, so if they're still running,
+	# they're supposed to be
+	if [ -x /sbin/initctl ]; then
+		for pid in $(initctl list | sed -n -e "/process [0-9]/s/.*process //p"); do
+			OMITPIDS="${OMITPIDS:+$OMITPIDS }-o $pid"
+		done
+	fi
+
+	# Flush the kernel I/O buffer before we start to kill
+	# processes, to make sure the IO of already stopped services to
+	# not slow down the remaining processes to a point where they
+	# are accidentily killed with SIGKILL because they did not
+	# manage to shut down in time.
+	sync
+
+	# Kill all processes.
+	log_action_begin_msg "Asking all remaining processes to terminate"
+	killall5 -15 $OMITPIDS # SIGTERM
+	log_action_end_msg 0
+	alldead=""
+	for seq in 1 2 3 4 5 6 7 8 9 10; do
+		# use SIGCONT/signal 18 to check if there are
+		# processes left.  No need to check the exit code
+		# value, because either killall5 work and it make
+		# sense to wait for processes to die, or it fail and
+		# there is nothing to wait for.
+
+		# did an upstart job start since we last polled initctl? check
+		# again on each loop and add any new jobs (e.g., plymouth) to
+		# the list.  If we did miss one starting up, this beats waiting
+		# 10 seconds before shutting down.
+		if [ -x /sbin/initctl ]; then
+		    for pid in $(initctl list | sed -n -e "/process [0-9]/s/.*process //p"); do
+			OMITPIDS="${OMITPIDS:+$OMITPIDS }-o $pid"
+		    done
+		fi
+		if killall5 -18 $OMITPIDS ; then
+		    :
+		else
+		    alldead=1
+		    break
+		fi
+
+		sleep 1
+	done
+	if [ -z "$alldead" ] ; then
+	    report_unkillable
+	    log_action_begin_msg "Killing all remaining processes"
+	    killall5 -9 $OMITPIDS # SIGKILL
+	    log_action_end_msg 1
+	else
+	    log_action_begin_msg "All processes ended within $seq seconds."
+	    log_action_end_msg 0
+	fi
+}
+
+case "$1" in
+  start)
+	# No-op
+	;;
+  restart|reload|force-reload)
+	echo "Error: argument '$1' not supported" >&2
+	exit 3
+	;;
+  stop)
+	do_stop
+	;;
+  *)
+	echo "Usage: $0 start|stop" >&2
+	exit 3
+	;;
+esac
+
+:
diff -urN sysvinit-2.88dsf.original/debian/src/initscripts/etc/init.d/umountnfs.sh sysvinit-2.88dsf/debian/src/initscripts/etc/init.d/umountnfs.sh
--- sysvinit-2.88dsf.original/debian/src/initscripts/etc/init.d/umountnfs.sh	2011-03-30 16:46:27.679265316 +0100
+++ sysvinit-2.88dsf/debian/src/initscripts/etc/init.d/umountnfs.sh	2011-03-30 17:51:05.979695304 +0100
@@ -48,7 +48,7 @@
 	while read -r DEV MTPT FSTYPE OPTS REST
 	do
 		case "$MTPT" in
-		  /|/proc|/dev|/dev/pts|/dev/shm|/proc/*|/sys|/lib/init/rw)
+		  /|/proc|/dev|/dev/pts|/dev/shm|/proc/*|/sys|/run|/lib/init/rw)
 			continue
 			;;
 		  /var/run)
diff -urN sysvinit-2.88dsf.original/debian/src/initscripts/lib/init/mount-functions.sh sysvinit-2.88dsf/debian/src/initscripts/lib/init/mount-functions.sh
--- sysvinit-2.88dsf.original/debian/src/initscripts/lib/init/mount-functions.sh	2011-03-30 16:46:27.675265266 +0100
+++ sysvinit-2.88dsf/debian/src/initscripts/lib/init/mount-functions.sh	2011-03-30 17:14:44.064097020 +0100
@@ -41,7 +41,7 @@
 			*)         FSTYPE=procfs ;;
 		esac
 	elif [ "$1" = tmpfs ]
-	then # always accept tmpfs, to mount /lib/init/rw before /proc
+	then # always accept tmpfs, to mount /run before /proc
 		FSTYPE=$1
 	elif grep -E -qs "$1\$" /proc/filesystems
 	then
@@ -136,30 +136,13 @@
 }
 
 #
-# Restore /var/run and /var/lock mountpoints if something was mounted
-# as /var/.  Avoid mounting them back over themselves if nothing was
-# mounted as /var/ by checking if /var/run/ and /var/lock/ are still
-# mount points.  Enabling RAMRUN and RAMLOCK while listing /var/run or
-# /var/lock in /etc/fstab is not supported.
+# For compatibility, create /var/run and /var/lock symlinks to /run
+# and /run/lock, respectively.
 #
 post_mountall ()
 {
-	if [ yes = "$RAMRUN" ] ; then
-		[ -d /var/run ] || mkdir /var/run
-		if mountpoint -q /var/run ; then
-			umount /lib/init/rw/var.run
-		else
-			mount -n --move /lib/init/rw/var.run /var/run
-		fi
-		rmdir /lib/init/rw/var.run
-	fi
-	if [ yes = "$RAMLOCK" ] ; then
-		[ -d /var/lock ] || mkdir /var/lock
-		if mountpoint -q /var/lock ; then
-			umount /lib/init/rw/var.lock
-		else
-			mount -n --move /lib/init/rw/var.lock /var/lock
-		fi
-		rmdir /lib/init/rw/var.lock
-	fi
+	[ -d /var/run ] && rm -fr /var/run
+	ln -fs /run /var/run
+	[ -d /var/lock ] && rm -fr /var/lock
+	ln -fs /run/lock /var/lock
 }
diff -urN sysvinit-2.88dsf.original/debian/src/initscripts/Makefile sysvinit-2.88dsf/debian/src/initscripts/Makefile
--- sysvinit-2.88dsf.original/debian/src/initscripts/Makefile	2011-03-30 16:46:27.675265266 +0100
+++ sysvinit-2.88dsf/debian/src/initscripts/Makefile	2011-03-30 16:54:07.988949558 +0100
@@ -10,7 +10,7 @@
 all:
 
 install:
-	$(INSTALL) -d $(DESTDIR)/lib/init/rw/.
+	ln -s /run $(DESTDIR)/lib/init/rw
 	$(INSTALL) -d $(DESTDIR)/var/lib/initscripts/.
 	$(INSTALL) -d $(DESTDIR)/var/lib/urandom/.
 	$(INSTALL) -d $(DESTDIR)/var/log/fsck/.

Reply via email to