Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 691056 - user.eclass: egetgroupname() is broken
Summary: user.eclass: egetgroupname() is broken
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Eclasses (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Michał Górny
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-07-30 14:06 UTC by Alexander Tsoy
Modified: 2019-08-13 03:00 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Possible fix (acct-group.eclass.patch,525 bytes, text/plain)
2019-07-30 14:17 UTC, Alexander Tsoy
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander Tsoy 2019-07-30 14:06:34 UTC
egetgroupname() accepts USER ID and returns its primary GID. As a result if I set ACCT_GROUP_ENFORCE_ID variable, I get a lot of pkg_pretend failures.


Example 1: the group doesn't have a corresponding user:

$ getent group 190
systemd-journal:x:190:
$ id -g -n 190
id: '190': no such user

>>> Running pre-merge checks for acct-group/systemd-journal-0
id: ‘190’: no such user          
 * The requested group exists already with wrong GID.
 *   groupname: systemd-journal  
 *   requested GID: 190
 *   current entry: systemd-journal:x:190:
 * ERROR: acct-group/systemd-journal-0::gentoo failed (pretend phase):
 *   Group systemd-journal exists with wrong GID
 *
 * Call stack:
 *           ebuild.sh, line 125:  Called pkg_pretend
 *           ebuild.sh, line 370:  Called acct-group_pkg_pretend
 *   acct-group.eclass, line 109:  Called die
 * The specific snippet of code:
 *                      die "Group ${ACCT_GROUP_NAME} exists with wrong GID"
 *
 * If you need support, post the output of `emerge --info '=acct-group/systemd-journal-0::gentoo'`,
 * the complete build log and the output of `emerge -pqv '=acct-group/systemd-journal-0::gentoo'`.
 * The complete build log is located at '/var/log/portage/build/acct-group/systemd-journal-0:20190730-131723.log.gz'.
 * For convenience, a symlink to the build log is located at '/var/tmp/portage/acct-group/systemd-journal-0/temp/build.log.gz'.
 * The ebuild environment file is located at '/var/tmp/portage/acct-group/systemd-journal-0/temp/die.env'.
 * Working directory: '/var/tmp/portage/acct-group/systemd-journal-0/homedir'
 * S: '/var/tmp/portage/acct-group/systemd-journal-0/work'


Example 2: GID is equal to the UID of some user.

$ getent group 4
adm:x:4:root,adm,daemon
$ id -g -n 4
lp

>>> Running pre-merge checks for acct-group/adm-0                                                                                                                                                                                            
 * The required GID is already taken by another group.                                                                                                                                                                                       
 *   GID: 4                                                                                                                                                                                                                                  
 *   needed for: adm
 *   current group: lp
 * ERROR: acct-group/adm-0::gentoo failed (pretend phase):
 *   GID 4 taken already
 *
 * Call stack:
 *           ebuild.sh, line 125:  Called pkg_pretend
 *           ebuild.sh, line 370:  Called acct-group_pkg_pretend
 *   acct-group.eclass, line 102:  Called die
 * The specific snippet of code:
 *                              die "GID ${ACCT_GROUP_ID} taken already"
 *
 * If you need support, post the output of `emerge --info '=acct-group/adm-0::gentoo'`,
 * the complete build log and the output of `emerge -pqv '=acct-group/adm-0::gentoo'`.
 * The complete build log is located at '/var/log/portage/build/acct-group/adm-0:20190730-131716.log.gz'.
 * For convenience, a symlink to the build log is located at '/var/tmp/portage/acct-group/adm-0/temp/build.log.gz'.
 * The ebuild environment file is located at '/var/tmp/portage/acct-group/adm-0/temp/die.env'.
 * Working directory: '/var/tmp/portage/acct-group/adm-0/homedir'
 * S: '/var/tmp/portage/acct-group/adm-0/work'
Comment 1 Alexander Tsoy 2019-07-30 14:17:50 UTC
Created attachment 585116 [details]
Possible fix
Comment 2 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2019-07-30 14:35:34 UTC
It's egetgroupname working incorrectly.
Comment 3 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2019-07-30 14:46:03 UTC
Patch sent to -dev.
Comment 4 Larry the Git Cow gentoo-dev 2019-08-13 03:00:50 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=e51c5cfae41952f32a75c9e680785f4c1242f9b7

commit e51c5cfae41952f32a75c9e680785f4c1242f9b7
Author:     Michał Górny <mgorny@gentoo.org>
AuthorDate: 2019-07-30 14:45:38 +0000
Commit:     Mike Gilbert <floppym@gentoo.org>
CommitDate: 2019-08-13 03:00:28 +0000

    user.eclass: Use egetent in eget{user,group}name
    
    Use egetent+cut to obtain user/group names rather than id(1).
    The latter has no real advantage (besides being shorter to type),
    and does not work correctly for getting groups.
    
    Closes: https://bugs.gentoo.org/691056
    Signed-off-by: Michał Górny <mgorny@gentoo.org>
    Signed-off-by: Mike Gilbert <floppym@gentoo.org>

 eclass/user.eclass | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)