summaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/kdb/kdb5.c94
-rw-r--r--src/lib/kdb/kdb5.h2
-rw-r--r--src/lib/krb5/os/init_os_ctx.c2
-rw-r--r--src/lib/krb5/os/locate_kdc.c11
4 files changed, 52 insertions, 57 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;
diff --git a/src/lib/krb5/os/init_os_ctx.c b/src/lib/krb5/os/init_os_ctx.c
index e91a05ff1..866038940 100644
--- a/src/lib/krb5/os/init_os_ctx.c
+++ b/src/lib/krb5/os/init_os_ctx.c
@@ -481,7 +481,7 @@ krb5_os_free_context(krb5_context ctx)
ctx->profile = 0;
}
- krb5int_close_plugin_dir (&ctx->libkrb5_plugins);
+ krb5int_close_plugin_dirs (&ctx->libkrb5_plugins);
#ifdef _WIN32
WSACleanup();
diff --git a/src/lib/krb5/os/locate_kdc.c b/src/lib/krb5/os/locate_kdc.c
index 83b006634..979337a35 100644
--- a/src/lib/krb5/os/locate_kdc.c
+++ b/src/lib/krb5/os/locate_kdc.c
@@ -545,10 +545,10 @@ krb5_locate_srv_dns_1 (const krb5_data *realm,
#include "k5-locate.h"
-#ifdef KFM_FRAMEWORK_PLUGIN_DIR
-static const char objdir[] = KFM_FRAMEWORK_PLUGIN_DIR ;
+#if TARGET_OS_MAC
+static const char *objdirs[] = { KRB5_PLUGIN_BUNDLE_DIR, LIBDIR "/krb5/plugins/libkrb5", NULL }; /* should be a list */
#else
-static const char objdir[] = LIBDIR "/krb5/plugins/libkrb5";
+static const char *objdirs[] = { LIBDIR "/krb5/plugins/libkrb5", NULL };
#endif
struct module_callback_data {
@@ -612,8 +612,9 @@ module_locate_server (krb5_context ctx, const krb5_data *realm,
Tprintf("in module_locate_server\n");
cbdata.lp = addrlist;
if (!PLUGIN_DIR_OPEN (&ctx->libkrb5_plugins)) {
- code = krb5int_open_plugin_dir (objdir, &ctx->libkrb5_plugins,
- &ctx->err);
+
+ code = krb5int_open_plugin_dirs (objdirs, NULL, &ctx->libkrb5_plugins,
+ &ctx->err);
if (code)
return KRB5_PLUGIN_NO_HANDLE;
}