summaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
authorKen Raeburn <raeburn@mit.edu>2005-08-17 02:22:14 +0000
committerKen Raeburn <raeburn@mit.edu>2005-08-17 02:22:14 +0000
commitdc576447d2e573082e64575885d54a1f87ac1beb (patch)
treeebc136549e63dc110ba63a46d65db7f5f8848f2b /src/lib
parent24d1bca4a0bacd4a691b699b254e8b130872a565 (diff)
downloadkrb5-dc576447d2e573082e64575885d54a1f87ac1beb.tar.gz
krb5-dc576447d2e573082e64575885d54a1f87ac1beb.tar.xz
krb5-dc576447d2e573082e64575885d54a1f87ac1beb.zip
* kdb5.c (kdb_load_library): Look up db_modules>db_module_dir in config file,
and use any indicated directories before the compiled-in directories. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@17337 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/kdb/ChangeLog6
-rw-r--r--src/lib/kdb/kdb5.c33
2 files changed, 37 insertions, 2 deletions
diff --git a/src/lib/kdb/ChangeLog b/src/lib/kdb/ChangeLog
index d62537cd5..344eeb20f 100644
--- a/src/lib/kdb/ChangeLog
+++ b/src/lib/kdb/ChangeLog
@@ -1,3 +1,9 @@
+2005-08-16 Ken Raeburn <raeburn@mit.edu>
+
+ * kdb5.c (kdb_load_library): Look up db_modules>db_module_dir in
+ config file, and use any indicated directories before the
+ compiled-in directories.
+
2005-07-06 Ken Raeburn <raeburn@mit.edu>
* kdb5.c (kdb_get_library_name, kdb_load_library): Change default
diff --git a/src/lib/kdb/kdb5.c b/src/lib/kdb/kdb5.c
index 0eb6a45dd..82bcf8f32 100644
--- a/src/lib/kdb/kdb5.c
+++ b/src/lib/kdb/kdb5.c
@@ -349,6 +349,7 @@ kdb_load_library(krb5_context kcontext, char *lib_name, db_library * lib)
#else
static char *db_dl_location[] = DEFAULT_KDB_LIB_PATH;
+#define db_dl_n_locations (sizeof(db_dl_location) / sizeof(db_dl_location[0]))
static krb5_error_code
kdb_load_library(krb5_context kcontext, char *lib_name, db_library * lib)
@@ -358,6 +359,11 @@ kdb_load_library(krb5_context kcontext, char *lib_name, db_library * lib)
int ndx;
void *vftabl_addr;
char *err_str = NULL;
+ const char *const dbpath_names[] = {
+ KDB_MODULE_SECTION, "db_module_dir", NULL,
+ };
+ char **profpath = NULL;
+ char **path = NULL;
if (!strcmp("db2", lib_name) && (kdb_db2_pol_err_loaded == 0)) {
initialize_adb_error_table();
@@ -377,8 +383,28 @@ kdb_load_library(krb5_context kcontext, char *lib_name, db_library * lib)
strcpy((*lib)->name, lib_name);
- for (ndx = 0; db_dl_location[ndx]; ndx++) {
- sprintf(dl_name, "%s/%s.so", db_dl_location[ndx], lib_name);
+ /* Fetch the list of directories specified in the config
+ file(s) first. */
+ status = profile_get_values(kcontext->profile, dbpath_names, &profpath);
+ if (status != 0 && status != PROF_NO_RELATION)
+ goto clean_n_exit;
+ ndx = 0;
+ if (profpath)
+ while (profpath[ndx] != NULL)
+ ndx++;
+
+ path = calloc(ndx + db_dl_n_locations, sizeof (char *));
+ if (path == NULL) {
+ status = errno;
+ goto clean_n_exit;
+ }
+ if (ndx)
+ memcpy(path, profpath, ndx * sizeof(profpath[0]));
+ memcpy(path + ndx, db_dl_location, db_dl_n_locations * sizeof(char *));
+ 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) {
/* found the module */
@@ -417,6 +443,9 @@ kdb_load_library(krb5_context kcontext, char *lib_name, db_library * lib)
}
clean_n_exit:
+ /* Both of these DTRT with NULL. */
+ profile_free_list(profpath);
+ free(path);
if (status) {
if (*lib) {
kdb_destroy_lib_lock(*lib);