Attempt to keep PID and logfile as netdisco user even when running as root
This commit is contained in:
@@ -1,16 +1,20 @@
|
||||
2.029000
|
||||
|
||||
[ENHANCEMENTS]
|
||||
[NEW FEATURES]
|
||||
|
||||
* [#108] Port Bounce port control feature (down and up in succession)
|
||||
* Support for stuffing other locations into @INC at runtime
|
||||
|
||||
[ENHANCEMENTS]
|
||||
|
||||
* Reports config is now a list (see ReleaseNotes)
|
||||
* Add "AP" as a hint for WAP support
|
||||
* Attempt to keep PID and logfile as netdisco user even when running as root
|
||||
|
||||
[BUG FIXES]
|
||||
|
||||
* Missing action to netdisco-do should not throw Perl error
|
||||
* Sort CDP/LLDP data to be more consistent when multiple neighbors on a port
|
||||
* Add "AP" as a hint for WAP support
|
||||
|
||||
2.028013 - 2014-07-31
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@ BEGIN {
|
||||
|
||||
use Daemon::Control;
|
||||
use Filesys::Notify::Simple;
|
||||
use IO::File;
|
||||
|
||||
use App::Netdisco::Environment;
|
||||
my $config = ($ENV{PLACK_ENV} || $ENV{DANCER_ENVIRONMENT}) .'.yml';
|
||||
@@ -53,6 +54,19 @@ my $gid = (stat($netdisco->stringify))[5] || 0;
|
||||
|
||||
my $log_dir = dir($home, 'logs');
|
||||
mkdir $log_dir if ! -d $log_dir;
|
||||
chown $uid, $gid, $log_dir;
|
||||
|
||||
my $pid_file = file($home, 'netdisco-web.pid');
|
||||
my $log_file = file($log_dir, 'netdisco-web.log');
|
||||
|
||||
# change ownership of key files to be netdisco user
|
||||
foreach my $file ($pid_file, $log_file) {
|
||||
unless (-e $file) {
|
||||
sysopen my $fh, $file, O_WRONLY|O_CREAT|O_NONBLOCK|O_NOCTTY;
|
||||
close $fh;
|
||||
}
|
||||
chown $uid, $gid, $file;
|
||||
}
|
||||
|
||||
Daemon::Control->new({
|
||||
name => 'Netdisco Web',
|
||||
@@ -62,9 +76,9 @@ Daemon::Control->new({
|
||||
'--user', $uid, '--group', $gid,
|
||||
@args, $netdisco->stringify
|
||||
],
|
||||
pid_file => file($home, 'netdisco-web.pid'),
|
||||
stderr_file => file($log_dir, 'netdisco-web.log'),
|
||||
stdout_file => file($log_dir, 'netdisco-web.log'),
|
||||
pid_file => $pid_file,
|
||||
stderr_file => $log_file,
|
||||
stdout_file => $log_file,
|
||||
redirect_before_fork => 0,
|
||||
((scalar grep { $_ =~ m/port/ } @args) ? ()
|
||||
: (uid => $uid, gid => $gid)),
|
||||
|
||||
Reference in New Issue
Block a user