Run daemons as target binary's owning user

This commit is contained in:
Oliver Gorwits
2014-03-10 23:33:27 +00:00
parent b9205c1c80
commit e94c049f29
3 changed files with 11 additions and 0 deletions

View File

@@ -3,6 +3,7 @@
[ENHANCEMENTS] [ENHANCEMENTS]
* Use daterange for IP Subnets (same as IP Inventory) * Use daterange for IP Subnets (same as IP Inventory)
* Run daemons as target binary's owning user (supports run control)
[BUG FIXES] [BUG FIXES]

View File

@@ -32,6 +32,9 @@ my @args = (scalar @ARGV > 1 ? @ARGV[1 .. $#ARGV] : ());
my $log_dir = dir($home, 'logs'); my $log_dir = dir($home, 'logs');
mkdir $log_dir if ! -d $log_dir; mkdir $log_dir if ! -d $log_dir;
my $uid = stat($netdisco)[4] || 0;
my $gid = stat($netdisco)[5] || 0;
Daemon::Control->new({ Daemon::Control->new({
name => 'Netdisco Daemon', name => 'Netdisco Daemon',
program => $netdisco, program => $netdisco,
@@ -39,6 +42,8 @@ Daemon::Control->new({
pid_file => file($home, 'netdisco-daemon.pid'), pid_file => file($home, 'netdisco-daemon.pid'),
stderr_file => file($log_dir, 'netdisco-daemon.log'), stderr_file => file($log_dir, 'netdisco-daemon.log'),
stdout_file => file($log_dir, 'netdisco-daemon.log'), stdout_file => file($log_dir, 'netdisco-daemon.log'),
uid => $uid,
gid => $gid,
})->run; })->run;
=head1 NAME =head1 NAME

View File

@@ -32,6 +32,9 @@ my @args = (scalar @ARGV > 1 ? @ARGV[1 .. $#ARGV] : ());
my $log_dir = dir($home, 'logs'); my $log_dir = dir($home, 'logs');
mkdir $log_dir if ! -d $log_dir; mkdir $log_dir if ! -d $log_dir;
my $uid = stat($netdisco)[4] || 0;
my $gid = stat($netdisco)[5] || 0;
Daemon::Control->new({ Daemon::Control->new({
name => 'Netdisco Web', name => 'Netdisco Web',
program => 'starman', program => 'starman',
@@ -39,6 +42,8 @@ Daemon::Control->new({
pid_file => file($home, 'netdisco-web.pid'), pid_file => file($home, 'netdisco-web.pid'),
stderr_file => file($log_dir, 'netdisco-web.log'), stderr_file => file($log_dir, 'netdisco-web.log'),
stdout_file => file($log_dir, 'netdisco-web.log'), stdout_file => file($log_dir, 'netdisco-web.log'),
uid => $uid,
gid => $gid,
})->run; })->run;
=head1 NAME =head1 NAME