krb5 commit: Improve kdb5 error when default realm is unset
Greg Hudson
ghudson at mit.edu
Fri Jul 1 14:26:31 EDT 2016
https://github.com/krb5/krb5/commit/4131988dec0199287765e1875fe0bbd375656a62
commit 4131988dec0199287765e1875fe0bbd375656a62
Author: Greg Hudson <ghudson at mit.edu>
Date: Fri Jul 1 11:10:19 2016 -0400
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.
ticket: 8448
target_version: 1.14-next
target_version: 1.13-next
tags: pullup
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 2886d05..713b39d 100644
--- a/src/lib/kdb/kdb5.c
+++ b/src/lib/kdb/kdb5.c
@@ -236,11 +236,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)
@@ -269,12 +271,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
@@ -553,9 +558,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;
}
More information about the cvs-krb5
mailing list