diff options
author | Natanael Copa <ncopa@alpinelinux.org> | 2022-11-08 17:21:20 +0100 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2022-11-08 17:21:20 +0100 |
commit | 70c76e7114acb684094067b5a3369bc3dff61e14 (patch) | |
tree | 5d37ea12659948c91017972b12945ed747bab48c | |
parent | 1e1ac71fc0e6efe8c6bacc5ff3ba6429a97330cd (diff) | |
download | alpine-conf-70c76e7114acb684094067b5a3369bc3dff61e14.zip |
setup-user: skip user creation if 'none' is set
Skip user creation if username is 'none' and no other options are set.
fixes https://gitlab.alpinelinux.org/alpine/alpine-conf/-/issues/10528
-rw-r--r-- | setup-user.in | 4 | ||||
-rwxr-xr-x | tests/setup_user_test | 9 |
2 files changed, 13 insertions, 0 deletions
diff --git a/setup-user.in b/setup-user.in index 82c2f38..a61749c 100644 --- a/setup-user.in +++ b/setup-user.in @@ -38,6 +38,10 @@ while getopts "af:g:hk:u" opt; do done shift $(($OPTIND - 1)) +if [ -z "$admin$fullnameopt$groups$keysopt$forceunlock" ] && [ "$1" = "none" ]; then + exit 0 +fi + if [ $# -gt 1 ]; then usage "1" >&2 elif [ $# -eq 1 ]; then diff --git a/tests/setup_user_test b/tests/setup_user_test index 2211f67..6b17d94 100755 --- a/tests/setup_user_test +++ b/tests/setup_user_test @@ -3,6 +3,7 @@ . $(atf_get_srcdir)/test_env.sh init_tests \ setup_user_usage \ + setup_user_none \ setup_user_fullname \ setup_user_interactive_no \ setup_user_interactive \ @@ -28,6 +29,14 @@ setup_user_body() { setup-user testuser } +setup_user_none_body () { + init_env + atf_check -s exit:0 \ + -o empty \ + -e empty \ + setup-user none +} + setup_user_fullname_body() { init_env atf_check -s exit:0 \ |