selinux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] selinux-testsuite: fix test/file to avoid noise in test output
@ 2019-09-18 12:52 Stephen Smalley
  2019-09-19  7:17 ` Ondrej Mosnacek
  0 siblings, 1 reply; 2+ messages in thread
From: Stephen Smalley @ 2019-09-18 12:52 UTC (permalink / raw)
  To: paul; +Cc: selinux, omosnace, 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.

Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
---
 tests/file/test | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tests/file/test b/tests/file/test
index 8fe98f6a5b4a..5e080fc6d4e9 100755
--- a/tests/file/test
+++ b/tests/file/test
@@ -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
-- 
2.21.0


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

* Re: [PATCH] selinux-testsuite: fix test/file to avoid noise in test output
  2019-09-18 12:52 [PATCH] selinux-testsuite: fix test/file to avoid noise in test output Stephen Smalley
@ 2019-09-19  7:17 ` Ondrej Mosnacek
  0 siblings, 0 replies; 2+ messages in thread
From: Ondrej Mosnacek @ 2019-09-19  7:17 UTC (permalink / raw)
  To: Stephen Smalley; +Cc: Paul Moore, SElinux list

On Wed, Sep 18, 2019 at 2:52 PM Stephen Smalley <sds@tycho.nsa.gov> wrote:
> 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.
>
> Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
> ---
>  tests/file/test | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/tests/file/test b/tests/file/test
> index 8fe98f6a5b4a..5e080fc6d4e9 100755
> --- a/tests/file/test
> +++ b/tests/file/test
> @@ -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
> --
> 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...

-- 
Ondrej Mosnacek <omosnace at redhat dot com>
Software Engineer, Security Technologies
Red Hat, Inc.


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

end of thread, other threads:[~2019-09-19  7:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-18 12:52 [PATCH] selinux-testsuite: fix test/file to avoid noise in test output Stephen Smalley
2019-09-19  7:17 ` Ondrej Mosnacek

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).