Whamcloud - gitweb
LU-7859 tests: Use getent instead of /etc/passwd 46/18846/4
authorNathaniel Clark <nathaniel.l.clark@intel.com>
Wed, 9 Mar 2016 22:14:15 +0000 (17:14 -0500)
committerOleg Drokin <oleg.drokin@intel.com>
Mon, 2 May 2016 23:59:02 +0000 (23:59 +0000)
Use getent passwd instead of directly reading form /etc/passwd
to prevent missing user checks if users come from ldap or another
auth source that isn't /etc/passwd.

Signed-off-by: Nathaniel Clark <nathaniel.l.clark@intel.com>
Change-Id: Ia2831c777c7c3f8bae5a634fa897744954d14c1e
Reviewed-on: http://review.whamcloud.com/18846
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: James Simmons <uja.ornl@yahoo.com>
Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/tests/conf-sanity.sh
lustre/tests/sanity-sec.sh

index 7254a2f..221f2ac 100755 (executable)
@@ -2992,7 +2992,7 @@ test_43a() {
        [ $UID -ne 0 -o $RUNAS_ID -eq 0 ] && skip_env "run as root"
 
        ID1=${ID1:-501}
-       USER1=$(cat /etc/passwd | grep :$ID1:$ID1: | cut -d: -f1)
+       USER1=$(getent passwd | grep :$ID1:$ID1: | cut -d: -f1)
        [ -z "$USER1" ] && skip_env "missing user with uid=$ID1 gid=$ID1" &&
                return
 
index 9f303c2..7fc381d 100755 (executable)
@@ -50,14 +50,14 @@ clients_arr=($clients)
 
 ID0=${ID0:-500}
 ID1=${ID1:-501}
-USER0=$(grep :$ID0:$ID0: /etc/passwd | cut -d: -f1)
-USER1=$(grep :$ID1:$ID1: /etc/passwd | cut -d: -f1)
+USER0=$(getent passwd | grep :$ID0:$ID0: | cut -d: -f1)
+USER1=$(getent passwd | grep :$ID1:$ID1: | cut -d: -f1)
 
 [ -z "$USER0" ] &&
-       skip "need to add user0 ($ID0:$ID0) to /etc/passwd" && exit 0
+       skip "need to add user0 ($ID0:$ID0)" && exit 0
 
 [ -z "$USER1" ] &&
-       skip "need to add user1 ($ID1:$ID1) to /etc/passwd" && exit 0
+       skip "need to add user1 ($ID1:$ID1)" && exit 0
 
 IDBASE=${IDBASE:-60000}