05278cd
From: Jan-Marek Glogowski <jan-marek.glogowski@muenchen.de>
05278cd
Date: Tue, 18 May 2010 17:47:05 +0200
05278cd
Subject: [PATCH] Switch to lt_dlopenadvise() to get RTLD_GLOBAL set.
05278cd
05278cd
Proof of concept for fixing http://bugs.debian.org/327585
05278cd
(patch ported from freeradius bug http://bugs.debian.org/416266)
05278cd
05278cd
Resolves: #960048
05278cd
---
05278cd
--- openldap/servers/slapd/module.c.orig	2010-05-18 17:42:04.000000000 +0200
05278cd
+++ openldap/servers/slapd/module.c	2010-05-18 17:45:46.000000000 +0200
05278cd
@@ -117,6 +117,20 @@
05278cd
 	return -1;	/* not found */
05278cd
 }
05278cd
 
05278cd
+static lt_dlhandle slapd_lt_dlopenext_global( const char *filename )
05278cd
+{
05278cd
+	lt_dlhandle handle = 0;
05278cd
+	lt_dladvise advise;
05278cd
+
05278cd
+	if (!lt_dladvise_init (&advise) && !lt_dladvise_ext (&advise)
05278cd
+			&& !lt_dladvise_global (&advise))
05278cd
+		handle = lt_dlopenadvise (filename, advise);
05278cd
+
05278cd
+	lt_dladvise_destroy (&advise);
05278cd
+
05278cd
+	return handle;
05278cd
+}
05278cd
+
05278cd
 int module_load(const char* file_name, int argc, char *argv[])
05278cd
 {
05278cd
 	module_loaded_t *module;
05278cd
@@ -180,7 +194,7 @@
05278cd
 	 * to calling Debug. This is because Debug is a macro that expands
05278cd
 	 * into multiple function calls.
05278cd
 	 */
05278cd
-	if ((module->lib = lt_dlopenext(file)) == NULL) {
05278cd
+	if ((module->lib = slapd_lt_dlopenext_global(file)) == NULL) {
05278cd
 		error = lt_dlerror();
05278cd
 #ifdef HAVE_EBCDIC
05278cd
 		strcpy( ebuf, error );