Skip to content

Commit

Permalink
define a sane mask before launching class action scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
yannrouillard committed Oct 31, 2013
1 parent bbc98c9 commit 8d82493
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions svr4pkg
Original file line number Diff line number Diff line change
Expand Up @@ -727,6 +727,7 @@ use 5.010001;
);

use constant RESTRICTED_MASK => oct('077');
use constant SANE_MASK => oct('022');
use constant EXECUTABLE_PERMISSIONS => oct('755');

## Public methods
Expand Down Expand Up @@ -1391,6 +1392,11 @@ use 5.010001;
sub _install_files_by_action_script {
my ( $self, $class, $pkgmap_entries, $dest, $action_script ) = @_;

# The script has to make sure the file are created with the appropriate
# permissions depending on the security requirements but we make sure
# a sane default mask is used at least in the worst case
my $original_umask = umask(SANE_MASK);

$action_script = $self->_relocate_path_in_script($action_script);
my $command = $self->{trace} ? "sh -x $action_script" : $action_script;
$command .= ' ENDOFCLASS';
Expand Down Expand Up @@ -1426,6 +1432,10 @@ use 5.010001;
print $fh "$src_path $dest_path\n";
}
}

# we restore the previous umask;
umask($original_umask);

my $result = eval { close($fh); };
}

Expand Down

0 comments on commit 8d82493

Please sign in to comment.