Bug#931719: 40-systemd: line 11: 1: unbound variable when sourcing /lib/lsb/init-functions with $1 unset

Thomas Baetzler t.baetzler+debian-bug-reports at bringe.com
Tue Jul 9 16:11:13 BST 2019


Package: systemd
Version: 241-5
Severity: normal
Tags: patch

Dear Maintainer,

After upgrading to Debian 10 we noticed a slightly different behaviour
in  /lib/lsb/init-functions.d/40-systemd which caused one of our scripts
to break and which also causes some /etc/init.d files like /etc/init.d/mysql
to no longer to display their help text when calling them without a parameter.

The root cause are accesses to the $1 and $2 variables without checking
if they are defined beforehand. When running code using "set -u", this
causes the above mentioned error.

I've outlined this very simple fix which bypasses all further tests if
$1 and so on are undefined.

	$ diff -C 9 40-systemd.orig 40-systemd 
	*** 40-systemd.orig     2019-05-24 22:58:59.000000000 +0200
	--- 40-systemd  2019-07-09 16:40:39.642678140 +0200
	***************
	*** 1,18 ****
	--- 1,21 ----
	  # -*-Shell-script-*-
	  # /lib/lsb/init-functions

	  _use_systemctl=0
	  if [ -d /run/systemd/system ]; then

	      if [ -n "${__init_d_script_name:-}" ]; then # scripts run
with new init-d-script
		  executable="$__init_d_script_name"
		  argument="$1"
	+     elif [ $# -eq 0 ] ; then
	+         executable="$0"
	+         argument=""
	      elif [ "${0##*/}" = "init-d-script" ] ||
		   [ "${0##*/}" = "${1##*/}" ]; then # scripts run with
old  init-d-script
		  executable="$1"
		  argument="$2"
	      else # plain old scripts
		  executable="$0"
		  argument="$1"
	      fi

-- Package-specific info:

-- System Information:
Debian Release: 10.0
  APT prefers stable
  APT policy: (500, 'stable')
Architecture: amd64 (x86_64)

Kernel: Linux 4.19.0-5-amd64 (SMP w/32 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE=en_US:en (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages systemd depends on:
ii  adduser          3.118
ii  libacl1          2.2.53-4
ii  libapparmor1     2.13.2-10
ii  libaudit1        1:2.8.4-3
ii  libblkid1        2.33.1-0.1
ii  libc6            2.28-10
ii  libcap2          1:2.25-2
ii  libcryptsetup12  2:2.1.0-5
ii  libgcrypt20      1.8.4-5
ii  libgnutls30      3.6.7-4
ii  libgpg-error0    1.35-1
ii  libidn11         1.33-2.2
ii  libip4tc0        1.8.2-4
ii  libkmod2         26-1
ii  liblz4-1         1.8.3-1
ii  liblzma5         5.2.4-1
ii  libmount1        2.33.1-0.1
ii  libpam0g         1.3.1-5
ii  libseccomp2      2.3.3-4
ii  libselinux1      2.8-1+b1
ii  libsystemd0      241-5
ii  mount            2.33.1-0.1
ii  util-linux       2.33.1-0.1

Versions of packages systemd recommends:
ii  dbus            1.12.16-1
ii  libpam-systemd  241-5

Versions of packages systemd suggests:
ii  policykit-1        0.105-25
pn  systemd-container  <none>

Versions of packages systemd is related to:
pn  dracut           <none>
ii  initramfs-tools  0.133
ii  udev             241-5

-- no debconf information



More information about the Pkg-systemd-maintainers mailing list