Created
January 8, 2009 12:39
-
-
Save omega/44711 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
has 'user' => (is => 'ro', isa => 'Str', default => 'nobody'); | |
has 'group' => (is => 'ro', isa => 'Str', default => 'nogroup'); | |
after 'daemonize' => sub { | |
my $self = shift; | |
return unless $self->is_daemon; | |
return unless (defined $self->user and defined $self->group); | |
my $uid = getpwnam($self->user) or $self->log->error( "cannot find uid for username: " . $self->user); | |
my $gid = getgrnam($self->group) or $self->log->error("cannot find gid for group: " . $self->group); | |
# EGID, set twice to remove inherited groups | |
$) = "$gid $gid"; | |
# GID change | |
$( = $gid; | |
# EUID change, leave UID alone | |
$> = $uid; | |
}; | |
before 'stop' => sub { | |
my $self = shift; | |
$self->log->info("stopping"); | |
}; | |
before 'remove_pid' => sub { | |
# Regain EUID | |
$> = $<; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment