summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKen Raeburn <raeburn@mit.edu>2006-04-25 07:21:19 +0000
committerKen Raeburn <raeburn@mit.edu>2006-04-25 07:21:19 +0000
commitb059a3adda55fe90f2758be9d010efb63c9b2bc0 (patch)
treeb997faf264f6a1f280003d912590cd3c4ec170c0
parentb87d443c1d3a7bb1520be3918f2dab6c2f45d4b6 (diff)
downloadkrb5-b059a3adda55fe90f2758be9d010efb63c9b2bc0.tar.gz
krb5-b059a3adda55fe90f2758be9d010efb63c9b2bc0.tar.xz
krb5-b059a3adda55fe90f2758be9d010efb63c9b2bc0.zip
Change kdb plugin code to use the new plugin support instead of
directly calling dlopen and friends. Change the test config files to refer to "db2.so" instead of "db2". git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@17961 dc483132-0cff-0310-8789-dd5450dbe970
-rw-r--r--src/kadmin/testing/proto/krb5.conf.proto2
-rw-r--r--src/lib/kdb/kdb5.c43
-rw-r--r--src/lib/kdb/kdb5.h2
-rw-r--r--src/tests/dejagnu/config/default.exp2
4 files changed, 27 insertions, 22 deletions
diff --git a/src/kadmin/testing/proto/krb5.conf.proto b/src/kadmin/testing/proto/krb5.conf.proto
index 9fe7ec124..981a58c15 100644
--- a/src/kadmin/testing/proto/krb5.conf.proto
+++ b/src/kadmin/testing/proto/krb5.conf.proto
@@ -25,6 +25,6 @@
[dbmodules]
db_module_dir = __MODDIR__
foobar_db2_module_blah = {
- db_library = db2
+ db_library = db2.so
database_name = __K5ROOT__/kdb5
}
diff --git a/src/lib/kdb/kdb5.c b/src/lib/kdb/kdb5.c
index e80259f9f..66de71a96 100644
--- a/src/lib/kdb/kdb5.c
+++ b/src/lib/kdb/kdb5.c
@@ -22,7 +22,10 @@
* or implied warranty.
*/
-/*This code was based on code donated to MIT by Novell for distribution under the MIT license.*/
+/*
+ * This code was based on code donated to MIT by Novell for
+ * distribution under the MIT license.
+ */
/*
* Include files
@@ -30,7 +33,6 @@
#include <stdio.h>
#include <string.h>
-#include <dlfcn.h>
#include <k5-int.h>
#include <osconf.h>
#include "kdb5.h"
@@ -352,13 +354,15 @@ kdb_load_library(krb5_context kcontext, char *lib_name, db_library * lib)
status = 0;
for (ndx = 0; path[ndx]; ndx++) {
- sprintf(dl_name, "%s/%s.so", path[ndx], lib_name);
- (*lib)->dl_handle = dlopen(dl_name, RTLD_NOW);
- if ((*lib)->dl_handle) {
+ sprintf(dl_name, "%s/%s", path[ndx], lib_name);
+ status = krb5int_open_plugin (dl_name, &(*lib)->dl_handle,
+ &kcontext->err);
+ if (status == 0) {
/* found the module */
- dlerror();
- vftabl_addr = dlsym((*lib)->dl_handle, "kdb_function_table");
- if (vftabl_addr) {
+ status = krb5int_get_plugin_data((*lib)->dl_handle,
+ "kdb_function_table",
+ &vftabl_addr, &kcontext->err);
+ if (status == 0) {
memcpy(&(*lib)->vftabl, vftabl_addr, sizeof(kdb_vftabl));
kdb_setup_opt_functions(*lib);
@@ -366,28 +370,29 @@ kdb_load_library(krb5_context kcontext, char *lib_name, db_library * lib)
if ((status = (*lib)->vftabl.init_library())) {
/* ERROR. library not initialized cleanly */
goto clean_n_exit;
-
}
} else {
- err_str = dlerror();
- if(err_str == NULL)
- err_str = "";
+ const char *emsg = krb5_get_error_message (kcontext, status);
status = KRB5_KDB_DBTYPE_INIT;
- krb5_set_error_message (kcontext, status, "%s", err_str);
+ krb5_set_error_message (kcontext, status,
+ "plugin symbol 'kdb_function_table' lookup failed: %s",
+ dl_name, emsg);
+ krb5_free_error_message (kcontext, emsg);
goto clean_n_exit;
}
break;
} else {
- /* set the error. Later if we find everything fine.. we will reset this */
- err_str = dlerror();
-/* fprintf(stderr, "Error loading library %s\n", t); */
+ err_str = krb5_get_error_message(kcontext, status);
}
}
if (!(*lib)->dl_handle) {
/* library not found in the given list. Error str is already set */
status = KRB5_KDB_DBTYPE_NOTFOUND;
- krb5_set_error_message (kcontext, status, "%s", err_str);
+ krb5_set_error_message (kcontext, status,
+ _("Unable to find requested database type: %s"),
+ err_str);
+ krb5_free_error_message (kcontext, err_str);
goto clean_n_exit;
}
@@ -399,7 +404,7 @@ kdb_load_library(krb5_context kcontext, char *lib_name, db_library * lib)
if (*lib) {
kdb_destroy_lib_lock(*lib);
if ((*lib)->dl_handle) {
- dlclose((*lib)->dl_handle);
+ krb5int_close_plugin((*lib)->dl_handle);
}
free(*lib);
*lib = NULL;
@@ -480,7 +485,7 @@ kdb_free_library(db_library lib)
/* close the library */
if (lib->dl_handle) {
- dlclose(lib->dl_handle);
+ krb5int_close_plugin(lib->dl_handle);
}
kdb_destroy_lib_lock(lib);
diff --git a/src/lib/kdb/kdb5.h b/src/lib/kdb/kdb5.h
index 112875c30..a522ac686 100644
--- a/src/lib/kdb/kdb5.h
+++ b/src/lib/kdb/kdb5.h
@@ -181,7 +181,7 @@ typedef struct _kdb_vftabl{
typedef struct _db_library {
char name[KDB_MAX_DB_NAME];
int reference_cnt;
- void *dl_handle;
+ struct plugin_file_handle *dl_handle;
kdb_vftabl vftabl;
struct _db_library *next, *prev;
} *db_library;
diff --git a/src/tests/dejagnu/config/default.exp b/src/tests/dejagnu/config/default.exp
index 7f964a341..603673830 100644
--- a/src/tests/dejagnu/config/default.exp
+++ b/src/tests/dejagnu/config/default.exp
@@ -941,7 +941,7 @@ proc setup_krb5_conf { {type client} } {
puts $conffile "\[dbmodules\]"
puts $conffile " db_module_dir = $tmppwd/../../../util/fakedest$KRB5_DB_MODULE_DIR"
puts $conffile " foo_db2 = {"
- puts $conffile " db_library = db2"
+ puts $conffile " db_library = db2.so"
puts $conffile " database_name = $tmppwd/db"
puts $conffile " }"
close $conffile