]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
chcon: do not validate security context if SELinux is disabled
authorKamil Dudka <kdudka@redhat.com>
Mon, 2 Dec 2019 13:02:02 +0000 (14:02 +0100)
committerPádraig Brady <P@draigBrady.com>
Mon, 2 Dec 2019 16:21:05 +0000 (16:21 +0000)
* 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

src/chcon.c

index 674a244c4ccf19486330391004025b527da0dbf5..72fc451ab86e2ac496cf008b5e6db88fc72efcf4 100644 (file)
@@ -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));
     }