public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] [PATCH v2 0/4] acct-{user,group}.eclass: make user/group names writable
@ 2024-05-09 20:41 Michael Orlitzky
  2024-05-09 20:41 ` [gentoo-dev] [PATCH v2 1/4] acct-user.eclass: make ACCT_USER_NAME writable Michael Orlitzky
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Michael Orlitzky @ 2024-05-09 20:41 UTC (permalink / raw
  To: gentoo-dev

Support changing the user/group name of GLEP81 packages. This is
sometimes required in overlays because package naming restrictions
prohibit valid user/group names from being package names.

We drop "readonly" from the eclasses, and use PN instead of
ACCT_{USER,GROUP}_NAME to construct the make.conf overrides.

Changes in v2:

  - Two spaces after a period.
  - Use PN directly for override names

Michael Orlitzky (4):
  acct-user.eclass: make ACCT_USER_NAME writable
  acct-group.eclass: make ACCT_GROUP_NAME writable
  eclass/acct-user.eclass: use $PN to construct make.conf override vars
  eclass/acct-group.eclass: use $PN to construct make.conf override vars

 eclass/acct-group.eclass | 18 ++++++++++--------
 eclass/acct-user.eclass  | 22 ++++++++++++----------
 2 files changed, 22 insertions(+), 18 deletions(-)

-- 
2.43.2



^ permalink raw reply	[flat|nested] 6+ messages in thread

* [gentoo-dev] [PATCH v2 1/4] acct-user.eclass: make ACCT_USER_NAME writable
  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 ` Michael Orlitzky
  2024-05-09 20:41 ` [gentoo-dev] [PATCH v2 2/4] acct-group.eclass: make ACCT_GROUP_NAME writable Michael Orlitzky
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Michael Orlitzky @ 2024-05-09 20:41 UTC (permalink / raw
  To: gentoo-dev

The ACCT_USER_NAME variable is set to $PN by Gentoo policy. Prior to
this commit, it was also marked "readonly", preventing it from being
changed in an ebuild. In an overlay, and combined with the package
naming restrictions in the PMS, this has the unfortunate side effect of
prohibiting some otherwise-valid usernames. We drop the "readonly" to
allow those users to be managed (in overlays) using GLEP81 packages.

Signed-off-by: Michael Orlitzky <mjo@gentoo.org>
---
 eclass/acct-user.eclass | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/eclass/acct-user.eclass b/eclass/acct-user.eclass
index 66a4d6667888..765487391fbd 100644
--- a/eclass/acct-user.eclass
+++ b/eclass/acct-user.eclass
@@ -1,4 +1,4 @@
-# Copyright 2019-2023 Gentoo Authors
+# Copyright 2019-2024 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 # @ECLASS: acct-user.eclass
@@ -58,12 +58,12 @@ inherit user-info
 # << Eclass variables >>
 
 # @ECLASS_VARIABLE: ACCT_USER_NAME
-# @INTERNAL
 # @DESCRIPTION:
-# The name of the user.  This is forced to ${PN} and the policy prohibits
-# it from being changed.
+# The name of the user.  This is forced to ${PN} and the policy
+# prohibits it from being changed.  The variable is left writable for
+# use in overlays; package naming restrictions would prohibit some
+# otherwise-valid usernames.
 ACCT_USER_NAME=${PN}
-readonly ACCT_USER_NAME
 
 # @ECLASS_VARIABLE: ACCT_USER_ID
 # @REQUIRED
-- 
2.43.2



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [gentoo-dev] [PATCH v2 2/4] acct-group.eclass: make ACCT_GROUP_NAME writable
  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 ` Michael Orlitzky
  2024-05-09 20:41 ` [gentoo-dev] [PATCH v2 3/4] eclass/acct-user.eclass: use $PN to construct make.conf override vars Michael Orlitzky
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Michael Orlitzky @ 2024-05-09 20:41 UTC (permalink / raw
  To: gentoo-dev

The ACCT_GROUP_NAME variable is set to $PN by Gentoo policy. Prior to
this commit, it was also marked "readonly", preventing it from being
changed in an ebuild. In an overlay, and combined with the package
naming restrictions in the PMS, this has the unfortunate side effect of
prohibiting some otherwise-valid group names. We drop the "readonly" to
allow those groups to be managed (in overlays) using GLEP81 packages.

Signed-off-by: Michael Orlitzky <mjo@gentoo.org>
---
 eclass/acct-group.eclass | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/eclass/acct-group.eclass b/eclass/acct-group.eclass
index a0ad86066309..6dd6dc06a07e 100644
--- a/eclass/acct-group.eclass
+++ b/eclass/acct-group.eclass
@@ -1,4 +1,4 @@
-# Copyright 2019-2023 Gentoo Authors
+# Copyright 2019-2024 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 # @ECLASS: acct-group.eclass
@@ -50,12 +50,12 @@ inherit user-info
 # << Eclass variables >>
 
 # @ECLASS_VARIABLE: ACCT_GROUP_NAME
-# @INTERNAL
 # @DESCRIPTION:
 # The name of the group.  This is forced to ${PN} and the policy
-# prohibits it from being changed.
+# prohibits it from being changed.  The variable is left writable for
+# use in overlays; package naming restrictions would prohibit some
+# otherwise-valid group names.
 ACCT_GROUP_NAME=${PN}
-readonly ACCT_GROUP_NAME
 
 # @ECLASS_VARIABLE: ACCT_GROUP_ID
 # @REQUIRED
-- 
2.43.2



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [gentoo-dev] [PATCH v2 3/4] eclass/acct-user.eclass: use $PN to construct make.conf override vars
  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
  2024-05-09 20:41 ` [gentoo-dev] [PATCH v2 4/4] eclass/acct-group.eclass: " Michael Orlitzky
  2024-05-13 13:26 ` [gentoo-dev] [PATCH v2 0/4] acct-{user,group}.eclass: make user/group names writable Michael Orlitzky
  4 siblings, 0 replies; 6+ messages in thread
From: Michael Orlitzky @ 2024-05-09 20:41 UTC (permalink / raw
  To: gentoo-dev

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



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [gentoo-dev] [PATCH v2 4/4] eclass/acct-group.eclass: use $PN to construct make.conf override vars
  2024-05-09 20:41 [gentoo-dev] [PATCH v2 0/4] acct-{user,group}.eclass: make user/group names writable Michael Orlitzky
                   ` (2 preceding siblings ...)
  2024-05-09 20:41 ` [gentoo-dev] [PATCH v2 3/4] eclass/acct-user.eclass: use $PN to construct make.conf override vars Michael Orlitzky
@ 2024-05-09 20:41 ` Michael Orlitzky
  2024-05-13 13:26 ` [gentoo-dev] [PATCH v2 0/4] acct-{user,group}.eclass: make user/group names writable Michael Orlitzky
  4 siblings, 0 replies; 6+ messages in thread
From: Michael Orlitzky @ 2024-05-09 20:41 UTC (permalink / raw
  To: gentoo-dev

If (after upcasing and replacing hyphens by underscores) ACCT_GROUP_NAME
is set to something that isn't valid in a bash variable name, the eclass
will crash: it uses ACCT_GROUP_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_GROUP_NAME. In ::gentoo, the two
are equivalent, but in an overlay this allows weirder group names at the
expense of slightly mismatched variable names.

Signed-off-by: Michael Orlitzky <mjo@gentoo.org>
---
 eclass/acct-group.eclass | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/eclass/acct-group.eclass b/eclass/acct-group.eclass
index 6dd6dc06a07e..2c2c88cfc7e1 100644
--- a/eclass/acct-group.eclass
+++ b/eclass/acct-group.eclass
@@ -96,8 +96,9 @@ acct-group_pkg_pretend() {
 	[[ ${ACCT_GROUP_ID} -ge -1 ]] || die "Ebuild error: ACCT_GROUP_ID=${ACCT_GROUP_ID} invalid!"
 	local group_id=${ACCT_GROUP_ID}
 
-	# check for the override
-	local override_name=${ACCT_GROUP_NAME^^}
+	# check for the override, use PN in case this is an overlay and
+	# ACCT_GROUP_NAME is not PN and not valid in a bash variable name
+	local override_name=${PN^^}
 	local override_var=ACCT_GROUP_${override_name//-/_}_ID
 	if [[ -n ${!override_var} ]]; then
 		group_id=${!override_var}
@@ -132,8 +133,9 @@ acct-group_pkg_pretend() {
 acct-group_src_install() {
 	debug-print-function ${FUNCNAME} "${@}"
 
-	# check for the override
-	local override_name=${ACCT_GROUP_NAME^^}
+	# check for the override, use PN in case this is an overlay and
+	# ACCT_GROUP_NAME is not PN and not valid in a bash variable name
+	local override_name=${PN^^}
 	local override_var=ACCT_GROUP_${override_name//-/_}_ID
 	if [[ -n ${!override_var} ]]; then
 		ewarn "${override_var}=${!override_var} override in effect, support will not be provided."
-- 
2.43.2



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [gentoo-dev] [PATCH v2 0/4] acct-{user,group}.eclass: make user/group names writable
  2024-05-09 20:41 [gentoo-dev] [PATCH v2 0/4] acct-{user,group}.eclass: make user/group names writable Michael Orlitzky
                   ` (3 preceding siblings ...)
  2024-05-09 20:41 ` [gentoo-dev] [PATCH v2 4/4] eclass/acct-group.eclass: " Michael Orlitzky
@ 2024-05-13 13:26 ` Michael Orlitzky
  4 siblings, 0 replies; 6+ messages in thread
From: Michael Orlitzky @ 2024-05-13 13:26 UTC (permalink / raw
  To: gentoo-dev

On Thu, 2024-05-09 at 16:41 -0400, Michael Orlitzky wrote:
> Support changing the user/group name of GLEP81 packages. This is
> sometimes required in overlays because package naming restrictions
> prohibit valid user/group names from being package names.

Pushed.



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-05-13 13:26 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [gentoo-dev] [PATCH v2 3/4] eclass/acct-user.eclass: use $PN to construct make.conf override vars Michael Orlitzky
2024-05-09 20:41 ` [gentoo-dev] [PATCH v2 4/4] eclass/acct-group.eclass: " Michael Orlitzky
2024-05-13 13:26 ` [gentoo-dev] [PATCH v2 0/4] acct-{user,group}.eclass: make user/group names writable Michael Orlitzky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox