Whamcloud - gitweb
LU-4703 tests: Add test to check setxattr fails when it should 08/9508/5
authorNathaniel Clark <nathaniel.l.clark@intel.com>
Wed, 5 Mar 2014 17:36:52 +0000 (12:36 -0500)
committerOleg Drokin <oleg.drokin@intel.com>
Wed, 12 Mar 2014 15:06:40 +0000 (15:06 +0000)
Setxattr was not correctly checking permissions in all cases. This
adds a test to sanity to ensure that trying to set xattrs on a file
fails when it should.

Signed-off-by: Nathaniel Clark <nathaniel.l.clark@intel.com>
Change-Id: Id95e13ec3bcbedb7cbb069c610d506d1f3d899a8
Reviewed-on: http://review.whamcloud.com/9508
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Bob Glossman <bob.glossman@intel.com>
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
lustre/tests/sanity.sh

index 84b18e0..a1c5f65 100644 (file)
@@ -6549,6 +6549,25 @@ test_102n() { # LU-4101 mdt: protect internal xattrs
 }
 run_test 102n "silently ignore setxattr on internal trusted xattrs"
 
+test_102p() { # LU-4703 setxattr did not check ownership
+       local testfile=$DIR/$tfile
+
+       [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.56) ] &&
+               skip "MDS needs to be at least 2.5.56" && return
+
+       touch $testfile
+
+       echo "setfacl as user..."
+       $RUNAS setfacl -m "u:$RUNAS_ID:rwx" $testfile
+       [ $? -ne 0 ] || error "setfacl by $RUNAS_ID was allowed on $testfile"
+
+       echo "setfattr as user..."
+       setfacl -m "u:$RUNAS_ID:---" $testfile
+       $RUNAS setfattr -x system.posix_acl_access $testfile
+       [ $? -ne 0 ] || error "setfattr by $RUNAS_ID was allowed on $testfile"
+}
+run_test 102p "check setxattr(2) correctly fails without permission"
+
 run_acl_subtest()
 {
     $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test