[Openvas-discuss] Installing on Ubuntu 12.04 - bug in greenbone init.d script

Whit Blauvelt whit at transpect.com
Sun Jun 17 22:00:06 CEST 2012


Ah well, the rest of the instructions don't quite work either:

...# sudo openvassd
All plugins loaded                                   
...# sudo openvasmd --migrate
md   main:WARNING:13109:2012-06-17 15h11.00 EDT: sql_x: sqlite3_prepare failed: no such table: meta
...# sudo openvasmd --rebuild
...# sudo killall openvassd
...# sleep 15
...# sudo /etc/init.d/openvas-scanner start
Starting OpenVAS Scanner: openvassd.
...# sudo /etc/init.d/openvas-manager start
Starting OpenVAS Manager: openvasmd.
...# sudo /etc/init.d/openvas-administrator restart
Restarting OpenVAS Administrator: openvasad.
...# sudo /etc/init.d/greenbone-security-assistant restart
Restarting Greenbone Security Assistant: ERROR.

Now, that's a flaw in the init.d script. Since after killing the gsad instance on the system:

...# /etc/init.d/greenbone-security-assistant start
Starting Greenbone Security Assistant: ERROR.
...# ps aux | grep gsad
root     13338  0.0  0.0  91412  1524 pts/1    Sl   15:41   0:00 /usr/sbin/gsad --listen=127.0.0.1 --port=9392 --alisten=127.0.0.1 --aport=9393 --mlisten=127.0.0.1 --mport=9390

The "running" function in the init.d function is failing. Now, it starts by
trying to find the pid file:

running()
{
    # No pidfile, probably no daemon present
    #
    [ ! -f "$PIDFILE" ] && return 1
    pid=`cat $PIDFILE`
    
    # No pid, probably no daemon present
    [ -z "$pid" ] && return 1
    
    [ ! -d /proc/$pid ] &&  return 1
    cmd=`cat /proc/$pid/cmdline | tr "\000" "\n"|head -n 1 |cut -d : -f 1`
    # No gsad?
    [ "$cmd" != "$NAME" ] &&  return 1
    
    return 0
}

and the pid file is there on the system:

# ls /var/run/gsad.pid 
/var/run/gsad.pid

Not only is the pid file there, it has the right pid:

...# cat /var/run/gsad.pid
13338
...# ps aux | grep gsad
root     13338  0.0  0.0  91412  1524 pts/1    Sl   15:41   0:00 /usr/sbin/gsad --listen=127.0.0.1 --port=9392 --alisten=127.0.0.1 --aport=9393 --mlisten=127.0.0.1 --mport=9390

Okay if I run the "cmd"

... # cat /proc/13338/cmdline | tr "\000" "\n"|head -n 1 |cut -d : -f 1
/usr/sbin/gsad

Why then does $cmd not equal $NAME. Obviously because:

NAME=gsad - which could work with an awk or sed invocation to do a regex.
Hmm, would changing that variable from $NAME to $DAEMON fix it ... 

YES, it does!

Whit



More information about the Openvas-discuss mailing list