From: Eric Sandeen Date: Mon, 10 Mar 2025 17:55:51 +0000 (-0500) Subject: common/rc: use getent when available X-Git-Tag: v2025.03.17~7 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=63347f3f52078868e5be79258584309da320f365;p=xfstests-dev.git common/rc: use getent when available 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 Reviewed-by: Zorro Lang Reviewed-by: Darrick J. Wong Signed-off-by: Zorro Lang --- diff --git a/common/rc b/common/rc index ca755055..dcdfa86e 100644 --- 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