summaryrefslogtreecommitdiffstats
path: root/src/lib/kdb
diff options
context:
space:
mode:
authorAlexandra Ellwood <lxs@mit.edu>2006-05-04 03:06:33 +0000
committerAlexandra Ellwood <lxs@mit.edu>2006-05-04 03:06:33 +0000
commit3dc32ec784b46bc0163fc4eb7da6001d35dc65c5 (patch)
tree69985d2fecebf17fba18c0af7e04822392cf07c7 /src/lib/kdb
parent6948c382617723bf68bd4ab455336cf8c8b85e07 (diff)
downloadkrb5-3dc32ec784b46bc0163fc4eb7da6001d35dc65c5.tar.gz
krb5-3dc32ec784b46bc0163fc4eb7da6001d35dc65c5.tar.xz
krb5-3dc32ec784b46bc0163fc4eb7da6001d35dc65c5.zip
Changed to krb5int_open_plugin_dirs/krb5int_close_plugin_dirs which
takes a list of filebases and directories rather than a list of full paths so the caller doesn't have to generate the possibilities themselves. krb5int_open_plugin_dirs will append the possible suffixes for that platform (including no suffix in case there already is one on the file base). Modified the kdb and locate kdc interfaces to use the new API. ticket: 3716 git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@17975 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/lib/kdb')
-rw-r--r--src/lib/kdb/kdb5.c94
-rw-r--r--src/lib/kdb/kdb5.h2
2 files changed, 45 insertions, 51 deletions
diff --git a/src/lib/kdb/kdb5.c b/src/lib/kdb/kdb5.c
index 51c31200d..c6225474a 100644
--- a/src/lib/kdb/kdb5.c
+++ b/src/lib/kdb/kdb5.c
@@ -161,7 +161,7 @@ kdb_get_library_name(krb5_context kcontext)
goto clean_n_exit;
}
-#define DB2_NAME "db2.so"
+#define DB2_NAME "db2"
/* we got the module section. Get the library name from the module */
status = profile_get_string(kcontext->profile, KDB_MODULE_SECTION, value,
KDB_LIB_POINTER,
@@ -301,10 +301,8 @@ static krb5_error_code
kdb_load_library(krb5_context kcontext, char *lib_name, db_library * lib)
{
krb5_error_code status = 0;
- char dl_name[1024];
int ndx;
- void *vftabl_addr;
- char *err_str = NULL;
+ void **vftabl_addrs = NULL;
/* N.B.: If this is "const" but not "static", the Solaris 10
native compiler has trouble building the library because of
absolute relocations needed in read-only section ".rodata".
@@ -313,6 +311,7 @@ kdb_load_library(krb5_context kcontext, char *lib_name, db_library * lib)
static const char *const dbpath_names[] = {
KDB_MODULE_SECTION, "db_module_dir", NULL,
};
+ const char *filebases[] = { lib_name, NULL };
char **profpath = NULL;
char **path = NULL;
@@ -353,60 +352,55 @@ kdb_load_library(krb5_context kcontext, char *lib_name, db_library * lib)
memcpy(path, profpath, ndx * sizeof(profpath[0]));
memcpy(path + ndx, db_dl_location, db_dl_n_locations * sizeof(char *));
status = 0;
+
+ if ((status = krb5int_open_plugin_dirs ((const char **) path,
+ filebases,
+ &(*lib)->dl_dir_handle, &kcontext->err))) {
+ char *err_str = krb5_get_error_message(kcontext, status);
+ status = KRB5_KDB_DBTYPE_NOTFOUND;
+ 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;
+ }
- for (ndx = 0; path[ndx]; ndx++) {
- 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 */
- 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);
-
- if ((status = (*lib)->vftabl.init_library())) {
- /* ERROR. library not initialized cleanly */
- goto clean_n_exit;
- }
- } else {
- const char *emsg = krb5_get_error_message (kcontext, status);
- status = KRB5_KDB_DBTYPE_INIT;
- 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 {
- err_str = krb5_get_error_message(kcontext, status);
- }
+ if ((status = krb5int_get_plugin_dir_data (&(*lib)->dl_dir_handle, "kdb_function_table",
+ &vftabl_addrs, &kcontext->err))) {
+ char *err_str = krb5_get_error_message(kcontext, status);
+ status = KRB5_KDB_DBTYPE_INIT;
+ krb5_set_error_message (kcontext, status,
+ "plugin symbol 'kdb_function_table' lookup failed: %s", err_str);
+ krb5_free_error_message (kcontext, err_str);
+ goto clean_n_exit;
}
- if (!(*lib)->dl_handle) {
- /* library not found in the given list. Error str is already set */
+ if (vftabl_addrs[0] == NULL) {
+ /* No plugins! */
status = KRB5_KDB_DBTYPE_NOTFOUND;
- krb5_set_error_message (kcontext, status,
- _("Unable to find requested database type: %s"),
- err_str);
- krb5_free_error_message (kcontext, err_str);
+ krb5_set_error_message (kcontext, status,
+ "Unable to find requested database type");
goto clean_n_exit;
}
- clean_n_exit:
+ memcpy(&(*lib)->vftabl, vftabl_addrs[0], sizeof(kdb_vftabl));
+ kdb_setup_opt_functions(*lib);
+
+ if ((status = (*lib)->vftabl.init_library())) {
+ /* ERROR. library not initialized cleanly */
+ goto clean_n_exit;
+ }
+
+clean_n_exit:
+ if (vftabl_addrs != NULL) { krb5int_free_plugin_dir_data (vftabl_addrs); }
/* Both of these DTRT with NULL. */
profile_free_list(profpath);
free(path);
if (status) {
- if (*lib) {
+ if (*lib) {
kdb_destroy_lib_lock(*lib);
- if ((*lib)->dl_handle) {
- krb5int_close_plugin((*lib)->dl_handle);
- }
+ if (PLUGIN_DIR_OPEN((&(*lib)->dl_dir_handle))) {
+ krb5int_close_plugin_dirs (&(*lib)->dl_dir_handle);
+ }
free(*lib);
*lib = NULL;
}
@@ -485,10 +479,10 @@ kdb_free_library(db_library lib)
}
/* close the library */
- if (lib->dl_handle) {
- krb5int_close_plugin(lib->dl_handle);
- }
-
+ if (PLUGIN_DIR_OPEN((&lib->dl_dir_handle))) {
+ krb5int_close_plugin_dirs (&lib->dl_dir_handle);
+ }
+
kdb_destroy_lib_lock(lib);
if (lib->prev == NULL) {
diff --git a/src/lib/kdb/kdb5.h b/src/lib/kdb/kdb5.h
index a522ac686..9b6d1c70c 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;
- struct plugin_file_handle *dl_handle;
+ struct plugin_dir_handle dl_dir_handle;
kdb_vftabl vftabl;
struct _db_library *next, *prev;
} *db_library;