[Pkg-sysvinit-devel] Bug#497665: invoke-rc.d: no-op test for failure to determine runlevel

pmoulder pjrm at internode.on.net
Wed Sep 3 13:22:04 UTC 2008


Package: sysv-rc
Version: 2.86.ds1-61
Severity: minor


The following two lines:

  RL=`${RUNLEVEL} | sed 's/.*\ //'`
  if test ! $? ; then

have two problems:

  - In Bourne shell, the return value of a pipeline is determined solely
    by the last command, here sed, which will pretty much always succeed
    (space or no space).

    This can be fixed either by splitting into two parts:

      RL=`${RUNLEVEL}`
      if ...
      fi
      RL=`echo "$RL" | sed 's/.* //'`

    or by switching from /bin/sh to /bin/bash and setting the pipefail
    option (after checking the effect on the rest of the script, I
    haven't looked).

  - In any case, `test ! $?' tests whether $? is empty, but $? is always
    non-empty (whether it's 0 or non-zero).  It should be

      if test $? != 0; then
         ... /sbin/runlevel failed ...

Should failure of /sbin/runlevel fall back to the ps -fp 1 trick,
perhaps piped to  sed -n 's/.*init \[\(.*\)\].*/\1/p' ?

(I haven't looked into the expected behaviour in chroots.)

pjrm.


-- System Information:
Debian Release: lenny/sid
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: i386 (i686)

Kernel: Linux 2.6.25-2-686 (SMP w/1 CPU core)
Locale: LANG=C, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

sysv-rc depends on no packages.

Versions of packages sysv-rc recommends:
ii  lsb-base                      3.2-19     Linux Standard Base 3.2 init scrip

Versions of packages sysv-rc suggests:
pn  bum                           <none>     (no description available)
pn  sysv-rc-conf                  <none>     (no description available)

-- no debconf information





More information about the Pkg-sysvinit-devel mailing list