svn rev #24159: trunk/src/ include/ lib/kdb/ plugins/kdb/db2/ plugins/kdb/ldap/ ...

ghudson@MIT.EDU ghudson at MIT.EDU
Fri Jul 2 10:19:39 EDT 2010


http://src.mit.edu/fisheye/changelog/krb5/?cs=24159
Commit By: ghudson
Log Message:
ticket: 6749
status: open

Remove errcode_2_string and release_errcode_string from the DAL table,
and stop using them in kdb5.c.  Modules can simply set error messages
in the krb5 context on error.



Changed Files:
U   trunk/src/include/kdb.h
U   trunk/src/lib/kdb/kdb5.c
U   trunk/src/plugins/kdb/db2/db2_exp.c
U   trunk/src/plugins/kdb/ldap/ldap_exp.c
U   trunk/src/plugins/kdb/ldap/libkdb_ldap/kdb_ldap.h
U   trunk/src/plugins/kdb/ldap/libkdb_ldap/ldap_misc.c
Modified: trunk/src/include/kdb.h
===================================================================
--- trunk/src/include/kdb.h	2010-07-02 14:08:20 UTC (rev 24158)
+++ trunk/src/include/kdb.h	2010-07-02 14:19:39 UTC (rev 24159)
@@ -1133,21 +1133,6 @@
     void (*db_free_policy)(krb5_context kcontext, osa_policy_ent_t val);
 
     /*
-     * Optional: Convert an error code returned by a module function (casted
-     * from krb5_error_code to long) into a string.  If this function is
-     * implemented, libkdb5 will invoke it and call krb5_set_error_message with
-     * the result.  This function may never return NULL.
-     *
-     * This function is not productively implemented in current modules, and it
-     * is better for a module to simply call krb5_set_error_message inside
-     * modules when appropriate.
-     */
-    const char *(*errcode_2_string)(krb5_context kcontext, long err_code);
-
-    /* Optional: Free an error string returned by errcode_2_string. */
-    void (*release_errcode_string)(krb5_context kcontext, const char *msg);
-
-    /*
      * Mandatory: Has the semantics of realloc(ptr, size).  Callers use this to
      * allocate memory for new or changed principal entries, so the module
      * should expect to potentially see this memory in db_free_principal.

Modified: trunk/src/lib/kdb/kdb5.c
===================================================================
--- trunk/src/lib/kdb/kdb5.c	2010-07-02 14:08:20 UTC (rev 24158)
+++ trunk/src/lib/kdb/kdb5.c	2010-07-02 14:19:39 UTC (rev 24159)
@@ -569,25 +569,6 @@
     return 0;
 }
 
-static void
-get_errmsg(krb5_context kcontext, krb5_error_code err_code)
-{
-    kdb_vftabl *v;
-    const char *e;
-
-    if (err_code == 0)
-        return;
-    assert(kcontext != NULL && kcontext->dal_handle != NULL);
-    v = &kcontext->dal_handle->lib_handle->vftabl;
-    if (v->errcode_2_string == NULL)
-        return;
-    e = v->errcode_2_string(kcontext, err_code);
-    assert (e != NULL);
-    krb5_set_error_message(kcontext, err_code, "%s", e);
-    if (v->release_errcode_string)
-        v->release_errcode_string(kcontext, e);
-}
-
 static krb5_error_code
 get_vftabl(krb5_context kcontext, kdb_vftabl **vftabl_ptr)
 {
@@ -627,7 +608,6 @@
         goto clean_n_exit;
     assert(v->init_module != NULL);
     status = v->init_module(kcontext, section, db_args, mode);
-    get_errmsg(kcontext, status);
 
 clean_n_exit:
     if (section)
@@ -666,7 +646,6 @@
         goto clean_n_exit;
     }
     status = v->db_create(kcontext, section, db_args);
-    get_errmsg(kcontext, status);
 
 clean_n_exit:
     if (section)
@@ -687,7 +666,6 @@
     v = &kcontext->dal_handle->lib_handle->vftabl;
     assert(v->fini_module != NULL);
     status = v->fini_module(kcontext);
-    get_errmsg(kcontext, status);
 
     if (status)
         return status;
@@ -719,7 +697,6 @@
         goto clean_n_exit;
     }
     status = v->db_destroy(kcontext, section, db_args);
-    get_errmsg(kcontext, status);
 
 clean_n_exit:
     if (section)
@@ -738,9 +715,7 @@
         return status;
     if (v->db_get_age == NULL)
         return KRB5_KDB_DBTYPE_NOSUP;
-    status = v->db_get_age(kcontext, db_name, t);
-    get_errmsg(kcontext, status);
-    return status;
+    return v->db_get_age(kcontext, db_name, t);
 }
 
 krb5_error_code
@@ -754,9 +729,7 @@
         return status;
     if (v->db_lock == NULL)
         return KRB5_KDB_DBTYPE_NOSUP;
-    status = v->db_lock(kcontext, lock_mode);
-    get_errmsg(kcontext, status);
-    return status;
+    return v->db_lock(kcontext, lock_mode);
 }
 
 krb5_error_code
@@ -770,9 +743,7 @@
         return status;
     if (v->db_unlock == NULL)
         return KRB5_KDB_DBTYPE_NOSUP;
-    status = v->db_unlock(kcontext);
-    get_errmsg(kcontext, status);
-    return status;
+    return v->db_unlock(kcontext);
 }
 
 krb5_error_code
@@ -789,10 +760,8 @@
         return status;
     if (v->db_get_principal == NULL)
         return KRB5_KDB_DBTYPE_NOSUP;
-    status = v->db_get_principal(kcontext, search_for, 0, entries, nentries,
-                                 more);
-    get_errmsg(kcontext, status);
-    return status;
+    return v->db_get_principal(kcontext, search_for, 0, entries, nentries,
+                               more);
 }
 
 krb5_error_code
@@ -810,10 +779,8 @@
         return status;
     if (v->db_get_principal == NULL)
         return KRB5_KDB_DBTYPE_NOSUP;
-    status = v->db_get_principal(kcontext, search_for,
-                                 flags, entries, nentries, more);
-    get_errmsg(kcontext, status);
-    return status;
+    return v->db_get_principal(kcontext, search_for, flags, entries, nentries,
+                               more);
 }
 
 krb5_error_code
@@ -827,9 +794,7 @@
         return status;
     if (v->db_free_principal == NULL)
         return KRB5_KDB_DBTYPE_NOSUP;
-    status = v->db_free_principal(kcontext, entry, count);
-    get_errmsg(kcontext, status);
-    return status;
+    return v->db_free_principal(kcontext, entry, count);
 }
 
 static void
@@ -931,7 +896,6 @@
     if (status)
         return status;
     status = v->db_put_principal(kcontext, entries, nentries, db_args);
-    get_errmsg(kcontext, status);
     free_db_args(kcontext, db_args);
     return status;
 }
@@ -1001,7 +965,6 @@
     }
 
     status = v->db_put_principal(kcontext, entries, nentries, db_args);
-    get_errmsg(kcontext, status);
     if (status == 0 && fupd) {
         upd = fupd;
         for (i = 0; i < *nentries; i++) {
@@ -1035,9 +998,7 @@
         return status;
     if (v->db_delete_principal == NULL)
         return KRB5_KDB_DBTYPE_NOSUP;
-    status = v->db_delete_principal(kcontext, search_for, nentries);
-    get_errmsg(kcontext, status);
-    return status;
+    return v->db_delete_principal(kcontext, search_for, nentries);
 }
 
 krb5_error_code
@@ -1086,7 +1047,6 @@
         return KRB5_KDB_DBTYPE_NOSUP;
 
     status = v->db_delete_principal(kcontext, search_for, nentries);
-    get_errmsg(kcontext, status);
 
     /*
      * We need to commit our update upon success
@@ -1114,9 +1074,7 @@
         return status;
     if (v->db_iterate == NULL)
         return 0;
-    status = v->db_iterate(kcontext, match_entry, func, func_arg);
-    get_errmsg(kcontext, status);
-    return status;
+    return v->db_iterate(kcontext, match_entry, func, func_arg);
 }
 
 krb5_error_code
@@ -1129,9 +1087,7 @@
     status = get_vftabl(kcontext, &v);
     if (status)
         return status;
-    status = v->set_master_key(kcontext, pwd, key);
-    get_errmsg(kcontext, status);
-    return status;
+    return v->set_master_key(kcontext, pwd, key);
 }
 
 krb5_error_code
@@ -1150,9 +1106,7 @@
     status = get_vftabl(kcontext, &v);
     if (status)
         return status;
-    status = v->set_master_key_list(kcontext, keylist);
-    get_errmsg(kcontext, status);
-    return status;
+    return v->set_master_key_list(kcontext, keylist);
 }
 
 krb5_error_code
@@ -1164,9 +1118,7 @@
     status = get_vftabl(kcontext, &v);
     if (status)
         return status;
-    status = v->get_master_key(kcontext, key);
-    get_errmsg(kcontext, status);
-    return status;
+    return v->get_master_key(kcontext, key);
 }
 
 krb5_error_code
@@ -1180,9 +1132,7 @@
         return status;
     if (v->get_master_key_list == NULL)
         return KRB5_KDB_DBTYPE_NOSUP;
-    status = v->get_master_key_list(kcontext, keylist);
-    get_errmsg(kcontext, status);
-    return status;
+    return v->get_master_key_list(kcontext, keylist);
 }
 
 krb5_error_code
@@ -1198,9 +1148,7 @@
     status = get_vftabl(context, &v);
     if (status)
         return status;
-    status = v->fetch_master_key_list(context, mname, mkey, mkvno, mkey_list);
-    get_errmsg(context, status);
-    return status;
+    return v->fetch_master_key_list(context, mname, mkey, mkvno, mkey_list);
 }
 
 krb5_error_code
@@ -1234,10 +1182,8 @@
         return status;
     if (v->store_master_key == NULL)
         return KRB5_KDB_DBTYPE_NOSUP;
-    status = v->store_master_key(kcontext, keyfile, mname, kvno, key,
-                                 master_pwd);
-    get_errmsg(kcontext, status);
-    return status;
+    return v->store_master_key(kcontext, keyfile, mname, kvno, key,
+                               master_pwd);
 }
 
 krb5_error_code
@@ -1255,10 +1201,8 @@
         return status;
     if (v->store_master_key_list == NULL)
         return KRB5_KDB_DBTYPE_NOSUP;
-    status = v->store_master_key_list(kcontext, keyfile, mname, keylist,
-                                      master_pwd);
-    get_errmsg(kcontext, status);
-    return status;
+    return v->store_master_key_list(kcontext, keyfile, mname, keylist,
+                                    master_pwd);
 }
 
 char   *krb5_mkey_pwd_prompt1 = KRB5_KDC_MKEY_1;
@@ -1345,7 +1289,6 @@
 
         v = &context->dal_handle->lib_handle->vftabl;
         retval = v->fetch_master_key(context, mname, &tmp_key, kvno, db_args);
-        get_errmsg(context, retval);
 
         if (retval)
             goto clean_n_exit;
@@ -1384,9 +1327,7 @@
         return status;
     if (v->verify_master_key == NULL)
         return KRB5_KDB_DBTYPE_NOSUP;
-    status = v->verify_master_key(kcontext, mprinc, kvno, mkey);
-    get_errmsg(kcontext, status);
-    return status;
+    return v->verify_master_key(kcontext, mprinc, kvno, mkey);
 }
 
 krb5_error_code
@@ -1610,10 +1551,8 @@
     status = get_vftabl(kcontext, &v);
     if (status)
         return status;
-    status = v->dbe_search_enctype(kcontext, dbentp, start, ktype, stype,
-                                   kvno, kdatap);
-    get_errmsg(kcontext, status);
-    return status;
+    return v->dbe_search_enctype(kcontext, dbentp, start, ktype, stype, kvno,
+                                 kdatap);
 }
 
 #define REALM_SEP_STRING        "@"
@@ -2288,10 +2227,8 @@
     status = get_vftabl(kcontext, &v);
     if (status)
         return status;
-    status = v->db_change_pwd(kcontext, master_key, ks_tuple, ks_tuple_count,
-                              passwd, new_kvno, keepold, db_entry);
-    get_errmsg(kcontext, status);
-    return status;
+    return v->db_change_pwd(kcontext, master_key, ks_tuple, ks_tuple_count,
+                            passwd, new_kvno, keepold, db_entry);
 }
 
 /* policy management functions */
