nixos/systemd-sysusers: only create systemusers
systemd-sysusers cannot create normal users (i.e. with a UID > 1000). Thus we stop trying an explitily only use systemd-sysusers when there are no normal users on the system (e.g. appliances).
This commit is contained in:
@@ -2,8 +2,8 @@
|
||||
|
||||
let
|
||||
rootPassword = "$y$j9T$p6OI0WN7.rSfZBOijjRdR.$xUOA2MTcB48ac.9Oc5fz8cxwLv1mMqabnn333iOzSA6";
|
||||
normaloPassword = "$y$j9T$3aiOV/8CADAK22OK2QT3/0$67OKd50Z4qTaZ8c/eRWHLIM.o3ujtC1.n9ysmJfv639";
|
||||
newNormaloPassword = "mellow";
|
||||
sysuserPassword = "$y$j9T$3aiOV/8CADAK22OK2QT3/0$67OKd50Z4qTaZ8c/eRWHLIM.o3ujtC1.n9ysmJfv639";
|
||||
newSysuserPassword = "mellow";
|
||||
in
|
||||
|
||||
{
|
||||
@@ -19,15 +19,19 @@ in
|
||||
# Override the empty root password set by the test instrumentation
|
||||
users.users.root.hashedPasswordFile = lib.mkForce null;
|
||||
users.users.root.initialHashedPassword = rootPassword;
|
||||
users.users.normalo = {
|
||||
isNormalUser = true;
|
||||
initialHashedPassword = normaloPassword;
|
||||
users.users.sysuser = {
|
||||
isSystemUser = true;
|
||||
group = "wheel";
|
||||
home = "/sysuser";
|
||||
initialHashedPassword = sysuserPassword;
|
||||
};
|
||||
|
||||
specialisation.new-generation.configuration = {
|
||||
users.users.new-normalo = {
|
||||
isNormalUser = true;
|
||||
initialPassword = newNormaloPassword;
|
||||
users.users.new-sysuser = {
|
||||
isSystemUser = true;
|
||||
group = "wheel";
|
||||
home = "/new-sysuser";
|
||||
initialPassword = newSysuserPassword;
|
||||
};
|
||||
};
|
||||
};
|
||||
@@ -47,18 +51,18 @@ in
|
||||
print(machine.succeed("getent passwd root"))
|
||||
assert "${rootPassword}" in machine.succeed("getent shadow root"), "root user password is not correct"
|
||||
|
||||
with subtest("normalo user is created"):
|
||||
print(machine.succeed("getent passwd normalo"))
|
||||
assert machine.succeed("stat -c '%U' /home/normalo") == "normalo\n"
|
||||
assert "${normaloPassword}" in machine.succeed("getent shadow normalo"), "normalo user password is not correct"
|
||||
with subtest("sysuser user is created"):
|
||||
print(machine.succeed("getent passwd sysuser"))
|
||||
assert machine.succeed("stat -c '%U' /sysuser") == "sysuser\n"
|
||||
assert "${sysuserPassword}" in machine.succeed("getent shadow sysuser"), "sysuser user password is not correct"
|
||||
|
||||
|
||||
machine.succeed("/run/current-system/specialisation/new-generation/bin/switch-to-configuration switch")
|
||||
|
||||
|
||||
with subtest("new-normalo user is created after switching to new generation"):
|
||||
print(machine.succeed("getent passwd new-normalo"))
|
||||
print(machine.succeed("getent shadow new-normalo"))
|
||||
assert machine.succeed("stat -c '%U' /home/new-normalo") == "new-normalo\n"
|
||||
with subtest("new-sysuser user is created after switching to new generation"):
|
||||
print(machine.succeed("getent passwd new-sysuser"))
|
||||
print(machine.succeed("getent shadow new-sysuser"))
|
||||
assert machine.succeed("stat -c '%U' /new-sysuser") == "new-sysuser\n"
|
||||
'';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user