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 49725158064 for ; Mon, 13 May 2024 13:22:19 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id EEF28E2A57; Mon, 13 May 2024 13:22:17 +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 D7A70E2A56 for ; Mon, 13 May 2024 13:22:17 +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 0A46333BEEE for ; Mon, 13 May 2024 13:22:17 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 673751AA9 for ; Mon, 13 May 2024 13:22:15 +0000 (UTC) From: "Michael Orlitzky" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Michael Orlitzky" Message-ID: <1715606006.b7e37226a665a0613facd10386bbbbec8696699e.mjo@gentoo> Subject: [gentoo-commits] repo/gentoo:master commit in: eclass/ X-VCS-Repository: repo/gentoo X-VCS-Files: eclass/acct-user.eclass X-VCS-Directories: eclass/ X-VCS-Committer: mjo X-VCS-Committer-Name: Michael Orlitzky X-VCS-Revision: b7e37226a665a0613facd10386bbbbec8696699e X-VCS-Branch: master Date: Mon, 13 May 2024 13:22:15 +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: f43e65e9-7382-4264-af69-8ddb5ae18d23 X-Archives-Hash: 981c81e37c895b6515f2965628e32649 commit: b7e37226a665a0613facd10386bbbbec8696699e Author: Michael Orlitzky gentoo org> AuthorDate: Thu May 9 20:07:19 2024 +0000 Commit: Michael Orlitzky gentoo org> CommitDate: Mon May 13 13:13:26 2024 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=b7e37226 eclass/acct-user.eclass: use $PN to construct make.conf override vars If (after upcasing and replacing hyphens by underscores) ACCT_USER_NAME is set to something that isn't valid in a bash variable name, the eclass will crash: it uses ACCT_USER_NAME to construct the make.conf override variables in pkg_pretend() and src_install(). This commit constructs the variable names using PN instead of ACCT_USER_NAME. In ::gentoo, the two are equivalent, but in an overlay this allows weirder usernames at the expense of slightly mismatched variable names. Signed-off-by: Michael Orlitzky gentoo.org> eclass/acct-user.eclass | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/eclass/acct-user.eclass b/eclass/acct-user.eclass index 765487391fbd..9eab1f4c4ae6 100644 --- a/eclass/acct-user.eclass +++ b/eclass/acct-user.eclass @@ -231,8 +231,9 @@ acct-user_pkg_pretend() { [[ ${ACCT_USER_ID} -ge -1 ]] || die "Ebuild error: ACCT_USER_ID=${ACCT_USER_ID} invalid!" local user_id=${ACCT_USER_ID} - # check for the override - local override_name=${ACCT_USER_NAME^^} + # check for the override, use PN in case this is an overlay and + # ACCT_USER_NAME is not PN and not valid in a bash variable name + local override_name=${PN^^} local override_var=ACCT_USER_${override_name//-/_}_ID if [[ -n ${!override_var} ]]; then user_id=${!override_var} @@ -274,8 +275,9 @@ acct-user_src_install() { # serialize for override support local ACCT_USER_GROUPS=${ACCT_USER_GROUPS[*]} - # support make.conf overrides - local override_name=${ACCT_USER_NAME^^} + # support make.conf overrides, use PN in case this is an overlay and + # ACCT_USER_NAME is not PN and not valid in a bash variable name + local override_name=${PN^^} override_name=${override_name//-/_} local var for var in ACCT_USER_{ID,COMMENT,SHELL,HOME{,_OWNER,_PERMS},GROUPS}; do @@ -437,7 +439,7 @@ acct-user_pkg_postinst() { has "${g}" "${groups[@]}" || del_groups+="${del_groups:+, }${g}" done if [[ -n ${del_groups} ]]; then - local override_name=${ACCT_USER_NAME^^} + local override_name=${PN^^} override_name=${override_name//-/_} ewarn "Removing user ${ACCT_USER_NAME} from group(s): ${del_groups}" ewarn "To retain the user's group membership in the local system"