]> git-server-git.apps.pok.os.sepia.ceph.com Git - xfstests-dev.git/commitdiff
common/rc: use getent when available
authorEric Sandeen <sandeen@redhat.com>
Mon, 10 Mar 2025 17:55:51 +0000 (12:55 -0500)
committerZorro Lang <zlang@kernel.org>
Tue, 11 Mar 2025 19:53:34 +0000 (03:53 +0800)
Zorro noticed that on systems using nss-altfiles, some tests failed when
trying to parse /etc/passwd directly. The "getent" command does the
right thing in this case, so let's use it as long as it's available.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Zorro Lang <zlang@kernel.org>
common/rc

index ca7550557dce64a2cdce5c2a8ae4cd85f282fe11..dcdfa86e43b119d62a707eea4073a47ae89e588a 100644 (file)
--- a/common/rc
+++ b/common/rc
@@ -2764,7 +2764,11 @@ _yp_active()
 _cat_passwd()
 {
        [ $(_yp_active) -eq 0 ] && ypcat passwd
-       cat /etc/passwd
+       if command -v getent &>/dev/null; then
+               getent passwd
+       else
+               cat /etc/passwd
+       fi
 }
 
 # cat the group file
@@ -2772,7 +2776,11 @@ _cat_passwd()
 _cat_group()
 {
        [ $(_yp_active) -eq 0 ] && ypcat group
-       cat /etc/group
+       if command -v getent &>/dev/null; then
+               getent group
+       else
+               cat /etc/group
+       fi
 }
 
 # check if a user exists in the system