reopen 211858
tag 211858 patch
thanks

hi... i think there's been some confusion w.r.t. bug#211858.  it could be 
my fault, or it could just be that the package changed again between 2004 
and 2006... anyhow the current state of the sysklogd package is that this 
bug exists -- a regular user can stop syslogd from restarting.

the instructions i sent a while back still apply.  here is how you can 
demonstrate the bug:

in a non-root window:
% /sbin/syslogd -d -a /tmp/lalala

in a root window:

# psg syslogd
root     17561  0.0  0.0   1652   616 ?        Ss   12:17   0:00 /sbin/syslogd 
-r
dean     17595  0.0  0.0   1656   668 pts/0    S+   12:18   0:00 /sbin/syslogd 
-d -a /tmp/lalala

notice how there's a syslogd running as root, that's the good one... the
one we want to restart.  now watch what happens when we try to restart:

# /etc/init.d/sysklogd restart
Restarting system log daemon: syslogd.
# psg syslogd
dean     17595  0.0  0.0   1656   668 pts/0    S+   12:18   0:00 /sbin/syslogd 
-d -a /tmp/lalala

start-stop-daemon --stop stopped the root syslogd as expected, but because
there's no --pidfile the --start action does not have enough information
to verify that the user dean syslogd is the correct one... it scans
the process table and finds the rogue syslogd and decides not to start
a new one.

even if we try just "start" it won't start:

# /etc/init.d/sysklogd start
Starting system log daemon: syslogd.
# psg syslogd
dean     17595  0.0  0.0   1656   668 pts/0    S+   12:18   0:00 /sbin/syslogd 
-d -a /tmp/lalala

now apply the patch below, and try to start again:

# /etc/init.d/sysklogd start
Starting system log daemon: syslogd.
# psg syslogd
dean     17595  0.0  0.0   1656   668 pts/0    S+   12:18   0:00 /sbin/syslogd 
-d -a /tmp/lalala
root     17671  0.0  0.0   1656   616 ?        Ss   12:24   0:00 /sbin/syslogd 
-r -s gk.arctic.org:arctic.org

my patch further removes the running() function in favour of using the
start-stop-daemon exit code to decide if the SIGHUP worked or not.

-dean

--- etc/init.d/sysklogd.orig    2006-05-25 02:38:46.000000000 -0700
+++ etc/init.d/sysklogd 2006-05-28 12:30:38.000000000 -0700
@@ -20,46 +20,11 @@
     chown root:adm /dev/xconsole
 }
 
-running()
-{
-    # No pidfile, probably no daemon present
-    #
-    if [ ! -f $pidfile ]
-    then
-       return 1
-    fi
-
-    pid=`cat $pidfile`
-
-    # No pid, probably no daemon present
-    #
-    if [ -z "$pid" ]
-    then
-       return 1
-    fi
-
-    if [ ! -d /proc/$pid ]
-    then
-       return 1
-    fi
-
-    cmd=`cat /proc/$pid/cmdline | tr "\000" "\n"|head -n 1`
-
-    # No syslogd?
-    #
-    if [ "$cmd" != "$binpath" ]
-    then
-       return 1
-    fi
-
-    return 0
-}
-
 case "$1" in
   start)
     echo -n "Starting system log daemon: syslogd"
     create_xconsole
-    start-stop-daemon --start --quiet --exec $binpath -- $SYSLOGD
+    start-stop-daemon --start --quiet --exec $binpath --pidfile $pidfile -- 
$SYSLOGD
     echo "."
     ;;
   stop)
@@ -76,17 +41,15 @@
     echo -n "Restarting system log daemon: syslogd"
     start-stop-daemon --stop --quiet --exec $binpath --pidfile $pidfile
     sleep 1
-    start-stop-daemon --start --quiet --exec $binpath -- $SYSLOGD
+    start-stop-daemon --start --quiet --exec $binpath --pidfile $pidfile -- 
$SYSLOGD
     echo "."
     ;;
   reload-or-restart)
-    if running
-    then
-       echo -n "Reloading system log daemon: syslogd"
-       start-stop-daemon --stop --quiet --signal 1 --exec $binpath --pidfile 
$pidfile
-    else
+    echo -n "Reloading system log daemon: syslogd"
+    if ! start-stop-daemon --stop --quiet --signal 1 --exec $binpath --pidfile 
$pidfile; then
+       echo " ... failed."
        echo -n "Restarting system log daemon: syslogd"
-       start-stop-daemon --start --quiet --exec $binpath -- $SYSLOGD
+       start-stop-daemon --start --quiet --exec $binpath --pidfile $pidfile -- 
$SYSLOGD
     fi
     echo "."
     ;;


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to