@@ -2306,9 +2243,7 @@
         return status;
     if (v->db_create_policy == NULL)
         return KRB5_KDB_DBTYPE_NOSUP;
-    status = v->db_create_policy(kcontext, policy);
-    get_errmsg(kcontext, status);
-    return status;
+    return v->db_create_policy(kcontext, policy);
 }
 
 krb5_error_code
@@ -2323,9 +2258,7 @@
         return status;
     if (v->db_get_policy == NULL)
         return KRB5_KDB_DBTYPE_NOSUP;
-    status = v->db_get_policy(kcontext, name, policy, cnt);
-    get_errmsg(kcontext, status);
-    return status;
+    return v->db_get_policy(kcontext, name, policy, cnt);
 }
 
 krb5_error_code
@@ -2339,9 +2272,7 @@
         return status;
     if (v->db_put_policy == NULL)
         return KRB5_KDB_DBTYPE_NOSUP;
-    status = v->db_put_policy(kcontext, policy);
-    get_errmsg(kcontext, status);
-    return status;
+    return v->db_put_policy(kcontext, policy);
 }
 
 krb5_error_code
@@ -2356,9 +2287,7 @@
         return status;
     if (v->db_iter_policy == NULL)
         return 0;
-    status = v->db_iter_policy(kcontext, match_entry, func, data);
-    get_errmsg(kcontext, status);
-    return status;
+    return v->db_iter_policy(kcontext, match_entry, func, data);
 }
 
 krb5_error_code
