linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] xfstests: filter out selinux xattrs for generic/062
@ 2014-05-09 19:44 Josef Bacik
  2014-05-09 20:17 ` Eric Sandeen
  0 siblings, 1 reply; 4+ messages in thread
From: Josef Bacik @ 2014-05-09 19:44 UTC (permalink / raw)
  To: linux-btrfs, xfs

If you have selinux enabled getfattr will show the selinux xattrs, which screws
with the golden output of generic/062.  To make matters worse you can't just
greap it out because we'll still get the preamble and newline from getfattr when
the selinux attr is the only attr.  So this is the voodoo I came up with after
way more time than I'm comfortable admitting to make this test pass if you have
selinux enabled.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fb.com>
---
 common/filter     | 6 ++++++
 tests/generic/062 | 3 ++-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/common/filter b/common/filter
index 05dbae6..16a01ed 100644
--- a/common/filter
+++ b/common/filter
@@ -323,5 +323,11 @@ _filter_ro_mount() {
 	    -e "s/mount: cannot mount block device/mount: cannot mount/g"
 }
 
+# Filter out selinux xattrs from getfattr, and if selinux is the only xattr in
+# the file simply pretend like there were no xattrs
+_filter_selinux_xattr() {
+	grep -v selinux | sed -e "N; s/^\# file: .*\n$//; /^$/d"
+}
+
 # make sure this script returns success
 /bin/true
diff --git a/tests/generic/062 b/tests/generic/062
index 047c930..32f0bca 100755
--- a/tests/generic/062
+++ b/tests/generic/062
@@ -47,7 +47,8 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 
 getfattr()
 {
-    $GETFATTR_PROG --absolute-names -dh $@ 2>&1 | _filter_scratch
+    $GETFATTR_PROG --absolute-names -dh $@ 2>&1 | _filter_scratch | \
+	_filter_selinux_xattr
 }
 
 setfattr()
-- 
1.8.3.1


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

* Re: [PATCH] xfstests: filter out selinux xattrs for generic/062
  2014-05-09 19:44 [PATCH] xfstests: filter out selinux xattrs for generic/062 Josef Bacik
@ 2014-05-09 20:17 ` Eric Sandeen
  2014-05-09 20:20   ` Josef Bacik
  0 siblings, 1 reply; 4+ messages in thread
From: Eric Sandeen @ 2014-05-09 20:17 UTC (permalink / raw)
  To: Josef Bacik, linux-btrfs, xfs

On 5/9/14, 2:44 PM, Josef Bacik wrote:
> If you have selinux enabled getfattr will show the selinux xattrs, which screws
> with the golden output of generic/062.  To make matters worse you can't just
> greap it out because we'll still get the preamble and newline from getfattr when
> the selinux attr is the only attr.  So this is the voodoo I came up with after
> way more time than I'm comfortable admitting to make this test pass if you have
> selinux enabled.  Thanks,

I thought that we were pretty much universally mounting with an selinux
context, rather than allowing selinux to add its own on-disk attrs.

Why is that not the case for this test?

Works for me on this old kernel anyway:

[root@bp-05 xfstests]# getenforce
Enforcing
[root@bp-05 xfstests]# ./check generic/062
FSTYP         -- xfs (non-debug)
PLATFORM      -- Linux/x86_64 bp-05 2.6.32
MKFS_OPTIONS  -- -f -bsize=4096 /dev/sdc2
MOUNT_OPTIONS -- -o context=system_u:object_r:nfs_t:s0 /dev/sdc2 /mnt/scratch

generic/062 60s ... 3s
Ran: generic/062
Passed all 1 tests

Note the mount options above...

> Signed-off-by: Josef Bacik <jbacik@fb.com>
> ---
>  common/filter     | 6 ++++++
>  tests/generic/062 | 3 ++-
>  2 files changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/common/filter b/common/filter
> index 05dbae6..16a01ed 100644
> --- a/common/filter
> +++ b/common/filter
> @@ -323,5 +323,11 @@ _filter_ro_mount() {
>  	    -e "s/mount: cannot mount block device/mount: cannot mount/g"
>  }
>  
> +# Filter out selinux xattrs from getfattr, and if selinux is the only xattr in
> +# the file simply pretend like there were no xattrs
> +_filter_selinux_xattr() {
> +	grep -v selinux | sed -e "N; s/^\# file: .*\n$//; /^$/d"
> +}
> +
>  # make sure this script returns success
>  /bin/true
> diff --git a/tests/generic/062 b/tests/generic/062
> index 047c930..32f0bca 100755
> --- a/tests/generic/062
> +++ b/tests/generic/062
> @@ -47,7 +47,8 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
>  
>  getfattr()
>  {
> -    $GETFATTR_PROG --absolute-names -dh $@ 2>&1 | _filter_scratch
> +    $GETFATTR_PROG --absolute-names -dh $@ 2>&1 | _filter_scratch | \
> +	_filter_selinux_xattr
>  }
>  
>  setfattr()
> 


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

* Re: [PATCH] xfstests: filter out selinux xattrs for generic/062
  2014-05-09 20:17 ` Eric Sandeen
