From 5d43d60c56d75afb743cef2d32bffe60df0847d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= Date: Sat, 24 Aug 2024 21:03:08 +0200 Subject: [PATCH] Disable user name lookup in static builds against glibc Static linking against glibc might crash due to usage of NSS modules, e.g. via getpwuid() (see #503). The linker also warns about it: warning: Using 'getpwuid' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking --- UsersTable.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/UsersTable.c b/UsersTable.c index 6586a4b90..b0f8b7ee7 100644 --- a/UsersTable.c +++ b/UsersTable.c @@ -30,6 +30,7 @@ void UsersTable_delete(UsersTable* this) { } char* UsersTable_getRef(UsersTable* this, unsigned int uid) { +#if !defined(BUILD_STATIC) || !defined(__GLIBC__) char* name = Hashtable_get(this->users, uid); if (name == NULL) { const struct passwd* userData = getpwuid(uid); @@ -39,6 +40,11 @@ char* UsersTable_getRef(UsersTable* this, unsigned int uid) { } } return name; +#else + (void)this; + (void)uid; + return NULL; +#endif } inline void UsersTable_foreach(UsersTable* this, Hashtable_PairFunction f, void* userData) {