diff options
author | Michael Adam <obnox@samba.org> | 2010-03-02 22:02:46 +0100 |
---|---|---|
committer | Michael Adam <obnox@samba.org> | 2010-03-02 22:02:46 +0100 |
commit | 7a9abc2a04dd8ed1f113aa9c803af24adfb22773 (patch) | |
tree | c3c9bd159878ffdeaee8a3c7cc5d101ec1b79762 /src | |
parent | 2235a97f05faace446afe7c59dee8f32e69eee67 (diff) | |
download | tinyproxy-7a9abc2a04dd8ed1f113aa9c803af24adfb22773.tar.gz tinyproxy-7a9abc2a04dd8ed1f113aa9c803af24adfb22773.zip |
main: drop privileges right after reading the config
This is the second part of fixing bug #74.
I lets tinyproxy create its log and pid files as the
user as which it is running, so that later on at SIGHUP,
the log file can successfully be reopened.
Michael
Diffstat (limited to 'src')
-rw-r--r-- | src/main.c | 15 |
1 files changed, 8 insertions, 7 deletions
@@ -393,6 +393,14 @@ main (int argc, char **argv) exit (EX_SOFTWARE); } + /* Switch to a different user if we're running as root */ + if (geteuid () == 0) { + change_user (argv[0]); + } else { + log_message (LOG_WARNING, + "Not running as root, so not changing UID/GID."); + } + ret = setup_logging (); if (ret != 0) { exit (EX_SOFTWARE); @@ -438,13 +446,6 @@ main (int argc, char **argv) exit (EX_OSERR); } - /* Switch to a different user if we're running as root */ - if (geteuid () == 0) - change_user (argv[0]); - else - log_message (LOG_WARNING, - "Not running as root, so not changing UID/GID."); - if (child_pool_create () < 0) { fprintf (stderr, "%s: Could not create the pool of children.\n", |