Blame SOURCES/coreutils-8.30-chcon-invalid-context.patch

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