From mboxrd@z Thu Jan 1 00:00:00 1970 Delivery-date: Sun, 15 Nov 2026 11:03:08 +0100 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by lore.white.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1xSX4l-00B5ie-2E for lore@lore.pengutronix.de; Sun, 15 Nov 2026 11:03:08 +0100 Received: from [127.0.0.1] (helo=metis.whiteo.stw.pengutronix.de) by metis.whiteo.stw.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1xSX4l-0003uB-0U; Sun, 15 Nov 2026 11:03:07 +0100 Received: from mx1.white.stw.pengutronix.de ([185.203.200.13]) by metis.whiteo.stw.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1xSX4W-0003u3-Lt for ptxdist@pengutronix.de; Sun, 15 Nov 2026 11:02:53 +0100 Received: from ptx.office.stw.pengutronix.de (ptx.office.stw.4.pengutronix.de [10.9.0.3]) (Authenticated sender: relay-from-ptx.office.stw.pengutronix.de) by mx1.white.stw.pengutronix.de (Postfix) with ESMTPSA id 95348200B4C; Sun, 15 Nov 2026 11:02:52 +0100 (CET) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=pengutronix.de; s=20260414; t=1794736972; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=N0EFzqKOvHyrN0WBnkFpt2e40ET00gfM3LAuzR1ROJk=; b=biOiS9PNj7/KAzJnMb8b+sCMllw6TENaq9E8uR5ozG4Z7N0+Vd5agHmPSWrJRlmU1pFhec zZuBJroVdxTVhFNtcLVsj5RxKkF4EwHdBExu5mlYCBTMeqtMxHtrjoPuLSXrIyXfiaQmOK mGqzM7m5jU2k/KBQh1LWxr/qNsIdQRnlgqLsMD4GKuFOmEaXo7RKw/1w0fgm7je2EGEbvV TgrqD+2aaVGku2o+bysHrBtWg2uHS1tyvAf2yTVBnLQFmquhOpZjnBZg9h1ENgjKgcXi14 6JMx5XleZ7hcNHzuvBx1ftFAGlejTQ5/oUKjA/LJdKZBba8Pvk1n4y5PAqDvFw== ARC-Seal: i=1; s=20260414; d=pengutronix.de; t=1794736972; a=rsa-sha256; cv=none; b=KpFOfhiEgemuNUMuDQDlF2DPyNdlMZMmhHfYX7r2iEOsZiC5gcSJXwGK0eFqz557Ix0cQ4 luOfQxlzoNjRcLt/MwaQAaOKpbYD+Trfh3qzbYIGocw7rPi8EK0RYhjjAW9E5fcYAMGX19 Xj6Ha1/8Ht3PIJh09edKxPmFOFMbW1xANZ7+sws1YIv95LwLbpdVDGlAfMIKYDDgKDdKoN jGvQRJn8ptBMgyZyY+QPL/CKC3kHz2YkbDcELpDdjG3UdfERqRX+1I+RRBp0128ptc68rN uVFAs7xJsE1KKOn0xjLrm/qDqf0QLNNe8g09BXJgTp8rhXPuDIgXGlDb+Tlq7Q== ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.auth=relay-from-ptx.office.stw.pengutronix.de smtp.mailfrom=mol@pengutronix.de Received: by ptx.office.stw.pengutronix.de (Postfix, from userid 1014) id 65E351BF980; Sun, 15 Nov 2026 11:02:52 +0100 (CET) Date: Sun, 15 Nov 2026 11:02:52 +0100 From: Michael Olbrich To: Ladislav Michl Message-ID: References: <20261031203823.357406-1-oss-lists@triops.cz> <20261031203823.357406-8-oss-lists@triops.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Sent-From: Pengutronix Hildesheim X-URL: http://www.pengutronix.de/ X-IRC: #ptxdist @freenode X-Accept-Language: de,en X-Accept-Content-Type: text/plain X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on metis.whiteo.stw.pengutronix.de X-Spam-Level: X-Spam-Status: No, score=-3.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU autolearn=ham autolearn_force=no version=3.4.2 Subject: Re: [ptxdist] [PATCH v2 07/17] libselinux: version bump 2.1.12 -> 3.11 X-BeenThere: ptxdist@pengutronix.de X-Mailman-Version: 2.1.29 Precedence: list List-Id: PTXdist Development Mailing List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: ptxdist@pengutronix.de Cc: ptxdist@pengutronix.de Sender: "ptxdist" X-SA-Exim-Connect-IP: 127.0.0.1 X-SA-Exim-Mail-From: ptxdist-bounces@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false On Sun, Nov 15, 2026 at 09:52:37AM +0100, Ladislav Michl wrote: > On Sat, Nov 14, 2026 at 04:55:56PM +0100, Michael Olbrich wrote: > > On Sat, Oct 31, 2026 at 09:38:08PM +0100, Ladislav Michl wrote: > > > From: Ladislav Michl > > > > > > Signed-off-by: Ladislav Michl > > > --- > > > CHANGES: > > > - v2: build with setrans and rpm support, libselinux exports their > > > symbols even when disabled, leading to undefined references > > > (e.g. selinux_raw_context_to_color in secon). Select LIBC_DL. > > > Make python wrapper depend on PYTHON3 instead of selecting it to > > > avoid Kconfig recursive dependency (PYTHON3 -> LIBUUID -> > > > UTIL_LINUX -> LIBSELINUX -> PYTHON3). > > > > This does not work. It fails at build-time because $(CROSS_PYTHON3) is not > > available. And where is the "UTIL_LINUX -> LIBSELINUX" dependency with > > these patches. > > I have yet another batch of patches optionally enabling selinux for all > packages that supports it. I'll move libselinux python wrapper into a new > package, python3-selinux. > > > > ...PyString_FromString-with-PyUnicode_F.patch | 48 ++++++++++++ > > > patches/libselinux-3.11/series | 4 + > > > rules/libselinux.in | 57 +++++++++++--- > > > rules/libselinux.make | 76 +++++++++++++------ > > > 4 files changed, 154 insertions(+), 31 deletions(-) > > > create mode 100644 patches/libselinux-3.11/0001-libselinux-Replace-PyString_FromString-with-PyUnicode_F.patch > > > create mode 100644 patches/libselinux-3.11/series > > > > > > diff --git a/patches/libselinux-3.11/0001-libselinux-Replace-PyString_FromString-with-PyUnicode_F.patch b/patches/libselinux-3.11/0001-libselinux-Replace-PyString_FromString-with-PyUnicode_F.patch > > > new file mode 100644 > > > index 000000000..015ede608 > > > --- /dev/null > > > +++ b/patches/libselinux-3.11/0001-libselinux-Replace-PyString_FromString-with-PyUnicode_F.patch > > > @@ -0,0 +1,48 @@ > > > +From: Petr Lautrbach > > > +Date: Thu, 6 Aug 2026 16:30:44 +0200 > > > +Subject: [PATCH] libselinux: Replace PyString_FromString with > > > + PyUnicode_FromString for SWIG 4.5.0 compatibility > > > + > > > +SWIG 4.5.0 removed Python 2 C API compatibility macros (PyInt_*, > > > +PyString_*, SWIG_Python_str_*) from its runtime header pyhead.swg. > > > +These macros previously mapped deprecated Python 2 C API names to their > > > +Python 3 equivalents. > > > + > > > +Fixes: https://github.com/SELinuxProject/selinux/issues/538 > > > +Authored-by: Jitka Plesníková > > > +Signed-off-by: Petr Lautrbach > > > +Acked-by: Stephen Smalley > > > +--- > > > + src/selinuxswig_python.i | 6 +++--- > > > + 1 file changed, 3 insertions(+), 3 deletions(-) > > > + > > > +diff --git a/src/selinuxswig_python.i b/src/selinuxswig_python.i > > > +--- a/src/selinuxswig_python.i > > > ++++ b/src/selinuxswig_python.i > > > +@@ -69,7 +69,7 @@ > > > + PyObject* list = PyList_New(*$2); > > > + int i; > > > + for (i = 0; i < *$2; i++) { > > > +- PyList_SetItem(list, i, PyString_FromString((*$1)[i])); > > > ++ PyList_SetItem(list, i, PyUnicode_FromString((*$1)[i])); > > > + } > > > + $result = SWIG_AppendOutput($result, list); > > > + } > > > +@@ -102,7 +102,7 @@ > > > + len++; > > > + plist = PyList_New(len); > > > + for (i = 0; i < len; i++) { > > > +- PyList_SetItem(plist, i, PyString_FromString((*$1)[i])); > > > ++ PyList_SetItem(plist, i, PyUnicode_FromString((*$1)[i])); > > > + } > > > + } else { > > > + plist = PyList_New(0); > > > +@@ -119,7 +119,7 @@ > > > + if (*$1) { > > > + plist = PyList_New(result); > > > + for (i = 0; i < result; i++) { > > > +- PyList_SetItem(plist, i, PyString_FromString((*$1)[i])); > > > ++ PyList_SetItem(plist, i, PyUnicode_FromString((*$1)[i])); > > > + } > > > + } else { > > > + plist = PyList_New(0); > > > diff --git a/patches/libselinux-3.11/series b/patches/libselinux-3.11/series > > > new file mode 100644 > > > index 000000000..9d79f21d8 > > > --- /dev/null > > > +++ b/patches/libselinux-3.11/series > > > @@ -0,0 +1,4 @@ > > > +# generated by git-ptx-patches > > > +#tag:base --start-number 1 > > > +0001-libselinux-Replace-PyString_FromString-with-PyUnicode_F.patch > > > +# 9229b75b9f37589afb32a0e0c582e3b8 - git-ptx-patches magic > > > diff --git a/rules/libselinux.in b/rules/libselinux.in > > > index 6d6b1e655..0ff1358af 100644 > > > --- a/rules/libselinux.in > > > +++ b/rules/libselinux.in > > > @@ -1,27 +1,66 @@ > > > -## SECTION=staging > > > -## old section: > > > -### SECTION=selinux > > > +## SECTION=selinux > > > > > > menuconfig LIBSELINUX > > > tristate > > > prompt "libselinux " > > > - select LIBPCRE > > > + select LIBC_DL > > > + select PCRE2 > > > + select PCRE2_8 > > > select LIBSEPOL > > > - select PYTHON if LIBSELINUX_PYTHON > > > select HOST_SWIG if LIBSELINUX_PYTHON > > > + select HOST_PYTHON3_PIP if LIBSELINUX_PYTHON > > > help > > > libselinux provides an API for SELinux applications to get and set > > > process and file security contexts and to obtain security policy > > > decisions. Required for any applications that use the SELinux > > > API. > > > > > > - STAGING: remove in ptxdist-2020.12.0 > > > - Old version that need to be updated. Fails to build with gcc >= 9.x. > > > - > > > if LIBSELINUX > > > > > > +config LIBSELINUX_UTILS > > > + bool "install utilities" > > > + > > > +if LIBSELINUX_UTILS > > > + > > > +config LIBSELINUX_GETENFORCE > > > + bool "getenforce" > > > + depends on !BUSYBOX_GETENFORCE || ALLYES > > > + > > > +comment "busybox' getenforce is selected!" > > > + depends on BUSYBOX_GETENFORCE > > > + > > > +config LIBSELINUX_GETSEBOOL > > > + bool "getsebool" > > > + depends on !BUSYBOX_GETSEBOOL || ALLYES > > > + > > > +comment "busybox' getsebool is selected!" > > > + depends on BUSYBOX_GETSEBOOL > > > + > > > +config LIBSELINUX_MATCHPATHCON > > > + bool "matchpathcon" > > > + depends on !BUSYBOX_MATCHPATHCON || ALLYES > > > + > > > +comment "busybox' matchpathcon is selected!" > > > + depends on BUSYBOX_MATCHPATHCON > > > + > > > +config LIBSELINUX_SELINUXENABLED > > > + bool "selinuxenabled" > > > + depends on !BUSYBOX_SELINUXENABLED || ALLYES > > > + > > > +comment "busybox' selinuxenabled is selected!" > > > + depends on BUSYBOX_SELINUXENABLED > > > + > > > +config LIBSELINUX_SETENFORCE > > > + bool "setenforce" > > > + depends on !BUSYBOX_SETENFORCE || ALLYES > > > + > > > +comment "busybox' setenforce is selected!" > > > + depends on BUSYBOX_SETENFORCE > > > + > > > +endif > > > + > > > config LIBSELINUX_PYTHON > > > bool "python wrapper" > > > - depends on STAGING > > > + depends on PYTHON3 > > > > > > endif > > > diff --git a/rules/libselinux.make b/rules/libselinux.make > > > index 9f6b6a62f..b7bf42854 100644 > > > --- a/rules/libselinux.make > > > +++ b/rules/libselinux.make > > > @@ -14,62 +14,94 @@ PACKAGES-$(PTXCONF_LIBSELINUX) += libselinux > > > # > > > # Paths and names > > > # > > > -LIBSELINUX_VERSION := 2.1.12 > > > -LIBSELINUX_MD5 := 73270f384a032fad34b5fe075fa05ce2 > > > +LIBSELINUX_VERSION := $(SELINUX_VERSION) > > > +LIBSELINUX_SHA256 := 73d419c6e20e874adaa4019372cbd097eecf4d276e13f27ec5e67d35c0bd203c > > > LIBSELINUX := libselinux-$(LIBSELINUX_VERSION) > > > LIBSELINUX_SUFFIX := tar.gz > > > -LIBSELINUX_URL := https://raw.githubusercontent.com/wiki/SELinuxProject/selinux/files/releases/20120924/$(LIBSELINUX).$(LIBSELINUX_SUFFIX) > > > +LIBSELINUX_URL := $(SELINUX_URL)/$(LIBSELINUX).$(LIBSELINUX_SUFFIX) > > > LIBSELINUX_SOURCE := $(SRCDIR)/$(LIBSELINUX).$(LIBSELINUX_SUFFIX) > > > LIBSELINUX_DIR := $(BUILDDIR)/$(LIBSELINUX) > > > LIBSELINUX_LICENSE := public_domain > > > +LIBSELINUX_LICENSE_FILES := file://LICENSE;md5=84b4d2c6ef954a2d4081e775a270d0d0 > > > +LIBSELINUX_CVE_PRODUCT := selinuxproject:libselinux > > > > > > # ---------------------------------------------------------------------------- > > > # Prepare > > > # ---------------------------------------------------------------------------- > > > > > > -LIBSELINUX_CONF_TOOL := NO > > > -# no := due to CROSS_PYTHON > > > -LIBSELINUX_MAKE_ENV = \ > > > - $(CROSS_ENV) \ > > > - CFLAGS="-O2 -Wall -g" \ > > > - PYTHON=$(CROSS_PYTHON) > > > -LIBSELINUX_MAKE_OPT := \ > > > - LIBDIR=$(PTXDIST_SYSROOT_TARGET)/usr/lib > > > -LIBSELINUX_INSTALL_OPT := \ > > > +LIBSELINUX_CONF_TOOL := NO > > > +LIBSELINUX_MAKE_ENV := $(CROSS_ENV) > > > +LIBSELINUX_MAKE_OPT = \ > > > + PREFIX=/usr \ > > > + LIBDIR=/usr/lib \ > > > + SHLIBDIR=/usr/lib \ > > > + INCLUDEDIR=/usr/include \ > > > + SBINDIR=/usr/sbin \ > > > + USE_PCRE2=y \ > > > + USE_LFS=y \ > > > + DISABLE_SHARED=n \ > > > + DISABLE_BOOL=n \ > > > + DISABLE_SETRANS=n \ > > > + DISABLE_RPM=n \ > > > + DISABLE_X11=y \ > > > + ANDROID_HOST=n \ > > > + LABEL_BACKEND_ANDROID=n \ > > > + CFLAGS="-O2 -Wall -g" > > > + > > > +ifdef PTXCONF_LIBSELINUX_PYTHON > > > +LIBSELINUX_MAKE_OPT += \ > > > + PYTHON=$(CROSS_PYTHON3) \ > > > + PYTHONLIBDIR=$(PYTHON3_SITEPACKAGES) > > > +endif > > > + > > > +LIBSELINUX_INSTALL_OPT = \ > > > + $(LIBSELINUX_MAKE_OPT) \ > > > install > > > > > > ifdef PTXCONF_LIBSELINUX_PYTHON > > > -LIBSELINUX_MAKE_OPT += pywrap > > > LIBSELINUX_INSTALL_OPT += install-pywrap > > > endif > > > > > > +# ---------------------------------------------------------------------------- > > > +# Compile > > > +# ---------------------------------------------------------------------------- > > > + > > > +$(STATEDIR)/libselinux.compile: > > > + @$(call targetinfo) > > > + @$(call world/compile, LIBSELINUX) > > > +ifdef PTXCONF_LIBSELINUX_PYTHON > > > + @$(call compile, LIBSELINUX, $(LIBSELINUX_MAKE_OPT) pywrap) > > > > Why is it necessary to build pywrap separately? Please add a comment, wo we > > know in the future what is needed to remove the special case. > > Upstream's all doesn't include the python wrapper. In libsemanage and > libselinux src/Makefiles, 'all' builds only the library, the archive and > the .pc file, therefore world/compile alone never builds the bindings. > > It is not strictly needed, install-pywrap depends on pywrap, so > make install install-pywrap would build the wrapper during the install > stage. > > For libsemanage, there is 'pywrap: all $(SWIGSO)' - a real target in its > makefile. For libselinux pywrap is a phony target whose recipe always runs > '$(PYTHON) -m build --no-isolation --wheel ..' So that cost a bit of time. > > For consistency reasons I'd keep it here, but I have no clue, how to nicely > sum that in the comment :) I don't understand what you mean here. "$(MAKE) ... pywrap" in one go should work for both libselinux and libsemanage. "pywrap" depends on "all" so the order is handled correctly an all relevant targets should be built. So why would something like this ifdef PTXCONF_LIBSELINUX_PYTHON LIBSELINUX_MAKE_OPT += pywrap endif with the default compile stage not work? > > > +endif > > > + @$(call touch) > > > + > > > # ---------------------------------------------------------------------------- > > > # Target-Install > > > # ---------------------------------------------------------------------------- > > > > > > -LIBSELINUX_PROGS := \ > > > +LIBSELINUX_PROGS-$(PTXCONF_LIBSELINUX_UTILS) := \ > > > avcstat \ > > > compute_av \ > > > compute_create \ > > > compute_member \ > > > compute_relabel \ > > > - compute_user \ > > > getconlist \ > > > getdefaultcon \ > > > - getenforce \ > > > getfilecon \ > > > getpidcon \ > > > - getsebool \ > > > getseuser \ > > > - matchpathcon \ > > > policyvers \ > > > + sefcontext_compile \ > > > selinux_check_securetty_context \ > > > - selinuxenabled \ > > > selinuxexeccon \ > > > - setenforce \ > > > setfilecon \ > > > togglesebool > > > > > > +LIBSELINUX_PROGS-$(PTXCONF_LIBSELINUX_GETENFORCE) += getenforce > > > +LIBSELINUX_PROGS-$(PTXCONF_LIBSELINUX_GETSEBOOL) += getsebool > > > +LIBSELINUX_PROGS-$(PTXCONF_LIBSELINUX_MATCHPATHCON) += matchpathcon > > > +LIBSELINUX_PROGS-$(PTXCONF_LIBSELINUX_SELINUXENABLED) += selinuxenabled > > > +LIBSELINUX_PROGS-$(PTXCONF_LIBSELINUX_SETENFORCE) += setenforce > > > + > > > $(STATEDIR)/libselinux.targetinstall: > > > @$(call targetinfo) > > > > > > @@ -81,11 +113,11 @@ $(STATEDIR)/libselinux.targetinstall: > > > > > > @$(call install_lib, libselinux, 0, 0, 0644, libselinux) > > > > > > - @$(foreach prog, $(LIBSELINUX_PROGS), \ > > > + @$(foreach prog, $(LIBSELINUX_PROGS-y), \ > > > $(call install_copy, libselinux, 0, 0, 0755, -, /usr/sbin/$(prog));) > > > > > > + @$(foreach prog, $(LIBSELINUX_PROGS-y), \ > > $(call install_copy, libselinux, 0, 0, 0755, -, /usr/sbin/$(prog))$(ptx/nl)) > > > > That way, all errors are propagated. > > Fixed. > > > > > > > ifdef PTXCONF_LIBSELINUX_PYTHON > > > - @$(call install_tree, libselinux, 0, 0, -, $(PYTHON_SITEPACKAGES)) > > > + @$(call install_tree, libselinux, 0, 0, -, $(PYTHON3_SITEPACKAGES)) > > > > Use install_glob (to just install the .pyc files) like we do with all other > > Python stuff, or add a comment why that is not possible. > > There are no .pyc files at all, the wheel holds only the .so files, and __init__.py > is copied in afterwards, so no bytecode gets compiled. However something along Right. It's not using the standard Python install tooling :-/. > @$(call install_glob, libselinux, 0, 0, -, $(PYTHON3_SITEPACKAGES),, *.py) > would work. You probably mean @$(call install_glob, libselinux, 0, 0, -, $(PYTHON3_SITEPACKAGES), *.py) Note the number of commas. Your suggestion would skip all *.py files and without *.pyc files basically nothing is installed. And be careful with that. There is a reason we usually install everything _but_ the *.py files: There may be other stuff that is needed. So in that case, install_tree is probably the best we can do. Michael > Btw, there's another bug anyway, the suffix is wrong because PYCEXT reads the > host's value. I'll use: > PYCEXT=$(shell $(CROSS_PYTHON3) -c 'import sysconfig; print(sysconfig.get_config_var("EXT_SUFFIX"))') > > I will prepare v3 with those changes and send it after some more testing. > > > Michael > > > > > endif > > > @$(call install_finish, libselinux) > > > > > > -- > > > 2.47.3 > > > > > > > > > > > > > -- > > Pengutronix e.K. | | > > Steuerwalder Str. 21 | http://www.pengutronix.de/ | > > 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | > > Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | > > -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |