svn rev #23602: trunk/src/ kdc/ lib/krb5/krb/

ghudson@MIT.EDU ghudson at MIT.EDU
Thu Jan 7 12:26:58 EST 2010


http://src.mit.edu/fisheye/changelog/krb5/?cs=23602
Commit By: ghudson
Log Message:
Make preauth_module_dir override, rather than supplement, the
built-in path list, to avoid problems with running the same preauth
module twice.



Changed Files:
U   trunk/src/kdc/kdc_preauth.c
U   trunk/src/lib/krb5/krb/preauth2.c
Modified: trunk/src/kdc/kdc_preauth.c
===================================================================
--- trunk/src/kdc/kdc_preauth.c	2010-01-07 17:07:36 UTC (rev 23601)
+++ trunk/src/kdc/kdc_preauth.c	2010-01-07 17:26:58 UTC (rev 23602)
@@ -391,45 +391,22 @@
 
 /* Open plugin directories for preauth modules. */
 static krb5_error_code
-open_preauth_plugin_dirs(krb5_context kcontext)
+open_preauth_plugin_dirs(krb5_context ctx)
 {
     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;
+    const char **dirs;
+    krb5_error_code ret;
 
-    /* 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:
+    ret = profile_get_values(ctx->profile, path, &profpath);
+    if (ret != 0 && ret != PROF_NO_RELATION)
+        return ret;
+    dirs = (profpath != NULL) ? (const char **) profpath : objdirs;
+    ret = krb5int_open_plugin_dirs(dirs, NULL, &preauth_plugins, &ctx->err);
     profile_free_list(profpath);
-    free(plugindirs);
-    return retval;
+    return ret;
 }
 
 krb5_error_code

Modified: trunk/src/lib/krb5/krb/preauth2.c
===================================================================
--- trunk/src/lib/krb5/krb/preauth2.c	2010-01-07 17:07:36 UTC (rev 23601)
+++ trunk/src/lib/krb5/krb/preauth2.c	2010-01-07 17:26:58 UTC (rev 23602)
@@ -72,46 +72,23 @@
 
 /* Open plugin directories for preauth modules. */
 static krb5_error_code
-open_preauth_plugin_dirs(krb5_context kcontext)
+open_preauth_plugin_dirs(krb5_context ctx)
 {
     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;
+    const char **dirs;
+    krb5_error_code ret;
 
-    /* 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,
-                                      &kcontext->preauth_plugins,
-                                      &kcontext->err);
-
-cleanup:
+    ret = profile_get_values(ctx->profile, path, &profpath);
+    if (ret != 0 && ret != PROF_NO_RELATION)
+        return ret;
+    dirs = (profpath != NULL) ? (const char **) profpath : objdirs;
+    ret = krb5int_open_plugin_dirs(dirs, NULL, &ctx->preauth_plugins,
+                                   &ctx->err);
     profile_free_list(profpath);
-    free(plugindirs);
-    return retval;
+    return ret;
 }
 
 /* Create the per-krb5_context context. This means loading the modules




More information about the cvs-krb5 mailing list