public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xfstests: include NIS databases
@ 2010-07-30 21:52 Alex Elder
  2010-08-01 14:15 ` Christoph Hellwig
  0 siblings, 1 reply; 2+ messages in thread
From: Alex Elder @ 2010-07-30 21:52 UTC (permalink / raw)
  To: xfs

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>

---
 093          |    2 +-
 common.attr  |    4 ++--
 common.quota |   12 ++++++------
 common.rc    |   28 +++++++++++++++++++++++++++-
 4 files changed, 36 insertions(+), 10 deletions(-)

Index: b/093
===================================================================
--- 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 <<EOF
 #!/bin/bash
Index: b/common.attr
===================================================================
--- a/common.attr
+++ b/common.attr
@@ -25,7 +25,7 @@
 #
 _acl_setup_ids()
 {
-    eval `cat /etc/passwd /etc/group | awk -F: '
+    eval `(_cat_passwd; _cat_group) | awk -F: '
       { ids[$3]=1 }
       END {
         j=1
@@ -93,7 +93,7 @@ _filter_aces()
     $AWK_PROG '
 	BEGIN {
 	    FS=":"
-	    while ( getline <"/etc/passwd" > 0 ) {
+	    while ( "_cat_passwd" | getline > 0 ) {
 		idlist[$1] = $3 
 	    }
 	}
Index: b/common.quota
===================================================================
--- 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()
Index: b/common.rc
===================================================================
--- 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."
 }
 

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] xfstests: include NIS databases
  2010-07-30 21:52 [PATCH] xfstests: include NIS databases Alex Elder
@ 2010-08-01 14:15 ` Christoph Hellwig
  0 siblings, 0 replies; 2+ messages in thread
From: Christoph Hellwig @ 2010-08-01 14:15 UTC (permalink / raw)
  To: Alex Elder; +Cc: xfs

On Fri, Jul 30, 2010 at 04:52:39PM -0500, Alex Elder wrote:
> 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>

Looks good,


Reviewed-by: Christoph Hellwig <hch@lst.de>

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-06-11  6:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-30 21:52 [PATCH] xfstests: include NIS databases Alex Elder
2010-08-01 14:15 ` Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox