summaryrefslogtreecommitdiffstats
path: root/pki/base/ra/lib/perl/PKI/RA/Config.pm
diff options
context:
space:
mode:
Diffstat (limited to 'pki/base/ra/lib/perl/PKI/RA/Config.pm')
-rwxr-xr-xpki/base/ra/lib/perl/PKI/RA/Config.pm12
1 files changed, 10 insertions, 2 deletions
diff --git a/pki/base/ra/lib/perl/PKI/RA/Config.pm b/pki/base/ra/lib/perl/PKI/RA/Config.pm
index 317b9d91a..6dab970bd 100755
--- a/pki/base/ra/lib/perl/PKI/RA/Config.pm
+++ b/pki/base/ra/lib/perl/PKI/RA/Config.pm
@@ -104,10 +104,14 @@ sub commit
my $suffix = time();
if (-e $self->{filename}) {
- system("mv \"" . $self->{filename} . "\" \"" .
+ # Create a copy of the original file which
+ # preserves the original file permissions
+ system("cp -p \"" . $self->{filename} . "\" \"" .
$self->{filename} . "." . $suffix . "\"");
}
+ # Overwrite the contents of the original file
+ # to preserve the original file permissions
open(F, ">" . $self->{filename});
foreach my $k (sort keys %{$hash}) {
print F "$k=$self->{hash}{$k}\n";
@@ -127,9 +131,13 @@ sub commit_with_backup
# print $self->{filename} . "\n";
my $hash = $self->{hash};
my $suffix = time();
- system("mv \"" . $self->{filename} . "\" \"" .
+ # Create a copy of the original file which
+ # preserves the original file permissions
+ system("cp -p \"" . $self->{filename} . "\" \"" .
$self->{filename} . "." . $suffix . "\"");
+ # Overwrite the contents of the original file
+ # to preserve the original file permissions
open(F, ">" . $self->{filename});
foreach my $k (sort keys %{$hash}) {
print F "$k=$self->{hash}{$k}\n";