From ae8860583d2c2356b165a7936b8bcd2984e1a9a1 Mon Sep 17 00:00:00 2001 From: Greg Hudson Date: Sat, 3 Jul 2010 19:02:41 +0000 Subject: [PATCH] Use KRB5_PLUGIN_OP_NOTSUPP uniformly as the error code for operations not supported by a KDB module. (Previously KRB5_KDB_DBTYPE_NOSUP was used in some cases and KRB5_PLUGIN_OP_NOTSUPP in others.) ticket: 6749 status: open git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@24170 dc483132-0cff-0310-8789-dd5450dbe970 --- src/include/kdb.h | 16 ++++----- src/kdc/kdc_authdata.c | 2 +- src/kdc/kdc_util.c | 4 +-- src/kdc/policy.c | 4 +-- src/lib/kdb/kdb5.c | 38 +++++++++++----------- src/plugins/kdb/db2/kdb_ext.c | 2 +- src/plugins/kdb/ldap/libkdb_ldap/kdb_ext.c | 2 +- 7 files changed, 33 insertions(+), 35 deletions(-) diff --git a/src/include/kdb.h b/src/include/kdb.h index f7765c58b..425e7247c 100644 --- a/src/include/kdb.h +++ b/src/include/kdb.h @@ -824,7 +824,7 @@ krb5_dbe_free_tl_data(krb5_context, krb5_tl_data *); * Some module functions are mandatory for KDC operation; others are optional * or apply only to administrative operations. If a function is optional, a * module can leave the function pointer as NULL. Alternatively, modules can - * return KRB5_KDB_DBTYPE_NOSUP when asked to perform an inapplicable action. + * return KRB5_PLUGIN_OP_NOTSUPP when asked to perform an inapplicable action. * * Some module functions have default implementations which will call back into * the vtable interface. Leave these functions as NULL to use the default @@ -916,9 +916,8 @@ typedef struct _kdb_vftabl { * * Used by the "kadmin lock" command, incremental propagation, and * kdb5_util dump. Incremental propagation support requires shared locks - * to operate. kdb5_util dump will work if the module returns - * KRB5_PLUGIN_OP_NOTSUPP; note that this is *not* the usual "operation - * not supported" error code. + * to operate. kdb5_util dump will continue unlocked if the module returns + * KRB5_PLUGIN_OP_NOTSUPP. */ krb5_error_code (*lock)(krb5_context kcontext, int mode); @@ -1201,9 +1200,8 @@ typedef struct _kdb_vftabl { * invokes this function when the load is complete, thus replacing the live * database with no loss of read availability. * - * The default implementation returns KRB5_PLUGIN_OP_NOTSUPP (which is - * *not* the usual "operation not supported" error code); kdb5_util dump - * recognizes and ignores this error code. + * The default implementation returns KRB5_PLUGIN_OP_NOTSUPP; kdb5_util + * dump recognizes and ignores this error code. */ krb5_error_code (*promote_db)(krb5_context context, char *conf_section, char **db_args); @@ -1244,7 +1242,7 @@ typedef struct _kdb_vftabl { /* * Optional: Perform an operation on input data req with output stored in - * rep. Return KRB5_KDB_DBTYPE_NOSUP if the module does not implement the + * rep. Return KRB5_PLUGIN_OP_NOTSUPP if the module does not implement the * method. Defined methods are: * * KRB5_KDB_METHOD_SIGN_AUTH_DATA: req contains a krb5_sign_auth_data_req @@ -1260,7 +1258,7 @@ typedef struct _kdb_vftabl { * KRB5_KDB_METHOD_CHECK_TRANSITED_REALMS: req contains a * kdb_check_transited_realms_req structure. Perform a policy check on * a cross-realm ticket's transited field and return an error (other - * than KRB5_KDB_DBTYPE_NOSUP) if the check fails. Leave rep alone. + * than KRB5_PLUGIN_OP_NOTSUPP) if the check fails. Leave rep alone. * * KRB5_KDB_METHOD_CHECK_POLICY_AS: req contains a kdb_check_policy_as_req * structure. Perform a policy check on an AS request, in addition to diff --git a/src/kdc/kdc_authdata.c b/src/kdc/kdc_authdata.c index b5de64de2..90deae5b5 100644 --- a/src/kdc/kdc_authdata.c +++ b/src/kdc/kdc_authdata.c @@ -741,7 +741,7 @@ handle_kdb_authdata (krb5_context context, FALSE); /* !ignore_kdc_issued */ if (code != 0) krb5_free_authdata(context, db_authdata); - } else if (code == KRB5_KDB_DBTYPE_NOSUP) + } else if (code == KRB5_PLUGIN_OP_NOTSUPP) code = 0; return code; diff --git a/src/kdc/kdc_util.c b/src/kdc/kdc_util.c index 16c06296a..61fd9b345 100644 --- a/src/kdc/kdc_util.c +++ b/src/kdc/kdc_util.c @@ -2294,7 +2294,7 @@ check_allowed_to_delegate_to(krb5_context context, KRB5_KDB_METHOD_CHECK_ALLOWED_TO_DELEGATE, &req_data, &rep_data); - if (code == KRB5_KDB_DBTYPE_NOSUP) { + if (code == KRB5_PLUGIN_OP_NOTSUPP) { code = KRB5KDC_ERR_POLICY; } @@ -2380,7 +2380,7 @@ kdc_check_transited_list(krb5_context context, KRB5_KDB_METHOD_CHECK_TRANSITED_REALMS, &req_data, &rep_data); - if (code == KRB5_KDB_DBTYPE_NOSUP) { + if (code == KRB5_PLUGIN_OP_NOTSUPP) { code = 0; } diff --git a/src/kdc/policy.c b/src/kdc/policy.c index aefddfffc..fa403e58c 100644 --- a/src/kdc/policy.c +++ b/src/kdc/policy.c @@ -95,7 +95,7 @@ against_local_policy_as(register krb5_kdc_req *request, krb5_db_entry client, KRB5_KDB_METHOD_CHECK_POLICY_AS, &req_data, &rep_data); - if (code == KRB5_KDB_DBTYPE_NOSUP) + if (code == KRB5_PLUGIN_OP_NOTSUPP) return 0; *status = rep.status; @@ -153,7 +153,7 @@ against_local_policy_tgs(register krb5_kdc_req *request, krb5_db_entry server, KRB5_KDB_METHOD_CHECK_POLICY_TGS, &req_data, &rep_data); - if (code == KRB5_KDB_DBTYPE_NOSUP) + if (code == KRB5_PLUGIN_OP_NOTSUPP) return 0; *status = rep.status; diff --git a/src/lib/kdb/kdb5.c b/src/lib/kdb/kdb5.c index 7b31a96dc..e89d3244e 100644 --- a/src/lib/kdb/kdb5.c +++ b/src/lib/kdb/kdb5.c @@ -292,7 +292,7 @@ kdb_load_library(krb5_context kcontext, char *lib_name, db_library *libptr) krb5_set_error_message(kcontext, KRB5_KDB_DBTYPE_NOTFOUND, "Unable to find requested database type: %s", lib_name); - return KRB5_KDB_DBTYPE_NOSUP; + return KRB5_PLUGIN_OP_NOTSUPP; } lib = calloc(1, sizeof(*lib)); @@ -634,7 +634,7 @@ krb5_db_create(krb5_context kcontext, char **db_args) if (status) goto clean_n_exit; if (v->create == NULL) { - status = KRB5_KDB_DBTYPE_NOSUP; + status = KRB5_PLUGIN_OP_NOTSUPP; goto clean_n_exit; } status = v->create(kcontext, section, db_args); @@ -685,7 +685,7 @@ krb5_db_destroy(krb5_context kcontext, char **db_args) if (status) goto clean_n_exit; if (v->destroy == NULL) { - status = KRB5_KDB_DBTYPE_NOSUP; + status = KRB5_PLUGIN_OP_NOTSUPP; goto clean_n_exit; } status = v->destroy(kcontext, section, db_args); @@ -706,7 +706,7 @@ krb5_db_get_age(krb5_context kcontext, char *db_name, time_t * t) if (status) return status; if (v->get_age == NULL) - return KRB5_KDB_DBTYPE_NOSUP; + return KRB5_PLUGIN_OP_NOTSUPP; return v->get_age(kcontext, db_name, t); } @@ -720,7 +720,7 @@ krb5_db_lock(krb5_context kcontext, int lock_mode) if (status) return status; if (v->lock == NULL) - return KRB5_KDB_DBTYPE_NOSUP; + return KRB5_PLUGIN_OP_NOTSUPP; return v->lock(kcontext, lock_mode); } @@ -734,7 +734,7 @@ krb5_db_unlock(krb5_context kcontext) if (status) return status; if (v->unlock == NULL) - return KRB5_KDB_DBTYPE_NOSUP; + return KRB5_PLUGIN_OP_NOTSUPP; return v->unlock(kcontext); } @@ -751,7 +751,7 @@ krb5_db_get_principal(krb5_context kcontext, if (status) return status; if (v->get_principal == NULL) - return KRB5_KDB_DBTYPE_NOSUP; + return KRB5_PLUGIN_OP_NOTSUPP; return v->get_principal(kcontext, search_for, 0, entries, nentries, more); } @@ -769,7 +769,7 @@ krb5_db_get_principal_ext(krb5_context kcontext, if (status) return status; if (v->get_principal == NULL) - return KRB5_KDB_DBTYPE_NOSUP; + return KRB5_PLUGIN_OP_NOTSUPP; return v->get_principal(kcontext, search_for, flags, entries, nentries, more); } @@ -878,7 +878,7 @@ krb5int_put_principal_no_log(krb5_context kcontext, if (status) return status; if (v->put_principal == NULL) - return KRB5_KDB_DBTYPE_NOSUP; + return KRB5_PLUGIN_OP_NOTSUPP; status = extract_db_args_from_tl_data(kcontext, &entries->tl_data, &entries->n_tl_data, &db_args); @@ -949,7 +949,7 @@ krb5_db_put_principal(krb5_context kcontext, } if (v->put_principal == NULL) { - status = KRB5_KDB_DBTYPE_NOSUP; + status = KRB5_PLUGIN_OP_NOTSUPP; goto err_lock; } @@ -986,7 +986,7 @@ krb5int_delete_principal_no_log(krb5_context kcontext, if (status) return status; if (v->delete_principal == NULL) - return KRB5_KDB_DBTYPE_NOSUP; + return KRB5_PLUGIN_OP_NOTSUPP; return v->delete_principal(kcontext, search_for, nentries); } @@ -1033,7 +1033,7 @@ krb5_db_delete_principal(krb5_context kcontext, } if (v->delete_principal == NULL) - return KRB5_KDB_DBTYPE_NOSUP; + return KRB5_PLUGIN_OP_NOTSUPP; status = v->delete_principal(kcontext, search_for, nentries); @@ -1089,7 +1089,7 @@ krb5_db_get_mkey_list(krb5_context kcontext, krb5_keylist_node ** keylist) if (status) return status; if (v->get_master_key_list == NULL) - return KRB5_KDB_DBTYPE_NOSUP; + return KRB5_PLUGIN_OP_NOTSUPP; return v->get_master_key_list(kcontext, keylist); } @@ -1153,7 +1153,7 @@ krb5_db_store_master_key_list(krb5_context kcontext, if (status) return status; if (v->store_master_key_list == NULL) - return KRB5_KDB_DBTYPE_NOSUP; + return KRB5_PLUGIN_OP_NOTSUPP; return v->store_master_key_list(kcontext, keyfile, mname, keylist, master_pwd); } @@ -2178,7 +2178,7 @@ krb5_db_create_policy(krb5_context kcontext, osa_policy_ent_t policy) if (status) return status; if (v->create_policy == NULL) - return KRB5_KDB_DBTYPE_NOSUP; + return KRB5_PLUGIN_OP_NOTSUPP; return v->create_policy(kcontext, policy); } @@ -2193,7 +2193,7 @@ krb5_db_get_policy(krb5_context kcontext, char *name, if (status) return status; if (v->get_policy == NULL) - return KRB5_KDB_DBTYPE_NOSUP; + return KRB5_PLUGIN_OP_NOTSUPP; return v->get_policy(kcontext, name, policy, cnt); } @@ -2207,7 +2207,7 @@ krb5_db_put_policy(krb5_context kcontext, osa_policy_ent_t policy) if (status) return status; if (v->put_policy == NULL) - return KRB5_KDB_DBTYPE_NOSUP; + return KRB5_PLUGIN_OP_NOTSUPP; return v->put_policy(kcontext, policy); } @@ -2236,7 +2236,7 @@ krb5_db_delete_policy(krb5_context kcontext, char *policy) if (status) return status; if (v->delete_policy == NULL) - return KRB5_KDB_DBTYPE_NOSUP; + return KRB5_PLUGIN_OP_NOTSUPP; return v->delete_policy(kcontext, policy); } @@ -2342,6 +2342,6 @@ krb5_db_invoke(krb5_context kcontext, if (status) return status; if (v->invoke == NULL) - return KRB5_KDB_DBTYPE_NOSUP; + return KRB5_PLUGIN_OP_NOTSUPP; return v->invoke(kcontext, method, req, rep); } diff --git a/src/plugins/kdb/db2/kdb_ext.c b/src/plugins/kdb/db2/kdb_ext.c index f75767db0..1895b70e4 100644 --- a/src/plugins/kdb/db2/kdb_ext.c +++ b/src/plugins/kdb/db2/kdb_ext.c @@ -80,7 +80,7 @@ krb5_db2_invoke(krb5_context context, const krb5_data *req, krb5_data *rep) { - krb5_error_code code = KRB5_KDB_DBTYPE_NOSUP; + krb5_error_code code = KRB5_PLUGIN_OP_NOTSUPP; switch (method) { case KRB5_KDB_METHOD_CHECK_POLICY_AS: diff --git a/src/plugins/kdb/ldap/libkdb_ldap/kdb_ext.c b/src/plugins/kdb/ldap/libkdb_ldap/kdb_ext.c index cc8e50abe..fdbb1a17a 100644 --- a/src/plugins/kdb/ldap/libkdb_ldap/kdb_ext.c +++ b/src/plugins/kdb/ldap/libkdb_ldap/kdb_ext.c @@ -114,7 +114,7 @@ krb5_ldap_invoke(krb5_context context, const krb5_data *req, krb5_data *rep) { - krb5_error_code code = KRB5_KDB_DBTYPE_NOSUP; + krb5_error_code code = KRB5_PLUGIN_OP_NOTSUPP; switch (method) { case KRB5_KDB_METHOD_CHECK_POLICY_AS: -- 2.26.2