From: Alex Elder Date: Fri, 30 Jul 2010 21:52:39 +0000 (+0000) Subject: xfstests: include NIS databases X-Git-Tag: v1.1.0~153 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=cda0cb20ac45c7048592aa277d2b6bc1b3a7e7ef;p=xfstests-dev.git xfstests: include NIS databases If NIS is active on a test target system, additional password and group file information is available via their respective databases in NIS. Currently, some tests assume that /etc/passwd and /etc/group are the only places to find this information. This patch causes both the local database and the NIS database (if one is likely to be present) to be consulted for needed information. Signed-off-by: Alex Elder Reviewed-by: Christoph Hellwig --- diff --git a/093 b/093 index 5babfb34..4f14d86a 100755 --- a/093 +++ b/093 @@ -72,7 +72,7 @@ echo "" file=$testdir/$seq.file user=`grep ':all=:all=' /etc/capability | tail -1 | $AWK_PROG -F: '{print $1}'` -uid=`grep $user /etc/passwd | $AWK_PROG -F: '{print $3}'` +uid=`_cat_passwd | grep $user | $AWK_PROG -F: '{print $3}'` cat >$tmp.append < 0 ) { + while ( "_cat_passwd" | getline > 0 ) { idlist[$1] = $3 } } diff --git a/common.quota b/common.quota index 655e34d1..efb3ef9c 100644 --- a/common.quota +++ b/common.quota @@ -59,11 +59,11 @@ _require_prjquota() # _require_nobody() { - grep -q '^nobody' /etc/passwd - [ $? -ne 0 ] && _notrun "/etc/passwd does not contain user nobody." + _cat_passwd | grep -q '^nobody' + [ $? -ne 0 ] && _notrun "password file does not contain user nobody." - egrep -q '^no(body|group)' /etc/group - [ $? -ne 0 ] && _notrun "/etc/group does not contain nobody/nogroup." + _cat_group | egrep -q '^no(body|group)' + [ $? -ne 0 ] && _notrun "group file does not contain nobody/nogroup." } # create a file as a specific user (uid) @@ -108,12 +108,12 @@ EOF _choose_uid() { - grep '^nobody' /etc/passwd | perl -ne '@a = split(/:/); END { printf "id=%d name=%s\n", $a[2],$a[0] }' + _cat_passwd | grep '^nobody' | perl -ne '@a = split(/:/); END { printf "id=%d name=%s\n", $a[2],$a[0] }' } _choose_gid() { - egrep '^no(body|group)' /etc/group | perl -ne '@a = split(/:/); END { printf "id=%d name=%s\n", $a[2],$a[0] }' + _cat_group | egrep '^no(body|group)' | perl -ne '@a = split(/:/); END { printf "id=%d name=%s\n", $a[2],$a[0] }' } _choose_prid() diff --git a/common.rc b/common.rc index 72997f9c..e0cdfe65 100644 --- a/common.rc +++ b/common.rc @@ -793,12 +793,38 @@ _require_nonexternal() _notrun "External device testing in progress, skipped this test" } +# indicate whether YP/NIS is active or not +# +_yp_active() +{ + local dn + dn=$(domainname 2>/dev/null) + test -n "${dn}" -a "${dn}" != "(none)" +} + +# cat the password file +# +_cat_passwd() +{ + [ _yp_active ] && ypcat passwd + cat /etc/passwd +} + +# cat the group file +# +_cat_group() +{ + [ _yp_active ] && ypcat group + cat /etc/group +} +export -f _yp_active _cat_passwd _cat_group + # check for the fsgqa user on the machine # _require_user() { qa_user=fsgqa - cat /etc/passwd | grep -q $qa_user + _cat_passwd | grep -q $qa_user [ "$?" == "0" ] || _notrun "$qa_user user not defined." }