summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGreg Hudson <ghudson@mit.edu>2010-01-04 21:22:00 +0000
committerGreg Hudson <ghudson@mit.edu>2010-01-04 21:22:00 +0000
commit5b815bc782b211e800babfc9fafb521a2c16098b (patch)
tree89e514ed897788de4adc214adbc4de7577d097dd /src
parent5cc1fcb345d57e7ac9203ab1d92a0a509de9193f (diff)
downloadkrb5-5b815bc782b211e800babfc9fafb521a2c16098b.tar.gz
krb5-5b815bc782b211e800babfc9fafb521a2c16098b.tar.xz
krb5-5b815bc782b211e800babfc9fafb521a2c16098b.zip
Add preauth_module_dir support to the KDC preauth module loader
(should have been part of r23531). Most or all of this logic should be moved into the plugin code or a layer above it, after the branch. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@23584 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src')
-rw-r--r--src/kdc/kdc_preauth.c47
1 files changed, 44 insertions, 3 deletions
diff --git a/src/kdc/kdc_preauth.c b/src/kdc/kdc_preauth.c
index d14b18333..18052cf4e 100644
--- a/src/kdc/kdc_preauth.c
+++ b/src/kdc/kdc_preauth.c
@@ -389,6 +389,49 @@ static krb5_preauth_systems *preauth_systems;
static int n_preauth_systems;
static struct plugin_dir_handle preauth_plugins;
+/* Open plugin directories for preauth modules. */
+static krb5_error_code
+open_preauth_plugin_dirs(krb5_context kcontext)
+{
+ static const char *path[] = {
+ KRB5_CONF_LIBDEFAULTS, KRB5_CONF_PREAUTH_MODULE_DIR, NULL,
+ };
+ char **profpath = NULL;
+ const char **plugindirs = NULL;
+ size_t nprofdirs, nobjdirs;
+ krb5_error_code retval;
+
+ /* Fetch the list of paths specified in the profile, if any. */
+ retval = profile_get_values(kcontext->profile, path, &profpath);
+ if (retval != 0 && retval != PROF_NO_RELATION)
+ return retval;
+
+ /* Count the number of profile dirs. */
+ nprofdirs = 0;
+ if (profpath) {
+ while (profpath[nprofdirs] != NULL)
+ nprofdirs++;
+ }
+
+ nobjdirs = sizeof(objdirs) / sizeof(*objdirs);
+ plugindirs = k5alloc((nprofdirs + nobjdirs) * sizeof(char *), &retval);
+ if (retval != 0)
+ goto cleanup;
+
+ /* Concatenate the profile and hardcoded directory lists. */
+ if (profpath)
+ memcpy(plugindirs, profpath, nprofdirs * sizeof(char *));
+ memcpy(plugindirs + nprofdirs, objdirs, nobjdirs * sizeof(char *));
+
+ retval = krb5int_open_plugin_dirs(plugindirs, NULL, &preauth_plugins,
+ &kcontext->err);
+
+cleanup:
+ profile_free_list(profpath);
+ free(plugindirs);
+ return retval;
+}
+
krb5_error_code
load_preauth_plugins(krb5_context context)
{
@@ -402,10 +445,8 @@ load_preauth_plugins(krb5_context context)
/* Attempt to load all of the preauth plugins we can find. */
PLUGIN_DIR_INIT(&preauth_plugins);
if (PLUGIN_DIR_OPEN(&preauth_plugins) == 0) {
- if (krb5int_open_plugin_dirs(objdirs, NULL,
- &preauth_plugins, &context->err) != 0) {
+ if (open_preauth_plugin_dirs(context) != 0)
return KRB5_PLUGIN_NO_HANDLE;
- }
}
/* Get the method tables provided by the loaded plugins. */