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