This one time, at band camp, martin f krafft said:
> Package: fail2ban
> Version: 0.6.1-3
> Severity: grave
> Tags: patch
> 
> --- /etc/init.d/fail2ban.orig 2006-06-06 16:30:22.760214786 +0200
> +++ /etc/init.d/fail2ban  2006-06-06 16:38:44.260607142 +0200
> @@ -60,8 +60,10 @@
>     || return 1
>   # we need to remove pid file or fail2ban would refuse to start
>   # probably check could be ommited but... better be safe
> - pidofproc $NAME $PIDFILE > /dev/null
> - [ $? -eq 2 ] && rm -rf $PIDFILE
> + if [ -f $PIDFILE ]; then
> +   pidofproc $NAME < $PIDFILE > /dev/null
> +   [ $? -eq 2 ] && rm -rf $PIDFILE
> + fi
>   start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \
>     $DAEMON_ARGS \
>     || return 2

Just a couple of asides - pidofproc() takes a pidfile argument, if you
pass -p (although it is currently broken, since it hangs on read(), but
that's another bug).

Second, I am assuming like all good scripts, this is set -e.  So you
want your test to always be true, meaning you probably want:
[ $? -ne 2 ] || rm -f $PIDFILE.  Otherwise the first condition of your
and'ed statement is false, and the whole line is false, and it exits.

You also probably don't need to recursively remove a single file, and I
imagine it's vaguely safer in the event that $PIDFILE expands wrongly.
-- 
 -----------------------------------------------------------------
|   ,''`.                                            Stephen Gran |
|  : :' :                                        [EMAIL PROTECTED] |
|  `. `'                        Debian user, admin, and developer |
|    `-                                     http://www.debian.org |
 -----------------------------------------------------------------

Attachment: signature.asc
Description: Digital signature

Reply via email to