]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
chcon: exit immediately if SELinux is disabled
authorOndřej Vašík <ovasik@redhat.com>
Mon, 5 Oct 2009 07:20:48 +0000 (09:20 +0200)
committerJim Meyering <meyering@redhat.com>
Tue, 6 Oct 2009 08:10:51 +0000 (10:10 +0200)
This change happens to avoid an abort in chcon when SELinux is
disabled while operating on a file with an "unlabeled" context from
back in 2006.  However, that same abort can still be triggered by the
same file when running chcon with SELinux enabled.  This bug in chcon
will be fixed in a subsequent commit via a getfilecon wrapper.  See
http://thread.gmane.org/gmane.comp.gnu.coreutils.bugs/18378/focus=18384
for how to correct your disk attributes to avoid triggering this bug.
* src/chcon.c (main): Exit immediately if SELinux is disabled.
Reported in http://bugzilla.redhat.com/527142 by Yanko Kaneti.
* src/runcon.c (main): Do not hardcode program name in error message.
* THANKS: Update.

THANKS
src/chcon.c
src/runcon.c

diff --git a/THANKS b/THANKS
index e0e14e506922af2493623224822ef9bb4d6bea7a..65ac1bb4f9a69eb6a2ecd61f1e290ae9f57ca181 100644 (file)
--- a/THANKS
+++ b/THANKS
@@ -612,6 +612,7 @@ Wis Macomson                        wis.macomson@intel.com
 Wojciech Purczynski                 cliph@isec.pl
 Wolfram Kleff                       kleff@cs.uni-bonn.de
 Won-kyu Park                        wkpark@chem.skku.ac.kr
+Yanko Kaneti                        yaneti@declera.com
 Yann Dirson                         dirson@debian.org
 Zvi Har'El                          rl@math.technion.ac.il
 
index fbfdb4d297e85c1f4fe14db88d90f54e959f8339..c0da6949a74bcbe1675fe3ceb0517e571ed6104f 100644 (file)
@@ -519,6 +519,10 @@ main (int argc, char **argv)
       usage (EXIT_FAILURE);
     }
 
+  if (is_selinux_enabled () != 1)
+    error (EXIT_FAILURE, 0,
+           _("%s may be used only on a SELinux kernel"), program_name);
+
   if (reference_file)
     {
       if (getfilecon (reference_file, &ref_context) < 0)
index e0019da2a8dbba9172fafb14aca488f795c61e66..f87eada6a1549ba4793bc5ef6e9bc98022b2cb4f 100644 (file)
@@ -195,7 +195,7 @@ main (int argc, char **argv)
 
   if (is_selinux_enabled () != 1)
     error (EXIT_FAILURE, 0,
-           _("runcon may be used only on a SELinux kernel"));
+           _("%s may be used only on a SELinux kernel"), program_name);
 
   if (context)
     {