]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
util-linux: Fix build with latest musl
authorKhem Raj <raj.khem@gmail.com>
Sun, 10 Dec 2023 20:25:47 +0000 (12:25 -0800)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Wed, 13 Dec 2023 11:33:36 +0000 (11:33 +0000)
Musl has removed basename declaration in string.h which exposes this
error.

Signed-off-by: Khem Raj <raj.khem@gmail.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
meta/recipes-core/util-linux/util-linux.inc
meta/recipes-core/util-linux/util-linux/0001-login-utils-include-libgen.h-for-basename-API.patch [new file with mode: 0644]

index 952a680a8492e62052aa57a24c8f85fec11b8f38..e3bef5acfc50ec2ba1d516cbf3a9cba63ba43c3d 100644 (file)
@@ -36,6 +36,7 @@ SRC_URI = "${KERNELORG_MIRROR}/linux/utils/util-linux/v${MAJOR_VERSION}/util-lin
            file://display_testname_for_subtest.patch \
            file://avoid_parallel_tests.patch \
            file://0001-lscpu-Use-4K-buffer-size-instead-of-BUFSIZ.patch \
+           file://0001-login-utils-include-libgen.h-for-basename-API.patch \
            "
 
 SRC_URI[sha256sum] = "87abdfaa8e490f8be6dde976f7c80b9b5ff9f301e1b67e3899e1f05a59a1531f"
diff --git a/meta/recipes-core/util-linux/util-linux/0001-login-utils-include-libgen.h-for-basename-API.patch b/meta/recipes-core/util-linux/util-linux/0001-login-utils-include-libgen.h-for-basename-API.patch
new file mode 100644 (file)
index 0000000..2b9897a
--- /dev/null
@@ -0,0 +1,57 @@
+From 6581cf8ac95b99b5a35fea88c52646558d05b5e7 Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Sun, 3 Dec 2023 19:59:46 -0800
+Subject: [PATCH] login-utils: include libgen.h for basename API
+
+musl has removed the non-prototype declaration of basename from string.h [1] which now results in build errors with clang-17+ compiler
+
+include libgen.h for using the posix declaration of the funciton.
+
+Fixes
+
+../util-linux-2.39.2/login-utils/su-common.c:847:20: error: call to undeclared function 'basename'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
+  847 |                 shell_basename = basename(shell);
+      |                                  ^
+
+[1] https://git.musl-libc.org/cgit/musl/commit/?id=725e17ed6dff4d0cd22487bb64470881e86a92e7
+
+Upstream-Status: Submitted [https://github.com/util-linux/util-linux/pull/2615]
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+ login-utils/su-common.c | 8 ++++++--
+ 1 file changed, 6 insertions(+), 2 deletions(-)
+
+--- a/login-utils/su-common.c
++++ b/login-utils/su-common.c
+@@ -26,6 +26,7 @@
+ #include <sys/types.h>
+ #include <pwd.h>
+ #include <grp.h>
++#include <libgen.h>
+ #include <security/pam_appl.h>
+ #ifdef HAVE_SECURITY_PAM_MISC_H
+ # include <security/pam_misc.h>
+@@ -840,17 +841,20 @@ static void run_shell(
+                               su->simulate_login ? " login" : "",
+                               su->fast_startup ? " fast-start" : ""));
++  char* tmp = xstrdup(shell);
+       if (su->simulate_login) {
+               char *arg0;
+               char *shell_basename;
+-              shell_basename = basename(shell);
++              shell_basename = basename(tmp);
+               arg0 = xmalloc(strlen(shell_basename) + 2);
+               arg0[0] = '-';
+               strcpy(arg0 + 1, shell_basename);
+               args[0] = arg0;
+-      } else
+-              args[0] = basename(shell);
++      } else {
++    args[0] = basename(tmp);
++  }
++  free(tmp);
+       if (su->fast_startup)
+               args[argno++] = "-f";