@@ -, +, @@ --- configure.ac | 3 +++ libpam/include/missing.h | 12 ++++++++++++ modules/pam_exec/pam_exec.c | 1 + 3 files changed, 16 insertions(+) create mode 100644 libpam/include/missing.h --- a/configure.ac +++ a/configure.ac @@ -599,6 +599,9 @@ dnl AC_CHECK_DECL(__NR_keyctl, [have_key_syscalls=1],[have_key_syscalls=0],[#include ]) AC_CHECK_DECL(ENOKEY, [have_key_errors=1],[have_key_errors=0],[#include ]) +# musl and bionic don't have strndupa +AC_CHECK_DECLS_ONCE([strndupa]) + HAVE_KEY_MANAGEMENT=0 if test $have_key_syscalls$have_key_errors = 11 then --- a/libpam/include/missing.h +++ a/libpam/include/missing.h @@ -0,0 +1,12 @@ +#pragma once + +#if !HAVE_DECL_STRNDUPA +#define strndupa(s, n) \ + ({ \ + const char *__old = (s); \ + size_t __len = strnlen(__old, (n)); \ + char *__new = alloca(__len + 1); \ + __new[__len] = '\0'; \ + memcpy(__new, __old, __len); \ + }) +#endif --- a/modules/pam_exec/pam_exec.c +++ a/modules/pam_exec/pam_exec.c @@ -59,6 +59,7 @@ #include #include #include +#include #define ENV_ITEM(n) { (n), #n } static struct { --