summaryrefslogtreecommitdiffstats
path: root/src/clients
diff options
context:
space:
mode:
authorGreg Hudson <ghudson@mit.edu>2013-12-20 11:06:52 -0500
committerGreg Hudson <ghudson@mit.edu>2013-12-20 23:10:03 -0500
commitae027dd69fc80cca549c9198d10afad389f30873 (patch)
tree343dc9b63543d39b682296b7ff6ca3d16c9f877c /src/clients
parentc25fc42e8eac7350209df61e4a7b9960d17755ca (diff)
downloadkrb5-ae027dd69fc80cca549c9198d10afad389f30873.tar.gz
krb5-ae027dd69fc80cca549c9198d10afad389f30873.tar.xz
krb5-ae027dd69fc80cca549c9198d10afad389f30873.zip
Use an extended com_err hook in klist
Add an adapted version of extended_com_err_fn from kinit to klist and use it. In do_ccache(), rely on the ccache type to set a reasonable message if krb5_cc_set_flags() or krb5_cc_get_principal() fails due to a nonexistent or unreadable ccache, and don't confuse the user with the name of the ccache operation that failed. ticket: 7809
Diffstat (limited to 'src/clients')
-rw-r--r--src/clients/klist/klist.c35
1 files changed, 17 insertions, 18 deletions
diff --git a/src/clients/klist/klist.c b/src/clients/klist/klist.c
index 745a460854..15e75bb8c6 100644
--- a/src/clients/klist/klist.c
+++ b/src/clients/klist/klist.c
@@ -112,6 +112,19 @@ static void usage()
exit(1);
}
+static void
+extended_com_err_fn(const char *prog, errcode_t code, const char *fmt,
+ va_list args)
+{
+ const char *msg;
+
+ msg = krb5_get_error_message(kcontext, code);
+ fprintf(stderr, "%s: %s%s", prog, msg, (*fmt == '\0') ? "" : " ");
+ krb5_free_error_message(kcontext, msg);
+ vfprintf(stderr, fmt, args);
+ fprintf(stderr, "\n");
+}
+
int
main(argc, argv)
int argc;
@@ -123,6 +136,7 @@ main(argc, argv)
setlocale(LC_ALL, "");
progname = GET_PROGNAME(argv[0]);
+ set_com_err_hook(extended_com_err_fn);
name = NULL;
mode = DEFAULT;
@@ -472,28 +486,13 @@ do_ccache(krb5_ccache cache)
flags = 0; /* turns off OPENCLOSE mode */
if ((code = krb5_cc_set_flags(kcontext, cache, flags))) {
- if (code == KRB5_FCC_NOFILE) {
- if (!status_only) {
- com_err(progname, code, _("(ticket cache %s:%s)"),
- krb5_cc_get_type(kcontext, cache),
- krb5_cc_get_name(kcontext, cache));
-#ifdef KRB5_KRB4_COMPAT
- if (name == NULL)
- do_v4_ccache(0);
-#endif
- }
- } else {
- if (!status_only)
- com_err(progname, code,
- _("while setting cache flags (ticket cache %s:%s)"),
- krb5_cc_get_type(kcontext, cache),
- krb5_cc_get_name(kcontext, cache));
- }
+ if (!status_only)
+ com_err(progname, code, "");
return 1;
}
if ((code = krb5_cc_get_principal(kcontext, cache, &princ))) {
if (!status_only)
- com_err(progname, code, _("while retrieving principal name"));
+ com_err(progname, code, "");
return 1;
}
if ((code = krb5_unparse_name(kcontext, princ, &defname))) {