aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKamil Dudka <kdudka@redhat.com>2019-12-02 14:02:02 +0100
committerPádraig Brady <P@draigBrady.com>2019-12-02 16:21:05 +0000
commit5118a2e392c8cffb3c26eaffbb75e2b1ef7607f9 (patch)
tree2532773d80f8afd1069f18fec3a7ad8ff82728e8 /src
parentdoc: remove colon from node name (diff)
downloadcoreutils-5118a2e392c8cffb3c26eaffbb75e2b1ef7607f9.tar.gz
coreutils-5118a2e392c8cffb3c26eaffbb75e2b1ef7607f9.zip
chcon: do not validate security context if SELinux is disabled
* src/chcon.c (main): Skip call of security_check_context() in case SELinux is disabled to avoid unnecessary failure. Bug: https://bugzilla.redhat.com/1777831
Diffstat (limited to 'src')
-rw-r--r--src/chcon.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/chcon.c b/src/chcon.c
index 674a244c4..72fc451ab 100644
--- a/src/chcon.c
+++ b/src/chcon.c
@@ -18,6 +18,7 @@
#include <stdio.h>
#include <sys/types.h>
#include <getopt.h>
+#include <selinux/selinux.h>
#include "system.h"
#include "dev-ino.h"
@@ -557,7 +558,8 @@ main (int argc, char **argv)
else
{
specified_context = argv[optind++];
- if (security_check_context (se_const (specified_context)) < 0)
+ if (0 < is_selinux_enabled ()
+ && security_check_context (se_const (specified_context)) < 0)
die (EXIT_FAILURE, errno, _("invalid context: %s"),
quote (specified_context));
}