Closes: https://bugs.gentoo.org/886147 Closes: https://github.com/gentoo/gentoo/pull/28744 Signed-off-by: Mike Gilbert <flop...@gentoo.org> --- eclass/acct-user.eclass | 51 ++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 26 deletions(-)
diff --git a/eclass/acct-user.eclass b/eclass/acct-user.eclass index a37e12121f8..14fda76ced7 100644 --- a/eclass/acct-user.eclass +++ b/eclass/acct-user.eclass @@ -339,36 +339,35 @@ acct-user_pkg_preinst() { if egetent passwd "${ACCT_USER_NAME}" >/dev/null; then elog "User ${ACCT_USER_NAME} already exists" - return - fi - - local groups=( ${_ACCT_USER_GROUPS} ) - local aux_groups=${groups[*]:1} - local opts=( - --system - --no-create-home - --no-user-group - --comment "${_ACCT_USER_COMMENT}" - --home-dir "${_ACCT_USER_HOME}" - --shell "${_ACCT_USER_SHELL}" - --gid "${groups[0]}" - --groups "${aux_groups// /,}" - ) + else + local groups=( ${_ACCT_USER_GROUPS} ) + local aux_groups=${groups[*]:1} + local opts=( + --system + --no-create-home + --no-user-group + --comment "${_ACCT_USER_COMMENT}" + --home-dir "${_ACCT_USER_HOME}" + --shell "${_ACCT_USER_SHELL}" + --gid "${groups[0]}" + --groups "${aux_groups// /,}" + ) + + if [[ ${_ACCT_USER_ID} -ne -1 ]] && + ! egetent passwd "${_ACCT_USER_ID}" >/dev/null + then + opts+=( --uid "${_ACCT_USER_ID}" ) + fi - if [[ ${_ACCT_USER_ID} -ne -1 ]] && - ! egetent passwd "${_ACCT_USER_ID}" >/dev/null - then - opts+=( --uid "${_ACCT_USER_ID}" ) - fi + if [[ -n ${ROOT} ]]; then + opts+=( --prefix "${ROOT}" ) + fi - if [[ -n ${ROOT} ]]; then - opts+=( --prefix "${ROOT}" ) + elog "Adding user ${ACCT_USER_NAME}" + useradd "${opts[@]}" "${ACCT_USER_NAME}" || die + _ACCT_USER_ADDED=1 fi - elog "Adding user ${ACCT_USER_NAME}" - useradd "${opts[@]}" "${ACCT_USER_NAME}" || die - _ACCT_USER_ADDED=1 - if [[ ${_ACCT_USER_HOME} != /dev/null ]]; then # default ownership to user:group if [[ -z ${_ACCT_USER_HOME_OWNER} ]]; then -- 2.39.0