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>
[ $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
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}