stages/users: don't create homedir when home is empty

Don't create a home dir if the `home` property is given, but empty.
Modify the users tests to create a user that has no home directory.
This commit is contained in:
Christian Kellner 2022-12-02 12:08:56 +00:00
parent e5e70efc37
commit 8ee740dff2
4 changed files with 15 additions and 6 deletions

View file

@ -94,6 +94,8 @@ def useradd(root, name, uid=None, gid=None, groups=None, description=None, home=
if home:
arguments += ["--home-dir", home]
arguments += ["--create-home"]
elif home == "":
arguments += ["--no-create-home"]
if shell:
arguments += ["--shell", shell]
if password is not None:

View file

@ -320,6 +320,10 @@
},
"test.user_42-OSBUILD": {
"password": "$6$TZ9oR8s21Srjvamo$PRHaXMA6pcZc7M2yKGEDLVir/GjCUgV0gW8ZIrab3cY4fKth/MBGm/wndn2MxSU31dCmCnb.3uEODgyaAkaRh0"
},
"nohome": {
"home": "",
"uid": 1337
}
}
}

View file

@ -38,6 +38,10 @@
},
"test.user_42-OSBUILD": {
"password": "$6$TZ9oR8s21Srjvamo$PRHaXMA6pcZc7M2yKGEDLVir/GjCUgV0gW8ZIrab3cY4fKth/MBGm/wndn2MxSU31dCmCnb.3uEODgyaAkaRh0"
},
"nohome": {
"home": "",
"uid": 1337
}
}
}

View file

@ -15,6 +15,7 @@
"/home/test.user_42-OSBUILD/.bash_logout",
"/home/test.user_42-OSBUILD/.bashrc",
"/home/test.user_42-OSBUILD/.bash_profile",
"/var/spool/mail/nohome",
"/var/spool/mail/test",
"/var/spool/mail/test.user_42-OSBUILD"
],
@ -23,7 +24,7 @@
"/etc/group": {
"content": [
"sha256:5be46faf83078411c18ce0f3cb5e5fc5b56b8cb214a7f5a65dbbef6cb8249e16",
"sha256:b75a8542437c8c0265e36f719b0bb2176ab14bc843af12bb009180b53aeb51f6"
"sha256:0dc01c5c9a6ea8a7547fb4580f01dab24982a9aff3360269fbb65eeb64da7c93"
]
},
"/etc/gshadow": {
@ -35,7 +36,7 @@
"/etc/passwd": {
"content": [
"sha256:d137fa8bf6ca9020c35a5bf992f32d4c803497e856e0254618f5abcb2f2425c6",
"sha256:cb2abbc72a76ead35817e76050f6fbb85255a53e09ecfcd6966389dc2e563565"
"sha256:95492ec8ee8ca71b12fc15bead864fc5c2da768a7e23b78038111141f4bd2b24"
]
},
"/etc/shadow": {
@ -47,16 +48,14 @@
"/etc/subgid": {
"content": [
"sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"sha256:601e9cc755cb80e34e21999e732e25869f554f92a42e760533da8d5c701957ea"
"sha256:acdc2cb5c41bd8513c39752e2591ae0d01bd1cc04808481d52b58e54f8696b24"
]
},
"/etc/subuid": {
"content": [
"sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"sha256:601e9cc755cb80e34e21999e732e25869f554f92a42e760533da8d5c701957ea"
"sha256:acdc2cb5c41bd8513c39752e2591ae0d01bd1cc04808481d52b58e54f8696b24"
]
}
}
}