Bug#344553: [Logcheck-devel] Bug#344553: logcheck: Fails silently to read config file
Markus Peuhkuri
puhuri at iki.fi
Sun Jan 1 18:15:16 UTC 2006
Todd Troxell wrote:
> I see your point. The config is not really essential.
>
> What do you think about this:
>
> if [ -f $CONFFILE -a -r $CONFFILE]; then
The problem is still that if CONFFILE is somehow mistyped, it still
fails silently even if the fragment fixes the error I had with
permissions. For my view the correct operation would be following:
1) if CONFFILE (from command line) is set, use it. If it does not
exists or is unreadable, issue an error
2) if CONFFILE is not set, but the default CONFFILE exists AND is
readable use it
3) if default CONFFILE exists, but is unreadable, provide an error
4) if default CONFFILE does not exists, use defauls
To have 1), command line argument processing should be modified as below
case "$opt" in
c)
debug "Setting CONFFILE to $OPTARG"
CONFFILE="$OPTARG"
if [ ! -r $CONFFILE ]; then
error "Config file $CONFFILE unreadable or does not exists"
fi
;;
For 2) and 4), the existing condition is ok, but needs additional
condition for 3).
if [ -r $CONFFILE ]; then
. $CONFFILE
elif [ -f $CONFFILE ]; then # this provides 3)
error "Config file $CONFFILE unreadable"
fi
(sorry, if line wrap is problem).
--
Markus Peuhkuri | http://www.iki.fi/puhuri/
More information about the Logcheck-devel
mailing list