Blame SOURCES/apr-1.7.0-deepbind.patch

3ef932
3ef932
Add $APR_DEEPBIND to enable use of RTLD_DEEPBIND in apr_dso_open().
3ef932
3ef932
--- apr-1.7.0/dso/unix/dso.c.deepbind
3ef932
+++ apr-1.7.0/dso/unix/dso.c
3ef932
@@ -38,6 +38,8 @@
3ef932
 #define DYLD_LIBRARY_HANDLE (void *)-1
3ef932
 #endif
3ef932
 
3ef932
+static int use_deepbind; /* 0 = unset, 1 = use DEEPBIND, -1, don't use DEEPBIND */
3ef932
+
3ef932
 APR_DECLARE(apr_status_t) apr_os_dso_handle_put(apr_dso_handle_t **aprdso,
3ef932
                                                 apr_os_dso_handle_t osdso,
3ef932
                                                 apr_pool_t *pool)
3ef932
@@ -125,6 +127,12 @@
3ef932
 #else
3ef932
     int flags = RTLD_NOW | RTLD_GLOBAL;
3ef932
     void *os_handle;
3ef932
+
3ef932
+    if (use_deepbind == 0)
3ef932
+        use_deepbind = secure_getenv("APR_DEEPBIND") != NULL ? 1 : -1;
3ef932
+    if (use_deepbind == 1)
3ef932
+        flags |= RTLD_DEEPBIND;
3ef932
+
3ef932
 #ifdef _AIX
3ef932
     if (strchr(path + 1, '(') && path[strlen(path) - 1] == ')')
3ef932
     {
3ef932
--- apr-1.7.0/README.deepbind.deepbind
3ef932
+++ apr-1.7.0/README.deepbind
3ef932
@@ -0,0 +1,30 @@
3ef932
+This distribution of APR contains a modification of the behaviour of
3ef932
+the apr_dso_open() function which allows users enable the
3ef932
+"RTLD_DEEPBIND" flag when dlopen() is called.
3ef932
+
3ef932
+If the "APR_DEEPBIND" environment variable is set at runtime, the
3ef932
+RTLD_DEEPBIND flag is always added to the flags passed to dlopen().
3ef932
+
3ef932
+With normal use of dlopen(), dynamically loaded objects will use
3ef932
+global symbols in preference to any symbols defined within the object.
3ef932
+Using RTLD_DEEPBIND reverses this binding order.  See the dlopen(3)
3ef932
+man page for more information.
3ef932
+
3ef932
+This can be useful with Apache httpd, where two different modules are
3ef932
+loaded like:
3ef932
+
3ef932
+1. mod_foo.so uses library "libfoo.so"
3ef932
+   libfoo.so defines a function "SomeSym"
3ef932
+2. mod_bar.so uses library "libbar.so"
3ef932
+   libbar.so defines a different "SomeSym" function
3ef932
+
3ef932
+By default, mod_bar or mod_foo would use the "SomeSym" definition from
3ef932
+the "wrong" library depending on the load order.  If RTLD_DEEPBIND is
3ef932
+used, the "SomeSym" definition will always be mapped to the definition
3ef932
+from the corresponding dependent library.  This can avoid symbol
3ef932
+conflicts.
3ef932
+
3ef932
+There are some risks with using RTLD_DEEPBIND, in particular potential
3ef932
+issues with modules written in C++.  It is not recommended to enable
3ef932
+$APR_DEEPBIND unless it solves a specific problem and after thorough
3ef932
+testing of the configuration.