[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

sanity check in init.d



Hi,

someone pointed me towards a inconsistency in Debians init.d
scripts. They do a sanity check to ensure the daemon they want to
start exists. This is good, but realisation could be better.

1) some packages test for -f, some for -x 
   -> if there is no technical reason for this, we should just use -x

2) some test like test -x $DAEMON, some like test -x /usr/sbin/sshd 
   -> I suggest all scripts should move to the later form. It is
      easier to read, if you define DAEMON, CONFFILE etc. at the
      top. This is also the way the skeleton init.d file suggests
      this. It would also be more consistent.

3) (mein point) The tests do a test -x $DAEMON || exit 0
   -> This is bad. The Unix way is not to output anything if
      everything is OK, but report, if something is wrong. 

One could deduct, that something went wrong, when the message
"Starting foo" is not output, but this is not the way it should be.
You are first pusseld, then you check ps, then you check the init.d
script.

This is not the way we should force at our (new) users. One should be
able see that something is wrong directly.
 
I strongly opt for changing all these lines into 

DAEMON=/usr/sbin/foo
FAILMSG="$DAEMON can not be executed. Check the file
permissions"
test -x $DAEMON || echo $FAILMSG && exit 0

(Someone please correct my sh programming, this really is not my
realm)

If there are no objections, I will file bugreports for the packages I
have installed that fail these criteria.

Your opinion, please.

Ciao,
	Martin


Reply to: