From afc8978b783324f56d2b8010466339eade3b7e2c Mon Sep 17 00:00:00 2001 From: SymKat Date: Mon, 3 Sep 2012 13:24:55 -0700 Subject: [PATCH] New option: umask to set the umask value when the daemon launches. --- lib/Daemon/Control.pm | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/Daemon/Control.pm b/lib/Daemon/Control.pm index 50cd6a6..1fb8004 100644 --- a/lib/Daemon/Control.pm +++ b/lib/Daemon/Control.pm @@ -14,7 +14,7 @@ my @accessors = qw( pid color_map name program program_args directory uid path gid scan_name stdout_file stderr_file pid_file fork data lsb_start lsb_stop lsb_sdesc lsb_desc redirect_before_fork init_config - kill_timeout + kill_timeout umask ); # Accessor building @@ -65,6 +65,7 @@ sub new { color_map => { red => 31, green => 32 }, redirect_before_fork => 1, kill_timeout => 1, + umask => 0, }, $class; for my $accessor ( @accessors ) { @@ -128,6 +129,7 @@ sub _double_fork { if ( $new_pid == 0 ) { # Our double fork. setgid( $self->gid ) if $self->gid; setuid( $self->uid ) if $self->uid; + umask( $self->umask) if $self->umask; open( STDIN, "<", File::Spec->devnull ); if ( $self->redirect_before_fork ) { @@ -574,6 +576,18 @@ as root. Accepts numeric GID, for groupnames please see L. $daemon->gid( 1001 ); +=head2 umask + +If provided, the umask of the daemon will be set to the umask provided, +note that the umask must be in oct. By default the umask will not be +changed. + + $daemon->umask( 022 ); + +Or: + + $daemon->umask( oct("022") ); + =head2 directory If provided, chdir to this directory before execution.