public inbox for fstests@vger.kernel.org
 help / color / mirror / Atom feed
From: Eric Biggers <ebiggers@google.com>
To: fstests@vger.kernel.org
Cc: jack@suse.cz, agruenba@redhat.com, Eric Biggers <ebiggers@google.com>
Subject: [PATCH] generic/375: test both regular file and directory
Date: Wed, 12 Oct 2016 15:03:07 -0700	[thread overview]
Message-ID: <1476309788-101401-1-git-send-email-ebiggers@google.com> (raw)

generic/375 previously only tested SGID being cleared on a regular file.
It should test SGID being cleared on a directory too.  Though this is
not required by POSIX, it is the Linux behavior.

Signed-off-by: Eric Biggers <ebiggers@google.com>
---
 tests/generic/375     | 54 ++++++++++++++++++++++++++++++++-------------------
 tests/generic/375.out |  8 ++++++++
 2 files changed, 42 insertions(+), 20 deletions(-)

diff --git a/tests/generic/375 b/tests/generic/375
index f8c3260..1d523e5 100755
--- a/tests/generic/375
+++ b/tests/generic/375
@@ -52,30 +52,44 @@ _require_runas
 _require_acls
 
 cd $TEST_DIR
-testfile=testfile.$seq
-rm -f $testfile
 
-touch $testfile
-chown 100:100 $testfile
+# try with both regular file and directory
+for filetype in regular dir; do
 
-echo '*** SGID should remain set (twice)'
-chmod 2755 $testfile
-_runas -u 100 -g 100 -- chmod 2777 $testfile
-stat -c %A $testfile
-chmod 2755 $testfile
-_runas -u 100 -g 100 -- setfacl -m u::rwx,g::rwx,o::rwx $testfile
-stat -c %A $testfile
+	case $filetype in
+	regular)
+		testfile=testfile.$seq
+		rm -f $testfile
+		touch $testfile
+		;;
+	*)
+		testfile=testdir.$seq
+		rm -rf $testfile
+		mkdir $testfile
+		;;
+	esac
 
-echo '*** SGID should be cleared (twice)'
-chmod 2755 $testfile
-_runas -u 100 -g 101 -- chmod 2777 $testfile
-stat -c %A $testfile
-chmod 2755 $testfile
-_runas -u 100 -g 101 -- setfacl -m u::rwx,g::rwx,o::rwx $testfile
-stat -c %A $testfile
+	chown 100:100 $testfile
 
-echo '*** Expected failure'
-_runas -u 101 -g 101 -- chmod 2777 $testfile
+	echo '*** SGID should remain set (twice)'
+	chmod 2755 $testfile
+	_runas -u 100 -g 100 -- chmod 2777 $testfile
+	stat -c %A $testfile
+	chmod 2755 $testfile
+	_runas -u 100 -g 100 -- setfacl -m u::rwx,g::rwx,o::rwx $testfile
+	stat -c %A $testfile
+
+	echo '*** SGID should be cleared (twice)'
+	chmod 2755 $testfile
+	_runas -u 100 -g 101 -- chmod 2777 $testfile
+	stat -c %A $testfile
+	chmod 2755 $testfile
+	_runas -u 100 -g 101 -- setfacl -m u::rwx,g::rwx,o::rwx $testfile
+	stat -c %A $testfile
+
+	echo '*** Expected failure'
+	_runas -u 101 -g 101 -- chmod 2777 $testfile
+done
 
 status=0
 exit
diff --git a/tests/generic/375.out b/tests/generic/375.out
index 478d078..bb9bc72 100644
--- a/tests/generic/375.out
+++ b/tests/generic/375.out
@@ -7,3 +7,11 @@ QA output created by 375
 -rwxrwxrwx
 *** Expected failure
 chmod: changing permissions of 'testfile.375': Operation not permitted
+*** SGID should remain set (twice)
+drwxrwsrwx
+drwxrwsrwx
+*** SGID should be cleared (twice)
+drwxrwxrwx
+drwxrwxrwx
+*** Expected failure
+chmod: changing permissions of 'testdir.375': Operation not permitted
-- 
2.8.0.rc3.226.g39d4020


             reply	other threads:[~2016-10-12 22:03 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-12 22:03 Eric Biggers [this message]
2016-10-12 22:03 ` [PATCH] generic/314: don't test SGID behavior after setfacl Eric Biggers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1476309788-101401-1-git-send-email-ebiggers@google.com \
    --to=ebiggers@google.com \
    --cc=agruenba@redhat.com \
    --cc=fstests@vger.kernel.org \
    --cc=jack@suse.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox