make sure that HTTPd logfile is created on startup and on every SIGHUP

This commit is contained in:
Jordi Sanfeliu 2013-02-15 11:54:38 +01:00
parent 6b4eac6cb3
commit 4bbba328ac
2 changed files with 13 additions and 0 deletions

View File

@ -77,6 +77,11 @@ sub httpd_setup {
return; # parent returns
}
# create the HTTPd logfile
open(OUT, "> " . $config->{httpd_builtin}->{log_file});
close(OUT);
chown($uid, $gid, $config->{httpd_builtin}->{log_file});
setgid($gid);
setuid($uid);
setsid();

View File

@ -74,6 +74,9 @@ sub HUP_handler {
my ($signal) = @_;
my $myself = (caller(0))[3];
my (undef, undef, $uid) = getpwnam($config{httpd_builtin}->{user});
my (undef, undef, $gid) = getgrnam($config{httpd_builtin}->{group});
logger("SIG$signal caught.");
# upon receiving a SIGHUP signal the logfile is re-opened
@ -82,6 +85,11 @@ sub HUP_handler {
open(STDOUT, ">> $config{log_file}") || logger("Can't write to LOG: $!");
open(STDERR, ">> $config{log_file}") || logger("Can't write to LOG: $!");
logger("$myself: reopening log file.");
# create the HTTPd logfile
open(OUT, "> " . $config{httpd_builtin}->{log_file});
close(OUT);
chown($uid, $gid, $config{httpd_builtin}->{log_file});
}
sub ALRM_handler {