RunCommand: ensure we reset the umask
This commit is contained in:
parent
34e4c119f4
commit
8c67e32480
@ -8,6 +8,7 @@ use JSON::MaybeXS;
|
|||||||
use File::Basename qw(dirname);
|
use File::Basename qw(dirname);
|
||||||
use File::Path qw(make_path);
|
use File::Path qw(make_path);
|
||||||
use IPC::Run3;
|
use IPC::Run3;
|
||||||
|
use Try::Tiny;
|
||||||
|
|
||||||
sub isEnabled {
|
sub isEnabled {
|
||||||
my ($self) = @_;
|
my ($self) = @_;
|
||||||
@ -166,12 +167,14 @@ sub buildFinished {
|
|||||||
my $logPath = Hydra::Helper::Nix::constructRunCommandLogPath($runlog) or die "RunCommandLog not found.";
|
my $logPath = Hydra::Helper::Nix::constructRunCommandLogPath($runlog) or die "RunCommandLog not found.";
|
||||||
my $dir = dirname($logPath);
|
my $dir = dirname($logPath);
|
||||||
my $oldUmask = umask();
|
my $oldUmask = umask();
|
||||||
|
my $f;
|
||||||
|
|
||||||
|
try {
|
||||||
# file: 640, dir: 750
|
# file: 640, dir: 750
|
||||||
umask(0027);
|
umask(0027);
|
||||||
make_path($dir);
|
make_path($dir);
|
||||||
|
|
||||||
open(my $f, '>', $logPath);
|
open($f, '>', $logPath);
|
||||||
umask($oldUmask);
|
umask($oldUmask);
|
||||||
|
|
||||||
run3($command, \undef, $f, $f, { return_if_system_error => 1 }) == 1
|
run3($command, \undef, $f, $f, { return_if_system_error => 1 }) == 1
|
||||||
@ -180,6 +183,12 @@ sub buildFinished {
|
|||||||
close($f);
|
close($f);
|
||||||
|
|
||||||
$runlog->completed_with_child_error($?, $!);
|
$runlog->completed_with_child_error($?, $!);
|
||||||
|
1;
|
||||||
|
} catch {
|
||||||
|
die "Died while trying to process RunCommand (${\$runlog->uuid}): $_";
|
||||||
|
} finally {
|
||||||
|
umask($oldUmask);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user