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