shadow 4.14.x adds a number of libraries it dynamically links with
(md, bsd, attr). This causes troubles in setscene tasks where
shadow executables are used (such as useradd), as pulling in
the needed dynamic libraries needs unpleasant special-casing.

Signed-off-by: Alexander Kanavin <[email protected]>

---
v2: patch only Makefiles that produce executables and libshadow.a
(that executables all statically link with), do not patch libsubid/Makefile,
as patching in .a linking can clash with producing dynamic libraries.
libsubid is used only in getsubids executable, which is not used in
setscene user management (or anywhere else from what I can see).

v3: add -no-pie to linker flags, as otherwise some host distros
would refuse to link against libattr produced on other host distros
and supplied via sstate (libattr made with gcc 13 and used on gcc 11/12
hosts seems to be problematic)

Signed-off-by: Alexander Kanavin <[email protected]>
---
 meta/conf/distro/include/no-static-libs.inc |  5 +++++
 meta/recipes-extended/shadow/shadow.inc     | 10 ++++++++++
 2 files changed, 15 insertions(+)

diff --git a/meta/conf/distro/include/no-static-libs.inc 
b/meta/conf/distro/include/no-static-libs.inc
index 75359928a14..8898d53d756 100644
--- a/meta/conf/distro/include/no-static-libs.inc
+++ b/meta/conf/distro/include/no-static-libs.inc
@@ -21,6 +21,11 @@ DISABLE_STATIC:pn-libusb1-native = ""
 # needed by rust
 DISABLE_STATIC:pn-musl = ""
 
+# needed by shadow-native to build static executables, particularly useradd
+DISABLE_STATIC:pn-attr-native = ""
+DISABLE_STATIC:pn-libbsd-native = ""
+DISABLE_STATIC:pn-libmd-native = ""
+
 EXTRA_OECONF:append = "${DISABLE_STATIC}"
 
 EXTRA_OECMAKE:append:pn-libical = " -DSHARED_ONLY=True"
diff --git a/meta/recipes-extended/shadow/shadow.inc 
b/meta/recipes-extended/shadow/shadow.inc
index c024746d4ff..43f456251a5 100644
--- a/meta/recipes-extended/shadow/shadow.inc
+++ b/meta/recipes-extended/shadow/shadow.inc
@@ -47,6 +47,16 @@ EXTRA_OECONF += "--without-libcrack \
 
 CFLAGS:append:libc-musl = " -DLIBBSD_OVERLAY"
 
+# Force static linking of utilities so we can use from the sysroot/sstate for 
useradd
+# without worrying about the dependency libraries being available
+LDFLAGS:append:class-native = " -no-pie"
+do_compile:prepend:class-native () {
+       sed -i -e 's#\(LIBS.*\)-lbsd#\1 ${STAGING_LIBDIR}/libbsd.a 
${STAGING_LIBDIR}/libmd.a#g' \
+              -e 's#\(LIBBSD.*\)-lbsd#\1 ${STAGING_LIBDIR}/libbsd.a 
${STAGING_LIBDIR}/libmd.a#g' \
+              -e 's#\(LIBATTR.*\)-lattr#\1 ${STAGING_LIBDIR}/libattr.a#g' \
+               ${B}/lib/Makefile ${B}/src/Makefile
+}
+
 NSCDOPT = ""
 NSCDOPT:class-native = "--without-nscd"
 NSCDOPT:class-nativesdk = "--without-nscd"
-- 
2.39.2

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#193543): 
https://lists.openembedded.org/g/openembedded-core/message/193543
Mute This Topic: https://lists.openembedded.org/mt/103661548/21656
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to