Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 941977

Summary: sys-apps/portage: PORTAGE_USERNAME and PORTAGE_GRPNAME not defaulting to "portage"
Product: Portage Development Reporter: David Sardari <d>
Component: Core - ConfigurationAssignee: Portage team <dev-portage>
Status: RESOLVED FIXED    
Severity: normal CC: d, zmedico
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
See Also: https://github.com/gentoo/portage/pull/1390
https://github.com/gentoo/portage/pull/1414
https://github.com/gentoo/portage/pull/1416
Whiteboard:
Package list:
Runtime testing required: ---
Bug Depends on: 939444    
Bug Blocks: 941607    

Description David Sardari 2024-10-22 16:05:14 UTC
"man make.conf" states:

❯ man make.conf | sed -n -E '/PORTAGE_(USER|GRP)NAME/,/^$/p'
       PORTAGE_GRPNAME = [group]
              Defines the groupname to use when executing in userpriv/etc... modes (i.e.  non-root).
              Defaults to portage.

       PORTAGE_USERNAME = [user]
              Defines the username to use when executing in userpriv/etc... modes (i.e.  non-root).
              Defaults to portage.

Therefore, these two variables should be set in make.globals and perhaps in make.conf.example.
Comment 1 David Sardari 2024-10-22 16:16:11 UTC
This is relevant for:
https://github.com/gentoo/portage/pull/1390
Comment 2 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2025-01-10 16:44:07 UTC
Being documented as having a default value which *is* set on the python side doesn't necessarily mean it *must* be in make.globals/defaults. We may want to do that but it's important to be precise about the problem (and make an argument for it).
Comment 3 David Sardari 2025-01-10 17:03:40 UTC
It's been a while since I opened this bugs. IIRC, my reasoning was based upon:
https://github.com/gentoo/portage/blob/597229aff02810764223a4cdd1e8056142d70ed0/man/make.conf.5#L21-L31

If it's acceptable for PORTAGE_USERNAME and PORTAGE_GRPNAME to be defined outside of those places, it should be mentioned in that section of the make.conf manpage.

In general, I like to keep code and configuration separate.
Comment 4 Larry the Git Cow gentoo-dev 2025-01-11 18:56:26 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/proj/portage.git/commit/?id=5a652b1289830ccb0eb138ef0844a312d9531e0a

commit 5a652b1289830ccb0eb138ef0844a312d9531e0a
Author:     David Sardari <2036275+duxsco@users.noreply.github.com>
AuthorDate: 2025-01-11 13:45:40 +0000
Commit:     Zac Medico <zmedico@gentoo.org>
CommitDate: 2025-01-11 18:55:30 +0000

    make.globals: Set PORTAGE_USERNAME and PORTAGE_GRPNAME variables
    
    "man 5 make.conf" states that "PORTAGE_USERNAME" and "PORTAGE_GRPNAME" default to "portage":
    - https://github.com/gentoo/portage/blob/597229aff02810764223a4cdd1e8056142d70ed0/man/make.conf.5#L1257-L1261
    - https://github.com/gentoo/portage/blob/597229aff02810764223a4cdd1e8056142d70ed0/man/make.conf.5#L1109-L1113
    
    But, the two variables are not set in the files pointed out by "man 5 make.conf":
    https://github.com/gentoo/portage/blob/597229aff02810764223a4cdd1e8056142d70ed0/man/make.conf.5#L21-L31
    
    This commits solves the discrepancy.
    
    Bug: https://bugs.gentoo.org/941977
    Signed-off-by: David Sardari <d@duxsco.de>
    Closes: https://github.com/gentoo/portage/pull/1414
    Signed-off-by: Zac Medico <zmedico@gentoo.org>

 cnf/make.globals | 4 ++++
 1 file changed, 4 insertions(+)
Comment 5 Zac Medico gentoo-dev 2025-01-11 22:52:24 UTC
I've realized that this default change actually breaks PORTAGE_USERNAME and PORTAGE_GRPNAME setup for "unprivileged" mode. We should really set the defaults inside the config class, conditionally.
Comment 6 Zac Medico gentoo-dev 2025-01-11 23:13:26 UTC
Fixed to support unprivileged mode:

https://gitweb.gentoo.org/proj/portage.git/commit/?id=327848b1cb9dbcaea5a45f4e6cd83856ac07fb44
Author: Zac Medico <zmedico@gentoo.org>
Date:   2025-01-11 14:55:56 -0800

    config: Initialize default PORTAGE_USERNAME and PORTAGE_GRPNAME
    
    Intialize default PORTAGE_USERNAME and PORTAGE_GRPNAME for
    privileged mode.
    
    Signed-off-by: Zac Medico <zmedico@gentoo.org>