@@ -2372,9 +2301,7 @@
         return status;
     if (v->db_delete_policy == NULL)
         return KRB5_KDB_DBTYPE_NOSUP;
-    status = v->db_delete_policy(kcontext, policy);
-    get_errmsg(kcontext, status);
-    return status;
+    return v->db_delete_policy(kcontext, policy);
 }
 
 void
@@ -2387,7 +2314,6 @@
     if (status || v->db_free_policy == NULL)
         return;
     v->db_free_policy(kcontext, policy);
-    get_errmsg(kcontext, status);
 }
 
 krb5_error_code
@@ -2410,7 +2336,6 @@
     if (status)
         goto clean_n_exit;
     status = v->promote_db(kcontext, section, db_args);
-    get_errmsg(kcontext, status);
 
 clean_n_exit:
     free(section);

Modified: trunk/src/plugins/kdb/db2/db2_exp.c
===================================================================
--- trunk/src/plugins/kdb/db2/db2_exp.c	2010-07-02 14:08:20 UTC (rev 24158)
+++ trunk/src/plugins/kdb/db2/db2_exp.c	2010-07-02 14:19:39 UTC (rev 24159)
@@ -249,8 +249,6 @@
     /* db_iter_policy */                         wrap_krb5_db2_iter_policy,
     /* db_delete_policy */                       wrap_krb5_db2_delete_policy,
     /* db_free_policy */                         wrap_krb5_db2_free_policy,
