[PATCH] common/rc: use getent when available

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]



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@xxxxxxxxxx>
---

diff --git a/common/rc b/common/rc
index 6592c835..50312331 100644
--- a/common/rc
+++ b/common/rc
@@ -2621,7 +2621,11 @@ _yp_active()
 _cat_passwd()
 {
 	[ $(_yp_active) -eq 0 ] && ypcat passwd
-	cat /etc/passwd
+	if type getent &>/dev/null; then
+		getent passwd
+	else
+		cat /etc/passwd
+	fi
 }
 
 # cat the group file
@@ -2629,7 +2633,11 @@ _cat_passwd()
 _cat_group()
 {
 	[ $(_yp_active) -eq 0 ] && ypcat group
-	cat /etc/group
+	if type getent &>/dev/null; then
+		getent group
+	else
+		cat /etc/group
+	fi
 }
 
 # check if a user exists in the system





[Index of Archives]     [Linux Filesystems Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux