Skip to contentSkip to conversation

selinux-testsuite: fix test/file to avoid noise in test output

PATCH In review Stephen Smalley 2 participants 2 messages Sep 18, 2019 – Sep 19, 2019 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 selinux-testsuite: fix test/file to avoid noise in test output

commit ec3ea0fcf3742cba319 ("tests/file: use getfattr instead of ls -Z") introduced noise in the test output for the file tests because the context value returned by getfattr includes the terminating NUL and this caused the command lines to be truncated, omitting the stderr redirection. Use the same technique we already use in overlay/test by chop()'ing off the terminating NUL.

---
 tests/file/test | 1 +
 1 file changed, 1 insertion(+)
tests/file/test +1 -0
index 8fe98f6a5b4a..5e080fc6d4e9 100755
@@ -51,6 +51,7 @@ system "chcon -t fileop_exec_t $basedir/wait_io 2>&1 > /dev/null";
 #
 $good_file_sid =
   `getfattr --only-values -n security.selinux $basedir/temp_file`;
+chop($good_file_sid);
 
 #
 # Attempt to access a restricted file as the 'good' domain.  The first test
Signature · 1 line
2.21.0
#1 lore raw
Quoted 25 lines · Stephen Smalley

commit ec3ea0fcf3742cba319 ("tests/file: use getfattr instead of ls -Z") introduced noise in the test output for the file tests because the context value returned by getfattr includes the terminating NUL and this caused the command lines to be truncated, omitting the stderr redirection. Use the same technique we already use in overlay/test by chop()'ing off the terminating NUL.

---
 tests/file/test | 1 +
 1 file changed, 1 insertion(+)
tests/file/test +1 -1
index 8fe98f6a5b4a..5e080fc6d4e9 100755
@@ -51,6 +51,7 @@ system "chcon -t fileop_exec_t $basedir/wait_io 2>&1 > /dev/null";
 #
 $good_file_sid =
   `getfattr --only-values -n security.selinux $basedir/temp_file`;
+chop($good_file_sid);
 
 #
 # Attempt to access a restricted file as the 'good' domain.  The first test
--
Quoted 2 lines

2.21.0

Thanks for this patch. I agree that chop() is a more straightforward way to do it than my tr-based solution. I hadn't thought of looking for existing uses of getfattr in the testsuite...

Signature · 3 lines
Ondrej Mosnacek <omosnace at redhat dot com>
Software Engineer, Security Technologies
Red Hat, Inc.