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>
_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
_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