Skip to contentSkip to conversation

generic/377: filter out xattrs that don't start with 'user.'

PATCH Superseded Jeff Layton 2 participants 3 messages Jul 1, 2020 – Jul 6, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 generic/377: filter out xattrs that don't start with 'user.'

Most hosts that I've been testing on seem to display security.selinux in listxattr. 377.out doesn't account for that so it routinely fails for me in testing.

When testing the output of listxattr in generic/377, filter out any xattr names that don't start with 'user.'. That should help ensure consistent output on SELinux-enabled hosts.

---
 tests/generic/377 | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

I'm not sure why this doesn't fail for most people, unless most are turning off SELinux. Is this the right approach?

tests/generic/377 +2 -2
index f7835ee8ff9e..f08abdca60a6 100755
@@ -48,7 +48,7 @@ $SETFATTR_PROG -n user.ping -v pong $testfile
 $SETFATTR_PROG -n user.hello -v there $testfile
 
 # 1. Call listxattr without buffer length argument. This should succeed.
-$listxattr $testfile | sort
+$listxattr $testfile | grep '^xattr: user\.' | sort
 
 # 2. Calling listxattr on nonexistant file should fail with -ENOENT.
 $listxattr ""
@@ -66,7 +66,7 @@ $listxattr $testfile 9
 $listxattr $testfile 11
 
 # 6. Calling listxattr with buffersize bigger than needed should succeed.
-$listxattr $testfile 500 | sort
+$listxattr $testfile 500 | grep '^xattr: user\.' | sort
 
 status=0
 exit
Signature · 1 line
2.26.2
#1 lore raw
Quoted 10 lines · Jeff Layton

Most hosts that I've been testing on seem to display security.selinux in listxattr. 377.out doesn't account for that so it routinely fails for me in testing.

When testing the output of listxattr in generic/377, filter out any xattr names that don't start with 'user.'. That should help ensure consistent output on SELinux-enabled hosts.

---

Yeah, I hit this error[1] too. This patch looks good to me.

One more question, do you hit similar failure on generic/062, likes [2]?

Thanks,
Zorro

[1]

generic/377.out.bad renamed from dev/fd/63 +1 -0
@@ -1,4 +1,5 @@
 QA output created by 377
+xattr: security.selinux
 xattr: user.foo
 xattr: user.hello
 xattr: user.ping

...

[2]

generic/062.out.bad renamed from dev/fd/63 +1 -0
@@ -52,6 +52,7 @@
 SCRATCH_MNT/reg: user.name2: No such attribute or operation not permitted
 *** final list (strings, type=reg, nsp=user)
 # file: SCRATCH_MNT/reg
+security.selinux=0x73797374656d5f753a6f626a6563745f723a6e66735f743a733000
 user.name=0xbabe
 user.name3=0xdeface

...

Quoted 31 lines
 tests/generic/377 | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

I'm not sure why this doesn't fail for most people, unless most are turning off SELinux. Is this the right approach?

tests/generic/377 +2 -2
index f7835ee8ff9e..f08abdca60a6 100755
@@ -48,7 +48,7 @@ $SETFATTR_PROG -n user.ping -v pong $testfile
 $SETFATTR_PROG -n user.hello -v there $testfile
 
 # 1. Call listxattr without buffer length argument. This should succeed.
-$listxattr $testfile | sort
+$listxattr $testfile | grep '^xattr: user\.' | sort
 
 # 2. Calling listxattr on nonexistant file should fail with -ENOENT.
 $listxattr ""
@@ -66,7 +66,7 @@ $listxattr $testfile 9
 $listxattr $testfile 11
 
 # 6. Calling listxattr with buffersize bigger than needed should succeed.
-$listxattr $testfile 500 | sort
+$listxattr $testfile 500 | grep '^xattr: user\.' | sort
 
 status=0
 exit
Signature · 1 line
2.26.2
#2 lore raw
Quoted 35 lines · Zorro Lang
Quoted 10 lines · Jeff Layton

Most hosts that I've been testing on seem to display security.selinux in listxattr. 377.out doesn't account for that so it routinely fails for me in testing.

When testing the output of listxattr in generic/377, filter out any xattr names that don't start with 'user.'. That should help ensure consistent output on SELinux-enabled hosts.

---

Yeah, I hit this error[1] too. This patch looks good to me.

One more question, do you hit similar failure on generic/062, likes [2]?

Thanks,
Zorro

[1]

generic/377.out.bad renamed from dev/fd/63 +1 -0
@@ -1,4 +1,5 @@
 QA output created by 377
+xattr: security.selinux
 xattr: user.foo
 xattr: user.hello
 xattr: user.ping
...

[2]

generic/062.out.bad line 57

Quoted 7 lines
generic/062.out.bad renamed from dev/fd/63 +1 -0
@@ -52,6 +52,7 @@
 SCRATCH_MNT/reg: user.name2: No such attribute or operation not permitted
 *** final list (strings, type=reg, nsp=user)
 # file: SCRATCH_MNT/reg
+security.selinux=0x73797374656d5f753a6f626a6563745f723a6e66735f743a733000
 user.name=0xbabe
 user.name3=0xdeface
...

Thanks.

Yes, I generally hit this too. We can do a similar fix for that one. I just figured I'd float this smaller patch before I went to the effort.

I'll plan to spin up a second patch that similarly fixes generic/062.

Quoted 31 lines
Quoted 31 lines
 tests/generic/377 | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

I'm not sure why this doesn't fail for most people, unless most are turning off SELinux. Is this the right approach?

tests/generic/377 +2 -2
index f7835ee8ff9e..f08abdca60a6 100755
@@ -48,7 +48,7 @@ $SETFATTR_PROG -n user.ping -v pong $testfile
 $SETFATTR_PROG -n user.hello -v there $testfile
 
 # 1. Call listxattr without buffer length argument. This should succeed.
-$listxattr $testfile | sort
+$listxattr $testfile | grep '^xattr: user\.' | sort
 
 # 2. Calling listxattr on nonexistant file should fail with -ENOENT.
 $listxattr ""
@@ -66,7 +66,7 @@ $listxattr $testfile 9
 $listxattr $testfile 11
 
 # 6. Calling listxattr with buffersize bigger than needed should succeed.
-$listxattr $testfile 500 | sort
+$listxattr $testfile 500 | grep '^xattr: user\.' | sort
 
 status=0
 exit
Signature · 1 line
2.26.2
Signature · 1 line
Jeff Layton <[email protected]>