]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
build: don't build chcon or runcon unless selinux is available
authorPádraig Brady <P@draigBrady.com>
Sun, 26 Oct 2025 12:33:42 +0000 (12:33 +0000)
committerPádraig Brady <P@draigBrady.com>
Mon, 27 Oct 2025 16:57:39 +0000 (16:57 +0000)
The build can be force enabled with --with-selinux and vice versa.

* build-aux/gen-lists-of-programs.sh: Move chcon and runcon
to the list of optional programs.
* configure.ac: Only enable chcon and runcon if selinux.h is available.
* NEWS: Mention the Build-related change.
Fixes https://github.com/coreutils/coreutils/issues/121

NEWS
build-aux/gen-lists-of-programs.sh
configure.ac

diff --git a/NEWS b/NEWS
index 402585be328c10fe46fbc66c30afd6663e14acbd..21106f6910d07019e4a7dcf68049a0044c356260 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -67,6 +67,12 @@ GNU coreutils NEWS                                    -*- outline -*-
 
   wc -l now operates 10% faster on hosts that support AVX512 instructions.
 
+** Build-related
+
+  chcon and runcon are not built by default if selinux headers are not present,
+  or if the --without-selinux configure option is specified.
+  This can be overridden with the --with-selinux configure option.
+
 
 * Noteworthy changes in release 9.8 (2025-09-22) [stable]
 
index 4b6af8a4f2eecaf3a627351bb718aea3ddbab40f..454eba0aa4893faed4b35d2fa69f18503986ce60 100755 (executable)
@@ -24,12 +24,14 @@ disabled_by_default_progs='
 # Programs that can be built only when certain requisite system
 # features are detected at configure time.
 build_if_possible_progs='
+    chcon
     chroot
     df
     hostid
     libstdbuf.so
     nice
     pinky
+    runcon
     stdbuf
     stty
     timeout
@@ -47,7 +49,6 @@ normal_progs='
     basenc
     basename
     cat
-    chcon
     chgrp
     chmod
     chown
@@ -102,7 +103,6 @@ normal_progs='
     realpath
     rm
     rmdir
-    runcon
     seq
     sha1sum
     sha224sum
index 1e51aba0e2c58d9b7847a341c7128ba680267371..fd0b11a69a4536fb9fa38653080103bf54c42600 100644 (file)
@@ -529,6 +529,16 @@ CFLAGS=$ac_save_CFLAGS
 LDFLAGS=$ac_save_LDFLAGS
 ac_c_werror_flag=$cu_save_c_werror_flag
 
+# Don't build chcon and runcon if only have gnulib stubs
+# Honor --without-selinux to force disable
+# and --with-selinux to force enable.
+if test "$with_selinux" != no &&
+   { test "$with_selinux" = yes ||
+     test "$ac_cv_header_selinux_selinux_h" = yes; }; then
+  gl_ADD_PROG([optional_bin_progs], [chcon])
+  gl_ADD_PROG([optional_bin_progs], [runcon])
+fi
+
 # Test compiler support for half precision floating point types (for od)
 AC_MSG_CHECKING([IEEE 16 bit floating point])
 AC_CACHE_VAL([utils_cv_ieee_16_bit_supported],[