0
0
Fork 0
mirror of https://github.com/NixOS/nixpkgs.git synced 2025-07-13 13:40:28 +03:00

Merge pull request #168168 from fedeinthemix/home-mode

nixos/users-group: Add 'homeMode' option.
This commit is contained in:
Janne Heß 2022-05-23 12:27:49 +02:00 committed by GitHub
commit e9bdd5fa74
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 39 additions and 4 deletions

View file

@ -223,10 +223,10 @@ foreach my $u (@{$spec->{users}}) {
}
# Ensure home directory incl. ownership and permissions.
if ($u->{createHome}) {
make_path($u->{home}, { mode => 0700 }) if ! -e $u->{home} and ! $is_dry;
if ($u->{createHome} and !$is_dry) {
make_path($u->{home}, { mode => oct($u->{homeMode}) }) if ! -e $u->{home};
chown $u->{uid}, $u->{gid}, $u->{home};
chmod 0700, $u->{home};
chmod oct($u->{homeMode}), $u->{home};
}
if (defined $u->{passwordFile}) {

View file

@ -139,6 +139,12 @@ let
description = "The user's home directory.";
};
homeMode = mkOption {
type = types.strMatching "[0-7]{1,5}";
default = "700";
description = "The user's home directory mode in numeric format. See chmod(1). The mode is only applied if <option>users.users.&lt;name&gt;.createHome</option> is true.";
};
cryptHomeLuks = mkOption {
type = with types; nullOr str;
default = null;
@ -319,6 +325,7 @@ let
group = mkDefault "users";
createHome = mkDefault true;
home = mkDefault "/home/${config.name}";
homeMode = mkDefault "700";
useDefaultShell = mkDefault true;
isSystemUser = mkDefault false;
})
@ -430,7 +437,7 @@ let
inherit (cfg) mutableUsers;
users = mapAttrsToList (_: u:
{ inherit (u)
name uid group description home createHome isSystemUser
name uid group description home homeMode createHome isSystemUser
password passwordFile hashedPassword
autoSubUidGidRange subUidRanges subGidRanges
initialPassword initialHashedPassword;