mirror of
https://gitlab.alpinelinux.org/alpine/cloud/tiny-cloud.git
synced 2025-12-14 19:02:45 +03:00
Implement no_create_home for users
This commit is contained in:
parent
69c9545144
commit
0abcf08262
@ -270,7 +270,8 @@ in_list() {
|
||||
init__userdata_users() {
|
||||
local users="$(get_userdata users)"
|
||||
for i in $users; do
|
||||
local name gecos homedir shell system=false lock_passwd=true
|
||||
local name gecos homedir shell
|
||||
local system=false no_create_home=false lock_passwd=true
|
||||
local keys="$(get_userdata users/$i)"
|
||||
if [ "$i" = 1 ] && [ "$keys" = "default" ]; then
|
||||
continue
|
||||
@ -292,6 +293,9 @@ init__userdata_users() {
|
||||
if in_list system $keys; then
|
||||
system="$(get_userdata users/$i/system)"
|
||||
fi
|
||||
if in_list no_create_home $keys; then
|
||||
no_create_home="$(get_userdata users/$i/no_create_home)"
|
||||
fi
|
||||
|
||||
if getent passwd "$user" >/dev/null; then
|
||||
log -i -t "$phase" info "$ACTION: user $user already exists"
|
||||
@ -299,7 +303,10 @@ init__userdata_users() {
|
||||
if [ "$system" != "true" ]; then
|
||||
unset system
|
||||
fi
|
||||
$MOCK adduser -D ${gecos:+-g "$gecos"} ${homedir:+-h "$homedir"} ${shell:+-s "$shell"} ${system:+-S} "$name"
|
||||
if [ "$no_create_home" != "true" ]; then
|
||||
unset no_create_home
|
||||
fi
|
||||
$MOCK adduser -D ${gecos:+-g "$gecos"} ${homedir:+-h "$homedir"} ${shell:+-s "$shell"} ${system:+-S} ${no_create_home:+-H} "$name"
|
||||
fi
|
||||
|
||||
if in_list lock_passwd $keys; then
|
||||
|
||||
@ -23,6 +23,7 @@ init_tests \
|
||||
userdata_users_homedir \
|
||||
userdata_users_shell \
|
||||
userdata_users_system \
|
||||
userdata_users_no_create_home \
|
||||
userdata_users_lock_passwd \
|
||||
userdata_users_ssh_authorized_keys \
|
||||
userdata_ssh_authorized_keys \
|
||||
@ -264,6 +265,22 @@ userdata_users_system_body() {
|
||||
tiny-cloud main
|
||||
}
|
||||
|
||||
userdata_users_no_create_home_body() {
|
||||
# first specified user will replace default user
|
||||
fake_userdata_nocloud <<-EOF
|
||||
#alpine-config
|
||||
users:
|
||||
- default
|
||||
- name: foo
|
||||
no_create_home: true
|
||||
EOF
|
||||
atf_check -e ignore -o ignore tiny-cloud early
|
||||
atf_check \
|
||||
-e match:"userdata_users: done" \
|
||||
-o match:"adduser.*-H.*foo" \
|
||||
tiny-cloud main
|
||||
}
|
||||
|
||||
userdata_users_lock_passwd_body() {
|
||||
# first specified user will replace default user
|
||||
fake_userdata_nocloud <<-EOF
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user