* [gentoo-dev] [PATCH 1/4] acct-user.eclass: make ACCT_USER_NAME writable
2024-05-09 11:57 [gentoo-dev] [PATCH 0/4] acct-{user,group}.eclass: make user/group names writable Michael Orlitzky
@ 2024-05-09 11:57 ` Michael Orlitzky
2024-05-09 12:00 ` Michał Górny
2024-05-09 11:57 ` [gentoo-dev] [PATCH 2/4] acct-group.eclass: make ACCT_GROUP_NAME writable Michael Orlitzky
` (2 subsequent siblings)
3 siblings, 1 reply; 10+ messages in thread
From: Michael Orlitzky @ 2024-05-09 11:57 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 | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/eclass/acct-user.eclass b/eclass/acct-user.eclass
index 66a4d6667888..a4fe5e9f5e34 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,11 @@ 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.
+# 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] 10+ messages in thread
* Re: [gentoo-dev] [PATCH 1/4] acct-user.eclass: make ACCT_USER_NAME writable
2024-05-09 11:57 ` [gentoo-dev] [PATCH 1/4] acct-user.eclass: make ACCT_USER_NAME writable Michael Orlitzky
@ 2024-05-09 12:00 ` Michał Górny
2024-05-10 5:58 ` Ulrich Mueller
0 siblings, 1 reply; 10+ messages in thread
From: Michał Górny @ 2024-05-09 12:00 UTC (permalink / raw
To: gentoo-dev
[-- Attachment #1: Type: text/plain, Size: 1668 bytes --]
On Thu, 2024-05-09 at 07:57 -0400, Michael Orlitzky wrote:
> 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 | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/eclass/acct-user.eclass b/eclass/acct-user.eclass
> index 66a4d6667888..a4fe5e9f5e34 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,11 @@ 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.
> +# it from being changed. The variable is left writable for use in overlays;
> +# package naming restrictions would prohibit some otherwise-valid usernames.
You're not following the original style (double spaces).
> ACCT_USER_NAME=${PN}
> -readonly ACCT_USER_NAME
>
> # @ECLASS_VARIABLE: ACCT_USER_ID
> # @REQUIRED
--
Best regards,
Michał Górny
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 512 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* [gentoo-dev] [PATCH 2/4] acct-group.eclass: make ACCT_GROUP_NAME writable
2024-05-09 11:57 [gentoo-dev] [PATCH 0/4] acct-{user,group}.eclass: make user/group names writable Michael Orlitzky
2024-05-09 11:57 ` [gentoo-dev] [PATCH 1/4] acct-user.eclass: make ACCT_USER_NAME writable Michael Orlitzky
@ 2024-05-09 11:57 ` Michael Orlitzky
2024-05-09 11:57 ` [gentoo-dev] [PATCH 3/4] acct-user.eclass: use an eclass variable for the override variable name Michael Orlitzky
2024-05-09 11:57 ` [gentoo-dev] [PATCH 4/4] acct-group.eclass: " Michael Orlitzky
3 siblings, 0 replies; 10+ messages in thread
From: Michael Orlitzky @ 2024-05-09 11:57 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..305440116ecd 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] 10+ messages in thread
* [gentoo-dev] [PATCH 3/4] acct-user.eclass: use an eclass variable for the override variable name
2024-05-09 11:57 [gentoo-dev] [PATCH 0/4] acct-{user,group}.eclass: make user/group names writable Michael Orlitzky
2024-05-09 11:57 ` [gentoo-dev] [PATCH 1/4] acct-user.eclass: make ACCT_USER_NAME writable Michael Orlitzky
2024-05-09 11:57 ` [gentoo-dev] [PATCH 2/4] acct-group.eclass: make ACCT_GROUP_NAME writable Michael Orlitzky
@ 2024-05-09 11:57 ` Michael Orlitzky
2024-05-09 12:03 ` Michał Górny
2024-05-09 11:57 ` [gentoo-dev] [PATCH 4/4] acct-group.eclass: " Michael Orlitzky
3 siblings, 1 reply; 10+ messages in thread
From: Michael Orlitzky @ 2024-05-09 11:57 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 relocates the computation of the "override name" subsequent
to the definition of ACCT_USER_NAME="${PN}". In Gentoo, policy prohibits
redefinition of that variable; so nothing is changed. But in an overlay,
this allows the ebuild to define ACCT_USER_NAME to something that would
not be valid in a bash variable at the expense of violating expectations
about the override variable names.
Signed-off-by: Michael Orlitzky <mjo@gentoo.org>
---
eclass/acct-user.eclass | 32 ++++++++++++++++++++++----------
1 file changed, 22 insertions(+), 10 deletions(-)
diff --git a/eclass/acct-user.eclass b/eclass/acct-user.eclass
index a4fe5e9f5e34..fb3ccd2044da 100644
--- a/eclass/acct-user.eclass
+++ b/eclass/acct-user.eclass
@@ -64,6 +64,23 @@ inherit user-info
# package naming restrictions would prohibit some otherwise-valid usernames.
ACCT_USER_NAME=${PN}
+# @ECLASS_VARIABLE: _OVERRIDE_NAME
+# @INTERNAL
+# @DESCRIPTION:
+# A version of the user name suitable for use in a bash variable. This
+# is used to construct the names of the make.conf override variables and
+# it will always be uppercase $PN with the hyphens replaced by
+# underscores. It is defined once, here, so that in an overlay the
+# ebuild may set ACCT_USER_NAME to something other than $PN without
+# affecting the name of the override variable. This is necessary if the
+# username in question would lead to an invalid bash variable
+# name. Doing so does violate expectations with respect to the override
+# naming convention, but (a) your warranty is already void if you are
+# changing ACCT_USER_NAME or using make.conf overrides, and (b) you
+# shouldn't need make.conf overrides in an overlay.
+_OVERRIDE_NAME=${ACCT_USER_NAME^^}
+_OVERRIDE_NAME=${_OVERRIDE_NAME//-/_}
+
# @ECLASS_VARIABLE: ACCT_USER_ID
# @REQUIRED
# @DESCRIPTION:
@@ -231,8 +248,7 @@ acct-user_pkg_pretend() {
local user_id=${ACCT_USER_ID}
# check for the override
- local override_name=${ACCT_USER_NAME^^}
- local override_var=ACCT_USER_${override_name//-/_}_ID
+ local override_var=ACCT_USER_${_OVERRIDE_NAME}_ID
if [[ -n ${!override_var} ]]; then
user_id=${!override_var}
[[ ${user_id} -ge -1 ]] || die "${override_var}=${user_id} invalid!"
@@ -274,11 +290,9 @@ acct-user_src_install() {
local ACCT_USER_GROUPS=${ACCT_USER_GROUPS[*]}
# support make.conf overrides
- local override_name=${ACCT_USER_NAME^^}
- override_name=${override_name//-/_}
local var
for var in ACCT_USER_{ID,COMMENT,SHELL,HOME{,_OWNER,_PERMS},GROUPS}; do
- local var_name=ACCT_USER_${override_name}_${var#ACCT_USER_}
+ local var_name=ACCT_USER_${_OVERRIDE_NAME}_${var#ACCT_USER_}
if [[ -n ${!var_name} ]]; then
ewarn "${var_name}=${!var_name} override in effect, support will not be provided."
else
@@ -286,7 +300,7 @@ acct-user_src_install() {
fi
declare -g "_${var}=${!var_name}"
done
- var_name=ACCT_USER_${override_name}_GROUPS_ADD
+ var_name=ACCT_USER_${_OVERRIDE_NAME}_GROUPS_ADD
if [[ -n ${!var_name} ]]; then
ewarn "${var_name}=${!var_name} override in effect, support will not be provided."
_ACCT_USER_GROUPS+=" ${!var_name}"
@@ -436,12 +450,10 @@ acct-user_pkg_postinst() {
has "${g}" "${groups[@]}" || del_groups+="${del_groups:+, }${g}"
done
if [[ -n ${del_groups} ]]; then
- local override_name=${ACCT_USER_NAME^^}
- 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"
- ewarn "config, override with ACCT_USER_${override_name}_GROUPS or"
- ewarn "ACCT_USER_${override_name}_GROUPS_ADD in make.conf."
+ ewarn "config, override with ACCT_USER_${_OVERRIDE_NAME}_GROUPS or"
+ ewarn "ACCT_USER_${_OVERRIDE_NAME}_GROUPS_ADD in make.conf."
ewarn "Documentation reference:"
ewarn "https://wiki.gentoo.org/wiki/Practical_guide_to_the_GLEP_81_migration#Override_user_groups"
fi
--
2.43.2
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [gentoo-dev] [PATCH 3/4] acct-user.eclass: use an eclass variable for the override variable name
2024-05-09 11:57 ` [gentoo-dev] [PATCH 3/4] acct-user.eclass: use an eclass variable for the override variable name Michael Orlitzky
@ 2024-05-09 12:03 ` Michał Górny
2024-05-09 12:12 ` Michael Orlitzky
0 siblings, 1 reply; 10+ messages in thread
From: Michał Górny @ 2024-05-09 12:03 UTC (permalink / raw
To: gentoo-dev
[-- Attachment #1: Type: text/plain, Size: 4686 bytes --]
On Thu, 2024-05-09 at 07:57 -0400, Michael Orlitzky wrote:
> 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 relocates the computation of the "override name" subsequent
> to the definition of ACCT_USER_NAME="${PN}". In Gentoo, policy prohibits
> redefinition of that variable; so nothing is changed. But in an overlay,
> this allows the ebuild to define ACCT_USER_NAME to something that would
> not be valid in a bash variable at the expense of violating expectations
> about the override variable names.
>
> Signed-off-by: Michael Orlitzky <mjo@gentoo.org>
> ---
> eclass/acct-user.eclass | 32 ++++++++++++++++++++++----------
> 1 file changed, 22 insertions(+), 10 deletions(-)
>
> diff --git a/eclass/acct-user.eclass b/eclass/acct-user.eclass
> index a4fe5e9f5e34..fb3ccd2044da 100644
> --- a/eclass/acct-user.eclass
> +++ b/eclass/acct-user.eclass
> @@ -64,6 +64,23 @@ inherit user-info
> # package naming restrictions would prohibit some otherwise-valid usernames.
> ACCT_USER_NAME=${PN}
>
> +# @ECLASS_VARIABLE: _OVERRIDE_NAME
This is not prefixed correctly.
> +# @INTERNAL
> +# @DESCRIPTION:
> +# A version of the user name suitable for use in a bash variable. This
> +# is used to construct the names of the make.conf override variables and
> +# it will always be uppercase $PN with the hyphens replaced by
> +# underscores. It is defined once, here, so that in an overlay the
> +# ebuild may set ACCT_USER_NAME to something other than $PN without
> +# affecting the name of the override variable. This is necessary if the
> +# username in question would lead to an invalid bash variable
> +# name. Doing so does violate expectations with respect to the override
> +# naming convention, but (a) your warranty is already void if you are
> +# changing ACCT_USER_NAME or using make.conf overrides, and (b) you
> +# shouldn't need make.conf overrides in an overlay.
> +_OVERRIDE_NAME=${ACCT_USER_NAME^^}
> +_OVERRIDE_NAME=${_OVERRIDE_NAME//-/_}
Any reason not to just use PN directly below? After all, you need to
sanitize it anyway.
> +
> # @ECLASS_VARIABLE: ACCT_USER_ID
> # @REQUIRED
> # @DESCRIPTION:
> @@ -231,8 +248,7 @@ acct-user_pkg_pretend() {
> local user_id=${ACCT_USER_ID}
>
> # check for the override
> - local override_name=${ACCT_USER_NAME^^}
> - local override_var=ACCT_USER_${override_name//-/_}_ID
> + local override_var=ACCT_USER_${_OVERRIDE_NAME}_ID
> if [[ -n ${!override_var} ]]; then
> user_id=${!override_var}
> [[ ${user_id} -ge -1 ]] || die "${override_var}=${user_id} invalid!"
> @@ -274,11 +290,9 @@ acct-user_src_install() {
> local ACCT_USER_GROUPS=${ACCT_USER_GROUPS[*]}
>
> # support make.conf overrides
> - local override_name=${ACCT_USER_NAME^^}
> - override_name=${override_name//-/_}
> local var
> for var in ACCT_USER_{ID,COMMENT,SHELL,HOME{,_OWNER,_PERMS},GROUPS}; do
> - local var_name=ACCT_USER_${override_name}_${var#ACCT_USER_}
> + local var_name=ACCT_USER_${_OVERRIDE_NAME}_${var#ACCT_USER_}
> if [[ -n ${!var_name} ]]; then
> ewarn "${var_name}=${!var_name} override in effect, support will not be provided."
> else
> @@ -286,7 +300,7 @@ acct-user_src_install() {
> fi
> declare -g "_${var}=${!var_name}"
> done
> - var_name=ACCT_USER_${override_name}_GROUPS_ADD
> + var_name=ACCT_USER_${_OVERRIDE_NAME}_GROUPS_ADD
> if [[ -n ${!var_name} ]]; then
> ewarn "${var_name}=${!var_name} override in effect, support will not be provided."
> _ACCT_USER_GROUPS+=" ${!var_name}"
> @@ -436,12 +450,10 @@ acct-user_pkg_postinst() {
> has "${g}" "${groups[@]}" || del_groups+="${del_groups:+, }${g}"
> done
> if [[ -n ${del_groups} ]]; then
> - local override_name=${ACCT_USER_NAME^^}
> - 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"
> - ewarn "config, override with ACCT_USER_${override_name}_GROUPS or"
> - ewarn "ACCT_USER_${override_name}_GROUPS_ADD in make.conf."
> + ewarn "config, override with ACCT_USER_${_OVERRIDE_NAME}_GROUPS or"
> + ewarn "ACCT_USER_${_OVERRIDE_NAME}_GROUPS_ADD in make.conf."
> ewarn "Documentation reference:"
> ewarn "https://wiki.gentoo.org/wiki/Practical_guide_to_the_GLEP_81_migration#Override_user_groups"
> fi
--
Best regards,
Michał Górny
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 512 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [gentoo-dev] [PATCH 3/4] acct-user.eclass: use an eclass variable for the override variable name
2024-05-09 12:03 ` Michał Górny
@ 2024-05-09 12:12 ` Michael Orlitzky
2024-05-09 12:41 ` Michał Górny
0 siblings, 1 reply; 10+ messages in thread
From: Michael Orlitzky @ 2024-05-09 12:12 UTC (permalink / raw
To: gentoo-dev
On Thu, 2024-05-09 at 14:03 +0200, Michał Górny wrote:
> > @ECLASS_VARIABLE: _OVERRIDE_NAME
>
> This is not prefixed correctly.
>
ACCT_USER_OVERRIDE_NAME has an entirely different meaning, but I could
use _ACCT_USER_OVERRIDE_NAME if that's what you're suggesting.
> > +# @INTERNAL
> > +# @DESCRIPTION:
> > +# A version of the user name suitable for use in a bash variable. This
> > +# is used to construct the names of the make.conf override variables and
> > +# it will always be uppercase $PN with the hyphens replaced by
> > +# underscores. It is defined once, here, so that in an overlay the
> > +# ebuild may set ACCT_USER_NAME to something other than $PN without
> > +# affecting the name of the override variable. This is necessary if the
> > +# username in question would lead to an invalid bash variable
> > +# name. Doing so does violate expectations with respect to the override
> > +# naming convention, but (a) your warranty is already void if you are
> > +# changing ACCT_USER_NAME or using make.conf overrides, and (b) you
> > +# shouldn't need make.conf overrides in an overlay.
> > +_OVERRIDE_NAME=${ACCT_USER_NAME^^}
> > +_OVERRIDE_NAME=${_OVERRIDE_NAME//-/_}
>
> Any reason not to just use PN directly below? After all, you need to
> sanitize it anyway.
>
I started out with that, but I had to copy & paste the same comment
explaining why it uses $PN to each site. Then I had the idea to factor
it out. I don't really care though if you think it's preferable.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [gentoo-dev] [PATCH 3/4] acct-user.eclass: use an eclass variable for the override variable name
2024-05-09 12:12 ` Michael Orlitzky
@ 2024-05-09 12:41 ` Michał Górny
0 siblings, 0 replies; 10+ messages in thread
From: Michał Górny @ 2024-05-09 12:41 UTC (permalink / raw
To: gentoo-dev
[-- Attachment #1: Type: text/plain, Size: 1825 bytes --]
On Thu, 2024-05-09 at 08:12 -0400, Michael Orlitzky wrote:
> On Thu, 2024-05-09 at 14:03 +0200, Michał Górny wrote:
> > > @ECLASS_VARIABLE: _OVERRIDE_NAME
> >
> > This is not prefixed correctly.
> >
>
> ACCT_USER_OVERRIDE_NAME has an entirely different meaning, but I could
> use _ACCT_USER_OVERRIDE_NAME if that's what you're suggesting.
>
>
> > > +# @INTERNAL
> > > +# @DESCRIPTION:
> > > +# A version of the user name suitable for use in a bash variable. This
> > > +# is used to construct the names of the make.conf override variables and
> > > +# it will always be uppercase $PN with the hyphens replaced by
> > > +# underscores. It is defined once, here, so that in an overlay the
> > > +# ebuild may set ACCT_USER_NAME to something other than $PN without
> > > +# affecting the name of the override variable. This is necessary if the
> > > +# username in question would lead to an invalid bash variable
> > > +# name. Doing so does violate expectations with respect to the override
> > > +# naming convention, but (a) your warranty is already void if you are
> > > +# changing ACCT_USER_NAME or using make.conf overrides, and (b) you
> > > +# shouldn't need make.conf overrides in an overlay.
> > > +_OVERRIDE_NAME=${ACCT_USER_NAME^^}
> > > +_OVERRIDE_NAME=${_OVERRIDE_NAME//-/_}
> >
> > Any reason not to just use PN directly below? After all, you need to
> > sanitize it anyway.
> >
>
> I started out with that, but I had to copy & paste the same comment
> explaining why it uses $PN to each site. Then I had the idea to factor
> it out. I don't really care though if you think it's preferable.
>
I think it will be less confusing than trying to explain what
_ACCT_USER_OVERRIDE_NAME is, and that it doesn't oveerride name.
--
Best regards,
Michał Górny
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 512 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* [gentoo-dev] [PATCH 4/4] acct-group.eclass: use an eclass variable for the override variable name
2024-05-09 11:57 [gentoo-dev] [PATCH 0/4] acct-{user,group}.eclass: make user/group names writable Michael Orlitzky
` (2 preceding siblings ...)
2024-05-09 11:57 ` [gentoo-dev] [PATCH 3/4] acct-user.eclass: use an eclass variable for the override variable name Michael Orlitzky
@ 2024-05-09 11:57 ` Michael Orlitzky
3 siblings, 0 replies; 10+ messages in thread
From: Michael Orlitzky @ 2024-05-09 11:57 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 relocates the computation of the "override name" subsequent
to the definition of ACCT_GROUP_NAME="${PN}". In Gentoo, policy prohibits
redefinition of that variable; so nothing is changed. But in an overlay,
this allows the ebuild to define ACCT_GROUP_NAME to something that would
not be valid in a bash variable at the expense of violating expectations
about the override variable names.
Signed-off-by: Michael Orlitzky <mjo@gentoo.org>
---
eclass/acct-group.eclass | 23 +++++++++++++++++++----
1 file changed, 19 insertions(+), 4 deletions(-)
diff --git a/eclass/acct-group.eclass b/eclass/acct-group.eclass
index 305440116ecd..69b262fb49cf 100644
--- a/eclass/acct-group.eclass
+++ b/eclass/acct-group.eclass
@@ -57,6 +57,23 @@ inherit user-info
# otherwise-valid group names.
ACCT_GROUP_NAME=${PN}
+# @ECLASS_VARIABLE: _OVERRIDE_NAME
+# @INTERNAL
+# @DESCRIPTION:
+# A version of the group name suitable for use in a bash variable. This
+# is used to construct the names of the make.conf override variables and
+# it will always be uppercase $PN with the hyphens replaced by
+# underscores. It is defined once, here, so that in an overlay the
+# ebuild may set ACCT_GROUP_NAME to something other than $PN without
+# affecting the name of the override variable. This is necessary if the
+# group name in question would lead to an invalid bash variable
+# name. Doing so does violate expectations with respect to the override
+# naming convention, but (a) your warranty is already void if you are
+# changing ACCT_GROUP_NAME or using make.conf overrides, and (b) you
+# shouldn't need make.conf overrides in an overlay.
+_OVERRIDE_NAME=${ACCT_GROUP_NAME^^}
+_OVERRIDE_NAME=${_OVERRIDE_NAME//-/_}
+
# @ECLASS_VARIABLE: ACCT_GROUP_ID
# @REQUIRED
# @DESCRIPTION:
@@ -97,8 +114,7 @@ acct-group_pkg_pretend() {
local group_id=${ACCT_GROUP_ID}
# check for the override
- local override_name=${ACCT_GROUP_NAME^^}
- local override_var=ACCT_GROUP_${override_name//-/_}_ID
+ local override_var=ACCT_GROUP_${_OVERRIDE_NAME}_ID
if [[ -n ${!override_var} ]]; then
group_id=${!override_var}
[[ ${group_id} -ge -1 ]] || die "${override_var}=${group_id} invalid!"
@@ -133,8 +149,7 @@ acct-group_src_install() {
debug-print-function ${FUNCNAME} "${@}"
# check for the override
- local override_name=${ACCT_GROUP_NAME^^}
- local override_var=ACCT_GROUP_${override_name//-/_}_ID
+ 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."
_ACCT_GROUP_ID=${!override_var}
--
2.43.2
^ permalink raw reply related [flat|nested] 10+ messages in thread