summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMukund Sivaraman <muks@banu.com>2010-06-02 10:19:49 +0530
committerMukund Sivaraman <muks@banu.com>2010-06-02 10:36:05 +0530
commit691415a8f9eec3e46157ea77b8b3cfd4e247fcd4 (patch)
tree377209e832dc6b25fba1401d4bdc48e30c3da4fe
parent56257d3da3a37324e2e7f706a4c07c1663d23b0a (diff)
downloadtinyproxy-691415a8f9eec3e46157ea77b8b3cfd4e247fcd4.tar.gz
tinyproxy-691415a8f9eec3e46157ea77b8b3cfd4e247fcd4.zip
[BB#74] Create log and pid files after we drop privs
-rw-r--r--src/main.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/src/main.c b/src/main.c
index dd1ff73..a632c43 100644
--- a/src/main.c
+++ b/src/main.c
@@ -394,10 +394,6 @@ main (int argc, char **argv)
exit (EX_SOFTWARE);
}
- if (setup_logging ()) {
- exit (EX_SOFTWARE);
- }
-
init_stats ();
/* If ANONYMOUS is turned on, make sure that Content-Length is
@@ -412,14 +408,6 @@ main (int argc, char **argv)
if (config.godaemon == TRUE)
makedaemon ();
- if (config.pidpath) {
- if (pidfile_create (config.pidpath) < 0) {
- fprintf (stderr, "%s: Could not create PID file.\n",
- argv[0]);
- exit (EX_OSERR);
- }
- }
-
if (set_signal_handler (SIGPIPE, SIG_IGN) == SIG_ERR) {
fprintf (stderr, "%s: Could not set the \"SIGPIPE\" signal.\n",
argv[0]);
@@ -445,6 +433,20 @@ main (int argc, char **argv)
log_message (LOG_WARNING,
"Not running as root, so not changing UID/GID.");
+ /* Create log file after we drop privileges */
+ if (setup_logging ()) {
+ exit (EX_SOFTWARE);
+ }
+
+ /* Create pid file after we drop privileges */
+ if (config.pidpath) {
+ if (pidfile_create (config.pidpath) < 0) {
+ fprintf (stderr, "%s: Could not create PID file.\n",
+ argv[0]);
+ exit (EX_OSERR);
+ }
+ }
+
if (child_pool_create () < 0) {
fprintf (stderr,
"%s: Could not create the pool of children.\n",