Skip to content

Commit

Permalink
Keep file permissions
Browse files Browse the repository at this point in the history
This patch forces the system to keep the same permissions on the
files being tokenized.  This is useful for files in bin type
directories that need to be campified to point to the proper
lib directories.
  • Loading branch information
rmtemplet committed Oct 4, 2011
1 parent 89686fe commit 964c608
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/Camp/Master.pm
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2023,6 +2023,7 @@ sub install_templates {
for my $file (@edits) { for my $file (@edits) {
my $source_path = File::Spec->catfile($template_path, $file); my $source_path = File::Spec->catfile($template_path, $file);
print "Interpolating tokenized template file '$source_path'..."; print "Interpolating tokenized template file '$source_path'...";
my $mode = (stat($source_path))[2];
open(my $INFILE, '<', $source_path) or die "Failed to open template file '$source_path': $!\n"; open(my $INFILE, '<', $source_path) or die "Failed to open template file '$source_path': $!\n";
my $template = <$INFILE>; my $template = <$INFILE>;
$template = substitute_hash_tokens( $template = substitute_hash_tokens(
Expand All @@ -2037,6 +2038,7 @@ sub install_templates {
open(my $OUTFILE, '>', $target_path) or die "Failed writing configuration file '$target_path': $!\n"; open(my $OUTFILE, '>', $target_path) or die "Failed writing configuration file '$target_path': $!\n";
print $OUTFILE $template; print $OUTFILE $template;
close $OUTFILE or die "Error closing $target_path: $!\n"; close $OUTFILE or die "Error closing $target_path: $!\n";
chmod($mode, $target_path);
} }
type_message('install_templates'); type_message('install_templates');
return; return;
Expand Down

0 comments on commit 964c608

Please sign in to comment.