#define PLUGIN_DLOPEN_FLAGS (RTLD_NOW | RTLD_LOCAL | GROUP | NODELETE)
#endif
+/*
+ * glibc bug 11941, fixed in release 2.25, can cause an assertion failure in
+ * dlclose() on process exit. Our workaround is to leak dlopen() handles
+ * (which doesn't typically manifest in leak detection tools because the
+ * handles are still reachable via a global table in libdl). Because we
+ * dlopen() with RTLD_NODELETE, we weren't going to unload the plugin objects
+ * anyway.
+ */
+#ifdef __GLIBC_PREREQ
+#if ! __GLIBC_PREREQ(2, 25)
+#define dlclose(x)
+#endif
+#endif
+
#if USE_DLOPEN && USE_CFBUNDLE
#include <CoreFoundation/CoreFoundation.h>
krb5int_open_plugin (const char *filepath, struct plugin_file_handle **h, struct errinfo *ep)
{
long err = 0;
- struct stat statbuf;
struct plugin_file_handle *htmp = NULL;
int got_plugin = 0;
+#if defined(USE_CFBUNDLE) || defined(_WIN32)
+ struct stat statbuf;
if (!err) {
if (stat (filepath, &statbuf) < 0) {
filepath, strerror(err));
}
}
+#endif
if (!err) {
htmp = calloc (1, sizeof (*htmp)); /* calloc initializes ptrs to NULL */
}
#if USE_DLOPEN
- if (!err && ((statbuf.st_mode & S_IFMT) == S_IFREG
+ if (!err
#if USE_CFBUNDLE
- || (statbuf.st_mode & S_IFMT) == S_IFDIR
+ && ((statbuf.st_mode & S_IFMT) == S_IFREG
+ || (statbuf.st_mode & S_IFMT) == S_IFDIR)
#endif /* USE_CFBUNDLE */
- )) {
+ ) {
void *handle = NULL;
#if USE_CFBUNDLE