]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
id: don't show SMACK errors unless -Z is specified
authorPádraig Brady <P@draigBrady.com>
Tue, 2 Jul 2013 01:40:35 +0000 (02:40 +0100)
committerPádraig Brady <P@draigBrady.com>
Tue, 2 Jul 2013 08:47:16 +0000 (09:47 +0100)
* src/id.c (main): Be consistent with the SELinux case,
and only show errors in getting the security context
when -Z is specified.

src/id.c

index c91dbcdbc6edd05e5191271848a70f8d997c9a56..b7384a7cb988858d1046a8a0876bcc1dd8aa4a02 100644 (file)
--- a/src/id.c
+++ b/src/id.c
@@ -197,7 +197,7 @@ main (int argc, char **argv)
     error (EXIT_FAILURE, 0,
            _("cannot print only names or real IDs in default format"));
 
-  /* If we are on a selinux-enabled kernel, no user is specified, and
+  /* If we are on a SELinux/SMACK-enabled kernel, no user is specified, and
      either --context is specified or none of (-u,-g,-G) is specified,
      and we're not in POSIXLY_CORRECT mode, get our context.  Otherwise,
      leave the context variable alone - it has been initialized to an
@@ -211,7 +211,8 @@ main (int argc, char **argv)
         error (EXIT_FAILURE, 0, _("can't get process context"));
 #ifdef HAVE_SMACK
       else if (smack_enabled
-               && smack_new_label_from_self ((char **) &context) < 0)
+               && smack_new_label_from_self ((char **) &context) < 0
+               && just_context)
         error (EXIT_FAILURE, 0, _("can't get process context"));
 #endif
     }