user.eclass: Use egetent in eget{user,group}name
authorMichał Górny <mgorny@gentoo.org>
Tue, 30 Jul 2019 14:45:38 +0000 (16:45 +0200)
committerMike Gilbert <floppym@gentoo.org>
Tue, 13 Aug 2019 03:00:28 +0000 (23:00 -0400)
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

index a3cacb6d5f104f7f947ae624365939c0e4e8f709..f433d32bf7edfdcbb023363d443a6a570d33ac42 100644 (file)
@@ -358,7 +358,7 @@ enewgroup() {
 egetusername() {
        [[ $# -eq 1 ]] || die "usage: egetusername <uid>"
 
-       id -u -n "$1"
+       egetent passwd "$1" | cut -d: -f1
 }
 
 # @FUNCTION: egetgroupname
@@ -368,7 +368,7 @@ egetusername() {
 egetgroupname() {
        [[ $# -eq 1 ]] || die "usage: egetgroupname <gid>"
 
-       id -g -n "$1"
+       egetent group "$1" | cut -d: -f1
 }
 
 # @FUNCTION: egethome