Read config file and allow multi directories.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@19004 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -52,7 +52,9 @@ struct plugin {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static HEIMDAL_MUTEX plugin_mutex = HEIMDAL_MUTEX_INITIALIZER;
|
static HEIMDAL_MUTEX plugin_mutex = HEIMDAL_MUTEX_INITIALIZER;
|
||||||
struct plugin *registered = NULL;
|
static struct plugin *registered = NULL;
|
||||||
|
|
||||||
|
static const char *plugin_dir = LIBDIR "/plugin/krb5";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
@@ -146,7 +148,8 @@ _krb5_plugin_find(krb5_context context,
|
|||||||
struct krb5_plugin *e;
|
struct krb5_plugin *e;
|
||||||
struct plugin *p;
|
struct plugin *p;
|
||||||
krb5_error_code ret;
|
krb5_error_code ret;
|
||||||
const char *dir;
|
char *sysdirs[2] = { NULL, NULL };
|
||||||
|
char **dirs = NULL, **di;
|
||||||
struct dirent *entry;
|
struct dirent *entry;
|
||||||
char *path;
|
char *path;
|
||||||
DIR *d = NULL;
|
DIR *d = NULL;
|
||||||
@@ -173,40 +176,49 @@ _krb5_plugin_find(krb5_context context,
|
|||||||
}
|
}
|
||||||
HEIMDAL_MUTEX_unlock(&plugin_mutex);
|
HEIMDAL_MUTEX_unlock(&plugin_mutex);
|
||||||
|
|
||||||
dir = "/usr/heimdal/lib/krb5/plugins";
|
dirs = krb5_config_get_strings(context, NULL, "libdefaults",
|
||||||
|
"plugin_dir", NULL);
|
||||||
/* XXX allow more directories */
|
if (dirs == NULL) {
|
||||||
|
sysdirs[0] = rk_UNCONST(plugin_dir);
|
||||||
d = opendir(dir);
|
dirs = sysdirs;
|
||||||
if (d == NULL) {
|
|
||||||
if (*list == NULL) {
|
|
||||||
ret = errno;
|
|
||||||
krb5_set_error_string(context, "failed to open directory %s", dir);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
while ((entry = readdir(d)) != NULL) {
|
for (di = dirs; *di != NULL; di++) {
|
||||||
asprintf(&path, "%s/%s", dir, entry->d_name);
|
|
||||||
if (path == NULL) {
|
d = opendir(*di);
|
||||||
krb5_set_error_string(context, "out of memory");
|
if (d == NULL)
|
||||||
ret = ENOMEM;
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
ret = loadlib(context, type, name, path, &e);
|
|
||||||
free(path);
|
|
||||||
if (ret)
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
e->next = *list;
|
while ((entry = readdir(d)) != NULL) {
|
||||||
*list = e;
|
asprintf(&path, "%s/%s", *di, entry->d_name);
|
||||||
|
if (path == NULL) {
|
||||||
|
krb5_set_error_string(context, "out of memory");
|
||||||
|
ret = ENOMEM;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
ret = loadlib(context, type, name, path, &e);
|
||||||
|
free(path);
|
||||||
|
if (ret)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
e->next = *list;
|
||||||
|
*list = e;
|
||||||
|
}
|
||||||
|
closedir(d);
|
||||||
|
}
|
||||||
|
if (dirs != sysdirs)
|
||||||
|
krb5_config_free_strings(dirs);
|
||||||
|
|
||||||
|
if (*list == NULL) {
|
||||||
|
krb5_set_error_string(context, "Did not find a plugin for %s", name);
|
||||||
|
return ENOENT;
|
||||||
}
|
}
|
||||||
closedir(d);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
out:
|
out:
|
||||||
|
if (dirs && dirs != sysdirs)
|
||||||
|
krb5_config_free_strings(dirs);
|
||||||
if (d)
|
if (d)
|
||||||
closedir(d);
|
closedir(d);
|
||||||
_krb5_plugin_free(*list);
|
_krb5_plugin_free(*list);
|
||||||
|
Reference in New Issue
Block a user