package/samba4: enable musl support
PATCH 1/1 package/samba4: enable musl support
Signed-off-by Bernd Kuhls <[email protected]>
--- package/samba4/0002-musl-getpwent_r.patch | 79 ++++++++++++++++++++++++++ package/samba4/0003-musl-netdb-defines.patch | 26 +++++++++ package/samba4/0004-musl-pthread_mutex_t.patch | 26 +++++++++ package/samba4/Config.in | 7 +-- 4 files changed, 134 insertions(+), 4 deletions(-) create mode 100644 package/samba4/0002-musl-getpwent_r.patch create mode 100644 package/samba4/0003-musl-netdb-defines.patch create mode 100644 package/samba4/0004-musl-pthread_mutex_t.patch
package/samba4/0002-musl-getpwent_r.patch new file +79 -0
@@ -0,0 +1,79 @@ +Musl fix for getpwent_r + +Downloaded from +https://git.alpinelinux.org/cgit/aports/tree/main/samba/getpwent_r.patch + +Signed-off-by: Bernd Kuhls <[email protected]> + +diff --git a/source4/torture/local/nss_tests.c b/source4/torture/local/nss_tests.c +index 2cd6122..04f13c6 100644 +--- a/source4/torture/local/nss_tests.c ++++ b/source4/torture/local/nss_tests.c +@@ -333,6 +332,7 @@ static bool test_enum_passwd(struct torture_context *tctx, + return true; + } + ++#if HAVE_GETPWENT_R + static bool test_enum_r_passwd(struct torture_context *tctx, + struct passwd **pwd_array_p, + size_t *num_pwd_p) +@@ -381,6 +381,7 @@ static bool test_enum_r_passwd(struct torture_context *tctx, + + return true; + } ++#endif + + static bool torture_assert_passwd_equal(struct torture_context *tctx, + const struct passwd *p1, +@@ -432,7 +433,7 @@ static bool test_passwd_r(struct torture_context *tctx) + struct passwd *pwd, pwd1, pwd2; + size_t num_pwd; + +- torture_assert(tctx, test_enum_r_passwd(tctx, &pwd, &num_pwd), ++ torture_assert(tctx, test_enum_passwd(tctx, &pwd, &num_pwd), + "failed to enumerate passwd"); + + for (i=0; i < num_pwd; i++) { +@@ -460,7 +461,7 @@ static bool test_passwd_r_cross(struct torture_context *tctx) + struct passwd *pwd, pwd1, pwd2, pwd3, pwd4; + size_t num_pwd; + +- torture_assert(tctx, test_enum_r_passwd(tctx, &pwd, &num_pwd), ++ torture_assert(tctx, test_enum_passwd(tctx, &pwd, &num_pwd), + "failed to enumerate passwd"); + + for (i=0; i < num_pwd; i++) { +@@ -531,6 +532,7 @@ static bool test_enum_group(struct torture_context *tctx, + return true; + } + ++#if HAVE_GETGRENT_R + static bool test_enum_r_group(struct torture_context *tctx, + struct group **grp_array_p, + size_t *num_grp_p) +@@ -579,6 +581,7 @@ static bool test_enum_r_group(struct torture_context *tctx, + + return true; + } ++#endif + + static bool torture_assert_group_equal(struct torture_context *tctx, + const struct group *g1, +@@ -635,7 +638,7 @@ static bool test_group_r(struct torture_context *tctx) + struct group *grp, grp1, grp2; + size_t num_grp; + +- torture_assert(tctx, test_enum_r_group(tctx, &grp, &num_grp), ++ torture_assert(tctx, test_enum_group(tctx, &grp, &num_grp), + "failed to enumerate group"); + + for (i=0; i < num_grp; i++) { +@@ -663,7 +666,7 @@ static bool test_group_r_cross(struct torture_context *tctx) + struct group *grp, grp1, grp2, grp3, grp4; + size_t num_grp; + +- torture_assert(tctx, test_enum_r_group(tctx, &grp, &num_grp), ++ torture_assert(tctx, test_enum_group(tctx, &grp, &num_grp), + "failed to enumerate group"); + + for (i=0; i < num_grp; i++) {
package/samba4/0003-musl-netdb-defines.patch new file +26 -0
@@ -0,0 +1,26 @@ +Musl fix for missing netdb defines + +Downloaded from +https://git.alpinelinux.org/cgit/aports/tree/main/samba/netdb-defines.patch + +Signed-off-by: Bernd Kuhls <[email protected]> + +diff --git a/nsswitch/wins.c b/nsswitch/wins.c +index dccb6dd..bb24acb 100644 +--- a/nsswitch/wins.c ++++ b/nsswitch/wins.c +@@ -39,6 +39,14 @@ static pthread_mutex_t wins_nss_mutex = PTHREAD_MUTEX_INITIALIZER; + #define INADDRSZ 4 + #endif + ++#ifndef NETDB_INTERNAL ++#define NETDB_INTERNAL -1 ++#endif ++ ++#ifndef NETDB_SUCCESS ++#define NETDB_SUCCESS 0 ++#endif ++ + NSS_STATUS _nss_wins_gethostbyname_r(const char *hostname, + struct hostent *he, + char *buffer,
package/samba4/0004-musl-pthread_mutex_t.patch new file +26 -0
@@ -0,0 +1,26 @@ +Fixes musl build error + +../ctdb/tests/src/test_mutex_raw.c: In function 'main': +../ctdb/tests/src/test_mutex_raw.c:170:28: error: 'pthread_mutex_t {aka struct <anonymous>}' has no member named '__data' + printf("pid=%u\n", mutex->__data.__owner); + +Downloaded from +https://github.com/openembedded/meta-openembedded/blob/master/meta-networking/recipes-connectivity/samba/samba/glibc_only.patch + +Signed-off-by: Bernd Kuhls <[email protected]> + +Index: samba-4.6.2/ctdb/tests/src/test_mutex_raw.c +=================================================================== +--- samba-4.6.2.orig/ctdb/tests/src/test_mutex_raw.c ++++ samba-4.6.2/ctdb/tests/src/test_mutex_raw.c +@@ -166,8 +166,10 @@ int main(int argc, const char **argv) + if (ret == 0) { + pthread_mutex_unlock(mutex); + } ++#ifdef __GLIBC__ + } else if (ret == EBUSY) { + printf("pid=%u\n", mutex->__data.__owner); ++#endif + } else if (ret == 0) { + pthread_mutex_unlock(mutex); + }
package/samba4/Config.in +3 -4
@@ -1,7 +1,7 @@ -comment "samba4 needs a uClibc or glibc toolchain w/ wchar, dynamic library, NPTL" +comment "samba4 needs a toolchain w/ wchar, dynamic library, NPTL" depends on BR2_TOOLCHAIN_HAS_SYNC_4 - depends on !BR2_USE_WCHAR || BR2_TOOLCHAIN_USES_MUSL \ - || BR2_STATIC_LIBS || !BR2_TOOLCHAIN_HAS_THREADS_NPTL + depends on !BR2_USE_WCHAR || BR2_STATIC_LIBS || \ + !BR2_TOOLCHAIN_HAS_THREADS_NPTL depends on BR2_USE_MMU config BR2_PACKAGE_SAMBA4
@@ -12,7 +12,6 @@ config BR2_PACKAGE_SAMBA4 depends on !BR2_STATIC_LIBS # python, gnutls depends on !BR2_nios2 # binary too large, relocations don't fit depends on BR2_TOOLCHAIN_HAS_SYNC_4 - depends on !BR2_TOOLCHAIN_USES_MUSL select BR2_PACKAGE_E2FSPROGS select BR2_PACKAGE_LIBTIRPC if !BR2_TOOLCHAIN_HAS_NATIVE_RPC select BR2_PACKAGE_POPT
Signature · 1 line
2.11.0
PATCH 1/1 package/samba4: enable musl support
Hello,
Quoted 10 lines · Bernd Kuhls
Signed-off-by Bernd Kuhls <[email protected]>--- package/samba4/0002-musl-getpwent_r.patch | 79 ++++++++++++++++++++++++++ package/samba4/0003-musl-netdb-defines.patch | 26 +++++++++ package/samba4/0004-musl-pthread_mutex_t.patch | 26 +++++++++ package/samba4/Config.in | 7 +-- 4 files changed, 134 insertions(+), 4 deletions(-) create mode 100644 package/samba4/0002-musl-getpwent_r.patch create mode 100644 package/samba4/0003-musl-netdb-defines.patch create mode 100644 package/samba4/0004-musl-pthread_mutex_t.patch
Thanks for this. However, since Samba is using Git as a version control system, we want to use Git formatted patches.
Also, could you submit upstream those patches ?
See below for other comments/questions.
Quoted 30 lines
package/samba4/0002-musl-getpwent_r.patch new file +24
-0@@ -0,0 +1,79 @@ +Musl fix for getpwent_r + +Downloaded from +https://git.alpinelinux.org/cgit/aports/tree/main/samba/getpwent_r.patch + +Signed-off-by: Bernd Kuhls <[email protected]> + +diff --git a/source4/torture/local/nss_tests.c b/source4/torture/local/nss_tests.c +index 2cd6122..04f13c6 100644 +--- a/source4/torture/local/nss_tests.c ++++ b/source4/torture/local/nss_tests.c +@@ -333,6 +332,7 @@ static bool test_enum_passwd(struct torture_context *tctx, + return true; + } + ++#if HAVE_GETPWENT_R + static bool test_enum_r_passwd(struct torture_context *tctx, + struct passwd **pwd_array_p, + size_t *num_pwd_p) +@@ -381,6 +381,7 @@ static bool test_enum_r_passwd(struct torture_context *tctx, + + return true; + } ++#endif
package/samba4/0002-musl-getpwent_r.patch line 34
Quoted 10 lines
package/samba4/0002-musl-getpwent_r.patch new file +10
-0+ + static bool torture_assert_passwd_equal(struct torture_context *tctx, + const struct passwd *p1, +@@ -432,7 +433,7 @@ static bool test_passwd_r(struct torture_context *tctx) + struct passwd *pwd, pwd1, pwd2; + size_t num_pwd; + +- torture_assert(tctx, test_enum_r_passwd(tctx, &pwd, &num_pwd), ++ torture_assert(tctx, test_enum_passwd(tctx, &pwd, &num_pwd), + "failed to enumerate passwd");
This patch looks bogus, because is uses test_enum_passwd() unconditionally, even if test_enum_r_passwd() is available.
Also, if Samba is using getpwent_r() instead of getpwent(), perhaps there's a reason?
Quoted 19 lines
package/samba4/0004-musl-pthread_mutex_t.patch new file +13
-0@@ -0,0 +1,26 @@ +Fixes musl build error + +../ctdb/tests/src/test_mutex_raw.c: In function 'main': +../ctdb/tests/src/test_mutex_raw.c:170:28: error: 'pthread_mutex_t {aka struct <anonymous>}' has no member named '__data' + printf("pid=%u\n", mutex->__data.__owner); + +Downloaded from +https://github.com/openembedded/meta-openembedded/blob/master/meta-networking/recipes-connectivity/samba/samba/glibc_only.patch + +Signed-off-by: Bernd Kuhls <[email protected]> + +Index: samba-4.6.2/ctdb/tests/src/test_mutex_raw.c +===================================================================
package/samba4/0004-musl-pthread_mutex_t.patch line 23
Quoted 10 lines
package/samba4/0004-musl-pthread_mutex_t.patch new file +10
-0+--- samba-4.6.2.orig/ctdb/tests/src/test_mutex_raw.c ++++ samba-4.6.2/ctdb/tests/src/test_mutex_raw.c +@@ -166,8 +166,10 @@ int main(int argc, const char **argv) + if (ret == 0) { + pthread_mutex_unlock(mutex); + } ++#ifdef __GLIBC__ + } else if (ret == EBUSY) { + printf("pid=%u\n", mutex->__data.__owner); ++#endif
So how is the ret == EBUSY case being handled ?
package/samba4/0004-musl-pthread_mutex_t.patch line 26
Quoted 3 lines
package/samba4/0004-musl-pthread_mutex_t.patch new file +3
-0+ } else if (ret == 0) { + pthread_mutex_unlock(mutex); + }
Thanks!
Thomas Petazzoni
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com