diff options
author | Janne Heß <dasJ@users.noreply.github.com> | 2023-10-30 10:49:50 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-30 10:49:50 +0100 |
commit | d80d7d66977956d13ae476b898d6b93532f3636f (patch) | |
tree | 861fabed8f1f99307a18dae4cec4078ef9925807 /nixos/modules/system | |
parent | 699e0ab8d9fd618b2ddfc13b2428abf46db4cc32 (diff) | |
parent | 5d7723dd5ba1ee02595f03554acc139b627b3834 (diff) | |
download | nixpkgs-d80d7d66977956d13ae476b898d6b93532f3636f.tar nixpkgs-d80d7d66977956d13ae476b898d6b93532f3636f.tar.gz nixpkgs-d80d7d66977956d13ae476b898d6b93532f3636f.tar.bz2 nixpkgs-d80d7d66977956d13ae476b898d6b93532f3636f.tar.lz nixpkgs-d80d7d66977956d13ae476b898d6b93532f3636f.tar.xz nixpkgs-d80d7d66977956d13ae476b898d6b93532f3636f.tar.zst nixpkgs-d80d7d66977956d13ae476b898d6b93532f3636f.zip |
Merge pull request #258071 from helsinki-systems/feat/stc-lock
nixos/switch-to-configuration: Lock the switch
Diffstat (limited to 'nixos/modules/system')
-rwxr-xr-x | nixos/modules/system/activation/switch-to-configuration.pl | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/nixos/modules/system/activation/switch-to-configuration.pl b/nixos/modules/system/activation/switch-to-configuration.pl index b3ff3ac0abf..e2f66a287bc 100755 --- a/nixos/modules/system/activation/switch-to-configuration.pl +++ b/nixos/modules/system/activation/switch-to-configuration.pl @@ -22,6 +22,7 @@ use JSON::PP; use IPC::Cmd; use Sys::Syslog qw(:standard :macros); use Cwd qw(abs_path); +use Fcntl ':flock'; ## no critic(ControlStructures::ProhibitDeepNests) ## no critic(ErrorHandling::RequireCarping) @@ -91,6 +92,8 @@ if (!-f "/etc/NIXOS" && (read_file("/etc/os-release", err_mode => "quiet") // "" } make_path("/run/nixos", { mode => oct(755) }); +open(my $stc_lock, '>>', '/run/nixos/switch-to-configuration.lock') or die "Could not open lock - $!"; +flock($stc_lock, LOCK_EX) or die "Could not acquire lock - $!"; openlog("nixos", "", LOG_USER); # Install or update the bootloader. @@ -985,4 +988,5 @@ if ($res == 0) { syslog(LOG_ERR, "switching to system configuration $toplevel failed (status $res)"); } +close($stc_lock) or die "Could not close lock - $!"; exit($res); |