diff options
author | Greg Hudson <ghudson@mit.edu> | 2016-07-01 11:10:19 -0400 |
---|---|---|
committer | Tom Yu <tlyu@mit.edu> | 2016-07-06 16:23:43 -0400 |
commit | dcc8b9541947024386905d73a966f458e94ac3d5 (patch) | |
tree | 9664ede4b7cf885e156f85f8282b99a934e9c588 | |
parent | c0a12661789ac536f0657506f0541dfb4d8a0cd9 (diff) | |
download | krb5-dcc8b9541947024386905d73a966f458e94ac3d5.zip krb5-dcc8b9541947024386905d73a966f458e94ac3d5.tar.gz krb5-dcc8b9541947024386905d73a966f458e94ac3d5.tar.bz2 |
Improve kdb5 error when default realm is unset
When the default realm name is unspecified, and none was set in the
krb5_context object, return KRB5_CONFIG_NODEFREALM from libkdb5
instead of the confusing KRB5_KDB_DBTYPE_NOTFOUND. To accomplish
this, make kdb_get_library_name() return a krb5_error_code.
(cherry picked from commit 4131988dec0199287765e1875fe0bbd375656a62)
ticket: 8448
version_fixed: 1.14.3
tags: -pullup
status: resolved
-rw-r--r-- | src/lib/kdb/kdb5.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/src/lib/kdb/kdb5.c b/src/lib/kdb/kdb5.c index 50daf74..b85af5a 100644 --- a/src/lib/kdb/kdb5.c +++ b/src/lib/kdb/kdb5.c @@ -239,11 +239,13 @@ get_conf_section(krb5_context context, char **section) return 0; } -static char * -kdb_get_library_name(krb5_context kcontext) +static krb5_error_code +kdb_get_library_name(krb5_context kcontext, char **libname_out) { krb5_error_code status = 0; - char *result = NULL, *value = NULL, *lib = NULL, *defrealm = NULL; + char *value = NULL, *lib = NULL, *defrealm = NULL; + + *libname_out = NULL; status = krb5_get_default_realm(kcontext, &defrealm); if (status) @@ -272,12 +274,15 @@ kdb_get_library_name(krb5_context kcontext) goto clean_n_exit; } - result = strdup(lib); + *libname_out = strdup(lib); + if (*libname_out == NULL) + status = ENOMEM; + clean_n_exit: krb5_free_default_realm(kcontext, defrealm); profile_release_string(value); profile_release_string(lib); - return result; + return status; } static void @@ -554,9 +559,10 @@ krb5_db_setup_lib_handle(krb5_context kcontext) goto clean_n_exit; } - library = kdb_get_library_name(kcontext); + status = kdb_get_library_name(kcontext, &library); if (library == NULL) { - status = KRB5_KDB_DBTYPE_NOTFOUND; + k5_prependmsg(kcontext, status, + _("Cannot initialize database library")); goto clean_n_exit; } |