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;
setlocale(LC_ALL, "");
progname = GET_PROGNAME(argv[0]);
+ set_com_err_hook(extended_com_err_fn);
name = NULL;
mode = DEFAULT;
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))) {
fail('Authenticated as wrong principal')
# Make sure the tickets we acquired didn't become the default
out = realm.run([klist], expected_code=1)
-if 'No credentials cache found' not in out:
+if ' not found' not in out:
fail('Expected error not seen')
realm.run([kdestroy, '-A'])
# Test kdestroy and klist of a non-existent ccache.
realm.run([kdestroy])
output = realm.run([klist], expected_code=1)
-if 'No credentials cache found' not in output:
+if ' not found' not in output:
fail('Expected error message not seen in klist output')
realm.addprinc('alice', password('alice'))
fail('Initial kinit failed to get credentials for alice.')
realm.run([kdestroy])
output = realm.run([klist], expected_code=1)
- if 'No credentials cache found' not in output:
+ if ' not found' not in output:
fail('Initial kdestroy failed to destroy primary cache.')
output = realm.run([klist, '-l'], expected_code=1)
if not output.endswith('---\n') or output.count('\n') != 2:
del realm.env['KRB5CCNAME']
uidstr = str(os.getuid())
out = realm.run([klist], expected_code=1)
-if 'FILE:testdir/abc%s' % uidstr not in out:
+if 'testdir/abc%s' % uidstr not in out:
fail('Wrong ccache in klist')
success('Credential cache tests')