coreutils icon indicating copy to clipboard operation
coreutils copied to clipboard

Build failure without libselinux (missing `ifeq` in GNUmakefile)

Open kpcyrd opened this issue 6 months ago • 3 comments

Hello!

We noticed a build failure with 0.1.0 for the uutils-coreutils Arch Linux package if selinux isn't present/available, even with SELINUX_ENABLED=0.

I tracked this down to a missing check in the Makefile, it builds fine with this patch:

diff --git a/GNUmakefile b/GNUmakefile
index f46126a82..58bf7fbdd 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -181,8 +181,6 @@ SELINUX_PROGS := \
 
 ifneq ($(OS),Windows_NT)
 	PROGS := $(PROGS) $(UNIX_PROGS)
-# Build the selinux command even if not on the system
-	PROGS := $(PROGS) $(SELINUX_PROGS)
 endif
 
 UTILS ?= $(PROGS)

The selinux command is currently enabled on "everything that isn't windows", this should instead check ifeq ($(SELINUX_ENABLED),1) in addition.

This is related to #7964, which observes the same problem, but only fixes this for MacOS.

kpcyrd avatar May 26 '25 11:05 kpcyrd

I haven't tested it but this might be needed also:


ifdef SELINUX_ENABLED
	ifeq ($(OS),Windows_NT)
		# Disable SELinux on windows
$(info Disabling SELinux for Windows)
		override SELINUX_ENABLED := 0
	else
		# Now check if we should enable it (only on non-Windows)
		ifeq ($(SELINUX_ENABLED), 1)
			ifeq ($(shell if [ -x /sbin/selinuxenabled ] && /sbin/selinuxenabled 2>/dev/null; then echo 0; else echo 1; fi),0)
				override SELINUX_ENABLED := 1
$(info /sbin/selinuxenabled successful)
			else
$(info SELINUX_ENABLED=1 but /sbin/selinuxenabled failed)
				override SELINUX_ENABLED := 0
			endif
		endif
	endif
endif

I'm using arch and had to install libselinux to compile

$ pacman -Qo /sbin/selinuxenabled
/usr/bin/selinuxenabled is owned by libselinux 3.8-1

ic3man5 avatar May 28 '25 01:05 ic3man5

I think this may already be taken into account (somewhat) here:

https://github.com/uutils/coreutils/blob/0f632f2fbab49b16705fc2a80cc3b02a6d6d1b47/GNUmakefile#L61-L72

I'm not good with reading Makefile, but I'm wondering if this should be ifndef SELINUX_ENABLED, so "only do auto-detection if SELINUX_ENABLED isn't already set, default to 0 and only set to 1 if /sbin/selinuxenabled exists".

kpcyrd avatar May 28 '25 12:05 kpcyrd

People needs workaround without patch can make SKIP_UTILS="runcon chcon" even libselinux.so is installed.

oech3 avatar Jun 09 '25 09:06 oech3

@sylvestre Would you reopen this as current PR looks not acceptible for you?

oech3 avatar Nov 08 '25 08:11 oech3

Since uutils changed upstream to coreutils 9.9, existense of runcon and chcon without libselinux is a bug of uutils/coreutils: https://github.com/coreutils/coreutils/commit/8ba47d09a33f0740e071a8394f3504e0fb57948e

oech3 avatar Nov 10 '25 18:11 oech3