@ 2014-05-09 20:20   ` Josef Bacik
  2014-05-09 20:22     ` Eric Sandeen
  0 siblings, 1 reply; 4+ messages in thread
From: Josef Bacik @ 2014-05-09 20:20 UTC (permalink / raw)
  To: Eric Sandeen, linux-btrfs, xfs

On 05/09/2014 04:17 PM, Eric Sandeen wrote:
> On 5/9/14, 2:44 PM, Josef Bacik wrote:
>> If you have selinux enabled getfattr will show the selinux xattrs, which screws
>> with the golden output of generic/062.  To make matters worse you can't just
>> greap it out because we'll still get the preamble and newline from getfattr when
>> the selinux attr is the only attr.  So this is the voodoo I came up with after
>> way more time than I'm comfortable admitting to make this test pass if you have
>> selinux enabled.  Thanks,
>
> I thought that we were pretty much universally mounting with an selinux
> context, rather than allowing selinux to add its own on-disk attrs.
>
> Why is that not the case for this test?
>
> Works for me on this old kernel anyway:
>
> [root@bp-05 xfstests]# getenforce
> Enforcing
> [root@bp-05 xfstests]# ./check generic/062
> FSTYP         -- xfs (non-debug)
> PLATFORM      -- Linux/x86_64 bp-05 2.6.32
> MKFS_OPTIONS  -- -f -bsize=4096 /dev/sdc2
> MOUNT_OPTIONS -- -o context=system_u:object_r:nfs_t:s0 /dev/sdc2 /mnt/scratch
>
> generic/062 60s ... 3s
> Ran: generic/062
> Passed all 1 tests
>
> Note the mount options above...
>

I have MOUNT_OPTIONS set to something else so I lose the context bit. 
Thanks,

Josef


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

* Re: [PATCH] xfstests: filter out selinux xattrs for generic/062
  2014-05-09 20:20   ` Josef Bacik
@ 2014-05-09 20:22     ` Eric Sandeen
  0 siblings, 0 replies; 4+ messages in thread
From: Eric Sandeen @ 2014-05-09 20:22 UTC (permalink / raw)
  To: Josef Bacik, linux-btrfs, xfs

On 5/9/14, 3:20 PM, Josef Bacik wrote:
> I have MOUNT_OPTIONS set to something else so I lose the context bit. Thanks,

Seems like we need to add to them, then, not overwrite them, for selinux?

Otherwise I imagine many other tests will fail.

-Eric

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

end of thread, other threads:[~2014-05-09 20:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-09 19:44 [PATCH] xfstests: filter out selinux xattrs for generic/062 Josef Bacik
2014-05-09 20:17 ` Eric Sandeen
2014-05-09 20:20   ` Josef Bacik
2014-05-09 20:22     ` Eric Sandeen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).