Skip to content

Commit

Permalink
write_timezone: Always truncate before writing
Browse files Browse the repository at this point in the history
In #93 it was reported that previous timezones were still ending up in
/etc/timezone. This sounded improbable since everything was working for
me, but then of course I checked myself and saw:

    % cat /etc/timezone
    Europe/Paris

    rk
    es

It seems like glibc only cares up to the first newline, so I never
noticed that we're not truncating properly, but we should certainly be
truncating here.

Fixes #93.
  • Loading branch information
cdown committed Sep 28, 2023
1 parent 8c8ef6c commit aac2ea0
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ pub fn write_timezone(timezone: &str, filename: PathBuf, always_write: bool) ->
let mut file = match fs::OpenOptions::new()
.write(true)
.create(always_write)
.truncate(true)
.mode(0o644)
.open(&filename)
{
Expand Down

0 comments on commit aac2ea0

Please sign in to comment.