Your message dated Thu, 22 Nov 2018 17:12:47 +0000
with message-id <[email protected]>
and subject line Bug#699087: fixed in sysvinit 2.92~beta-1
has caused the Debian Bug report #699087,
regarding sysvinit: avoid potentional bugs, more efficient code and cleanups
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact [email protected]
immediately.)


-- 
699087: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=699087
Debian Bug Tracking System
Contact [email protected] with problems
--- Begin Message ---
Package: sysvinit
Version: 2.88dsf-39
Severity: wishlist
Tags: patch

Please find attached a series of patches that mostly cleanup some scripts,
but also avoid potentional bugs and make the code more efficient.

Mostly checking if there's interest for further work along those lines.
Among the patches, these:

        0015-List-fstab-files-without-forking-ls-grep-nor-sed-and.patch
        0016-Use-shell-builtin-redirection-instead-of-using-a-tou.patch
        0017-Use-guaranteed-builtin-instead-of-sometimes-true-for.patch
        0018-Use-proper-test.patch
        0019-Don-t-fork-and-simplify-value-extractions-from-proc-.patch
        0020-Use-safer-inverted-logic.patch

may be more interesting.

-- System Information:
Debian Release: 7.0
  APT prefers unstable
  APT policy: (500, 'unstable'), (500, 'testing'), (1, 'experimental')
Architecture: i386 (i686)

Kernel: Linux 3.2.0-4-686-pae (SMP w/2 CPU cores)
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)
Shell: /bin/sh linked to /bin/bash

Versions of packages sysvinit depends on:
ii  debianutils     4.3.4
ii  initscripts     2.88dsf-39
ii  libc6           2.13-38
ii  libselinux1     2.1.9-5
ii  libsepol1       2.1.4-3
ii  sysv-rc         2.88dsf-39
ii  sysvinit-utils  2.88dsf-39

sysvinit recommends no packages.

sysvinit suggests no packages.

-- no debconf information


Cheers,

-- 
Cristian
From e341aea111516c5298a96578351483b86252f279 Mon Sep 17 00:00:00 2001
From: Cristian Ionescu-Idbohrn <[email protected]>
Date: Fri, 25 Jan 2013 22:48:44 +0100
Subject: [PATCH 01/21] Uniformize style; no code changes.

Signed-off-by: Cristian Ionescu-Idbohrn <[email protected]>
---
 debian/src/initscripts/lib/init/mount-functions.sh |   42 ++++++++------------
 1 file changed, 16 insertions(+), 26 deletions(-)

diff --git a/debian/src/initscripts/lib/init/mount-functions.sh b/debian/src/initscripts/lib/init/mount-functions.sh
index 2ad4528..b9759bb 100644
--- a/debian/src/initscripts/lib/init/mount-functions.sh
+++ b/debian/src/initscripts/lib/init/mount-functions.sh
@@ -5,8 +5,7 @@
 
 # List available fstab files, including any files in /etc/fstab.d.
 # This looks ugly, but we can't use find and it's safer than globbing.
