Subject: | perms 644 on output |
Date: | Sat, 02 Jul 2011 08:42:38 +1000 |
To: | bug-IPC-Run [...] rt.cpan.org |
From: | Kevin Ryde <user42 [...] zip.com.au> |
IPC::Run 0.89 creates it's output files only 644, which prevents a user
giving group write permissions with umask.
The program foo.pl below shows how perl's open() or the shell ">foo"
output both follow the umask on output, giving group write perms, but
IPC::Run does not.
perlfunc.pod under sysopen() notes that 0644 is usually wrong, for this
reason. Normally 0666 is right (or for something security related then
0600).
#!/usr/bin/perl -w
use strict;
use warnings;
use IPC::Run;
umask 0002 or die;
print "umask is ",umask(),"\n";
unlink "/tmp/ipc-run.txt";
unlink "/tmp/system.txt";
unlink "/tmp/open.txt";
IPC::Run::run (['echo', 'hello'], '>', "/tmp/ipc-run.txt");
system "echo hello >/tmp/system.txt";
open my $fh, '>', '/tmp/open.txt' or die;
close $fh;
system("ls -l /tmp/ipc-run.txt /tmp/system.txt /tmp/open.txt");