Gentoo Archives: gentoo-dev

From: "Michał Górny" <mgorny@g.o>
To: gentoo-dev@l.g.o
Cc: "Michał Górny" <mgorny@g.o>
Subject: [gentoo-dev] [PATCH] user.eclass: Use egetent in eget{user,group}name
Date: Tue, 30 Jul 2019 14:45:50
Message-Id: 20190730144538.21047-1-mgorny@gentoo.org
1 Use egetent+cut to obtain user/group names rather than id(1).
2 The latter has no real advantage (besides being shorter to type),
3 and does not work correctly for getting groups.
4
5 Closes: https://bugs.gentoo.org/691056
6 Signed-off-by: Michał Górny <mgorny@g.o>
7 ---
8 eclass/user.eclass | 4 ++--
9 1 file changed, 2 insertions(+), 2 deletions(-)
10
11 diff --git a/eclass/user.eclass b/eclass/user.eclass
12 index a3cacb6d5f10..f433d32bf7ed 100644
13 --- a/eclass/user.eclass
14 +++ b/eclass/user.eclass
15 @@ -358,7 +358,7 @@ enewgroup() {
16 egetusername() {
17 [[ $# -eq 1 ]] || die "usage: egetusername <uid>"
18
19 - id -u -n "$1"
20 + egetent passwd "$1" | cut -d: -f1
21 }
22
23 # @FUNCTION: egetgroupname
24 @@ -368,7 +368,7 @@ egetusername() {
25 egetgroupname() {
26 [[ $# -eq 1 ]] || die "usage: egetgroupname <gid>"
27
28 - id -g -n "$1"
29 + egetent group "$1" | cut -d: -f1
30 }
31
32 # @FUNCTION: egethome
33 --
34 2.22.0

Replies