# [solved] Syslog-ng running as non-root user problem

## Kosa

Hi everybody,

before a while i succesfully configure syslog-ng to run as non-root user. But now i recognized that pid file created during start is still owned by root, so when syslog-ng daemon is reloaded using "/etc/init.d/syslog-ng reload" it contains wrong pid and logging doesn't work anymore. Other thing is that syslog-ng doesn't have access to logging console /dev/tty12 (as configured by default).

Below is my slightly modified init script:

```
opts="depend checkconfig start stop reload"

depend() {

        # Make networking dependency conditional on configuration

        case $(sed 's/#.*//' /etc/syslog-ng/syslog-ng.conf) in

                *source*tcp*|*source*udp*|*destination*tcp*|*destination*udp*)

                        need net ;;

        esac

        need clock hostname

        provide logger

}

checkconfig() {

        if [ ! -e /etc/syslog-ng/syslog-ng.conf ] ; then

                eerror "You need to create /etc/syslog-ng/syslog-ng.conf first."

                eerror "An example can be found in /etc/syslog-ng/syslog-ng.conf.sample"

                return 1

        fi

        syslog-ng -s /etc/syslog-ng/syslog-ng.conf

        eend $? "Configuration error. Please fix your configfile (/etc/syslog-ng/syslog-ng.conf)"

}

start() {

        checkconfig || return 1

        ebegin "Starting syslog-ng"

        start-stop-daemon --start --quiet --exec /usr/sbin/syslog-ng -- -u syslog-ng -g syslog-ng

        eend $? "Failed to start syslog-ng"

}

stop() {

        ebegin "Stopping syslog-ng"

        start-stop-daemon --stop --quiet --pidfile /var/run/syslog-ng.pid

        eend $? "Failed to stop syslog-ng"

        sleep 1 # needed for syslog-ng to stop in case we're restarting

}

reload() {

        if [ ! -f /var/run/syslog-ng.pid ]; then

                eerror "syslog-ng isn't running"

                return 1

        fi

        checkconfig || return 1

        ebegin "Reloading configuration and re-opening log files"

        kill -HUP `cat /var/run/syslog-ng.pid` &>/dev/null

        eend $?

}

```

And part of my syslog-ng.conf:

```
options {

        chain_hostnames(off);

        sync(0);

        perm(0640);

        owner("syslog-ng");

        group("syslog-ng");

        create_dirs(yes);

        dir_perm(0750);

        dir_owner("syslog-ng");

        dir_group("syslog-ng");

};

```

Thanks for any suggestion.Last edited by Kosa on Thu Dec 15, 2005 11:39 am; edited 1 time in total

----------

## dgaffuri

May I ask why you want to run it as non root?

----------

## Kosa

Maybe for "some unknown security bug waiting inside" and because there's option to do so. On the other hand, if this problem doesn't have easy solution i can switch it back.

Btw. changing owner of /var/run/syslog-ng.pid doesn't work and it seems it's not updated during reload.

----------

## dgaffuri

I think you may change the script and use ps -C syslog-ng return code to verify if it's running and killall -s HUP syslog-ng to signal (or assign ps -o pid --no-heading -C syslog-ng output to a variable and use it as pid for kill).

Hope this helps.

----------

