public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
From: Michael Orlitzky <mjo@gentoo.org>
To: gentoo-dev@lists.gentoo.org
Subject: [gentoo-dev] [PATCH v2 3/4] eclass/acct-user.eclass: use $PN to construct make.conf override vars
Date: Thu,  9 May 2024 16:41:58 -0400	[thread overview]
Message-ID: <20240509204159.18123-4-mjo@gentoo.org> (raw)
In-Reply-To: <20240509204159.18123-1-mjo@gentoo.org>

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 <mjo@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"
-- 
2.43.2



  parent reply	other threads:[~2024-05-09 20:43 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-09 20:41 [gentoo-dev] [PATCH v2 0/4] acct-{user,group}.eclass: make user/group names writable Michael Orlitzky
2024-05-09 20:41 ` [gentoo-dev] [PATCH v2 1/4] acct-user.eclass: make ACCT_USER_NAME writable Michael Orlitzky
2024-05-09 20:41 ` [gentoo-dev] [PATCH v2 2/4] acct-group.eclass: make ACCT_GROUP_NAME writable Michael Orlitzky
2024-05-09 20:41 ` Michael Orlitzky [this message]
2024-05-09 20:41 ` [gentoo-dev] [PATCH v2 4/4] eclass/acct-group.eclass: use $PN to construct make.conf override vars Michael Orlitzky
2024-05-13 13:26 ` [gentoo-dev] [PATCH v2 0/4] acct-{user,group}.eclass: make user/group names writable Michael Orlitzky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240509204159.18123-4-mjo@gentoo.org \
    --to=mjo@gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox