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 <aelder@sgi.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
This commit is contained in:
Alex Elder
2010-07-30 21:52:39 +00:00
parent b05ae2d653
commit cda0cb20ac
4 changed files with 36 additions and 10 deletions
+1 -1
View File
@@ -72,7 +72,7 @@ echo ""
file=$testdir/$seq.file file=$testdir/$seq.file
user=`grep ':all=:all=' /etc/capability | tail -1 | $AWK_PROG -F: '{print $1}'` 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 <<EOF cat >$tmp.append <<EOF
#!/bin/bash #!/bin/bash
+2 -2
View File
@@ -25,7 +25,7 @@
# #
_acl_setup_ids() _acl_setup_ids()
{ {
eval `cat /etc/passwd /etc/group | awk -F: ' eval `(_cat_passwd; _cat_group) | awk -F: '
{ ids[$3]=1 } { ids[$3]=1 }
END { END {
j=1 j=1
@@ -93,7 +93,7 @@ _filter_aces()
$AWK_PROG ' $AWK_PROG '
BEGIN { BEGIN {
FS=":" FS=":"
while ( getline <"/etc/passwd" > 0 ) { while ( "_cat_passwd" | getline > 0 ) {
idlist[$1] = $3 idlist[$1] = $3
} }
} }
+6 -6
View File
@@ -59,11 +59,11 @@ _require_prjquota()
# #
_require_nobody() _require_nobody()
{ {
grep -q '^nobody' /etc/passwd _cat_passwd | grep -q '^nobody'
[ $? -ne 0 ] && _notrun "/etc/passwd does not contain user nobody." [ $? -ne 0 ] && _notrun "password file does not contain user nobody."
egrep -q '^no(body|group)' /etc/group _cat_group | egrep -q '^no(body|group)'
[ $? -ne 0 ] && _notrun "/etc/group does not contain nobody/nogroup." [ $? -ne 0 ] && _notrun "group file does not contain nobody/nogroup."
} }
# create a file as a specific user (uid) # create a file as a specific user (uid)
@@ -108,12 +108,12 @@ EOF
_choose_uid() _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() _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() _choose_prid()
+27 -1
View File
@@ -793,12 +793,38 @@ _require_nonexternal()
_notrun "External device testing in progress, skipped this test" _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 # check for the fsgqa user on the machine
# #
_require_user() _require_user()
{ {
qa_user=fsgqa qa_user=fsgqa
cat /etc/passwd | grep -q $qa_user _cat_passwd | grep -q $qa_user
[ "$?" == "0" ] || _notrun "$qa_user user not defined." [ "$?" == "0" ] || _notrun "$qa_user user not defined."
} }