-fstab_files()
-{
+fstab_files() {
     echo /etc/fstab
     if [ -d /etc/fstab.d ]; then
         ls -1 /etc/fstab.d | grep '\.fstab$' | sed -e 's;^;/etc/fstab.d/;'
@@ -27,7 +26,7 @@ is_empty_dir() {
 }
 
 
-selinux_enabled () {
+selinux_enabled() {
 	which selinuxenabled >/dev/null 2>&1 && selinuxenabled
 }
 
@@ -36,7 +35,7 @@ selinux_enabled () {
 #	device node,
 # 2) Swap that is on a md device or a file that may be on a md
 #	device,
-_read_fstab () {
+_read_fstab() {
 	echo "fstabroot=/dev/root"
 	echo "rootdev=none"
 	echo "roottype=none"
@@ -93,14 +92,14 @@ _read_fstab () {
 # 2) Swap that is on a md device or a file that may be on a md
 #	device,
 
-read_fstab () {
+read_fstab() {
 	eval "$(_read_fstab)"
 }
 
 # Find a specific fstab entry
 # $1=mountpoint
 # $2=fstype (optional)
-_read_fstab_entry () {
+_read_fstab_entry() {
 	# Not found by default.
 	echo "MNT_FSNAME="
 	echo "MNT_DIR="
@@ -139,7 +138,7 @@ _read_fstab_entry () {
 # $1=mountpoint
 # $2=fstype (optional)
 # returns 0 on success, 1 on failure (not found or no fstab)
-read_fstab_entry () {
+read_fstab_entry() {
 	eval "$(_read_fstab_entry "$1" "$2")"
 
 	# Not found by default.
@@ -158,7 +157,7 @@ read_fstab_entry () {
 # $4: mount point
 # $5: mount device name
 # $6... : extra mount program options
-domount () {
+domount() {
 	MOUNTMODE="$1"
 	PRIFSTYPE="$2"
 	ALTFSTYPE="$3"
@@ -297,8 +296,7 @@ domount () {
 #
 # Preserve /var/run and /var/lock mountpoints
 #
-pre_mountall ()
-{
+pre_mountall() {
 	# RAMRUN and RAMLOCK on /var/run and /var/lock are obsoleted by
 	# /run.  Note that while RAMRUN is no longer used (/run is always
 	# a tmpfs), RAMLOCK is still functional, but will cause a second
@@ -313,8 +311,7 @@ pre_mountall ()
 # If the device/inode are the same, a bind mount already exists or the
 # transition is complete, so set up is not required.  Otherwise bind
 # mount $SRC on $DEST.
-bind_mount ()
-{
+bind_mount() {
 	SRC=$1
 	DEST=$2
 
@@ -349,8 +346,7 @@ bind_mount ()
 # Migrate a directory to /run and create compatibility symlink or bind
 # mount.
 #
-run_migrate ()
-{
+run_migrate() {
 	OLD=$1
 	RUN=$2
 
@@ -414,8 +410,7 @@ run_migrate ()
 #
 # Migrate /etc/mtab to a compatibility symlink
 #
-mtab_migrate ()
-{
+mtab_migrate() {
 	# Don't symlink if /proc/mounts does not exist.
 	if [ ! -r "/proc/mounts" ]; then
 		return 1
@@ -439,8 +434,7 @@ mtab_migrate ()
 # For compatibility, create /var/run and /var/lock symlinks to /run
 # and /run/lock, respectively.
 #
-post_mountall ()
-{
+post_mountall() {
 	# /var/run and /var/lock are now /run and /run/lock,
 	# respectively.  Cope with filesystems being deliberately
 	# mounted on /var/run and /var/lock.  We will create bind
@@ -490,8 +484,7 @@ post_mountall ()
 }
 
 # Mount /run
-mount_run ()
-{
+mount_run() {
 	MNTMODE="$1"
 
 	# Needed to determine if root is being mounted read-only.
@@ -520,8 +513,7 @@ mount_run ()
 }
 
 # Mount /run/lock
-mount_lock ()
-{
+mount_lock() {
 	MNTMODE="$1"
 
 	# Make lock directory as the replacement for /var/lock
@@ -557,8 +549,7 @@ mount_lock ()
 }
 
 # Mount /run/shm
-mount_shm ()
-{
+mount_shm() {
 	MNTMODE="$1"
 
 	RAMSHM_ON_DEV_SHM="no"
@@ -622,8 +613,7 @@ mount_shm ()
 #
 # Mount /tmp
 #
-mount_tmp ()
-{
+mount_tmp() {
 	MNTMODE="$1"
 
 	# If /tmp is a symlink, make sure the linked-to directory exists.
-- 
1.7.10.4

From 2a7f166367772c494957bddc5a033200ed115554 Mon Sep 17 00:00:00 2001
From: Cristian Ionescu-Idbohrn <[email protected]>
Date: Fri, 25 Jan 2013 23:16:33 +0100
Subject: [PATCH 02/21] Whitespace cleanup.  No code shanges.

Signed-off-by: Cristian Ionescu-Idbohrn <[email protected]>
---
 debian/src/initscripts/lib/init/mount-functions.sh |  234 ++++++++++++--------
 1 file changed, 139 insertions(+), 95 deletions(-)

diff --git a/debian/src/initscripts/lib/init/mount-functions.sh b/debian/src/initscripts/lib/init/mount-functions.sh
index b9759bb..263672e 100644
--- a/debian/src/initscripts/lib/init/mount-functions.sh
+++ b/debian/src/initscripts/lib/init/mount-functions.sh
@@ -6,10 +6,10 @@
 # List available fstab files, including any files in /etc/fstab.d.
 # This looks ugly, but we can't use find and it's safer than globbing.
 fstab_files() {
-    echo /etc/fstab
-    if [ -d /etc/fstab.d ]; then
-        ls -1 /etc/fstab.d | grep '\.fstab$' | sed -e 's;^;/etc/fstab.d/;'
-    fi
+	echo /etc/fstab
+	if [ -d /etc/fstab.d ]; then
+		ls -1 /etc/fstab.d | grep '\.fstab$' | sed -e 's;^;/etc/fstab.d/;'
+	fi
 }
 
 # $1: directory
@@ -17,9 +17,15 @@ is_empty_dir() {
 	for FILE in $1/* $1/.*
 	do
 		case "$FILE" in
-		  "$1/.*") return 0 ;;
-		  "$1/*"|"$1/."|"$1/..") continue ;;
-		  *) return 1 ;;
+			"$1/.*")
+				return 0
+				;;
+			"$1/*"|"$1/."|"$1/..")
+				continue
+				;;
+			*)
+				return 1
+				;;
 		esac
 	done
 	return 0
@@ -49,37 +55,37 @@ _read_fstab() {
 		if [ -f "$file" ]; then
 			while read DEV MTPT FSTYPE OPTS DUMP PASS JUNK; do
 				case "$DEV" in
-				  ""|\#*)
-					continue;
-					;;
-				  /dev/mapper/*)
-					[ "$FSTYPE" = "swap" ] && echo swap_on_lv=yes
-					;;
-				  /dev/*)
-					;;
-				  LABEL=*|UUID=*)
-					if [ "$MTPT" = "/" ] && [ -x /sbin/findfs ]
-					then
-						DEV="$(findfs "$DEV")"
-					fi
-					;;
-				  /*)
-					[ "$FSTYPE" = "swap" ] && echo swap_on_file=yes
-					;;
-				  *)
-					;;
+					""|\#*)
+						continue;
+						;;
+					/dev/mapper/*)
+						[ "$FSTYPE" = "swap" ] && echo swap_on_lv=yes
+						;;
+					/dev/*)
+						;;
+					LABEL=*|UUID=*)
+						if [ "$MTPT" = "/" ] && [ -x /sbin/findfs ]
+						then
+							DEV="$(findfs "$DEV")"
+						fi
+						;;
+					/*)
+						[ "$FSTYPE" = "swap" ] && echo swap_on_file=yes
+						;;
+					*)
+						;;
 				esac
 				[ "$MTPT" != "/" ] && continue
 				echo rootdev=\"$DEV\"
 				echo fstabroot=\"$DEV\"
 				echo rootopts=\"$OPTS\"
 				echo roottype=\"$FSTYPE\"
-				( [ "$PASS" != 0 ] && [ "$PASS" != "" ]   ) && echo rootcheck=yes
+				( [ "$PASS" != 0 ] && [ "$PASS" != "" ] ) && echo rootcheck=yes
 				( [ "$FSTYPE" = "nfs" ] || [ "$FSTYPE" = "nfs4" ] ) && echo rootcheck=no
 				case "$OPTS" in
-				  ro|ro,*|*,ro|*,ro,*)
-					echo rootmode=ro
-					;;
+					ro|ro,*|*,ro|*,ro,*)
+						echo rootmode=ro
+						;;
 				esac
 			done < "$file"
 		fi
@@ -112,9 +118,9 @@ _read_fstab_entry() {
 		if [ -f "$file" ]; then
 			while read MNT_FSNAME MNT_DIR MNT_TYPE MNT_OPTS MNT_FREQ MNT_PASS MNT_JUNK; do
 				case "$MNT_FSNAME" in
-				  ""|\#*)
-					continue;
-					;;
+					""|\#*)
+						continue;
+						;;
 				esac
 				if [ "$MNT_DIR" = "$1" ]; then
 					if [ -n "$2" ]; then
@@ -175,22 +181,41 @@ domount() {
 
 	if [ "$PRIFSTYPE" = proc ]; then
 		case "$KERNEL" in
-			Linux|GNU) FSTYPE=proc ;;
-			*FreeBSD)  FSTYPE=linprocfs ;;
-			*)         FSTYPE=procfs ;;
+			Linux|GNU)
+				FSTYPE=proc
+				;;
+			*FreeBSD)
+				FSTYPE=linprocfs
+				;;
+			*)
+				FSTYPE=procfs
+				;;
 		esac
 	elif [ "$PRIFSTYPE" = bind ]; then
 		case "$KERNEL" in
-			Linux)     FSTYPE="$DEVNAME"; FS_OPTS="-obind" ;;
-			*FreeBSD)  FSTYPE=nullfs ;;
-			GNU)       FSTYPE=firmlink ;;
-			*)         FSTYPE=none ;;
+			Linux)
+				FSTYPE="$DEVNAME"
+				FS_OPTS="-obind"
+				;;
+			*FreeBSD)
+				FSTYPE=nullfs
+				;;
+			GNU)
+				FSTYPE=firmlink
+				;;
+			*)
+				FSTYPE=none
+				;;
 		esac
 	elif [ "$PRIFSTYPE" = tmpfs ]; then
 		# always accept tmpfs, to mount /run before /proc
 		case "$KERNEL" in
-			GNU)	FSTYPE=none ;; # for now
-			*)	FSTYPE=$PRIFSTYPE ;;
+			GNU)
+				FSTYPE=none
+				;; # for now
+			*)
+				FSTYPE=$PRIFSTYPE
+				;;
 		esac
 	elif grep -E -qs "$PRIFSTYPE\$" /proc/filesystems; then
 		FSTYPE=$PRIFSTYPE
@@ -210,8 +235,8 @@ domount() {
 
 	# We give file system type as device name if not specified as
 	# an argument
-	if [ -z "$DEVNAME" ] ; then
-	    DEVNAME=$FSTYPE
+	if [ -z "$DEVNAME" ]; then
+		DEVNAME=$FSTYPE
 	fi
 
 	# Get the mount options from /etc/fstab
@@ -226,8 +251,7 @@ domount() {
 		esac
 	fi
 
-	if [ ! -d "$MTPT" ]
-	then
+	if [ ! -d "$MTPT" ]; then
 		log_warning_msg "Mount point '$MTPT' does not exist. Skipping mount."
 		return
 	fi
@@ -244,10 +268,10 @@ domount() {
 	case "$MOUNTMODE" in
 		mount)
 			if mountpoint -q "$MTPT"; then
-			    # Already mounted, probably moved from the
-			    # initramfs, so remount with the
-			    # user-specified mount options later on.
-			    :
+				# Already mounted, probably moved from the
+				# initramfs, so remount with the
+				# user-specified mount options later on.
+				:
 			else
 				if [ "$VERBOSE" != "no" ]; then
 					is_empty_dir "$MTPT" >/dev/null 2>&1 || log_warning_msg "Files under mount point '$MTPT' will be hidden."
@@ -271,8 +295,7 @@ domount() {
 
 			if mountpoint -q "$MTPT"; then
 				# Already recorded?
-				if ! grep -E -sq "^([^ ]+) +$MTPT +" /etc/mtab < /dev/null
-				then
+				if ! grep -E -sq "^([^ ]+) +$MTPT +" /etc/mtab < /dev/null; then
 					mount $MOUNTFLAGS -t $FSTYPE $CALLER_OPTS $FSTAB_OPTS $FS_OPTS $DEVNAME $MTPT < /dev/null
 				fi
 			fi
@@ -282,7 +305,6 @@ domount() {
 			# Note does not work for bind mounts, and does
 			# not work if the fstab already has an entry
 			# for the filesystem.
-
 			if ! read_fstab_entry "$MTPT" "$FSTYPE"; then
 				CALLER_OPTS="$(echo "$CALLER_OPTS" | sed -e 's/^-o//')"
 				echo "Creating /etc/fstab entry for $MTPT to replace default in /etc/default/tmpfs (deprecated)" >&2
@@ -322,17 +344,26 @@ bind_mount() {
 	sdest="$(/usr/bin/stat -L --format="%d %i" "$DEST" 2>/dev/null || :)"
 
 	case "$(uname -s)" in
-		Linux)     FSTYPE=$SRC; OPTS="-orw -obind" ;;
-		*FreeBSD)  FSTYPE=nullfs; OPTS="-orw" ;;
-		GNU)       FSTYPE=firmlink ;;
-		*)         FSTYPE=none ;;
+		Linux)
+			FSTYPE=$SRC; OPTS="-orw -obind"
+			;;
+		*FreeBSD)
+			FSTYPE=nullfs
+			OPTS="-orw"
+			;;
+		GNU)
+			FSTYPE=firmlink
+			;;
+		*)
+			FSTYPE=none
+			;;
 	esac
 
 	# Bind mount $SRC on $DEST
 	if [ -n "$ssrc" ] && [ "$ssrc" != "$sdest" ]; then
 		[ -d "$DEST" ] || mkdir "$DEST"
 		[ -x /sbin/restorecon ] && /sbin/restorecon "$DEST"
-		if mount -t $FSTYPE "$SRC" "$DEST" $OPTS ; then
+		if mount -t $FSTYPE "$SRC" "$DEST" $OPTS; then
 			echo "Please reboot to complete migration to tmpfs-based /run" > "${DEST}/.run-transition"
 			return 0
 		fi
@@ -353,10 +384,18 @@ run_migrate() {
 	KERNEL="$(uname -s)"
 	OPTS=""
 	case "$KERNEL" in
-		Linux)     FSTYPE=none OPTS="-orw -obind";;
-		*FreeBSD)  FSTYPE=nullfs OPTS="-orw" ;;
-		GNU)       FSTYPE=firmlink ;;
-		*)         FSTYPE=none ;;
+		Linux)
+			FSTYPE=none OPTS="-orw -obind"
+			;;
+		*FreeBSD)
+			FSTYPE=nullfs OPTS="-orw"
+			;;
+		GNU)
+			FSTYPE=firmlink
+			;;
+		*)
+			FSTYPE=none
+			;;
 	esac
 
 	# Create absolute symlink if not already present.  This is to
@@ -382,12 +421,12 @@ run_migrate() {
 	# them yet.  If the user explicitly mounted a filesystem here,
 	# it will be cleaned out, but this would happen later on when
 	# bootclean runs in any case.
-	if [ ! -L "$OLD" ] && [ -d "$OLD" ] ; then
+	if [ ! -L "$OLD" ] && [ -d "$OLD" ]; then
 		rm -fr "$OLD" 2>/dev/null || true
 	fi
 
 	# If removal failed (directory still exists), set up bind mount.
-	if [ ! -L "$OLD" ] && [ -d "$OLD" ] ; then
+	if [ ! -L "$OLD" ] && [ -d "$OLD" ]; then
 		if [ "$OLD" != "/tmp" ]; then
 			log_warning_msg "Filesystem mounted on $OLD; setting up compatibility bind mount."
 			log_warning_msg "Please remove this mount from /etc/fstab; it is no longer needed, and it is preventing completion of the transition to $RUN."
@@ -465,21 +504,21 @@ post_mountall() {
 			mkdir /run
 		fi
 		if bind_mount /var/run /run; then
-		    bind_mount /var/lock /run/lock
-		    if [ yes = "$RAMSHM_ON_DEV_SHM" ]; then
+			bind_mount /var/lock /run/lock
+			if [ yes = "$RAMSHM_ON_DEV_SHM" ]; then
+				run_migrate /run/shm /dev/shm
+			else
+				run_migrate /dev/shm /run/shm
+			fi
+		fi
+	else
+		run_migrate /var/run /run
+		run_migrate /var/lock /run/lock
+		if [ yes = "$RAMSHM_ON_DEV_SHM" ]; then
 			run_migrate /run/shm /dev/shm
-		    else
+		else
 			run_migrate /dev/shm /run/shm
-		    fi
 		fi
-	else
-	    run_migrate /var/run /run
-	    run_migrate /var/lock /run/lock
-	    if [ yes = "$RAMSHM_ON_DEV_SHM" ]; then
-		run_migrate /run/shm /dev/shm
-	    else
-		run_migrate /dev/shm /run/shm
-	    fi
 	fi
 }
 
@@ -499,7 +538,7 @@ mount_run() {
 	# If /run/shm is separately mounted, /run can be safely mounted noexec.
 	RUNEXEC=
 	if [ yes = "$RAMSHM" ] || read_fstab_entry /run/shm tmpfs; then
-	    RUNEXEC=',noexec'
+		RUNEXEC=',noexec'
 	fi
 	# TODO: Add -onodev once checkroot no longer creates a device node.
 	domount "$MNTMODE" tmpfs shmfs /run tmpfs "-onosuid$RUNEXEC$RUN_OPT"
@@ -523,17 +562,19 @@ mount_lock() {
 	# Now check if there's an entry in /etc/fstab.  If there is,
 	# it overrides the existing RAMLOCK setting.
 	if read_fstab_entry /run/lock; then
-	    if [ "$MNT_TYPE" = "tmpfs" ] ; then
-		RAMLOCK="yes"
-	    else
-		RAMLOCK="no"
-	    fi
+		if [ "$MNT_TYPE" = "tmpfs" ]; then
+			RAMLOCK="yes"
+		else
+			RAMLOCK="no"
+		fi
 	fi
 
 	KERNEL="$(uname -s)"
 	NODEV="nodev,"
 	case "$KERNEL" in
-		*FreeBSD)  NODEV="" ;;
+		*FreeBSD)
+			NODEV=""
+			;;
 	esac
 
 	# Mount /run/lock as tmpfs if enabled.  This prevents user DoS
@@ -570,8 +611,7 @@ mount_shm() {
 		RAMSHM_ON_DEV_SHM="no"
 	fi
 
-	if [ ! -d "$SHMDIR" ]
-	then
+	if [ ! -d "$SHMDIR" ]; then
 		mkdir --mode=755 "$SHMDIR"
 		[ -x /sbin/restorecon ] && /sbin/restorecon "$SHMDIR"
 	fi
@@ -579,7 +619,7 @@ mount_shm() {
 	# Now check if there's an entry in /etc/fstab.  If there is,
 	# it overrides the existing RAMSHM setting.
 	if read_fstab_entry "$SHMDIR"; then
-		if [ "$MNT_TYPE" = "tmpfs" ] ; then
+		if [ "$MNT_TYPE" = "tmpfs" ]; then
 			RAMSHM="yes"
 		else
 			RAMSHM="no"
@@ -589,7 +629,9 @@ mount_shm() {
 	KERNEL="$(uname -s)"
 	NODEV="nodev,"
 	case "$KERNEL" in
-		*FreeBSD)  NODEV="" ;;
+		*FreeBSD)
+			NODEV=""
+			;;
 	esac
 
 	if [ yes = "$RAMSHM" ]; then
@@ -636,7 +678,7 @@ mount_tmp() {
 		# If there's an entry in fstab for /tmp (any
 		# filesystem type, not just tmpfs), then we don't need
 		# a tmpfs on /tmp by default.
-		if read_fstab_entry /tmp ; then
+		if read_fstab_entry /tmp; then
 			:
 		else
 			log_warning_msg "Root filesystem is read-only; mounting tmpfs on /tmp"
@@ -648,7 +690,7 @@ mount_tmp() {
 		# If there's an entry in fstab for /tmp (any
 		# filesystem type, not just tmpfs), then we don't need
 		# a tmpfs on /tmp by default.
-		if read_fstab_entry /tmp ; then
+		if read_fstab_entry /tmp; then
 			:
 		else
 			log_warning_msg "Root filesystem has insufficient free space; mounting tmpfs on /tmp"
@@ -659,17 +701,19 @@ mount_tmp() {
 	# Now check if there's an entry in /etc/fstab.  If there is,
 	# it overrides all the above settings.
 	if read_fstab_entry /tmp; then
-	    if [ "$MNT_TYPE" = "tmpfs" ] ; then
-		RAMTMP="yes"
-	    else
-		RAMTMP="no"
-	    fi
+		if [ "$MNT_TYPE" = "tmpfs" ]; then
+			RAMTMP="yes"
+		else
+			RAMTMP="no"
+		fi
 	fi
 
 	KERNEL="$(uname -s)"
 	NODEV="nodev,"
 	case "$KERNEL" in
-		*FreeBSD)  NODEV="" ;;
+		*FreeBSD)
+			NODEV=""
+			;;
 	esac
 
 	# Mount /tmp as tmpfs if enabled.
-- 
1.7.10.4

From 4016b9a53587d7e06be5a5f2397d1c0af4b5ffec Mon Sep 17 00:00:00 2001
From: Cristian Ionescu-Idbohrn <[email protected]>
Date: Fri, 25 Jan 2013 23:19:43 +0100
Subject: [PATCH 03/21] More whitespace cleanup.

Signed-off-by: Cristian Ionescu-Idbohrn <[email protected]>
---
 debian/src/initscripts/lib/init/mount-functions.sh |   20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/debian/src/initscripts/lib/init/mount-functions.sh b/debian/src/initscripts/lib/init/mount-functions.sh
index 263672e..99a8833 100644
--- a/debian/src/initscripts/lib/init/mount-functions.sh
+++ b/debian/src/initscripts/lib/init/mount-functions.sh
@@ -126,12 +126,12 @@ _read_fstab_entry() {
 					if [ -n "$2" ]; then
 						[ "$MNT_TYPE" = "$2" ] || continue;
 					fi
-	                                echo "MNT_FSNAME=$MNT_FSNAME"
-	                                echo "MNT_DIR=$MNT_DIR"
-	                                echo "MNT_TYPE=$MNT_TYPE"
-	                                echo "MNT_OPTS=$MNT_OPTS"
-	                                echo "MNT_FREQ=$MNT_FREQ"
-	                                echo "MNT_PASS=$MNT_PASS"
+					echo "MNT_FSNAME=$MNT_FSNAME"
+					echo "MNT_DIR=$MNT_DIR"
+					echo "MNT_TYPE=$MNT_TYPE"
+					echo "MNT_OPTS=$MNT_OPTS"
+					echo "MNT_FREQ=$MNT_FREQ"
+					echo "MNT_PASS=$MNT_PASS"
 					break 2
 				fi
 				MNT_DIR=""
@@ -288,7 +288,7 @@ domount() {
 				mount $MOUNTFLAGS -oremount $CALLER_OPTS $FSTAB_OPTS $MTPT
 			fi
 			;;
-	        mtab)
+		mtab)
 			# Update mtab with correct mount options if
 			# the filesystem is mounted
 			MOUNTFLAGS="-f"
@@ -300,7 +300,7 @@ domount() {
 				fi
 			fi
 			;;
-	        fstab)
+		fstab)
 			# Generate fstab with default mount options.
 			# Note does not work for bind mounts, and does
 			# not work if the fstab already has an entry
@@ -308,8 +308,8 @@ domount() {
 			if ! read_fstab_entry "$MTPT" "$FSTYPE"; then
 				CALLER_OPTS="$(echo "$CALLER_OPTS" | sed -e 's/^-o//')"
 				echo "Creating /etc/fstab entry for $MTPT to replace default in /etc/default/tmpfs (deprecated)" >&2
-	                        echo "# This mount for $MTPT replaces the default configured in /etc/default/tmpfs"
-	                        echo "$DEVNAME	$MTPT	$FSTYPE	$CALLER_OPTS	0	0"
+				echo "# This mount for $MTPT replaces the default configured in /etc/default/tmpfs"
+				echo "$DEVNAME	$MTPT	$FSTYPE	$CALLER_OPTS	0	0"
 			fi
 			;;
 	esac
-- 
1.7.10.4

From 92d5f4f2c04162c4bf341dc3b4b8a087d1fd9382 Mon Sep 17 00:00:00 2001
From: Cristian Ionescu-Idbohrn <[email protected]>
Date: Fri, 25 Jan 2013 23:24:06 +0100
Subject: [PATCH 04/21] Even more whitespace uniformization. No code changes.

Signed-off-by: Cristian Ionescu-Idbohrn <[email protected]>
---
 debian/src/initscripts/lib/init/mount-functions.sh |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/debian/src/initscripts/lib/init/mount-functions.sh b/debian/src/initscripts/lib/init/mount-functions.sh
index 99a8833..5e63c44 100644
--- a/debian/src/initscripts/lib/init/mount-functions.sh
+++ b/debian/src/initscripts/lib/init/mount-functions.sh
@@ -14,8 +14,7 @@ fstab_files() {
 
 # $1: directory
 is_empty_dir() {
-	for FILE in $1/* $1/.*
-	do
+	for FILE in $1/* $1/.*; do
 		case "$FILE" in
 			"$1/.*")
 				return 0
-- 
1.7.10.4

From d6fe110f7f574c8e8c071b63512833950315a28a Mon Sep 17 00:00:00 2001
From: Cristian Ionescu-Idbohrn <[email protected]>
Date: Fri, 25 Jan 2013 23:27:07 +0100
Subject: [PATCH 05/21] Remove useless `return 0'.

Signed-off-by: Cristian Ionescu-Idbohrn <[email protected]>
---
 debian/src/initscripts/lib/init/mount-functions.sh |    7 -------
 1 file changed, 7 deletions(-)

diff --git a/debian/src/initscripts/lib/init/mount-functions.sh b/debian/src/initscripts/lib/init/mount-functions.sh
index 5e63c44..0e53691 100644
--- a/debian/src/initscripts/lib/init/mount-functions.sh
+++ b/debian/src/initscripts/lib/init/mount-functions.sh
@@ -27,7 +27,6 @@ is_empty_dir() {
 				;;
 		esac
 	done
-	return 0
 }
 
 
@@ -368,8 +367,6 @@ bind_mount() {
 		fi
 		return 1
 	fi
-
-	return 0
 }
 
 #
@@ -441,8 +438,6 @@ run_migrate() {
 			[ -x /sbin/restorecon ] && /sbin/restorecon "$OLD"
 		fi
 	fi
-
-	return 0
 }
 
 #
@@ -464,8 +459,6 @@ mtab_migrate() {
 		ln -fs "/proc/mounts" "/etc/mtab" || return 1
 		[ -x /sbin/restorecon ] && /sbin/restorecon "/etc/mtab"
 	fi
-
-	return 0
 }
 
 #
-- 
1.7.10.4

From 7e889bb3f1adf9be98407dc93e4dc991963360d6 Mon Sep 17 00:00:00 2001
From: Cristian Ionescu-Idbohrn <[email protected]>
Date: Fri, 25 Jan 2013 23:28:28 +0100
Subject: [PATCH 06/21] Add explicit return status.

Signed-off-by: Cristian Ionescu-Idbohrn <[email protected]>
---
 debian/src/initscripts/lib/init/mount-functions.sh |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/debian/src/initscripts/lib/init/mount-functions.sh b/debian/src/initscripts/lib/init/mount-functions.sh
index 0e53691..3182f02 100644
--- a/debian/src/initscripts/lib/init/mount-functions.sh
+++ b/debian/src/initscripts/lib/init/mount-functions.sh
@@ -228,7 +228,7 @@ domount() {
 		else
 			log_warning_msg "Filesystem type '$PRIFSTYPE' is not supported. Skipping mount."
 		fi
-		return
+		return 0
 	fi
 
 	# We give file system type as device name if not specified as
@@ -241,7 +241,7 @@ domount() {
 	if read_fstab_entry "$MTPT" "$FSTYPE"; then
 		case "$MNT_OPTS" in
 			noauto|*,noauto|noauto,*|*,noauto,*)
-				return
+				return 0
 				;;
 			?*)
 				FSTAB_OPTS="-o$MNT_OPTS"
@@ -251,7 +251,7 @@ domount() {
 
 	if [ ! -d "$MTPT" ]; then
 		log_warning_msg "Mount point '$MTPT' does not exist. Skipping mount."
-		return
+		return 0
 	fi
 
 	if [ "$MOUNTMODE" = "mount_noupdate" ]; then
-- 
1.7.10.4

From 58a56dfcb3259c315e3bb6bc5e1f8cc03fd3fdfe Mon Sep 17 00:00:00 2001
From: Cristian Ionescu-Idbohrn <[email protected]>
Date: Fri, 25 Jan 2013 23:29:41 +0100
Subject: [PATCH 07/21] Remove some useless quotes.

Signed-off-by: Cristian Ionescu-Idbohrn <[email protected]>
---
 debian/src/initscripts/lib/init/mount-functions.sh |   14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/debian/src/initscripts/lib/init/mount-functions.sh b/debian/src/initscripts/lib/init/mount-functions.sh
index 3182f02..f211f57 100644
--- a/debian/src/initscripts/lib/init/mount-functions.sh
+++ b/debian/src/initscripts/lib/init/mount-functions.sh
@@ -132,7 +132,7 @@ _read_fstab_entry() {
 					echo "MNT_PASS=$MNT_PASS"
 					break 2
 				fi
-				MNT_DIR=""
+				MNT_DIR=
 			done < "$file"
 		fi
 	done
@@ -335,8 +335,8 @@ bind_mount() {
 	SRC=$1
 	DEST=$2
 
-	FSTYPE=""
-	OPTS=""
+	FSTYPE=
+	OPTS=
 
 	ssrc="$(/usr/bin/stat -L --format="%d %i" "$SRC" 2>/dev/null || :)"
 	sdest="$(/usr/bin/stat -L --format="%d %i" "$DEST" 2>/dev/null || :)"
@@ -378,7 +378,7 @@ run_migrate() {
 	RUN=$2
 
 	KERNEL="$(uname -s)"
-	OPTS=""
+	OPTS=
 	case "$KERNEL" in
 		Linux)
 			FSTYPE=none OPTS="-orw -obind"
@@ -565,7 +565,7 @@ mount_lock() {
 	NODEV="nodev,"
 	case "$KERNEL" in
 		*FreeBSD)
-			NODEV=""
+			NODEV=
 			;;
 	esac
 
@@ -622,7 +622,7 @@ mount_shm() {
 	NODEV="nodev,"
 	case "$KERNEL" in
 		*FreeBSD)
-			NODEV=""
+			NODEV=
 			;;
 	esac
 
@@ -704,7 +704,7 @@ mount_tmp() {
 	NODEV="nodev,"
 	case "$KERNEL" in
 		*FreeBSD)
-			NODEV=""
+			NODEV=
 			;;
 	esac
 
-- 
1.7.10.4

From 86d0cf921749f24c60ad112b210b8688cf9e9af5 Mon Sep 17 00:00:00 2001
From: Cristian Ionescu-Idbohrn <[email protected]>
Date: Fri, 25 Jan 2013 23:31:00 +0100
Subject: [PATCH 08/21] Cleanup useless null string test.

Signed-off-by: Cristian Ionescu-Idbohrn <[email protected]>
---
 debian/src/initscripts/lib/init/mount-functions.sh |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/debian/src/initscripts/lib/init/mount-functions.sh b/debian/src/initscripts/lib/init/mount-functions.sh
index f211f57..a55ea93 100644
--- a/debian/src/initscripts/lib/init/mount-functions.sh
+++ b/debian/src/initscripts/lib/init/mount-functions.sh
@@ -78,7 +78,7 @@ _read_fstab() {
 				echo fstabroot=\"$DEV\"
 				echo rootopts=\"$OPTS\"
 				echo roottype=\"$FSTYPE\"
-				( [ "$PASS" != 0 ] && [ "$PASS" != "" ] ) && echo rootcheck=yes
+				( [ "$PASS" != 0 ] && [ "$PASS" ] ) && echo rootcheck=yes
 				( [ "$FSTYPE" = "nfs" ] || [ "$FSTYPE" = "nfs4" ] ) && echo rootcheck=no
 				case "$OPTS" in
 					ro|ro,*|*,ro|*,ro,*)
-- 
1.7.10.4

From 65ea7ee4e579f4a8ed4c084b9daaf82c43838376 Mon Sep 17 00:00:00 2001
From: Cristian Ionescu-Idbohrn <[email protected]>
Date: Fri, 25 Jan 2013 23:40:57 +0100
Subject: [PATCH 09/21] Remove useless control operators.

Signed-off-by: Cristian Ionescu-Idbohrn <[email protected]>
---
 debian/src/initscripts/lib/init/mount-functions.sh |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/debian/src/initscripts/lib/init/mount-functions.sh b/debian/src/initscripts/lib/init/mount-functions.sh
index a55ea93..05d21bd 100644
--- a/debian/src/initscripts/lib/init/mount-functions.sh
+++ b/debian/src/initscripts/lib/init/mount-functions.sh
@@ -54,7 +54,7 @@ _read_fstab() {
 			while read DEV MTPT FSTYPE OPTS DUMP PASS JUNK; do
 				case "$DEV" in
 					""|\#*)
-						continue;
+						continue
 						;;
 					/dev/mapper/*)
 						[ "$FSTYPE" = "swap" ] && echo swap_on_lv=yes
@@ -117,12 +117,12 @@ _read_fstab_entry() {
 			while read MNT_FSNAME MNT_DIR MNT_TYPE MNT_OPTS MNT_FREQ MNT_PASS MNT_JUNK; do
 				case "$MNT_FSNAME" in
 					""|\#*)
-						continue;
+						continue
 						;;
 				esac
 				if [ "$MNT_DIR" = "$1" ]; then
 					if [ -n "$2" ]; then
-						[ "$MNT_TYPE" = "$2" ] || continue;
+						[ "$MNT_TYPE" = "$2" ] || continue
 					fi
 					echo "MNT_FSNAME=$MNT_FSNAME"
 					echo "MNT_DIR=$MNT_DIR"
-- 
1.7.10.4

From 5de3b0b91e2f99f849b13980677df3f7f3b2c26f Mon Sep 17 00:00:00 2001
From: Cristian Ionescu-Idbohrn <[email protected]>
Date: Fri, 25 Jan 2013 23:59:19 +0100
Subject: [PATCH 10/21] Remove totally useless quotes.

Signed-off-by: Cristian Ionescu-Idbohrn <[email protected]>
---
 debian/src/initscripts/lib/init/mount-functions.sh |  173 ++++++++++----------
 1 file changed, 88 insertions(+), 85 deletions(-)

diff --git a/debian/src/initscripts/lib/init/mount-functions.sh b/debian/src/initscripts/lib/init/mount-functions.sh
index 05d21bd..c713ee7 100644
--- a/debian/src/initscripts/lib/init/mount-functions.sh
+++ b/debian/src/initscripts/lib/init/mount-functions.sh
@@ -15,11 +15,11 @@ fstab_files() {
 # $1: directory
 is_empty_dir() {
 	for FILE in $1/* $1/.*; do
-		case "$FILE" in
-			"$1/.*")
+		case $FILE in
+			$1/.*)
 				return 0
 				;;
-			"$1/*"|"$1/."|"$1/..")
+			$1/*|$1/.|$1/..)
 				continue
 				;;
 			*)
@@ -57,30 +57,30 @@ _read_fstab() {
 						continue
 						;;
 					/dev/mapper/*)
-						[ "$FSTYPE" = "swap" ] && echo swap_on_lv=yes
+						[ "$FSTYPE" = swap ] && echo swap_on_lv=yes
 						;;
 					/dev/*)
 						;;
 					LABEL=*|UUID=*)
-						if [ "$MTPT" = "/" ] && [ -x /sbin/findfs ]
+						if [ "$MTPT" = / ] && [ -x /sbin/findfs ]
 						then
-							DEV="$(findfs "$DEV")"
+							DEV=$(findfs "$DEV")
 						fi
 						;;
 					/*)
-						[ "$FSTYPE" = "swap" ] && echo swap_on_file=yes
+						[ "$FSTYPE" = swap ] && echo swap_on_file=yes
 						;;
 					*)
 						;;
 				esac
-				[ "$MTPT" != "/" ] && continue
+				[ "$MTPT" != / ] && continue
 				echo rootdev=\"$DEV\"
 				echo fstabroot=\"$DEV\"
 				echo rootopts=\"$OPTS\"
 				echo roottype=\"$FSTYPE\"
 				( [ "$PASS" != 0 ] && [ "$PASS" ] ) && echo rootcheck=yes
-				( [ "$FSTYPE" = "nfs" ] || [ "$FSTYPE" = "nfs4" ] ) && echo rootcheck=no
-				case "$OPTS" in
+				( [ "$FSTYPE" = nfs ] || [ "$FSTYPE" = nfs4 ] ) && echo rootcheck=no
+				case $OPTS in
 					ro|ro,*|*,ro|*,ro,*)
 						echo rootmode=ro
 						;;
@@ -115,7 +115,7 @@ _read_fstab_entry() {
 	fstab_files | while read file; do
 		if [ -f "$file" ]; then
 			while read MNT_FSNAME MNT_DIR MNT_TYPE MNT_OPTS MNT_FREQ MNT_PASS MNT_JUNK; do
-				case "$MNT_FSNAME" in
+				case $MNT_FSNAME in
 					""|\#*)
 						continue
 						;;
@@ -169,7 +169,7 @@ domount() {
 	DEVNAME="$5"
 	CALLER_OPTS="$6"
 
-	KERNEL="$(uname -s)"
+	KERNEL=$(uname -s)
 	# Figure out filesystem type from primary and alternative type
 	FSTYPE=
 	# Filesystem-specific mount options
@@ -190,10 +190,10 @@ domount() {
 				;;
 		esac
 	elif [ "$PRIFSTYPE" = bind ]; then
-		case "$KERNEL" in
+		case $KERNEL in
 			Linux)
-				FSTYPE="$DEVNAME"
-				FS_OPTS="-obind"
+				FSTYPE=$DEVNAME
+				FS_OPTS=-obind
 				;;
 			*FreeBSD)
 				FSTYPE=nullfs
@@ -207,7 +207,7 @@ domount() {
 		esac
 	elif [ "$PRIFSTYPE" = tmpfs ]; then
 		# always accept tmpfs, to mount /run before /proc
-		case "$KERNEL" in
+		case $KERNEL in
 			GNU)
 				FSTYPE=none
 				;; # for now
@@ -239,12 +239,12 @@ domount() {
 
 	# Get the mount options from /etc/fstab
 	if read_fstab_entry "$MTPT" "$FSTYPE"; then
-		case "$MNT_OPTS" in
+		case $MNT_OPTS in
 			noauto|*,noauto|noauto,*|*,noauto,*)
 				return 0
 				;;
 			?*)
-				FSTAB_OPTS="-o$MNT_OPTS"
+				FSTAB_OPTS=-o$MNT_OPTS
 				;;
 		esac
 	fi
@@ -254,16 +254,16 @@ domount() {
 		return 0
 	fi
 
-	if [ "$MOUNTMODE" = "mount_noupdate" ]; then
-		MOUNTFLAGS="-n"
+	if [ "$MOUNTMODE" = mount_noupdate ]; then
+		MOUNTFLAGS=-n
 		MOUNTMODE=mount
 	fi
-	if [ "$MOUNTMODE" = "remount_noupdate" ]; then
-		MOUNTFLAGS="-n"
+	if [ "$MOUNTMODE" = remount_noupdate ]; then
+		MOUNTFLAGS=-n
 		MOUNTMODE=remount
 	fi
 
-	case "$MOUNTMODE" in
+	case $MOUNTMODE in
 		mount)
 			if mountpoint -q "$MTPT"; then
 				# Already mounted, probably moved from the
@@ -271,11 +271,11 @@ domount() {
 				# user-specified mount options later on.
 				:
 			else
-				if [ "$VERBOSE" != "no" ]; then
+				if [ "$VERBOSE" != no ]; then
 					is_empty_dir "$MTPT" >/dev/null 2>&1 || log_warning_msg "Files under mount point '$MTPT' will be hidden."
 				fi
 				mount $MOUNTFLAGS -t $FSTYPE $CALLER_OPTS $FSTAB_OPTS $FS_OPTS $DEVNAME $MTPT
-				if [ "$FSTYPE" = "tmpfs" -a -x /sbin/restorecon ]; then
+				if [ "$FSTYPE" = tmpfs -a -x /sbin/restorecon ]; then
 					/sbin/restorecon $MTPT
 				fi
 			fi
@@ -289,7 +289,7 @@ domount() {
 		mtab)
 			# Update mtab with correct mount options if
 			# the filesystem is mounted
-			MOUNTFLAGS="-f"
+			MOUNTFLAGS=-f
 
 			if mountpoint -q "$MTPT"; then
 				# Already recorded?
@@ -338,16 +338,17 @@ bind_mount() {
 	FSTYPE=
 	OPTS=
 
-	ssrc="$(/usr/bin/stat -L --format="%d %i" "$SRC" 2>/dev/null || :)"
-	sdest="$(/usr/bin/stat -L --format="%d %i" "$DEST" 2>/dev/null || :)"
+	ssrc=$(/usr/bin/stat -L --format="%d %i" "$SRC" 2>/dev/null || :)
+	sdest=$(/usr/bin/stat -L --format="%d %i" "$DEST" 2>/dev/null || :)
 
-	case "$(uname -s)" in
+	case $(uname -s) in
 		Linux)
-			FSTYPE=$SRC; OPTS="-orw -obind"
+			FSTYPE=$SRC
+			OPTS="-orw -obind"
 			;;
 		*FreeBSD)
 			FSTYPE=nullfs
-			OPTS="-orw"
+			OPTS=-orw
 			;;
 		GNU)
 			FSTYPE=firmlink
@@ -377,14 +378,16 @@ run_migrate() {
 	OLD=$1
 	RUN=$2
 
-	KERNEL="$(uname -s)"
+	KERNEL=$(uname -s)
 	OPTS=
-	case "$KERNEL" in
+	case $KERNEL in
 		Linux)
-			FSTYPE=none OPTS="-orw -obind"
+			FSTYPE=none
+			OPTS="-orw -obind"
 			;;
 		*FreeBSD)
-			FSTYPE=nullfs OPTS="-orw"
+			FSTYPE=nullfs
+			OPTS=-orw
 			;;
 		GNU)
 			FSTYPE=firmlink
@@ -406,8 +409,8 @@ run_migrate() {
 
 	# If both directories are the same, we don't need to do
 	# anything further.
-	sold="$(/usr/bin/stat -L --format="%d %i" "$OLD" 2>/dev/null || :)"
-	srun="$(/usr/bin/stat -L --format="%d %i" "$RUN" 2>/dev/null || :)"
+	sold=$(/usr/bin/stat -L --format="%d %i" "$OLD" 2>/dev/null || :)
+	srun=$(/usr/bin/stat -L --format="%d %i" "$RUN" 2>/dev/null || :)
 	if [ -n "$sold" ] && [ "$sold" = "$srun" ]; then
 		return 0
 	fi
@@ -423,7 +426,7 @@ run_migrate() {
 
 	# If removal failed (directory still exists), set up bind mount.
 	if [ ! -L "$OLD" ] && [ -d "$OLD" ]; then
-		if [ "$OLD" != "/tmp" ]; then
+		if [ "$OLD" != /tmp ]; then
 			log_warning_msg "Filesystem mounted on $OLD; setting up compatibility bind mount."
 			log_warning_msg "Please remove this mount from /etc/fstab; it is no longer needed, and it is preventing completion of the transition to $RUN."
 		fi
@@ -445,19 +448,19 @@ run_migrate() {
 #
 mtab_migrate() {
 	# Don't symlink if /proc/mounts does not exist.
-	if [ ! -r "/proc/mounts" ]; then
+	if [ ! -r /proc/mounts ]; then
 		return 1
 	fi
 
 	# Create symlink if not already present.
-	if [ -L "/etc/mtab" ] && [ "$(readlink "/etc/mtab")" = "/proc/mounts" ]; then
+	if [ -L /etc/mtab ] && [ "$(readlink "/etc/mtab")" = /proc/mounts ]; then
 		:
 	else
 		log_warning_msg "Creating compatibility symlink from /etc/mtab to /proc/mounts."
 
-		rm -f "/etc/mtab" || return 1
-		ln -fs "/proc/mounts" "/etc/mtab" || return 1
-		[ -x /sbin/restorecon ] && /sbin/restorecon "/etc/mtab"
+		rm -f /etc/mtab || return 1
+		ln -fs /proc/mounts /etc/mtab || return 1
+		[ -x /sbin/restorecon ] && /sbin/restorecon /etc/mtab
 	fi
 }
 
@@ -482,16 +485,16 @@ post_mountall() {
 	# directory.  The migration logic will then take care of the
 	# rest.  Note that it will take a second boot to fully
 	# migrate; it should only ever be needed on broken systems.
-	RAMSHM_ON_DEV_SHM="no"
-	if read_fstab_entry "/dev/shm"; then
-	    RAMSHM_ON_DEV_SHM="yes"
+	RAMSHM_ON_DEV_SHM=no
+	if read_fstab_entry /dev/shm; then
+	    RAMSHM_ON_DEV_SHM=yes
 	fi
-	if read_fstab_entry "/run/shm"; then
-	    RAMSHM_ON_DEV_SHM="no"
+	if read_fstab_entry /run/shm; then
+	    RAMSHM_ON_DEV_SHM=no
 	fi
 
 	if [ -L /run ]; then
-		if [ "$(readlink /run)" = "/var/run" ]; then
+		if [ "$(readlink /run)" = /var/run ]; then
 			rm -f /run
 			mkdir /run
 		fi
@@ -530,7 +533,7 @@ mount_run() {
 	# If /run/shm is separately mounted, /run can be safely mounted noexec.
 	RUNEXEC=
 	if [ yes = "$RAMSHM" ] || read_fstab_entry /run/shm tmpfs; then
-		RUNEXEC=',noexec'
+		RUNEXEC=,noexec
 	fi
 	# TODO: Add -onodev once checkroot no longer creates a device node.
 	domount "$MNTMODE" tmpfs shmfs /run tmpfs "-onosuid$RUNEXEC$RUN_OPT"
@@ -554,16 +557,16 @@ mount_lock() {
 	# Now check if there's an entry in /etc/fstab.  If there is,
 	# it overrides the existing RAMLOCK setting.
 	if read_fstab_entry /run/lock; then
-		if [ "$MNT_TYPE" = "tmpfs" ]; then
-			RAMLOCK="yes"
+		if [ "$MNT_TYPE" = tmpfs ]; then
+			RAMLOCK=yes
 		else
-			RAMLOCK="no"
+			RAMLOCK=no
 		fi
 	fi
 
-	KERNEL="$(uname -s)"
-	NODEV="nodev,"
-	case "$KERNEL" in
+	KERNEL=$(uname -s)
+	NODEV=nodev,
+	case $KERNEL in
 		*FreeBSD)
 			NODEV=
 			;;
@@ -585,22 +588,22 @@ mount_lock() {
 mount_shm() {
 	MNTMODE="$1"
 
-	RAMSHM_ON_DEV_SHM="no"
-	SHMDIR="/run/shm"
-	if read_fstab_entry "/dev/shm"; then
-		if [ "$MNTMODE" = "mount_noupdate" ]; then
+	RAMSHM_ON_DEV_SHM=no
+	SHMDIR=/run/shm
+	if read_fstab_entry /dev/shm; then
+		if [ "$MNTMODE" = mount_noupdate ]; then
 			log_warning_msg "Warning: fstab entry for /dev/shm; should probably be for /run/shm unless working around a bug in the Oracle database"
 		fi
-		SHMDIR="/dev/shm"
-		RAMSHM_ON_DEV_SHM="yes"
+		SHMDIR=/dev/shm
+		RAMSHM_ON_DEV_SHM=yes
 	fi
-	if read_fstab_entry "/run/shm"; then
-		if [ "$MNTMODE" = "mount_noupdate" ] && [ "$RAMSHM_ON_DEV_SHM" = "yes" ]; then
+	if read_fstab_entry /run/shm; then
+		if [ "$MNTMODE" = mount_noupdate ] && [ "$RAMSHM_ON_DEV_SHM" = yes ]; then
 			log_warning_msg "Warning: fstab entries for both /dev/shm and /run/shm found; only /run/shm will be used"
 		fi
 
-		SHMDIR="/run/shm"
-		RAMSHM_ON_DEV_SHM="no"
+		SHMDIR=/run/shm
+		RAMSHM_ON_DEV_SHM=no
 	fi
 
 	if [ ! -d "$SHMDIR" ]; then
@@ -611,16 +614,16 @@ mount_shm() {
 	# Now check if there's an entry in /etc/fstab.  If there is,
 	# it overrides the existing RAMSHM setting.
 	if read_fstab_entry "$SHMDIR"; then
-		if [ "$MNT_TYPE" = "tmpfs" ]; then
-			RAMSHM="yes"
+		if [ "$MNT_TYPE" = tmpfs ]; then
+			RAMSHM=yes
 		else
-			RAMSHM="no"
+			RAMSHM=no
 		fi
 	fi
 
-	KERNEL="$(uname -s)"
-	NODEV="nodev,"
-	case "$KERNEL" in
+	KERNEL=$(uname -s)
+	NODEV=nodev,
+	case $KERNEL in
 		*FreeBSD)
 			NODEV=
 			;;
@@ -652,21 +655,21 @@ mount_tmp() {
 
 	# If /tmp is a symlink, make sure the linked-to directory exists.
 	if [ -L /tmp ] && [ ! -d /tmp ]; then
-		TMPPATH="$(readlink /tmp)"
+		TMPPATH=$(readlink /tmp)
 		mkdir -p --mode=755 "$TMPPATH"
 		[ -x /sbin/restorecon ] && /sbin/restorecon "$TMPPATH"
 	fi
 
 	# Disable RAMTMP if there's 64MiB RAM or less.  May be
 	# re-enabled by overflow or read only root, below.
-	RAM_SIZE="$(ram_size)"
-	if [ -n "$RAM_SIZE" ] && [ "$((RAM_SIZE <= 65536))" = "1" ]; then
+	RAM_SIZE=$(ram_size)
+	if [ -n "$RAM_SIZE" ] && [ "$((RAM_SIZE <= 65536))" = 1 ]; then
 		RAMTMP=no
 	fi
 
 	# If root is read only, default to mounting a tmpfs on /tmp,
 	# unless one is due to be mounted from fstab.
-	if [ "$RAMTMP" != "yes" ] && [ rw != "$rootmode" ]; then
+	if [ "$RAMTMP" != yes ] && [ rw != "$rootmode" ]; then
 		# If there's an entry in fstab for /tmp (any
 		# filesystem type, not just tmpfs), then we don't need
 		# a tmpfs on /tmp by default.
@@ -674,11 +677,11 @@ mount_tmp() {
 			:
 		else
 			log_warning_msg "Root filesystem is read-only; mounting tmpfs on /tmp"
-			RAMTMP="yes"
+			RAMTMP=yes
 		fi
 	fi
 
-	if [ "$RAMTMP" != "yes" ] && need_overflow_tmp; then
+	if [ "$RAMTMP" != yes ] && need_overflow_tmp; then
 		# If there's an entry in fstab for /tmp (any
 		# filesystem type, not just tmpfs), then we don't need
 		# a tmpfs on /tmp by default.
@@ -686,23 +689,23 @@ mount_tmp() {
 			:
 		else
 			log_warning_msg "Root filesystem has insufficient free space; mounting tmpfs on /tmp"
-			RAMTMP="yes"
+			RAMTMP=yes
 		fi
 	fi
 
 	# Now check if there's an entry in /etc/fstab.  If there is,
 	# it overrides all the above settings.
 	if read_fstab_entry /tmp; then
-		if [ "$MNT_TYPE" = "tmpfs" ]; then
-			RAMTMP="yes"
+		if [ "$MNT_TYPE" = tmpfs ]; then
+			RAMTMP=yes
 		else
-			RAMTMP="no"
+			RAMTMP=no
 		fi
 	fi
 
-	KERNEL="$(uname -s)"
-	NODEV="nodev,"
-	case "$KERNEL" in
+	KERNEL=$(uname -s)
+	NODEV=nodev,
+	case $KERNEL in
 		*FreeBSD)
 			NODEV=
 			;;
-- 
1.7.10.4

From 569606aa56e375eb56fc7e421046d311eceb194a Mon Sep 17 00:00:00 2001
From: Cristian Ionescu-Idbohrn <[email protected]>
Date: Sat, 26 Jan 2013 00:08:35 +0100
Subject: [PATCH 11/21] Uniformize tests.

Signed-off-by: Cristian Ionescu-Idbohrn <[email protected]>
---
 debian/src/initscripts/lib/init/mount-functions.sh |   21 ++++++++++----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/debian/src/initscripts/lib/init/mount-functions.sh b/debian/src/initscripts/lib/init/mount-functions.sh
index c713ee7..1a47eb8 100644
--- a/debian/src/initscripts/lib/init/mount-functions.sh
+++ b/debian/src/initscripts/lib/init/mount-functions.sh
@@ -62,8 +62,7 @@ _read_fstab() {
 					/dev/*)
 						;;
 					LABEL=*|UUID=*)
-						if [ "$MTPT" = / ] && [ -x /sbin/findfs ]
-						then
+						if [ "$MTPT" = / ] && [ -x /sbin/findfs ]; then
 							DEV=$(findfs "$DEV")
 						fi
 						;;
@@ -500,7 +499,7 @@ post_mountall() {
 		fi
 		if bind_mount /var/run /run; then
 			bind_mount /var/lock /run/lock
-			if [ yes = "$RAMSHM_ON_DEV_SHM" ]; then
+			if [ "$RAMSHM_ON_DEV_SHM" = yes ]; then
 				run_migrate /run/shm /dev/shm
 			else
 				run_migrate /dev/shm /run/shm
@@ -509,7 +508,7 @@ post_mountall() {
 	else
 		run_migrate /var/run /run
 		run_migrate /var/lock /run/lock
-		if [ yes = "$RAMSHM_ON_DEV_SHM" ]; then
+		if [ "$RAMSHM_ON_DEV_SHM" = yes ]; then
 			run_migrate /run/shm /dev/shm
 		else
 			run_migrate /dev/shm /run/shm
@@ -532,7 +531,7 @@ mount_run() {
 
 	# If /run/shm is separately mounted, /run can be safely mounted noexec.
 	RUNEXEC=
-	if [ yes = "$RAMSHM" ] || read_fstab_entry /run/shm tmpfs; then
+	if [ "$RAMSHM" = yes ] || read_fstab_entry /run/shm tmpfs; then
 		RUNEXEC=,noexec
 	fi
 	# TODO: Add -onodev once checkroot no longer creates a device node.
@@ -575,7 +574,7 @@ mount_lock() {
 	# Mount /run/lock as tmpfs if enabled.  This prevents user DoS
 	# of /run by filling /run/lock at the expense of using an
 	# additional tmpfs.
-	if [ yes = "$RAMLOCK" ]; then
+	if [ "$RAMLOCK" = yes ]; then
 		domount "$MNTMODE" tmpfs shmfs /run/lock tmpfs "-o${NODEV}noexec,nosuid$LOCK_OPT"
 		# Make sure we don't get cleaned
 		touch /run/lock/.tmpfs
@@ -629,7 +628,7 @@ mount_shm() {
 			;;
 	esac
 
-	if [ yes = "$RAMSHM" ]; then
+	if [ "$RAMSHM" = yes ]; then
 		domount "$MNTMODE" tmpfs shmfs "$SHMDIR" tmpfs "-onosuid,${NODEV}noexec$SHM_OPT"
 		# Make sure we don't get cleaned
 		touch "$SHMDIR"/.tmpfs
@@ -639,7 +638,7 @@ mount_shm() {
 
 	# Migrate early, so /dev/shm is available from the start
 	if [ "$MNTMODE" = mount_noupdate ] || [ "$MNTMODE" = mount ]; then
-		if [ yes = "$RAMSHM_ON_DEV_SHM" ]; then
+		if [ "$RAMSHM_ON_DEV_SHM" = yes ]; then
 			run_migrate /run/shm /dev/shm
 		else
 			run_migrate /dev/shm /run/shm
@@ -669,7 +668,7 @@ mount_tmp() {
 
 	# If root is read only, default to mounting a tmpfs on /tmp,
 	# unless one is due to be mounted from fstab.
-	if [ "$RAMTMP" != yes ] && [ rw != "$rootmode" ]; then
+	if [ "$RAMTMP" != yes ] && [ "$rootmode" != rw ]; then
 		# If there's an entry in fstab for /tmp (any
 		# filesystem type, not just tmpfs), then we don't need
 		# a tmpfs on /tmp by default.
@@ -712,13 +711,13 @@ mount_tmp() {
 	esac
 
 	# Mount /tmp as tmpfs if enabled.
-	if [ yes = "$RAMTMP" ]; then
+	if [ "$RAMTMP" = yes ]; then
 		domount "$MNTMODE" tmpfs shmfs /tmp tmpfs "-o${NODEV}nosuid$TMP_OPT"
 		# Make sure we don't get cleaned
 		touch /tmp/.tmpfs
 	else
 		# When root is still read only, this will fail.
-		if [ mount_noupdate != "$MNTMODE" ] && [ rw = "$rootmode" ]; then
+		if [ "$MNTMODE" != mount_noupdate ] && [ "$rootmode" = rw ]; then
 			chmod "$TMP_MODE" /tmp
 		fi
 	fi
-- 
1.7.10.4

From 212240e7eb355f7a603d03d15b0cce192b636cab Mon Sep 17 00:00:00 2001
From: Cristian Ionescu-Idbohrn <[email protected]>
Date: Sat, 26 Jan 2013 00:09:33 +0100
Subject: [PATCH 12/21] Remove useless '-n' test operator.

Signed-off-by: Cristian Ionescu-Idbohrn <[email protected]>
---
 debian/src/initscripts/lib/init/mount-functions.sh |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/debian/src/initscripts/lib/init/mount-functions.sh b/debian/src/initscripts/lib/init/mount-functions.sh
index 1a47eb8..aab951d 100644
--- a/debian/src/initscripts/lib/init/mount-functions.sh
+++ b/debian/src/initscripts/lib/init/mount-functions.sh
@@ -120,7 +120,7 @@ _read_fstab_entry() {
 						;;
 				esac
 				if [ "$MNT_DIR" = "$1" ]; then
-					if [ -n "$2" ]; then
+					if [ "$2" ]; then
 						[ "$MNT_TYPE" = "$2" ] || continue
 					fi
 					echo "MNT_FSNAME=$MNT_FSNAME"
@@ -358,7 +358,7 @@ bind_mount() {
 	esac
 
 	# Bind mount $SRC on $DEST
-	if [ -n "$ssrc" ] && [ "$ssrc" != "$sdest" ]; then
+	if [ "$ssrc" ] && [ "$ssrc" != "$sdest" ]; then
 		[ -d "$DEST" ] || mkdir "$DEST"
 		[ -x /sbin/restorecon ] && /sbin/restorecon "$DEST"
 		if mount -t $FSTYPE "$SRC" "$DEST" $OPTS; then
@@ -410,7 +410,7 @@ run_migrate() {
 	# anything further.
 	sold=$(/usr/bin/stat -L --format="%d %i" "$OLD" 2>/dev/null || :)
 	srun=$(/usr/bin/stat -L --format="%d %i" "$RUN" 2>/dev/null || :)
-	if [ -n "$sold" ] && [ "$sold" = "$srun" ]; then
+	if [ "$sold" ] && [ "$sold" = "$srun" ]; then
 		return 0
 	fi
 
@@ -662,7 +662,7 @@ mount_tmp() {
 	# Disable RAMTMP if there's 64MiB RAM or less.  May be
 	# re-enabled by overflow or read only root, below.
 	RAM_SIZE=$(ram_size)
-	if [ -n "$RAM_SIZE" ] && [ "$((RAM_SIZE <= 65536))" = 1 ]; then
+	if [ "$RAM_SIZE" ] && [ "$((RAM_SIZE <= 65536))" = 1 ]; then
 		RAMTMP=no
 	fi
 
-- 
1.7.10.4

From 15b312099603c4b1294e4c81c1b8a598b1439643 Mon Sep 17 00:00:00 2001
From: Cristian Ionescu-Idbohrn <[email protected]>
Date: Sat, 26 Jan 2013 00:11:46 +0100
Subject: [PATCH 13/21] Uniformize logical test operator.

Signed-off-by: Cristian Ionescu-Idbohrn <[email protected]>
---
 debian/src/initscripts/lib/init/mount-functions.sh |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/debian/src/initscripts/lib/init/mount-functions.sh b/debian/src/initscripts/lib/init/mount-functions.sh
index aab951d..46e4b57 100644
--- a/debian/src/initscripts/lib/init/mount-functions.sh
+++ b/debian/src/initscripts/lib/init/mount-functions.sh
@@ -274,7 +274,7 @@ domount() {
 					is_empty_dir "$MTPT" >/dev/null 2>&1 || log_warning_msg "Files under mount point '$MTPT' will be hidden."
 				fi
 				mount $MOUNTFLAGS -t $FSTYPE $CALLER_OPTS $FSTAB_OPTS $FS_OPTS $DEVNAME $MTPT
-				if [ "$FSTYPE" = tmpfs -a -x /sbin/restorecon ]; then
+				if [ "$FSTYPE" = tmpfs ] && [ -x /sbin/restorecon ]; then
 					/sbin/restorecon $MTPT
 				fi
 			fi
-- 
1.7.10.4

From 978e2ba30204ed239108bbe5351f1c32c2ec6134 Mon Sep 17 00:00:00 2001
From: Cristian Ionescu-Idbohrn <[email protected]>
Date: Sat, 26 Jan 2013 00:13:16 +0100
Subject: [PATCH 14/21] Remove more useless quotes.

Signed-off-by: Cristian Ionescu-Idbohrn <[email protected]>
---
 debian/src/initscripts/lib/init/mount-functions.sh |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/debian/src/initscripts/lib/init/mount-functions.sh b/debian/src/initscripts/lib/init/mount-functions.sh
index 46e4b57..3a526b9 100644
--- a/debian/src/initscripts/lib/init/mount-functions.sh
+++ b/debian/src/initscripts/lib/init/mount-functions.sh
@@ -52,7 +52,7 @@ _read_fstab() {
 	fstab_files | while read file; do
 		if [ -f "$file" ]; then
 			while read DEV MTPT FSTYPE OPTS DUMP PASS JUNK; do
-				case "$DEV" in
+				case $DEV in
 					""|\#*)
 						continue
 						;;
@@ -177,7 +177,7 @@ domount() {
 	FSTAB_OPTS=
 
 	if [ "$PRIFSTYPE" = proc ]; then
-		case "$KERNEL" in
+		case $KERNEL in
 			Linux|GNU)
 				FSTYPE=proc
 				;;
-- 
1.7.10.4

From 47a54e37de0e78f7288886f45396add08c087f62 Mon Sep 17 00:00:00 2001
From: Cristian Ionescu-Idbohrn <[email protected]>
Date: Sun, 27 Jan 2013 09:08:25 +0100
Subject: [PATCH 16/21] Use shell builtin redirection instead of using a
 `touch' fork.

Signed-off-by: Cristian Ionescu-Idbohrn <[email protected]>
---
 debian/src/initscripts/lib/init/mount-functions.sh |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/debian/src/initscripts/lib/init/mount-functions.sh b/debian/src/initscripts/lib/init/mount-functions.sh
index 67a4578..bd6f5fa 100644
--- a/debian/src/initscripts/lib/init/mount-functions.sh
+++ b/debian/src/initscripts/lib/init/mount-functions.sh
@@ -549,7 +549,7 @@ mount_run() {
 	[ -d /run/sendsigs.omit.d ] || mkdir --mode=755 /run/sendsigs.omit.d/
 
 	# Make sure we don't get cleaned
-	touch /run/.tmpfs
+	>>/run/.tmpfs
 }
 
 # Mount /run/lock
@@ -584,7 +584,7 @@ mount_lock() {
 	if [ "$RAMLOCK" = yes ]; then
 		domount "$MNTMODE" tmpfs shmfs /run/lock tmpfs "-o${NODEV}noexec,nosuid$LOCK_OPT"
 		# Make sure we don't get cleaned
-		touch /run/lock/.tmpfs
+		>>/run/lock/.tmpfs
 	else
 		chmod "$LOCK_MODE" /run/lock
 	fi
@@ -638,7 +638,7 @@ mount_shm() {
 	if [ "$RAMSHM" = yes ]; then
 		domount "$MNTMODE" tmpfs shmfs "$SHMDIR" tmpfs "-onosuid,${NODEV}noexec$SHM_OPT"
 		# Make sure we don't get cleaned
-		touch "$SHMDIR"/.tmpfs
+		>>"$SHMDIR"/.tmpfs
 	else
 		chmod "$SHM_MODE" "$SHMDIR"
 	fi
@@ -721,7 +721,7 @@ mount_tmp() {
 	if [ "$RAMTMP" = yes ]; then
 		domount "$MNTMODE" tmpfs shmfs /tmp tmpfs "-o${NODEV}nosuid$TMP_OPT"
 		# Make sure we don't get cleaned
-		touch /tmp/.tmpfs
+		>>/tmp/.tmpfs
 	else
 		# When root is still read only, this will fail.
 		if [ "$MNTMODE" != mount_noupdate ] && [ "$rootmode" = rw ]; then
-- 
1.7.10.4

From 47a54e37de0e78f7288886f45396add08c087f62 Mon Sep 17 00:00:00 2001
From: Cristian Ionescu-Idbohrn <[email protected]>
Date: Sun, 27 Jan 2013 09:08:25 +0100
Subject: [PATCH 16/21] Use shell builtin redirection instead of using a
 `touch' fork.

Signed-off-by: Cristian Ionescu-Idbohrn <[email protected]>
---
 debian/src/initscripts/lib/init/mount-functions.sh |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/debian/src/initscripts/lib/init/mount-functions.sh b/debian/src/initscripts/lib/init/mount-functions.sh
index 67a4578..bd6f5fa 100644
--- a/debian/src/initscripts/lib/init/mount-functions.sh
+++ b/debian/src/initscripts/lib/init/mount-functions.sh
@@ -549,7 +549,7 @@ mount_run() {
 	[ -d /run/sendsigs.omit.d ] || mkdir --mode=755 /run/sendsigs.omit.d/
 
 	# Make sure we don't get cleaned
-	touch /run/.tmpfs
+	>>/run/.tmpfs
 }
 
 # Mount /run/lock
@@ -584,7 +584,7 @@ mount_lock() {
 	if [ "$RAMLOCK" = yes ]; then
 		domount "$MNTMODE" tmpfs shmfs /run/lock tmpfs "-o${NODEV}noexec,nosuid$LOCK_OPT"
 		# Make sure we don't get cleaned
-		touch /run/lock/.tmpfs
+		>>/run/lock/.tmpfs
 	else
 		chmod "$LOCK_MODE" /run/lock
 	fi
@@ -638,7 +638,7 @@ mount_shm() {
 	if [ "$RAMSHM" = yes ]; then
 		domount "$MNTMODE" tmpfs shmfs "$SHMDIR" tmpfs "-onosuid,${NODEV}noexec$SHM_OPT"
 		# Make sure we don't get cleaned
-		touch "$SHMDIR"/.tmpfs
+		>>"$SHMDIR"/.tmpfs
 	else
 		chmod "$SHM_MODE" "$SHMDIR"
 	fi
@@ -721,7 +721,7 @@ mount_tmp() {
 	if [ "$RAMTMP" = yes ]; then
 		domount "$MNTMODE" tmpfs shmfs /tmp tmpfs "-o${NODEV}nosuid$TMP_OPT"
 		# Make sure we don't get cleaned
-		touch /tmp/.tmpfs
+		>>/tmp/.tmpfs
 	else
 		# When root is still read only, this will fail.
 		if [ "$MNTMODE" != mount_noupdate ] && [ "$rootmode" = rw ]; then
-- 
1.7.10.4

From f9c0801e9d02ebc2b45cfb93c53ea8b511a96405 Mon Sep 17 00:00:00 2001
From: Cristian Ionescu-Idbohrn <[email protected]>
Date: Sun, 27 Jan 2013 09:19:29 +0100
Subject: [PATCH 17/21] Use guaranteed builtin `:' instead of (sometimes)
 `true' fork.

Signed-off-by: Cristian Ionescu-Idbohrn <[email protected]>
---
 debian/src/initscripts/lib/init/mount-functions.sh |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/debian/src/initscripts/lib/init/mount-functions.sh b/debian/src/initscripts/lib/init/mount-functions.sh
index bd6f5fa..20520ff 100644
--- a/debian/src/initscripts/lib/init/mount-functions.sh
+++ b/debian/src/initscripts/lib/init/mount-functions.sh
@@ -331,7 +331,7 @@ pre_mountall() {
 	# /lib/init/rw is obsolete and replaced by /run.  It's no
 	# longer used as a mountpoint, so attempt to remove it if
 	# possible (this will fail if root is read only).
-	rmdir /lib/init/rw >/dev/null 2>&1 || true
+	rmdir /lib/init/rw >/dev/null 2>&1 || :
 }
 
 # If the device/inode are the same, a bind mount already exists or the
@@ -427,7 +427,7 @@ run_migrate() {
 	# it will be cleaned out, but this would happen later on when
 	# bootclean runs in any case.
 	if [ ! -L "$OLD" ] && [ -d "$OLD" ]; then
-		rm -fr "$OLD" 2>/dev/null || true
+		rm -fr "$OLD" 2>/dev/null || :
 	fi
 
 	# If removal failed (directory still exists), set up bind mount.
-- 
1.7.10.4

From 0f8a9c0ae93efe787ec2b2b5350bf6a99cfc1e56 Mon Sep 17 00:00:00 2001
From: Cristian Ionescu-Idbohrn <[email protected]>
Date: Sun, 27 Jan 2013 10:11:08 +0100
Subject: [PATCH 18/21] Use proper test.

`$((foo <= 65536))' and `$(($foo <= 65536))' shows undetermined behaviour
with different shells depending on the $foo value and may hide script bugs
too.  Study `man 1 dash' and/or `man 1 bash', paragraphs "Arithmetic
Expansion", "ARITHMETIC EVALUATION".

Signed-off-by: Cristian Ionescu-Idbohrn <[email protected]>
---
 debian/src/initscripts/lib/init/mount-functions.sh |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/debian/src/initscripts/lib/init/mount-functions.sh b/debian/src/initscripts/lib/init/mount-functions.sh
index 20520ff..2471f40 100644
--- a/debian/src/initscripts/lib/init/mount-functions.sh
+++ b/debian/src/initscripts/lib/init/mount-functions.sh
@@ -91,7 +91,7 @@ _read_fstab() {
 						echo rootmode=ro
 						;;
 				esac
-			done < "$file"
+			done <"$file"
 		fi
 	done
 }
@@ -139,7 +139,7 @@ _read_fstab_entry() {
 					break 2
 				fi
 				MNT_DIR=
-			done < "$file"
+			done <"$file"
 		fi
 	done
 }
@@ -299,8 +299,8 @@ domount() {
 
 			if mountpoint -q "$MTPT"; then
 				# Already recorded?
-				if ! grep -E -sq "^([^ ]+) +$MTPT +" /etc/mtab < /dev/null; then
-					mount $MOUNTFLAGS -t $FSTYPE $CALLER_OPTS $FSTAB_OPTS $FS_OPTS $DEVNAME $MTPT < /dev/null
+				if ! grep -E -sq "^([^ ]+) +$MTPT +" /etc/mtab </dev/null; then
+					mount $MOUNTFLAGS -t $FSTYPE $CALLER_OPTS $FSTAB_OPTS $FS_OPTS $DEVNAME $MTPT </dev/null
 				fi
 			fi
 			;;
@@ -669,7 +669,7 @@ mount_tmp() {
 	# Disable RAMTMP if there's 64MiB RAM or less.  May be
 	# re-enabled by overflow or read only root, below.
 	RAM_SIZE=$(ram_size)
-	if [ "$RAM_SIZE" ] && [ "$((RAM_SIZE <= 65536))" = 1 ]; then
+	if [ "$RAM_SIZE" ] && [ $RAM_SIZE -le 65536 ]; then
 		RAMTMP=no
 	fi
 
-- 
1.7.10.4

From 620fd3dca41eb09b7d46131fe669e91d67da9f94 Mon Sep 17 00:00:00 2001
From: Cristian Ionescu-Idbohrn <[email protected]>
Date: Sun, 27 Jan 2013 10:53:21 +0100
Subject: [PATCH 19/21] Don't fork and simplify value extractions from
 /proc/meminfo.

Signed-off-by: Cristian Ionescu-Idbohrn <[email protected]>
---
 debian/src/initscripts/lib/init/tmpfs.sh |   21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/debian/src/initscripts/lib/init/tmpfs.sh b/debian/src/initscripts/lib/init/tmpfs.sh
index 117c342..8f95bd0 100644
--- a/debian/src/initscripts/lib/init/tmpfs.sh
+++ b/debian/src/initscripts/lib/init/tmpfs.sh
@@ -3,20 +3,29 @@
 #
 
 
+meminfo () {
+    _mif=/proc/meminfo
+    [ -r $_mif ] || return 0
+    while read _type _value _ignore; do
+	    case $_type in
+		    "$1")
+			    echo $_value
+			    break
+			    ;;
+	    esac
+    done <$_mif
+}
+
 # Get size of physical RAM in kiB
 ram_size ()
 {
-    [ -r /proc/meminfo ] && \
-	grep MemTotal /proc/meminfo | \
-	sed -e 's;.*[[:space:]]\([0-9][0-9]*\)[[:space:]]kB.*;\1;' || :
+    meminfo MemTotal:
 }
 
 # Get size of swap space in kiB
 swap_size ()
 {
-    [ -r /proc/meminfo ] && \
-	grep SwapTotal /proc/meminfo | \
-	sed -e 's;.*[[:space:]]\([0-9][0-9]*\)[[:space:]]kB.*;\1;' || :
+    meminfo SwapTotal:
 }
 
 #
-- 
1.7.10.4

From 11a298cb5c8a7c4e74ac91d49b232260ec65b073 Mon Sep 17 00:00:00 2001
From: Cristian Ionescu-Idbohrn <[email protected]>
Date: Sun, 27 Jan 2013 11:04:41 +0100
Subject: [PATCH 20/21] Use safer inverted logic.

A function like:

	foo() {
		[ -x bar ] && bar
	}

will return failure if `bar' does not exist or is not executable, but:

	foo() {
		[ ! -x bar ] || bar
	}

will return failure only is `bar' is executed and fails.

Signed-off-by: Cristian Ionescu-Idbohrn <[email protected]>
---
 debian/src/initscripts/lib/init/mount-functions.sh |   18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/debian/src/initscripts/lib/init/mount-functions.sh b/debian/src/initscripts/lib/init/mount-functions.sh
index 2471f40..e447240 100644
--- a/debian/src/initscripts/lib/init/mount-functions.sh
+++ b/debian/src/initscripts/lib/init/mount-functions.sh
@@ -38,7 +38,7 @@ is_empty_dir() {
 
 
 selinux_enabled() {
-	which selinuxenabled >/dev/null 2>&1 && selinuxenabled
+	! which selinuxenabled >/dev/null 2>&1 || selinuxenabled
 }
 
 # Read /etc/fstab, looking for:
@@ -367,7 +367,7 @@ bind_mount() {
 	# Bind mount $SRC on $DEST
 	if [ "$ssrc" ] && [ "$ssrc" != "$sdest" ]; then
 		[ -d "$DEST" ] || mkdir "$DEST"
-		[ -x /sbin/restorecon ] && /sbin/restorecon "$DEST"
+		[ ! -x /sbin/restorecon ] || /sbin/restorecon "$DEST"
 		if mount -t $FSTYPE "$SRC" "$DEST" $OPTS; then
 			echo "Please reboot to complete migration to tmpfs-based /run" > "${DEST}/.run-transition"
 			return 0
@@ -410,7 +410,7 @@ run_migrate() {
 	if [ -L "$OLD" ] && [ "$(readlink "$OLD")" != "$RUN" ]; then
 		rm -f "$OLD"
 		ln -fs "$RUN" "$OLD"
-		[ -x /sbin/restorecon ] && /sbin/restorecon "$OLD"
+		[ ! -x /sbin/restorecon ] || /sbin/restorecon "$OLD"
 	fi
 
 	# If both directories are the same, we don't need to do
@@ -444,7 +444,7 @@ run_migrate() {
 		else
 			rm -f "$OLD"
 			ln -fs "$RUN" "$OLD"
-			[ -x /sbin/restorecon ] && /sbin/restorecon "$OLD"
+			[ ! -x /sbin/restorecon ] || /sbin/restorecon "$OLD"
 		fi
 	fi
 }
@@ -466,7 +466,7 @@ mtab_migrate() {
 
 		rm -f /etc/mtab || return 1
 		ln -fs /proc/mounts /etc/mtab || return 1
-		[ -x /sbin/restorecon ] && /sbin/restorecon /etc/mtab
+		[ ! -x /sbin/restorecon ] || /sbin/restorecon /etc/mtab
 	fi
 }
 
@@ -543,7 +543,7 @@ mount_run() {
 	fi
 	# TODO: Add -onodev once checkroot no longer creates a device node.
 	domount "$MNTMODE" tmpfs shmfs /run tmpfs "-onosuid$RUNEXEC$RUN_OPT"
-	[ -x /sbin/restorecon ] && /sbin/restorecon -r /run
+	[ ! -x /sbin/restorecon ] || /sbin/restorecon -r /run
 
 	# Make pidfile omit directory for sendsigs
 	[ -d /run/sendsigs.omit.d ] || mkdir --mode=755 /run/sendsigs.omit.d/
@@ -558,7 +558,7 @@ mount_lock() {
 
 	# Make lock directory as the replacement for /var/lock
 	[ -d /run/lock ] || mkdir --mode=755 /run/lock
-	[ -x /sbin/restorecon ] && /sbin/restorecon /run/lock
+	[ ! -x /sbin/restorecon ] || /sbin/restorecon /run/lock
 
 	# Now check if there's an entry in /etc/fstab.  If there is,
 	# it overrides the existing RAMLOCK setting.
@@ -614,7 +614,7 @@ mount_shm() {
 
 	if [ ! -d "$SHMDIR" ]; then
 		mkdir --mode=755 "$SHMDIR"
-		[ -x /sbin/restorecon ] && /sbin/restorecon "$SHMDIR"
+		[ ! -x /sbin/restorecon ] || /sbin/restorecon "$SHMDIR"
 	fi
 
 	# Now check if there's an entry in /etc/fstab.  If there is,
@@ -663,7 +663,7 @@ mount_tmp() {
 	if [ -L /tmp ] && [ ! -d /tmp ]; then
 		TMPPATH=$(readlink /tmp)
 		mkdir -p --mode=755 "$TMPPATH"
-		[ -x /sbin/restorecon ] && /sbin/restorecon "$TMPPATH"
+		[ ! -x /sbin/restorecon ] || /sbin/restorecon "$TMPPATH"
 	fi
 
 	# Disable RAMTMP if there's 64MiB RAM or less.  May be
-- 
1.7.10.4

From 0aba7c40f8afa1286772b0303e348c64610c26b3 Mon Sep 17 00:00:00 2001
From: Cristian Ionescu-Idbohrn <[email protected]>
Date: Sun, 27 Jan 2013 11:09:46 +0100
Subject: [PATCH 21/21] Small whitespace cleanup.

Signed-off-by: Cristian Ionescu-Idbohrn <[email protected]>
---
 debian/src/initscripts/lib/init/mount-functions.sh |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/debian/src/initscripts/lib/init/mount-functions.sh b/debian/src/initscripts/lib/init/mount-functions.sh
index e447240..94db701 100644
--- a/debian/src/initscripts/lib/init/mount-functions.sh
+++ b/debian/src/initscripts/lib/init/mount-functions.sh
@@ -493,10 +493,10 @@ post_mountall() {
 	# migrate; it should only ever be needed on broken systems.
 	RAMSHM_ON_DEV_SHM=no
 	if read_fstab_entry /dev/shm; then
-	    RAMSHM_ON_DEV_SHM=yes
+		RAMSHM_ON_DEV_SHM=yes
 	fi
 	if read_fstab_entry /run/shm; then
-	    RAMSHM_ON_DEV_SHM=no
+		RAMSHM_ON_DEV_SHM=no
 	fi
 
 	if [ -L /run ]; then
-- 
1.7.10.4


--- End Message ---
--- Begin Message ---
Source: sysvinit
Source-Version: 2.92~beta-1

We believe that the bug you reported is fixed in the latest version of
sysvinit, which is due to be installed in the Debian FTP archive.

A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to [email protected],
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
Dmitry Bogatov <[email protected]> (supplier of updated sysvinit package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing [email protected])


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

Format: 1.8
Date: Thu, 22 Nov 2018 16:13:55 +0000
Source: sysvinit
Binary: sysvinit-core sysvinit-utils sysv-rc initscripts bootlogd
Architecture: source
Version: 2.92~beta-1
Distribution: unstable
Urgency: medium
Maintainer: Debian sysvinit maintainers 
<[email protected]>
Changed-By: Dmitry Bogatov <[email protected]>
Description:
 bootlogd   - daemon to log boot messages
 initscripts - scripts for initializing and shutting down the system
 sysv-rc    - System-V-like runlevel change mechanism
 sysvinit-core - System-V-like init utilities
 sysvinit-utils - System-V-like utilities
Closes: 82366 361935 375274 402847 463771 477656 507868 515595 538334 571590 
578827 590895 614893 619869 628140 630661 699087 717531 719273 724712 725123 
735521 764662 774179 799329 810229 811377 815839 822654 890041 890478 905245 
911044 913154 913247
Changes:
 sysvinit (2.92~beta-1) unstable; urgency=medium
 .
   [ Vincenzo (KatolaZ) Nicosia ]
   * New upstream release (Closes: #725123, #571590, #815839)
     (Closes: #905245, #890478, #402847, #717531, #590895, #630661)
     (Closes: #719273, #361935, #614893, #375274)
   * Refresh patches
 .
   [ Benda Xu ]
   * Provide an example for running inside systemd-nspawn (Closes: #799329).
 .
   [ Dmitry Bogatov ]
   * Upload to unstable
   * Adjust `debian/watch' to translate `-beta' suffix into `~beta'.
   * Remove redundant `/etc/init.d/motd' (Closes: #735521)
   * Pass `--force' option to `sulogin' program, enabling maintenance
     in single mode on systems, where `root' user is disabled. (Closes: #82366)
 .
 sysvinit (2.91-1) experimental; urgency=medium
 .
   [ Dmitry Bogatov ]
   * Revert changes, that removed `Uploaders' field
   * Make Vcs-* fields to point to debian/ repository
   * Revert changes to LSB headers that introduced breakages
     (Thanks: Andreas Henriksson)
   * Add lintian overrides for warnings about LSB headers
   * Update debian/copyright since `start-stop-daemon.c'
     is no longer provided by upstream.
   * Update `debian/watch' to check PGP signature
   * Change mailing field in `Maintainer' field
   * Support GNU/kFreeBSD-specific UFS filesystem in `bootclean.sh' script
     (Closes: #764662)
     + Thanks: Steven Chamberlain <[email protected]>
   * wrap-and-sort -sta (Closes: #774179)
   * Update example script in init-d-script(5) to work correctly on Debian
     GNU/kFreeBSD (Closes: #913247)
   * Remove `/etc/init.d/skeleton' from bin:initscripts, which is superseded
     by init-d-script(5) (Closes: #913154, #810229, #507868, #578827)
   * Remove alternative dependency on `file-rc', which is removed from Archives.
     (Closes: #911044)
   * Do not attempt to set hostname to value, just returned by hostname(1)
     in `/etc/init.d/hostname.sh' (Closes: #628140)
   * Simplify `/etc/init.d/hostname.sh' script, since output of hostname(1)
     is never empty.
   * Remove compressed logs on purge of `bootlogd' (Closes: #724712)
   * Fix whitespace errors in scripts.
   * Minor cleanup of `/etc/init.d/bootlogd' (Closes: #538334)
   * Fix misleading desciption of `PIDFILE' variable in init-d-script(5)
     (Closes: #822654)
 .
   [ Vincenzo (KatolaZ) Nicosia ]
   * New upstream release (Closes: #515595, #890041, #463771)
   * Refreshed patches
   * Add Vincenzo Nicosia to uploaders
   * Update list of copyright holders of debian/* files
   * Remove unnecessary patches
 .
   [ Boyuan Yang ]
   * Remove sysv-rc's suggestion to bum, this package has
     been removed from the archive.
 .
   [ Benda Xu ]
   * Select patches from Cristian Ionescu-Idbohrn (Closes: #699087).
   * Revert 7f0c9952b, swap is handled in checkroot.sh (Closes: #619869).
   * Provide a USB console example in inittab (Closes: #477656).
 .
 sysvinit (2.88dsf-60) experimental; urgency=medium
 .
   * New maintainer (Closes: #811377)
   * Update debian/gbp.conf
   * Replace deprecated priority 'extra' with 'optional'
   * Fix whitespace errors in `debian/changelog'
   * Update Vcs-* fields in `debian/control'
   * Update standards version to 4.2.1 (no changes needed)
   * Convert `debian/copyright' to dep-5 format
   * Bump compat version to 11 (no changes needed)
   * Clean-up unused lintian overrides
   * Remove unused debconf template
   * Declare missing dependency on $local_fs in init scripts
   * Remove virtual dependency $all from all scripts, except rc.local
   * Add lintian overrides about scripts not being registered with
     `update-rc.d'. Actually, they are registered with hand-written
     code in `postrm' scripts
Checksums-Sha1:
 854c6feb4baebd3a2a73904de1a759f5a4a7d688 2562 sysvinit_2.92~beta-1.dsc
 1790c7ed432eaecadff6daa891764a188e6a8bb6 117508 sysvinit_2.92~beta.orig.tar.xz
 ffef43ebd0f731e0386310e6fd7bf9d0d5241659 127792 
sysvinit_2.92~beta-1.debian.tar.xz
Checksums-Sha256:
 0bd6b5cd5fad6f57bf57b926d149942341952354e56a12c1fce5249a2b57c515 2562 
sysvinit_2.92~beta-1.dsc
 1c51a98b7ff26649a6580083dcd2612f2181ee7dc9b0eacbd87a6354ce0cb93a 117508 
sysvinit_2.92~beta.orig.tar.xz
 44cde3cc1fdc069fcb9cfeb27e1a4df7fa29a2a013d8dc9dfd172597f06e8b60 127792 
sysvinit_2.92~beta-1.debian.tar.xz
Files:
 96ae4d7766bca109dc074bf1fb2cdf5a 2562 admin optional sysvinit_2.92~beta-1.dsc
 bae179b131b075685aec8120ff75dbc4 117508 admin optional 
sysvinit_2.92~beta.orig.tar.xz
 173dac3897546173e46167ad6ce2e78b 127792 admin optional 
sysvinit_2.92~beta-1.debian.tar.xz

-----BEGIN PGP SIGNATURE-----

iQJHBAEBCgAxFiEEhnHVzDbtdH7ktKj4SBLY3qgmEeYFAlv21uATHGthY3Rpb25A
ZGViaWFuLm9yZwAKCRBIEtjeqCYR5hMGEACTR4PaGw40whpILanD26VJ8AFVzOMq
qhSiUWMU2Ja4Q1IiypSHmBw8BWT0/RaZ+Q2PTNy7xKj0Qk0qE/X/6mrLYod7hPvz
7a+fRV/6vEQ2sqvWVMADSW791R58xk51eDPs5Iy+1wM5VokM1IO3/GZrJuyMwv9t
mruUdbeYNXLM+8mhQS7RBATZHX0yT+DUB+cetGfX0dRaGxXII4pADd0I6JWgZAGE
uk94S6b/KcEv32cBC47uo9dAqA1JSTnNYeh9KK2+VMgOx9Rd/Ex56wyGjqmap9fn
KjTYHka6pf/1VYj+OJmWJ4jJMiLxQmn7wAtQFItywLoboTllTS3qBKPwR1CrxRC3
9Rg8rsIEIq0w26FiHjj6hjZQ9mi3AbNt9aZyoQN+Uq9NGbbcNhDIzzuUkiAZ3BTW
yKtYD8Yvs/q0Urgnbcp43/9HTEBmbeCnNWrQ5OO7b6fvNQqEPdd5wt7D9AF80xD4
vfHSKlhoax+ExCljRwOSfZlyOM2hRX3F508/bbQa5RU4bqaODr/ZsuPuDzryYMgp
85GvNe6r38VtbkUl/tmVXkisSnTeiyKbcaWGCV7CUCeFe4ujVw2DTIwpgVQF5QDb
dG2m3ycgdTIZajWs4Hy3jxntXnzeZvsqDtPaGIEa47kT3jyNpDVk7JVvl2n0l+jL
Ja68Fe45IGJMMw==
=obt9
-----END PGP SIGNATURE-----

--- End Message ---

Reply via email to