pull up r18873 from trunk
authorTom Yu <tlyu@mit.edu>
Thu, 30 Nov 2006 21:30:42 +0000 (21:30 +0000)
committerTom Yu <tlyu@mit.edu>
Thu, 30 Nov 2006 21:30:42 +0000 (21:30 +0000)
 r18873@cathode-dark-space:  coffman | 2006-11-28 19:17:52 -0500
 ticket: new
 subject: skip all modules in plugin if init function fails
 Target_Version: 1.6
 Tags: pullup
 Component: krb5-kdc

 If the plugin initialization function fails, skip all modules in
 the plugin, not just the first.  Also, print the error message from
 the plugin if supplied.

ticket: 4942
version_fixed: 1.6

git-svn-id: svn://anonsvn.mit.edu/krb5/branches/krb5-1-6@18886 dc483132-0cff-0310-8789-dd5450dbe970

src/kdc/kdc_preauth.c

index 9994ae3ea8aac25706ab5347e17d76bdcd2c24b9..6c362d9e61ac2935f3515aa37f937c3780175f5c 100644 (file)
@@ -394,10 +394,22 @@ load_preauth_plugins(krb5_context context)
                 * from the list of modules we'll be using. */
                if (j == 0) {
                    server_init_proc = ftable->init_proc;
-                   if ((server_init_proc != NULL) &&
-                       ((*server_init_proc)(context, &plugin_context) != 0)) {
-                       memset(&preauth_systems[k], 0, sizeof(preauth_systems[k]));
-                       continue;
+                   if (server_init_proc != NULL) {
+                       krb5_error_code initerr;
+                       initerr = (*server_init_proc)(context, &plugin_context);
+                       if (initerr) {
+                           const char *emsg;
+                           emsg = krb5_get_error_message(context, initerr);
+                           if (emsg) {
+                               krb5_klog_syslog(LOG_ERR,
+                                       "preauth %s failed to initialize: %s",
+                                       ftable->name, emsg);
+                               krb5_free_error_message(context, emsg);
+                           }
+                           memset(&preauth_systems[k], 0, sizeof(preauth_systems[k]));
+
+                           break;      /* skip all modules in this plugin */
+                       }
                    }
                }
                preauth_systems[k].name = ftable->name;