diff --git a/nixos/modules/config/update-users-groups.pl b/nixos/modules/config/update-users-groups.pl index 7c6851473f42..f0b692a759d1 100644 --- a/nixos/modules/config/update-users-groups.pl +++ b/nixos/modules/config/update-users-groups.pl @@ -234,7 +234,7 @@ foreach my $u (@{$spec->{users}}) { # Ensure home directory incl. ownership and permissions. if ($u->{createHome} and !$is_dry) { - make_path($u->{home}, { mode => oct($u->{homeMode}) }) if ! -e $u->{home}; + make_path($u->{home}, { mode => 0755 }) if ! -e $u->{home}; chown $u->{uid}, $u->{gid}, $u->{home}; chmod oct($u->{homeMode}), $u->{home}; } diff --git a/nixos/tests/user-home-mode.nix b/nixos/tests/user-home-mode.nix index 070cb0b75cc9..2d6d1af3f391 100644 --- a/nixos/tests/user-home-mode.nix +++ b/nixos/tests/user-home-mode.nix @@ -12,6 +12,12 @@ import ./make-test-python.nix ({ lib, ... }: { isNormalUser = true; homeMode = "750"; }; + users.users.carol = { + initialPassword = "pass3"; + isNormalUser = true; + createHome = true; + home = "/users/carol"; + }; }; testScript = '' @@ -23,5 +29,7 @@ import ./make-test-python.nix ({ lib, ... }: { machine.send_chars("pass1\n") machine.succeed('[ "$(stat -c %a /home/alice)" == "700" ]') machine.succeed('[ "$(stat -c %a /home/bob)" == "750" ]') + machine.succeed('[ "$(stat -c %a /users)" == "755" ]') + machine.succeed('[ "$(stat -c %a /users/carol)" == "700" ]') ''; })