Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Daemon-Control CPAN distribution.

Report information
The Basics
Id: 77425
Status: resolved
Priority: 0/
Queue: Daemon-Control

People
Owner: Nobody in particular
Requestors: chansen [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: umask
D::C should set umask() to something sensible. -- chansen
On Fri May 25 03:56:47 2012, CHANSEN wrote: Show quoted text
> D::C should set umask() to something sensible. > > -- > chansen
This should probably be configurable with a constructor argument.
Added umask() as a constructor argument to be set if given. Otherwise the inherited umask from the shell should be used. 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</group>. $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.