-    /* errcode_2_string */                       NULL,
-    /* release_errcode_string */                 NULL,
     /* db_alloc */                               krb5_db2_alloc,
     /* db_free */                                krb5_db2_free,
     /* set_master_key */                         wrap_krb5_db2_set_master_key_ext,

Modified: trunk/src/plugins/kdb/ldap/ldap_exp.c
===================================================================
--- trunk/src/plugins/kdb/ldap/ldap_exp.c	2010-07-02 14:08:20 UTC (rev 24158)
+++ trunk/src/plugins/kdb/ldap/ldap_exp.c	2010-07-02 14:19:39 UTC (rev 24159)
@@ -69,8 +69,6 @@
     /* db_iter_policy */                    krb5_ldap_iterate_password_policy,
     /* db_delete_policy */                  krb5_ldap_delete_password_policy,
     /* db_free_policy */                    krb5_ldap_free_password_policy,
-    /* errcode_2_string */                  krb5_ldap_errcode_2_string,
-    /* release_errcode_string */            krb5_ldap_release_errcode_string,
     /* db_alloc */                          krb5_ldap_alloc,
     /* db_free */                           krb5_ldap_free,
     /* optional functions */

Modified: trunk/src/plugins/kdb/ldap/libkdb_ldap/kdb_ldap.h
===================================================================
--- trunk/src/plugins/kdb/ldap/libkdb_ldap/kdb_ldap.h	2010-07-02 14:08:20 UTC (rev 24158)
+++ trunk/src/plugins/kdb/ldap/libkdb_ldap/kdb_ldap.h	2010-07-02 14:19:39 UTC (rev 24159)
@@ -311,12 +311,6 @@
 krb5_error_code
 krb5_ldap_unlock( krb5_context );
 
-const char *
-krb5_ldap_errcode_2_string( krb5_context, long );
-
-void
-krb5_ldap_release_errcode_string (krb5_context, const char *);
-
 #ifndef HAVE_LDAP_INITIALIZE
 int
 ldap_initialize(LDAP **, char *);

Modified: trunk/src/plugins/kdb/ldap/libkdb_ldap/ldap_misc.c
===================================================================
--- trunk/src/plugins/kdb/ldap/libkdb_ldap/ldap_misc.c	2010-07-02 14:08:20 UTC (rev 24158)
+++ trunk/src/plugins/kdb/ldap/libkdb_ldap/ldap_misc.c	2010-07-02 14:19:39 UTC (rev 24159)
@@ -1530,19 +1530,7 @@
     return status;
 }
 
-const char *
-krb5_ldap_errcode_2_string(krb5_context kcontext, long err_code)
-{
-    return krb5_get_error_message(kcontext, err_code);
-}
 
-void
-krb5_ldap_release_errcode_string(krb5_context kcontext, const char *msg)
-{
-    krb5_free_error_message(kcontext, msg);
-}
-
-
 /*
  * Get the number of times an object has been referred to in a realm. this is
  * needed to find out if deleting the attribute will cause dangling links.




More information about the cvs-krb5 mailing list