diff options
-rw-r--r-- | setup-user.in | 12 | ||||
-rwxr-xr-x | tests/setup_user_test | 13 |
2 files changed, 23 insertions, 2 deletions
diff --git a/setup-user.in b/setup-user.in index 8733dc9..4513c63 100644 --- a/setup-user.in +++ b/setup-user.in @@ -11,6 +11,7 @@ usage() { Create user account options: + -a Cerate admin user. Add to wheel group and set up doas -h Show this help -f Set full name for user -g Comma or space separated list of groups to add user to @@ -22,8 +23,9 @@ usage() { exit $1 } -while getopts "f:g:hk:" opt; do +while getopts "af:g:hk:" opt; do case $opt in + a) admin=1;; h) usage 0;; f) fullnameopt="$OPTARG";; g) groups="$OPTARG";; @@ -112,3 +114,11 @@ if [ -n "$groups" ] && [ "$groups" != "none" ]; then $MOCK addgroup "$username" "$i" || exit done fi + +if [ -n "$admin" ]; then + $MOCK apk add doas + mkdir -p "$ROOT"/etc/doas.d + echo "permit persist :wheel" >> "$ROOT"/etc/doas.d/doas.conf + $MOCK addgroup "$username" "wheel" || exit +fi + diff --git a/tests/setup_user_test b/tests/setup_user_test index 3d24ae5..2185c0d 100755 --- a/tests/setup_user_test +++ b/tests/setup_user_test @@ -9,7 +9,8 @@ init_tests \ setup_user_interactive_fullname \ setup_user_interactive_singlename \ setup_user_groups_commas \ - setup_user_groups_spaces + setup_user_groups_spaces \ + setup_user_admin setup_user_usage_body() { test_usage setup-user @@ -103,3 +104,13 @@ setup_user_groups_spaces_body() { -e empty \ setup-user -g "wheel audio video" testuser } + +setup_user_admin_body() { + init_env + atf_check -s exit:0 \ + -o match:"addgroup testuser wheel" \ + -e empty \ + setup-user -a testuser + grep wheel etc/doas.d/doas.conf + +} |