diff options
author | Mike Gilbert <floppym@gentoo.org> | 2022-10-17 14:33:13 -0400 |
---|---|---|
committer | Mike Gilbert <floppym@gentoo.org> | 2022-10-19 12:47:29 -0400 |
commit | eeea28a17aadcbd189e710a4433f94b4f903fd32 (patch) | |
tree | 80376c5398f27156efc09714595a0c5a03609050 /eclass/acct-group.eclass | |
parent | user.eclass: mark @DEAD (diff) | |
download | gentoo-eeea28a17aadcbd189e710a4433f94b4f903fd32.tar.gz gentoo-eeea28a17aadcbd189e710a4433f94b4f903fd32.tar.bz2 gentoo-eeea28a17aadcbd189e710a4433f94b4f903fd32.zip |
acct-group.eclass: inline groupadd
Signed-off-by: Mike Gilbert <floppym@gentoo.org>
Diffstat (limited to 'eclass/acct-group.eclass')
-rw-r--r-- | eclass/acct-group.eclass | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/eclass/acct-group.eclass b/eclass/acct-group.eclass index 3d02e4f713b4..85f0919509e1 100644 --- a/eclass/acct-group.eclass +++ b/eclass/acct-group.eclass @@ -40,7 +40,7 @@ case ${EAPI:-0} in *) die "EAPI=${EAPI:-0} not supported";; esac -inherit user +inherit user-info [[ ${CATEGORY} == acct-group ]] || die "Ebuild error: this eclass can be used only in acct-group category!" @@ -156,8 +156,30 @@ acct-group_src_install() { acct-group_pkg_preinst() { debug-print-function ${FUNCNAME} "${@}" - enewgroup ${ACCT_GROUP_ENFORCE_ID:+-F} "${ACCT_GROUP_NAME}" \ - "${_ACCT_GROUP_ID}" + if [[ ${EUID} -ne 0 ]]; then + einfo "Insufficient privileges to execute ${FUNCNAME[0]}" + return + fi + + if egetent group "${ACCT_GROUP_NAME}" >/dev/null; then + elog "Group ${ACCT_GROUP_NAME} already exists" + return + fi + + local opts=( --system ) + + if [[ ${_ACCT_GROUP_ID} -ne -1 ]] && + ! egetent group "${_ACCT_GROUP_ID}" >/dev/null + then + opts+=( --gid "${_ACCT_GROUP_ID}" ) + fi + + if [[ -n ${ROOT} ]]; then + opts+=( --prefix "${ROOT}" ) + fi + + elog "Adding group ${ACCT_GROUP_NAME}" + groupadd "${opts[@]}" "${ACCT_GROUP_NAME}" || die } fi |