summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorintrigeri <intrigeri@boum.org>2019-02-12 17:53:32 +0000
committerintrigeri <intrigeri@boum.org>2019-02-12 18:08:14 +0000
commit2f21d0579c0440f4c8b7dfa4d2fbdee04c7b9202 (patch)
tree771b1b04c7bfa22b10eb70f93fb21390ef615ae5
parent1d607562c6c509534c2f59e06b63d4854ef28184 (diff)
Use a safer method to write to persistence.conf (refs: #10976).
Path::Tiny's "spew" uses a temporary file + atomic rename, instead of writing directly to the original file. This lowers the chances the original file is truncated if anything goes wrong: likely we'll fail when we're writing to the temporary file, not to the real persistence.conf.
-rw-r--r--lib/Tails/Persistence/Configuration/ConfigFile.pm5
1 files changed, 1 insertions, 4 deletions
diff --git a/lib/Tails/Persistence/Configuration/ConfigFile.pm b/lib/Tails/Persistence/Configuration/ConfigFile.pm
index 6fb719a..848d52e 100644
--- a/lib/Tails/Persistence/Configuration/ConfigFile.pm
+++ b/lib/Tails/Persistence/Configuration/ConfigFile.pm
@@ -84,10 +84,7 @@ Throw exception on error.
=cut
method save () {
my $output = $self->output;
- my $fh = $self->config_file_path->openw();
- print $fh $output;
- $fh->sync;
- close $fh;
+ $self->config_file_path->spew($output);
$self->config_file_path->chmod(0600);
}