1
0
mirror of https://gitlab.alpinelinux.org/alpine/cloud/tiny-cloud.git synced 2025-12-16 03:42:44 +03:00

Make init__create_default_user return success

We should return success even if /etc/doas.d is missing
fixes https://gitlab.alpinelinux.org/alpine/cloud/tiny-cloud/-/issues/38
This commit is contained in:
Natanael Copa 2023-05-08 12:09:27 +02:00
parent 4ccc16f18f
commit d1ed0c29e3
2 changed files with 19 additions and 7 deletions

View File

@ -169,16 +169,18 @@ init__create_default_user() {
return return
fi fi
addgroup "$user" $MOCK addgroup "$user"
adduser -h "/home/$user" -s /bin/sh -G "$user" -D "$user" $MOCK adduser -h "/home/$user" -s /bin/sh -G "$user" -D "$user"
addgroup "$user" wheel $MOCK addgroup "$user" wheel
echo "$user:*" | chpasswd -e echo "$user:*" | $MOCK chpasswd -e
# setup sudo and/or doas # setup sudo and/or doas
[ -d "$ROOT/etc/sudoers.d" ] && if [ -d "$ROOT/etc/sudoers.d" ]; then
echo '%wheel ALL=(ALL) NOPASSWD: ALL' > "$ROOT/etc/sudoers.d/wheel" echo '%wheel ALL=(ALL) NOPASSWD: ALL' > "$ROOT/etc/sudoers.d/wheel"
[ -d "$ROOT/etc/doas.d" ] && fi
if [ -d "$ROOT/etc/doas.d" ]; then
echo 'permit nopass :wheel' > "$TARGET/etc/doas.d/wheel.conf" echo 'permit nopass :wheel' > "$TARGET/etc/doas.d/wheel.conf"
fi
} }
init__enable_sshd() { init__enable_sshd() {

View File

@ -14,7 +14,8 @@ init_tests \
find_first_interface_up \ find_first_interface_up \
auto_detect_ethernet_interface \ auto_detect_ethernet_interface \
set_default_interfaces \ set_default_interfaces \
enable_sshd enable_sshd \
create_default_user
PROVIDERS="aws azure gcp nocloud oci" PROVIDERS="aws azure gcp nocloud oci"
@ -109,3 +110,12 @@ enable_sshd_body() {
sh -c ". $lib; init__enable_sshd" sh -c ". $lib; init__enable_sshd"
done done
} }
create_default_user_body() {
atf_check \
-o match:"addgroup alpine" \
-o match:"adduser.*alpine" \
-o match:"addgroup alpine wheel" \
-o match:"chpasswd -e" \
sh -c ". $lib; init__create_default_user"
}