From 838ef2dd034d3ae001bfc4219afb2ed2da4f2220 Mon Sep 17 00:00:00 2001 From: Chris Lawrence Date: Thu, 1 Jun 2006 14:20:24 -0400 Subject: [PATCH] lsb 3.1-6 Debian release. --- debian/changelog | 8 ++++++++ debian/control | 2 +- init-functions | 40 +++++++++++++++++++--------------------- 3 files changed, 28 insertions(+), 22 deletions(-) diff --git a/debian/changelog b/debian/changelog index cb0c456..a3c112c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,11 @@ +lsb (3.1-6) unstable; urgency=low + + * Replace uses of $n with ${n:-} where $n could be unbound. + (Closes: #369193) + * Use pidof only if pid file is not specified. (Closes: #365736) + + -- Chris Lawrence Thu, 1 Jun 2006 14:20:24 -0400 + lsb (3.1-5) unstable; urgency=high * Remove /usr/X11R6/bin from lsb-core, since I'm pretty sure it's not diff --git a/debian/control b/debian/control index 08c9944..b0e51e3 100644 --- a/debian/control +++ b/debian/control @@ -3,7 +3,7 @@ Section: misc Priority: extra Maintainer: Chris Lawrence Build-Depends: debhelper (>= 4.1.13), po-debconf (>= 0.5.0), dpkg-dev (>= 1.10) -Standards-Version: 3.6.2 +Standards-Version: 3.7.2 Package: lsb-core Architecture: any diff --git a/init-functions b/init-functions index 8bd7c84..6b7a1ef 100644 --- a/init-functions +++ b/init-functions @@ -55,34 +55,31 @@ start_daemon () { } pidofproc () { - local pidfile line i pids= status + local pidfile line i pids= status specified pid set -- `POSIXLY_CORRECT=1 getopt "p:" $*` pidfile= + specified=0 for i in $*; do case $i in - -p) pidfile=$2; shift 2;; + -p) pidfile=$2; specified=1; shift 2;; --) shift; break;; esac done - if [ -z "$pidfile" ]; then + if [ -z "${pidfile:-}" ]; then pidfile=/var/run/$(basename "$1").pid fi if [ -f "$pidfile" ]; then - for i in `cat $pidfile`; do - if [ -z "$(echo $i | sed 's/[0-9]//g')" -a -d "/proc/$i" ]; then - pids="$i $pids" - fi - done - if [ -n "$pids" ]; then - echo "$pids" + read pid + if [ -n "${pid:-}" ]; then + echo "$pid" return 0 else return 2 # program is dead and /var/run pid file exists fi - elif [ -x /bin/pidof ]; then + elif [ -x /bin/pidof -a ! $specified ]; then /bin/pidof -o %PPID $1 status="$?" [ "$status" = 1 ] && return 3 # program is not running @@ -94,13 +91,14 @@ pidofproc () { # start-stop-daemon uses the same algorithm as "pidofproc" above. killproc () { - local pidfile sig status base i + local pidfile sig status base i specified set -- `POSIXLY_CORRECT=1 getopt "p:" $*` pidfile= + specified=0 for i in $*; do case $i in - -p) pidfile=$2; shift 2;; + -p) pidfile=$2; specified=1; shift 2;; --) shift; break;; esac done @@ -110,7 +108,7 @@ killproc () { pidfile=/var/run/$base.pid fi - if [ $2 ]; then + if [ $specified ]; then sig=$(echo $2 | sed -e 's/^-\(.*\)/\1/') sig=$(echo $sig | sed -e 's/^SIG\(.*\)/\1/') /sbin/start-stop-daemon --stop --pidfile "$pidfile" --signal $sig --quiet --name "$base" @@ -165,7 +163,7 @@ log_warning_msg () { # # int get_lsb_header_val (char *scriptpathname, char *key) get_lsb_header_val () { - if [ ! -f "$1" ] || [ -z "$2" ]; then + if [ ! -f "$1" ] || [ -z "${2:-}" ]; then return 1 fi LSB_S="### BEGIN INIT INFO" @@ -175,7 +173,7 @@ get_lsb_header_val () { # int log_begin_message (char *message) log_begin_msg () { - if [ -z "$1" ]; then + if [ -z "${1:-}" ]; then return 1 fi echo -n "$@" @@ -196,11 +194,11 @@ log_begin_msg () { # On Ubuntu, would output " * Starting remote filesystem services..." log_daemon_msg () { - if [ -z "$1" ]; then + if [ -z "${1:-}" ]; then return 1 fi - if [ -z "$2" ]; then + if [ -z "${2:-}" ]; then echo -n "$1:" return fi @@ -224,7 +222,7 @@ log_daemon_msg () { # # On Ubuntu, one would expect log_progress_msg to be a no-op. log_progress_msg () { - if [ -z "$1" ]; then + if [ -z "${1:-}" ]; then return 1 fi echo -n " $@" @@ -234,7 +232,7 @@ log_progress_msg () { # int log_end_message (int exitstatus) log_end_msg () { # If no arguments were passed, return - [ -z "$1" ] && return 1 + [ -z "${1:-}" ] && return 1 # Only do the fancy stuff if we have an appropriate terminal # and if /usr is already mounted @@ -269,7 +267,7 @@ log_action_cont_msg () { } log_action_end_msg () { - if [ -z "$2" ]; then + if [ -z "${2:-}" ]; then end="." else end=" ($2)." -- 2.30.2