]> source.dussan.org Git - rspamd.git/commitdiff
* Fix initialization procedure of redirector
authorVsevolod Stakhov <vsevolod@rambler-co.ru>
Fri, 6 Mar 2009 10:09:32 +0000 (13:09 +0300)
committerVsevolod Stakhov <vsevolod@rambler-co.ru>
Fri, 6 Mar 2009 10:09:32 +0000 (13:09 +0300)
* Do not write to log file if we cannot open it

src/util.c
utils/redirector.pl.in

index 589d5b5d95b12a97f39b5d407d1a225709d23911..4ca9a437b8c70c939a7b81fdc6ff4a2f073d4c6d 100644 (file)
@@ -813,7 +813,7 @@ open_log (struct config_file *cfg)
                case RSPAMD_LOG_FILE:
                        cfg->log_fd = open (cfg->log_file, O_CREAT | O_WRONLY | O_APPEND, S_IWUSR | S_IRUSR | S_IRGRP | S_IROTH);
                        if (cfg->log_fd == -1) {
-                               msg_err ("open_log: cannot open desired log file: %s, %s", cfg->log_file, strerror (errno));
+                               fprintf (stderr, "open_log: cannot open desired log file: %s, %s", cfg->log_file, strerror (errno));
                                return -1;
                        }
                        return 0;
index da34515804a4964da7dbb6e2e355f9c4082c043a..c406b48a3a042e1abd37abc451dd7206239e898a 100755 (executable)
@@ -40,7 +40,7 @@ my %cfg = (
     max_rec     => 5,
     pidfile =>  '/var/run/rspamd/redirector.pid',
     logfile =>  '/var/log/rspamd-redirector.log',
-    do_log  =>  1,
+    do_log  =>  0,
     debug   =>  0,
     digest_bits => 256,
     cache_expire => 3600,
@@ -50,6 +50,11 @@ my %cfg = (
 
 our $do_reopen_log = 0;
 
+die "Process is already started, check $cfg{pidfile}" if Proc::PidUtil::is_running($cfg{pidfile});
+
+# Do daemonization
+Proc::Daemon::Init if !$cfg{debug};
+
 # Drop privilleges
 if ($> == 0) {
     my $uid = getpwnam($cfg{user}) or die "user $cfg{user} unknown";
@@ -58,15 +63,10 @@ if ($> == 0) {
     $) = $gid;
 }
 
-die "Process is already started, check $cfg{pidfile}" if Proc::PidUtil::is_running($cfg{pidfile});
-
 die "Cannot write to pidfile $cfg{pidfile}" if ! open(PID, "> $cfg{pidfile}");
 close(PID);
 
-$cfg{do_log} = 0 if ! open(LOG, ">> $cfg{logfile}");
-
-# Do daemonization
-Proc::Daemon::Init if !$cfg{debug};
+$cfg{do_log} = 1 if open(LOG, ">> $cfg{logfile}");
 
 Proc::PidUtil::make_pidfile($cfg{pidfile}, $$) or die "Cannot write pidfile $cfg{pidfile}";
 
@@ -443,7 +443,6 @@ POE::Kernel->run();
 exit 0;
 
 END {
-    unlink($cfg{pidfile});
     if ($cfg{do_log}) {
         write_log ("", "Stopping URL resolver");
         close (LOG);