Craig Sanders wrote:
> Package: unbound
> Version: 1.0.0-2
> 
> when unbound is configured to log stats to syslog, it stops logging
> whenever the logfile is rotated.

hi, Craig,

thanks for the excellent bug report.

> my guess is that this is probably due to the chroot jail that unbound is
> running in. specifically, something to do with the syslog daemon being
> reloaded (and closing/re-opening all files) rather than the specific log
> file being rotated, because both /var/log/syslog and /var/log/daemon.log
> were affected (i.e. no unbound entries after rsyslog reload). syslog is
> rotated daily, daemon.log is rotated weekely.
> 
> note: i am using rsyslog rather than sysklogd, but i doubt if that is a
> relevant factor...i've been running rsyslog for many months now and it
> has proven to be 100% backwards compatible with sysklogd. unbound is the
> only program that exhibits this behaviour. unfortunately, i don't have
> any sysklogd machines left to test unbound on.

I can reproduce the problem with sysklogd... I based the debian init
script on the redhat one provided in the unbound tarball, which
bindmounts /dev/log to /var/lib/unbound/dev/log.  unfortunately since
/dev/log is a unix socket, it disappears and is recreated when the
syslog daemon is restarted, and the bindmount follows the inode rather
than the directory path.

just to verify, could you send the output of `stat /dev/log
/var/lib/unbound/dev/log | grep Inode` before and after a restart of
unbound?  it probably looks something like this:

    [EMAIL PROTECTED]:~# stat /dev/log /var/lib/unbound/dev/log | grep Inode
    Device: eh/14d  Inode: 7916330     Links: 1
    Device: eh/14d  Inode: 2945675     Links: 0
    [EMAIL PROTECTED]:~# /etc/init.d/unbound restart
    Restarting recursive DNS server: unbound.
    [EMAIL PROTECTED]:~# stat /dev/log /var/lib/unbound/dev/log | grep Inode
    Device: eh/14d  Inode: 7916330     Links: 1
    Device: eh/14d  Inode: 7916330     Links: 1
    [EMAIL PROTECTED]:~# 

now, could you please test this solution?

1) /etc/init.d/unbound stop

2) echo "$AddUnixListenSocket /var/lib/unbound/dev/log" > 
/etc/rsyslog.d/unbound.conf

3) /etc/init.d/rsyslog restart

4) replace /etc/init.d/unbound with the copy attached to this mail

5) /etc/init.d/unbound start

-- 
Robert Edmonds
[EMAIL PROTECTED]
#!/bin/sh

NAME=unbound
DESC="recursive DNS server"
DAEMON=/usr/sbin/unbound
CHROOT_DIR=/var/lib/unbound
PIDFILE=$CHROOT_DIR/unbound.pid

test -x $DAEMON || exit 0

. /lib/lsb/init-functions

test -f /etc/default/$NAME && . /etc/default/$NAME

install_chroot() {
    if [ "$CHROOT" != "no" ]; then
        [ -d $CHROOT_DIR/etc ] || mkdir -p $CHROOT_DIR/etc
        [ -d $CHROOT_DIR/dev ] || mkdir -p $CHROOT_DIR/dev
        [ -c $CHROOT_DIR/dev/random ] || ( cd $CHROOT_DIR/dev && MAKEDEV random 
)
        [ -c $CHROOT_DIR/dev/urandom ] || ( cd $CHROOT_DIR/dev && MAKEDEV 
urandom )
        #if ! egrep -q '^/[^[:space:]]+[[:space:]]+'$CHROOT_DIR'/dev/log' 
/proc/mounts; then
        #    [ -e $CHROOT_DIR/dev/log ] || touch $CHROOT_DIR/dev/log
        #    mount --bind -n /dev/log $CHROOT_DIR/dev/log >/dev/null 2>&1
        #fi
        test -f /etc/localtime && cp -fp /etc/localtime $CHROOT_DIR/etc
        install_chroot_conf
    fi
}

install_chroot_conf() {
    test -d $CHROOT_DIR/etc/unbound && rm -rf $CHROOT_DIR/etc/unbound
    cp -a /etc/unbound $CHROOT_DIR/etc
}

uninstall_chroot() {
    test -d $CHROOT_DIR/etc/unbound && rm -rf $CHROOT_DIR/etc/unbound
    #if [ "$CHROOT" != "no" ]; then
    #    while egrep -q '^[^[:space:]]+[[:space:]]+'$CHROOT_DIR'/dev/log' 
/proc/mounts; do
    #        umount $CHROOT_DIR/dev/log >/dev/null 2>&1
    #    done
    #fi
}

already_running() {
    return start-stop-daemon --start --pidfile $PIDFILE \
        --startas $DAEMON --test >/dev/null 2>&1
}

case "$1" in
    start)
        log_daemon_msg "Starting $DESC" "$NAME"
        if ! already_running; then
            install_chroot
        fi
        if start-stop-daemon --start --quiet --oknodo --pidfile $PIDFILE --name 
$NAME --startas $DAEMON -- $DAEMON_OPTS; then
            log_end_msg 0
        else
            log_end_msg 1
        fi
        ;;

    stop)
        log_daemon_msg "Stopping $DESC" "$NAME"
        if start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE --name 
$NAME; then
            log_end_msg 0
        else
            log_end_msg 1
        fi
        uninstall_chroot
        ;;

    restart|force-reload)
        log_daemon_msg "Restarting $DESC" "$NAME"
        start-stop-daemon --stop --quiet --pidfile $PIDFILE --name $NAME 
--retry 5
        uninstall_chroot
        install_chroot
        if start-stop-daemon --start --quiet --oknodo --pidfile $PIDFILE --name 
$NAME --startas $DAEMON -- $DAEMON_OPTS; then
            log_end_msg 0
        else
            log_end_msg 1
        fi
        ;;

    *)
        N=/etc/init.d/$NAME
        echo "Usage: $N {start|stop|restart|force-reload}" >&2
        exit 1
        ;;
esac

### BEGIN INIT INFO
# Provides:          unbound
# Required-Start:    $network $remote_fs $syslog
# Required-Stop:     $network $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
### END INIT INFO

Attachment: signature.asc
Description: Digital signature

Reply via email to