From patchwork Thu Feb 27 21:32:35 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?0L3QsNCx?= X-Patchwork-Id: 13995236 X-Patchwork-Delegate: plautrba@redhat.com Received: from tarta.nabijaczleweli.xyz (tarta.nabijaczleweli.xyz [139.28.40.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 28DD4270054 for ; Thu, 27 Feb 2025 21:32:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=139.28.40.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740691963; cv=none; b=F4AKrvKkhCZ2jlEyVZel6KK6MkFNjqqzfSDkTrr4u+ub+9JAUMSJqTsXjVMiklzCY9gIR35h5C1b2WWA2NZyQ/afoK7xG/Qehx9OohQbR7cYh4ntoBLggRATNXxOFdL2pbFe09bXOiXG5s6FJ4gOukcpD17rklzXGNKYgMUT8sA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740691963; c=relaxed/simple; bh=B8tSdwhUmEXjU9oJp2MBebRetK2+h4xhWfGIeTmRFMQ=; h=Date:From:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition; b=O1gfCzlrzCZHoelYv2XwwO2k2VWI2auT6asAC0xAF1fyFUXYCipYv1AFc8aR9RUq92uCEs07v3hDhztlWgyRlru8e+nkRhQjFhoPOOspxQVnC2MOAqOy0UzrL9RPAZPEMnT2J9VQ66SywBWUPVnBiurjDqySZ5CgLzsvd53qGGg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nabijaczleweli.xyz; spf=pass smtp.mailfrom=nabijaczleweli.xyz; dkim=pass (2048-bit key) header.d=nabijaczleweli.xyz header.i=@nabijaczleweli.xyz header.b=X1WwXwYc; arc=none smtp.client-ip=139.28.40.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nabijaczleweli.xyz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nabijaczleweli.xyz Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nabijaczleweli.xyz header.i=@nabijaczleweli.xyz header.b="X1WwXwYc" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nabijaczleweli.xyz; s=202405; t=1740691955; bh=B8tSdwhUmEXjU9oJp2MBebRetK2+h4xhWfGIeTmRFMQ=; h=Date:From:Cc:Subject:From; b=X1WwXwYcpr85648lPDsMffGLy4Q530vVGablRa4tQAfWSuhBduJ2G123zfThflfXb dNyE/gcfQ772vEVqJVl4dHOoFT2lhuQvueWNaQXYmc29dr7MxpYW2RtwuaQIlAoyo6 9bhCOZP/zIZgT39usj2I/UpQq8psA3w6juxxCUDUNhQi8UhT3ABoX6AgYi+43H01Vt t89zJ8gqD+pkBwhAMmDWjWQRaHr0LjhNGRozF4Jn/k/TzUIN18Alq8lncPFafdDZhh rNlVwtxUzNc0kLqcuCp01CN/VwdPuwDLOnEgiJxW+E6m7568yfODSRj4GZgYnZpmG3 3RqFK5QOrKhYw== Received: from tarta.nabijaczleweli.xyz (unknown [192.168.1.250]) by tarta.nabijaczleweli.xyz (Postfix) with ESMTPSA id 8C6AFA360 for ; Thu, 27 Feb 2025 22:32:35 +0100 (CET) Date: Thu, 27 Feb 2025 22:32:35 +0100 From: =?utf-8?b?0L3QsNCx?= Cc: selinux@vger.kernel.org Subject: [PATCH] Insert -I../../libselinux/include and -L../../libselinux/src into subprograms where needed Message-ID: Precedence: bulk X-Mailing-List: selinux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline User-Agent: NeoMutt/20231221-2-4202cf-dirty These subprograms (sublibraries) use plain #include cc ... -lselinux ... &c. which includes/links to the system libselinux. Naturally, this doesn't work if you don't have one. All of these fell out of a plain make invocation, yielding errors like cc -O2 -Werror -Wall -Wextra -Wfloat-equal -Wformat=2 -Winit-self -Wmissing-format-attribute -Wmissing-noreturn -Wmissing-prototypes -Wnull-dereference -Wpointer-arith -Wshadow -Wstrict-prototypes -Wundef -Wunused -Wwrite-strings -fno-common -I../include -D_GNU_SOURCE -c -o boolean_record.o boolean_record.c boolean_record.c:26:10: fatal error: selinux/selinux.h: No such file or directory 26 | #include | ^~~~~~~~~~~~~~~~~~~ compilation terminated. make[2]: Entering directory '/tmp/selinux/policycoreutils/sestatus' cc -O2 -Werror -Wall -Wextra -Wfloat-equal -Wformat=2 -Winit-self -Wmissing-format-attribute -Wmissing-noreturn -Wmissing-prototypes -Wnull-dereference -Wpointer-arith -Wshadow -Wstrict-prototypes -Wundef -Wunused -Wwrite-strings -fno-common -D_FILE_OFFSET_BITS=64 -c -o sestatus.o sestatus.c sestatus.c:12:10: fatal error: selinux/selinux.h: No such file or directory 12 | #include | ^~~~~~~~~~~~~~~~~~~ compilation terminated. Signed-off-by: наб --- libsemanage/src/Makefile | 4 ++-- mcstrans/src/Makefile | 2 ++ mcstrans/utils/Makefile | 3 +++ policycoreutils/load_policy/Makefile | 2 +- policycoreutils/newrole/Makefile | 3 ++- policycoreutils/run_init/Makefile | 3 ++- policycoreutils/secon/Makefile | 3 ++- policycoreutils/semodule/Makefile | 2 ++ policycoreutils/sestatus/Makefile | 3 ++- policycoreutils/setfiles/Makefile | 2 ++ policycoreutils/setsebool/Makefile | 2 ++ policycoreutils/unsetfiles/Makefile | 3 ++- python/audit2allow/Makefile | 2 ++ restorecond/Makefile | 4 ++-- 14 files changed, 28 insertions(+), 10 deletions(-) diff --git a/libsemanage/src/Makefile b/libsemanage/src/Makefile index 8dfbd762..4db45aad 100644 --- a/libsemanage/src/Makefile +++ b/libsemanage/src/Makefile @@ -60,7 +60,7 @@ CFLAGS ?= -Werror -Wall -W -Wundef -Wshadow -Wmissing-noreturn -Wmissing-format- SWIG_CFLAGS += -Wno-error -Wno-unused-but-set-variable -Wno-unused-variable -Wno-shadow \ -Wno-unused-parameter -Wno-missing-prototypes -override CFLAGS += -I../include -D_GNU_SOURCE +override CFLAGS += -I../include -I../../libselinux/include -D_GNU_SOURCE RANLIB ?= ranlib SWIG = swig -Wall -python -o $(SWIGCOUT) -outdir ./ @@ -90,7 +90,7 @@ $(LIBA): $(OBJS) $(RANLIB) $@ $(LIBSO): $(LOBJS) - $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -shared -o $@ $^ -lsepol -laudit -lselinux -lbz2 -Wl,-soname,$(LIBSO),--version-script=libsemanage.map,-z,defs + $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -shared -o $@ $^ -L../../libselinux/src -lsepol -laudit -lselinux -lbz2 -Wl,-soname,$(LIBSO),--version-script=libsemanage.map,-z,defs ln -sf $@ $(TARGET) $(LIBPC): $(LIBPC).in ../VERSION diff --git a/mcstrans/src/Makefile b/mcstrans/src/Makefile index 89dbac16..88487068 100644 --- a/mcstrans/src/Makefile +++ b/mcstrans/src/Makefile @@ -16,6 +16,8 @@ PROG_OBJS= $(patsubst %.c,%.o,$(PROG_SRC)) PROG=mcstransd INITSCRIPT=mcstrans CFLAGS ?= -Wall -W -Wundef -Wmissing-noreturn -Wmissing-format-attribute +override CFLAGS += -I../../libselinux/include +override LDFLAGS+= -L../../libselinux/src all: $(PROG) diff --git a/mcstrans/utils/Makefile b/mcstrans/utils/Makefile index eec714f1..57a73932 100644 --- a/mcstrans/utils/Makefile +++ b/mcstrans/utils/Makefile @@ -2,6 +2,9 @@ PREFIX ?= /usr SBINDIR ?= $(PREFIX)/sbin +override CFLAGS += -I../../libselinux/include +override LDFLAGS+= -L../../libselinux/src + TARGETS=transcon untranscon # If no specific libsepol.a is specified, fall back on LDFLAGS search path diff --git a/policycoreutils/load_policy/Makefile b/policycoreutils/load_policy/Makefile index ad80d500..6b2fa880 100644 --- a/policycoreutils/load_policy/Makefile +++ b/policycoreutils/load_policy/Makefile @@ -6,7 +6,7 @@ MANDIR ?= $(PREFIX)/share/man LOCALEDIR ?= $(DESTDIR)$(PREFIX)/share/locale CFLAGS ?= -Werror -Wall -W -override CFLAGS += $(LDFLAGS) -DUSE_NLS -DLOCALEDIR="\"$(LOCALEDIR)\"" -DPACKAGE="\"policycoreutils\"" +override CFLAGS += $(LDFLAGS) -I../../libselinux/include -L../../libselinux/src -DUSE_NLS -DLOCALEDIR="\"$(LOCALEDIR)\"" -DPACKAGE="\"policycoreutils\"" override LDLIBS += -lsepol -lselinux TARGETS=$(patsubst %.c,%,$(sort $(wildcard *.c))) diff --git a/policycoreutils/newrole/Makefile b/policycoreutils/newrole/Makefile index 4b8145d3..308e92dc 100644 --- a/policycoreutils/newrole/Makefile +++ b/policycoreutils/newrole/Makefile @@ -24,7 +24,8 @@ VERSION = $(shell cat ../VERSION) CFLAGS ?= -Werror -Wall -W EXTRA_OBJS = -override CFLAGS += -DVERSION=\"$(VERSION)\" -DUSE_NLS -DLOCALEDIR="\"$(LOCALEDIR)\"" -DPACKAGE="\"policycoreutils\"" +override CFLAGS += -I../../libselinux/include -DVERSION=\"$(VERSION)\" -DUSE_NLS -DLOCALEDIR="\"$(LOCALEDIR)\"" -DPACKAGE="\"policycoreutils\"" +override LDFLAGS+= -L../../libselinux/src override LDLIBS += -lselinux ifeq ($(PAMH), y) override CFLAGS += -DUSE_PAM diff --git a/policycoreutils/run_init/Makefile b/policycoreutils/run_init/Makefile index 619ebc1d..6c92fda1 100644 --- a/policycoreutils/run_init/Makefile +++ b/policycoreutils/run_init/Makefile @@ -10,7 +10,8 @@ PAMH ?= $(shell test -f /usr/include/security/pam_appl.h && echo y) AUDITH ?= $(shell test -f /usr/include/libaudit.h && echo y) CFLAGS ?= -Werror -Wall -W -override CFLAGS += -DUSE_NLS -DLOCALEDIR="\"$(LOCALEDIR)\"" -DPACKAGE="\"policycoreutils\"" +override CFLAGS += -I../../libselinux/include -DUSE_NLS -DLOCALEDIR="\"$(LOCALEDIR)\"" -DPACKAGE="\"policycoreutils\"" +override LDFLAGS+= -L../../libselinux/src override LDLIBS += -lselinux ifeq ($(PAMH), y) override CFLAGS += -DUSE_PAM diff --git a/policycoreutils/secon/Makefile b/policycoreutils/secon/Makefile index 440503a1..c2102606 100644 --- a/policycoreutils/secon/Makefile +++ b/policycoreutils/secon/Makefile @@ -7,7 +7,8 @@ MANDIR ?= $(PREFIX)/share/man WARNS=-Werror -W -Wall -Wundef -Wshadow -Wpointer-arith -Wbad-function-cast -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -Wno-format-zero-length -Wformat-nonliteral -Wformat-security -Wfloat-equal VERSION = $(shell cat ../VERSION) CFLAGS ?= $(WARNS) -O1 -override CFLAGS += -DVERSION=\"$(VERSION)\" +override CFLAGS += -I../../libselinux/include -DVERSION=\"$(VERSION)\" +override LDFLAGS+= -L../../libselinux/src override LDLIBS += -lselinux all: secon diff --git a/policycoreutils/semodule/Makefile b/policycoreutils/semodule/Makefile index 9fbf99d6..31cb2670 100644 --- a/policycoreutils/semodule/Makefile +++ b/policycoreutils/semodule/Makefile @@ -5,6 +5,8 @@ SBINDIR ?= $(PREFIX)/sbin MANDIR = $(PREFIX)/share/man CFLAGS ?= -Werror -Wall -W +override CFLAGS += -I../../libselinux/include -I../../libsemanage/include +override LDFLAGS+= -L../../libselinux/src -L../../libsemanage/src override LDLIBS += -lsepol -lselinux -lsemanage SEMODULE_OBJS = semodule.o diff --git a/policycoreutils/sestatus/Makefile b/policycoreutils/sestatus/Makefile index aebf050c..70748157 100644 --- a/policycoreutils/sestatus/Makefile +++ b/policycoreutils/sestatus/Makefile @@ -7,7 +7,8 @@ MANDIR = $(PREFIX)/share/man ETCDIR ?= /etc CFLAGS ?= -Werror -Wall -W -override CFLAGS += -D_FILE_OFFSET_BITS=64 +override CFLAGS += -I../../libselinux/include -D_FILE_OFFSET_BITS=64 +override LDFLAGS+= -L../../libselinux/src override LDLIBS += -lselinux all: sestatus diff --git a/policycoreutils/setfiles/Makefile b/policycoreutils/setfiles/Makefile index 84ffb08b..8e589a30 100644 --- a/policycoreutils/setfiles/Makefile +++ b/policycoreutils/setfiles/Makefile @@ -6,6 +6,8 @@ MANDIR = $(PREFIX)/share/man AUDITH ?= $(shell test -f /usr/include/libaudit.h && echo y) CFLAGS ?= -g -Werror -Wall -W +override CFLAGS += -I../../libselinux/include +override LDFLAGS+= -L../../libselinux/src override LDLIBS += -lselinux -lsepol -lpthread ifeq ($(AUDITH), y) diff --git a/policycoreutils/setsebool/Makefile b/policycoreutils/setsebool/Makefile index fc5b4ff6..54489ba3 100644 --- a/policycoreutils/setsebool/Makefile +++ b/policycoreutils/setsebool/Makefile @@ -6,6 +6,8 @@ MANDIR = $(PREFIX)/share/man BASHCOMPLETIONDIR ?= $(PREFIX)/share/bash-completion/completions CFLAGS ?= -Werror -Wall -W +override CFLAGS += -I../../libselinux/include -I../../libsemanage/include +override LDFLAGS+= -L../../libselinux/src -L../../libsemanage/src override LDLIBS += -lselinux -lsemanage SETSEBOOL_OBJS = setsebool.o diff --git a/policycoreutils/unsetfiles/Makefile b/policycoreutils/unsetfiles/Makefile index 9e5edc04..08fa1abb 100644 --- a/policycoreutils/unsetfiles/Makefile +++ b/policycoreutils/unsetfiles/Makefile @@ -2,7 +2,8 @@ PREFIX ?= /usr SBINDIR ?= $(PREFIX)/sbin MANDIR ?= $(PREFIX)/share/man -override CFLAGS += -D_GNU_SOURCE +override CFLAGS += -I../../libselinux/include -D_GNU_SOURCE +override LDFLAGS+= -L../../libselinux/src override LDLIBS += -lselinux diff --git a/python/audit2allow/Makefile b/python/audit2allow/Makefile index fb04b8bd..28b8f7f2 100644 --- a/python/audit2allow/Makefile +++ b/python/audit2allow/Makefile @@ -8,6 +8,8 @@ BINDIR ?= $(PREFIX)/bin MANDIR ?= $(PREFIX)/share/man CFLAGS ?= -Werror -Wall -W +override CFLAGS += -I../../libselinux/include +override LDFLAGS+= -L../../libselinux/src # If no specific libsepol.a is specified, fall back on LDFLAGS search path # Otherwise, as $(LIBSEPOLA) already appears in the dependencies, there diff --git a/restorecond/Makefile b/restorecond/Makefile index 1ddfcc92..b8b86eb4 100644 --- a/restorecond/Makefile +++ b/restorecond/Makefile @@ -18,8 +18,8 @@ GIO_CFLAGS = -DHAVE_DBUS $(shell $(PKG_CONFIG) --cflags gio-2.0) GIO_LIBS = $(shell $(PKG_CONFIG) --libs gio-2.0) CFLAGS ?= -g -Werror -Wall -W -override CFLAGS += $(GIO_CFLAGS) - +override CFLAGS += -I../../libselinux/include $(GIO_CFLAGS) +override LDFLAGS+= -L../../libselinux/src override LDLIBS += -lselinux $(GIO_LIBS) all: restorecond