[Fedora-directory-commits] ldapserver/ldap/servers/slapd dynalib.c, 1.6, 1.7

Richard Allen Megginson (rmeggins) fedora-directory-commits at redhat.com
Tue Jun 19 18:25:00 UTC 2007


Author: rmeggins

Update of /cvs/dirsec/ldapserver/ldap/servers/slapd
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv14112/ldapserver/ldap/servers/slapd

Modified Files:
	dynalib.c 
Log Message:
Resolves: bug 237356
Description: Move DS Admin Code into Admin Server - ldif templates, pwdhash
Reviewed by: nhosoi (Thanks!)
Fix Description: These changes are primarily to allow the admin server setup to run completely in perl with no more setuputil code.
1) Added LDIF templates for DS config.  template-dse.ldif is the core minimal directory server configuration.  Values can be replaced with parameters in the same style as used with register_server.pl - %token%.  For the plugin entries, the plugin shared library name is now just a name.  There is no more full path.  The code in dynalib.c handles this case by using the compiled in PLUGINDIR.  The NSPR function PR_GetLibraryName knows the correct shared lib suffix for the platform.   All of this allows us to do 2).
2) Added ability to run pwdhash with no server configuration.  If no configuration is given, it uses the template-dse.ldif above.  And instead of having to worry about where the plugins are installed and the shared lib suffix, it just depends on the above changes.  This allows us to generate password hashes during setup before the directory server instance is created, and also to keep clear text password usage to a minimum.
3) Added defaultuser and defaultgroup.
4) Added support for continuation lines in Inf files.
5) All user visible messages during setup should be localizable
Platforms tested: RHEL4
Flag Day: Yes, autotool file changes.
Doc impact: Yes, along with the previous fixes for this bug.



Index: dynalib.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/dynalib.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- dynalib.c	10 Nov 2006 23:45:40 -0000	1.6
+++ dynalib.c	19 Jun 2007 18:24:58 -0000	1.7
@@ -55,15 +55,36 @@
 	PRLibrary	*dl_handle;
 } **libs = NULL;
 
-static void symload_report_error( char *libpath, char *symbol, char *plugin,
+static void symload_report_error( const char *libpath, char *symbol, char *plugin,
 		int libopen );
 
+/* construct a full path and name of a plugin
+   very similar to PR_GetLibraryName except that function inserts
+   the string "lib" at the beginning of name, making that function
+   unsuitable for constructing plugin names
+*/
+static char *get_plugin_name(const char *dir, const char *name);
+
+static void free_plugin_name(char *name)
+{
+	PR_smprintf_free(name);
+}
+
 void *
 sym_load( char *libpath, char *symbol, char *plugin, int report_errors )
 {
 	return sym_load_with_flags(libpath, symbol, plugin, report_errors, PR_FALSE, PR_FALSE);
 }
 
+/* libpath is the pathname from the plugin config entry - it may be an absolute path
+   or a relative path.  It does not have to have the shared lib/dll suffix.  The
+   PR_GetLibraryName function will create the correct library name and path, including
+   the correct shared library suffix for the platform.  So, for example, if you just
+   pass in "libacl-plugin" as the libpath, and you are running on linux, the code
+   will first test for the existence of "libacl-plugin", then will construct the full
+   pathname to load as "PLUGINDIR/libacl-plugin.so" where PLUGINDIR is set during
+   build time to something like /usr/lib/brand/plugins.
+*/
 void *
 sym_load_with_flags( char *libpath, char *symbol, char *plugin, int report_errors, PRBool load_now, PRBool load_global )
 {
@@ -92,9 +113,17 @@
 		flags |= PR_LD_GLOBAL;
 	}
 
+	if (PR_SUCCESS != PR_Access(libpath, PR_ACCESS_READ_OK)) {
+		libSpec.value.pathname = get_plugin_name(PLUGINDIR, libpath);
+		/* then just handle that failure case with symload_report_error below */
+	}
+
 	if ( (handle = PR_LoadLibraryWithFlags( libSpec, flags )) == NULL ) {
 		if ( report_errors ) {
-			symload_report_error( libpath, symbol, plugin, 0 /* lib not open */ );
+			symload_report_error( libSpec.value.pathname, symbol, plugin, 0 /* lib not open */ );
+		}
+		if (libSpec.value.pathname != libpath) {
+			free_plugin_name((char *)libSpec.value.pathname); /* cast ok - allocated by get_plugin_name */
 		}
 		return( NULL );
 	}
@@ -108,14 +137,17 @@
 
 	handle = PR_FindSymbol( libs[i]->dl_handle, symbol );
 	if ( NULL == handle && report_errors ) {
-		symload_report_error( libpath, symbol, plugin, 1 /* lib open */ );
+		symload_report_error( libSpec.value.pathname, symbol, plugin, 1 /* lib open */ );
+	}
+	if (libSpec.value.pathname != libpath) {
+		free_plugin_name((char *)libSpec.value.pathname); /* cast ok - allocated by PR_GetLibraryName */
 	}
 	return handle;
 }
 
 
 static void
-symload_report_error( char *libpath, char *symbol, char *plugin, int libopen )
+symload_report_error( const char *libpath, char *symbol, char *plugin, int libopen )
 {
 	char	*errtext = NULL;
 	PRInt32	errlen, err;
@@ -139,3 +171,22 @@
 			libpath, plugin, 0 );
 	}
 }
+
+/* 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.
+*/
+static char *
+get_plugin_name(const char *path, const char *lib)
+{
+	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);
+	}
+
+	return fullname;
+}




More information about the Fedora-directory-commits mailing list