ldap/servers/slapd/dynalib.c | 27 ++++++++++++++++++++-------
1 file changed, 20 insertions(+), 7 deletions(-)
New commits:
commit 62d967419616d77891c78e4ee3553482cbea1c17
Author: Rich Megginson <rmeggins(a)redhat.com>
Date: Tue Jan 26 11:15:18 2010 -0700
Bug 537466 - nsslapd-distribution-plugin should not require plugin name to begin with
"lib"
https://bugzilla.redhat.com/show_bug.cgi?id=537466
Resolves: bug 537466
Bug Description: nsslapd-distribution-plugin should not require plugin name to begin
with "lib"
Reviewed by: nhosoi (Thanks!)
Branch: HEAD
Fix Description: We use the function PL_GetLibraryName from NSPR to get the
platform specific DLL/shared lib filename suffix. Unfortunately, this function
also prepends the string "lib" to the given name if the given file has no
suffix. If the given name already has the correct suffix, it does not prepend
the "lib" to the name. get_plugin_name() should look for the original
library name in the string returned by PL_GetLibraryName. If it is there, and
has something before it in the string, see if it is "/lib" - if so, remove
the
extraneous "lib" string. If "/lib" is not there, then just pass
the string
through as is.
To summarize:
/full/path/to/name.so -> /full/path/to/name.so - error if /full/path/to/name.so
does not exist
name -> /default/plugin/path/libname.so -> /default/plugin/path/name.so
name.so -> /default/plugin/path/name.so
Platforms tested: RHEL5 x86_64
Flag Day: no
Doc impact: no
diff --git a/ldap/servers/slapd/dynalib.c b/ldap/servers/slapd/dynalib.c
index 4acae45..a659a5e 100644
--- a/ldap/servers/slapd/dynalib.c
+++ b/ldap/servers/slapd/dynalib.c
@@ -174,18 +174,31 @@ symload_report_error( const char *libpath, char *symbol, char
*plugin, int libop
/* PR_GetLibraryName does almost everything we need, and unfortunately
a little bit more - it adds "lib" to be beginning of the library
- name. So we have to strip that part off.
+ name if the library name does not end with the current platform
+ DLL suffix - so
+ foo.so -> /path/foo.so
+ libfoo.so -> /path/libfoo.so
+ BUT
+ foo -> /path/libfoo.so
+ libfoo -> /path/liblibfoo.so
*/
static char *
get_plugin_name(const char *path, const char *lib)
{
+ const char *libstr = "/lib";
+ size_t libstrlen = 4;
char *fullname = PR_GetLibraryName(path, lib);
- char *ptr = PL_strrstr(fullname, "/lib");
-
- if (ptr) {
- ++ptr; /* now points at the "l" */
- /* just copy the remainder of the string on top of here */
- memmove(ptr, ptr+3, strlen(ptr+3)+1);
+ char *ptr = PL_strrstr(fullname, lib);
+
+ /* see if /lib was added */
+ if (ptr && ((ptr - fullname) >= libstrlen)) {
+ /* ptr is at the libname in fullname, and there is something before it */
+ ptr -= libstrlen; /* ptr now points at the "/" in "/lib" if
it is there */
+ if (0 == PL_strncmp(ptr, libstr, libstrlen)) {
+ /* just copy the remainder of the string on top of here */
+ ptr++; /* ptr now points at the "l" in "/lib" - keep the
"/" */
+ memmove(ptr, ptr+3, strlen(ptr+3)+1);
+ }
}
return fullname;