about summary refs log tree commit diff
path: root/nixos/tests
diff options
context:
space:
mode:
authorAdam C. Stephens <2071575+adamcstephens@users.noreply.github.com>2024-03-26 09:48:05 -0400
committerGitHub <noreply@github.com>2024-03-26 09:48:05 -0400
commitd729632b6fce2883fbe8ef839caf5a7ce63ef3fe (patch)
tree066704d37490a29084b6ac5663b24f19d8c9dea5 /nixos/tests
parent85b4838d3b659f73d137d05e16217950cea90f44 (diff)
parent790fb86a7f46dff6c89445fe332aee5b9740e19b (diff)
downloadnixlib-d729632b6fce2883fbe8ef839caf5a7ce63ef3fe.tar
nixlib-d729632b6fce2883fbe8ef839caf5a7ce63ef3fe.tar.gz
nixlib-d729632b6fce2883fbe8ef839caf5a7ce63ef3fe.tar.bz2
nixlib-d729632b6fce2883fbe8ef839caf5a7ce63ef3fe.tar.lz
nixlib-d729632b6fce2883fbe8ef839caf5a7ce63ef3fe.tar.xz
nixlib-d729632b6fce2883fbe8ef839caf5a7ce63ef3fe.tar.zst
nixlib-d729632b6fce2883fbe8ef839caf5a7ce63ef3fe.zip
Merge pull request #297782 from adamcstephens/fix-linger
nixos/users-groups: fix broken linger
Diffstat (limited to 'nixos/tests')
-rw-r--r--nixos/tests/all-tests.nix1
-rw-r--r--nixos/tests/systemd-user-linger.nix39
2 files changed, 40 insertions, 0 deletions
diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix
index 69d340bae277..fd1f884c8c28 100644
--- a/nixos/tests/all-tests.nix
+++ b/nixos/tests/all-tests.nix
@@ -902,6 +902,7 @@ in {
   systemd-sysusers-immutable = runTest ./systemd-sysusers-immutable.nix;
   systemd-timesyncd = handleTest ./systemd-timesyncd.nix {};
   systemd-timesyncd-nscd-dnssec = handleTest ./systemd-timesyncd-nscd-dnssec.nix {};
+  systemd-user-linger = handleTest ./systemd-user-linger.nix {};
   systemd-user-tmpfiles-rules = handleTest ./systemd-user-tmpfiles-rules.nix {};
   systemd-misc = handleTest ./systemd-misc.nix {};
   systemd-userdbd = handleTest ./systemd-userdbd.nix {};
diff --git a/nixos/tests/systemd-user-linger.nix b/nixos/tests/systemd-user-linger.nix
new file mode 100644
index 000000000000..2c3d71668979
--- /dev/null
+++ b/nixos/tests/systemd-user-linger.nix
@@ -0,0 +1,39 @@
+import ./make-test-python.nix (
+  { lib, ... }:
+  {
+    name = "systemd-user-linger";
+
+    nodes.machine =
+      { ... }:
+      {
+        users.users = {
+          alice = {
+            isNormalUser = true;
+            linger = true;
+            uid = 1000;
+          };
+
+          bob = {
+            isNormalUser = true;
+            linger = false;
+            uid = 10001;
+          };
+        };
+      };
+
+    testScript =
+      { ... }:
+      ''
+        machine.wait_for_file("/var/lib/systemd/linger/alice")
+        machine.succeed("systemctl status user-1000.slice")
+
+        machine.fail("test -e /var/lib/systemd/linger/bob")
+        machine.fail("systemctl status user-1001.slice")
+
+        with subtest("missing users have linger purged"):
+            machine.succeed("touch /var/lib/systemd/linger/missing")
+            machine.systemctl("restart linger-users")
+            machine.succeed("test ! -e /var/lib/systemd/linger/missing")
+      '';
+  }
+)