diff options
author | Simon Rettberg | 2024-02-01 23:05:43 +0100 |
---|---|---|
committer | Simon Rettberg | 2024-02-01 23:05:43 +0100 |
commit | 534b9739cda14a07fc5ffe3f2334e92a0b87b979 (patch) | |
tree | 51c80eb07f30c01fa36d2ae2f48c4f4895c3826f | |
parent | [vbox-src] Need bash (diff) | |
download | mltk-534b9739cda14a07fc5ffe3f2334e92a0b87b979.tar.gz mltk-534b9739cda14a07fc5ffe3f2334e92a0b87b979.tar.xz mltk-534b9739cda14a07fc5ffe3f2334e92a0b87b979.zip |
Make useradd and groupadd return 0
These functions will perror on error, so make sure on success we return
0, even though checking the return value is useless...
-rw-r--r-- | core/includes/useradd.inc | 8 | ||||
-rw-r--r-- | core/modules/dnbd3-proxy-mode/module.build | 3 |
2 files changed, 6 insertions, 5 deletions
diff --git a/core/includes/useradd.inc b/core/includes/useradd.inc index d47b43b9..348c5ecd 100644 --- a/core/includes/useradd.inc +++ b/core/includes/useradd.inc @@ -102,8 +102,9 @@ useradd () { [ "$pw" != "#" ] && usr_setpw "$name" "$pw" return 0 # Nothing to do fi - command useradd "${_USER_EXTRA_OPTS[@]}" "${opts[@]}" || perror "useradd failed" + command useradd "${_USER_EXTRA_OPTS[@]}" "${opts[@]}" || perror "useradd ${opts[*]} failed" [ "$pw" != "#" ] && usr_setpw "$name" "$pw" + true } groupadd () { @@ -135,7 +136,8 @@ groupadd () { (( sys == 0 && _ngid < 1000 )) && perror "$name: Already exists with system id $_ngid" return 0 fi - command groupadd "${_USER_EXTRA_OPTS[@]}" "${opts[@]}" || perror "groupadd failed" + command groupadd "${_USER_EXTRA_OPTS[@]}" "${opts[@]}" || perror "groupadd ${opts[*]} failed" + true } # Add user to given group. Not entirely safe as we don't wait for a lock, @@ -144,7 +146,7 @@ groupadd () { add_to_group () { ua_set_vars grep -qP "^${2}:.*:.*[:,]${1}(,|$)" "$_GROUP" && return 0 - grep -q "^${2}:" "$_GROUP" || return 1 + grep -q "^${2}:" "$_GROUP" || perror "Cannot add '$1' to '$2' - no such group" sed -i -r "s/^${2}:[^:]*:[^:]*:.+$/&,$1/;s/^${2}:[^:]*:[^:]*:$/&$1/" "$_GROUP" } diff --git a/core/modules/dnbd3-proxy-mode/module.build b/core/modules/dnbd3-proxy-mode/module.build index 6027ceeb..9a920069 100644 --- a/core/modules/dnbd3-proxy-mode/module.build +++ b/core/modules/dnbd3-proxy-mode/module.build @@ -8,6 +8,5 @@ build() { } post_copy() { - useradd --system --user-group --no-create-home --groups "fuse" "dnbd3" \ - || perror "Cannot create user dnbd3 with supp. group fuse" + useradd --system --user-group --no-create-home --groups "fuse" "dnbd3" } |