Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion nixos/modules/config/update-users-groups.pl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

sub updateFile {
my ($path, $contents, $perms) = @_;
write_file("$path.tmp", { binmode => ':utf8', perms => $perms // 0644 }, $contents);
write_file("$path.tmp", { binmode => ':utf8', perms => $perms // 0644, atomic => 1 }, $contents);
rename("$path.tmp", $path) or die;
Comment on lines +19 to 20
Copy link
Member

@Mic92 Mic92 Sep 23, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we use this flag I don't see a point of having an additional rename step, which was also meant to make the write atomic-ish (no really so when we have multiple writers).

Suggested change
write_file("$path.tmp", { binmode => ':utf8', perms => $perms // 0644, atomic => 1 }, $contents);
rename("$path.tmp", $path) or die;
write_file("$path", { binmode => ':utf8', perms => $perms // 0644, atomic => 1 }, $contents) or die;

Please also check if write_file or die is correct here. I assume so but than we have perl which is full of ways to shoot yourself in the foot.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}

Expand Down