ebee78
From 5d6c2c9b3869938592025ce169659f0c7e9970fc Mon Sep 17 00:00:00 2001
ebee78
From: Kamil Dudka <kdudka@redhat.com>
ebee78
Date: Mon, 2 Dec 2019 14:02:02 +0100
ebee78
Subject: [PATCH] chcon: do not validate security context if SELinux is
ebee78
 disabled
ebee78
ebee78
* src/chcon.c (main): Skip call of security_check_context()
ebee78
in case SELinux is disabled to avoid unnecessary failure.
ebee78
ebee78
Bug: https://bugzilla.redhat.com/1777831
ebee78
ebee78
Upstream-commit: 5118a2e392c8cffb3c26eaffbb75e2b1ef7607f9
ebee78
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
ebee78
---
ebee78
 src/chcon.c | 4 +++-
ebee78
 1 file changed, 3 insertions(+), 1 deletion(-)
ebee78
ebee78
diff --git a/src/chcon.c b/src/chcon.c
ebee78
index 6414406..eea4235 100644
ebee78
--- a/src/chcon.c
ebee78
+++ b/src/chcon.c
ebee78
@@ -18,6 +18,7 @@
ebee78
 #include <stdio.h>
ebee78
 #include <sys/types.h>
ebee78
 #include <getopt.h>
ebee78
+#include <selinux/selinux.h>
ebee78
 
ebee78
 #include "system.h"
ebee78
 #include "dev-ino.h"
ebee78
@@ -557,7 +558,8 @@ main (int argc, char **argv)
ebee78
   else
ebee78
     {
ebee78
       specified_context = argv[optind++];
ebee78
-      if (security_check_context (se_const (specified_context)) < 0)
ebee78
+      if (0 < is_selinux_enabled ()
ebee78
+          && security_check_context (se_const (specified_context)) < 0)
ebee78
         die (EXIT_FAILURE, errno, _("invalid context: %s"),
ebee78
              quote (specified_context));
ebee78
     }
ebee78
-- 
ebee78
2.21.1
ebee78