src/uid_wrapper.c: fix RTLD_NEXT handling for libpthread
authorStefan Metzmacher <metze@samba.org>
Fri, 13 Jan 2023 19:48:25 +0000 (20:48 +0100)
committerAndreas Schneider <asn@samba.org>
Tue, 17 Jan 2023 13:26:16 +0000 (14:26 +0100)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15228

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
src/uid_wrapper.c

index 0480394bcb51e7cbb0fb98fb69ad7c6e8dec95fa..da5db9260fbe966eacca826725e539f8f89140e9 100644 (file)
@@ -475,7 +475,14 @@ static void *uwrap_load_lib_handle(enum uwrap_lib lib)
 
        if (handle == NULL) {
 #ifdef RTLD_NEXT
-               handle = uwrap.libc.handle = RTLD_NEXT;
+               switch (lib) {
+               case UWRAP_LIBC:
+                       handle = uwrap.libc.handle = RTLD_NEXT;
+                       break;
+               case UWRAP_LIBPTHREAD:
+                       handle = uwrap.libpthread.handle = RTLD_NEXT;
+                       break;
+               }
 #else
                fprintf(stderr,
                        "Failed to dlopen library: %s\n",
@@ -2520,7 +2527,11 @@ void uwrap_destructor(void)
                dlclose(uwrap.libc.handle);
        }
 
-       if (uwrap.libpthread.handle != NULL) {
+       if (uwrap.libpthread.handle != NULL
+#ifdef RTLD_NEXT
+           && uwrap.libpthread.handle != RTLD_NEXT
+#endif
+          ) {
                dlclose(uwrap.libpthread.handle);
        }