From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id D7FA5158020 for ; Wed, 19 Oct 2022 13:30:19 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id F3E53E086C; Wed, 19 Oct 2022 13:30:18 +0000 (UTC) Received: from smtp.gentoo.org (dev.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id DD9DEE086C for ; Wed, 19 Oct 2022 13:30:18 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id E76CF340EA8 for ; Wed, 19 Oct 2022 13:30:17 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 4B47A5F7 for ; Wed, 19 Oct 2022 13:30:16 +0000 (UTC) From: "Michał Górny" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Michał Górny" Message-ID: <1666186204.acd0e195b2fba241d5eac52e34676a4a00493c2b.mgorny@gentoo> Subject: [gentoo-commits] repo/gentoo:master commit in: eclass/ X-VCS-Repository: repo/gentoo X-VCS-Files: eclass/acct-group.eclass X-VCS-Directories: eclass/ X-VCS-Committer: mgorny X-VCS-Committer-Name: Michał Górny X-VCS-Revision: acd0e195b2fba241d5eac52e34676a4a00493c2b X-VCS-Branch: master Date: Wed, 19 Oct 2022 13:30:16 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: cdeb558a-bd42-4443-8188-67c3df6ad9f0 X-Archives-Hash: 857ff4a3b255dabec8fb0febf6e489e6 commit: acd0e195b2fba241d5eac52e34676a4a00493c2b Author: Mike Gilbert gentoo org> AuthorDate: Mon Oct 17 18:33:13 2022 +0000 Commit: Michał Górny gentoo org> CommitDate: Wed Oct 19 13:30:04 2022 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=acd0e195 acct-group.eclass: inline groupadd Signed-off-by: Mike Gilbert gentoo.org> Signed-off-by: Michał Górny gentoo.org> eclass/acct-group.eclass | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/eclass/acct-group.eclass b/eclass/acct-group.eclass index 3d02e4f713b4..3f38ac36ec4d 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,32 @@ 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 [[ -z ${ACCT_GROUP_ENFORCE_ID} ]]; then + opts+=( --force ) + fi + + if [[ ${_ACCT_GROUP_ID} -ne -1 ]]; 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