umask change in Perl daemon example code
Bug #287119 is caused by the "umask(0);" line in the following code
snippet:
sub become_daemon {
my $child = fork;
die "Can't fork: $!" unless defined($child);
exit(0) if $child; # parent dies;
POSIX::setsid(); # become session leader
open(STDIN,"</dev/null");
open(STDOUT,">/dev/null");
open(STDERR, '>&STDOUT');
chdir '/'; # change working directory
umask(0); # forget file mode creation mask
$ENV{PATH} = '/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin';
delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};
$SIG{CHLD} = \&reap_child;
# signal handler for child die events
$SIG{TERM} = $SIG{INT} = \&do_term;
$SIG{HUP} = \&do_hup;
}
Apparently, this is part of some standard Perl example for
implementing daemons, which means other packages might be affected as
well. Symptoms are files which are created world-writable. For
pperl, I'm going to remove the line and add a regression test.
Reply to: