xref: /OK3568_Linux_fs/buildroot/package/libselinux/0001-fix-musl-build.patch (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593SmuzhiyunFrom 78f7f09028fdd6a5e8e4e4b584749621eaef412f Mon Sep 17 00:00:00 2001
2*4882a593SmuzhiyunFrom: Yann E. MORIN" <yann.morin.1998@free.fr>
3*4882a593SmuzhiyunDate: Sat, 7 Dec 2019 17:24:50 -0800
4*4882a593SmuzhiyunSubject: [PATCH] fix undefined macros in musl
5*4882a593Smuzhiyun
6*4882a593Smuzhiyunmusl does not define glibc-specific macros, so use a simple version of
7*4882a593Smuzhiyunthe macro when it is not defined.
8*4882a593Smuzhiyun
9*4882a593SmuzhiyunThis is very inefficient, however, but copying the code from glibc is
10*4882a593Smuzhiyunnot really possible because it is LGPL while libselinux in Public
11*4882a593SmuzhiyunDomain, and we want to avoid license propagation, so this macro is
12*4882a593Smuzhiyuncompletely written from scratch, and non-optimal.
13*4882a593Smuzhiyun
14*4882a593SmuzhiyunSigned-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
15*4882a593Smuzhiyun[Updated for 3.0]
16*4882a593SmuzhiyunSigned-off-by: Adam Duskett <Aduskett@gmail.com>
17*4882a593Smuzhiyundiff --git a/src/booleans.c b/src/booleans.c
18*4882a593Smuzhiyunindex ffa8d26..8569002 100644
19*4882a593Smuzhiyun--- a/src/booleans.c
20*4882a593Smuzhiyun+++ b/src/booleans.c
21*4882a593Smuzhiyun@@ -65,6 +65,14 @@ int security_get_boolean_names(char ***names, int *len)
22*4882a593Smuzhiyun 		goto bad;
23*4882a593Smuzhiyun 	}
24*4882a593Smuzhiyun
25*4882a593Smuzhiyun+/* Simple (but inefficient) version of _D_ALLOC_NAMLEN when
26*4882a593Smuzhiyun+ * building with a C library that misses it (e.g. musl).
27*4882a593Smuzhiyun+ * Note: glibc does a strlen on (d)->d_name, so assume it is safe.
28*4882a593Smuzhiyun+ */
29*4882a593Smuzhiyun+#ifndef _D_ALLOC_NAMLEN
30*4882a593Smuzhiyun+#define _D_ALLOC_NAMLEN(d) (strlen((d)->d_name)+1)
31*4882a593Smuzhiyun+#endif
32*4882a593Smuzhiyun+
33*4882a593Smuzhiyun 	for (i = 0; i < *len; i++) {
34*4882a593Smuzhiyun 		n[i] = strdup(namelist[i]->d_name);
35*4882a593Smuzhiyun 		if (!n[i]) {
36*4882a593Smuzhiyun--
37*4882a593Smuzhiyun2.23.0
38*4882a593Smuzhiyun
39