Permalink
Browse files

Keep file permissions

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...
1 parent 89686fe commit 2a12ae3a03fd04288ca2dca973370bdfe7f69345 @rmtemplet committed Oct 3, 2011
Showing with 4 additions and 0 deletions.
  1. +4 −0 lib/Camp/Master.pm
View
@@ -2020,9 +2020,12 @@ sub install_templates {
}
my $template_path = File::Spec->catfile(type_path(), 'etc');
local $/;
+ my ($mode,$perms);
for my $file (@edits) {
my $source_path = File::Spec->catfile($template_path, $file);
print "Interpolating tokenized template file '$source_path'...";
+ $mode = (stat($source_path))[2];
+ $perms = sprintf("%04o", $mode & 07777);
open(my $INFILE, '<', $source_path) or die "Failed to open template file '$source_path': $!\n";
my $template = <$INFILE>;
$template = substitute_hash_tokens(
@@ -2037,6 +2040,7 @@ sub install_templates {
open(my $OUTFILE, '>', $target_path) or die "Failed writing configuration file '$target_path': $!\n";
print $OUTFILE $template;
close $OUTFILE or die "Error closing $target_path: $!\n";
+ chmod($perms, $target_path);
}
type_message('install_templates');
return;

0 comments on commit 2a12ae3

Please sign in to comment.