summaryrefslogtreecommitdiffstats
path: root/src/clients
diff options
context:
space:
mode:
Diffstat (limited to 'src/clients')
-rw-r--r--src/clients/kinit/ChangeLog8
-rw-r--r--src/clients/kinit/kinit.c16
-rw-r--r--src/clients/kvno/ChangeLog8
-rw-r--r--src/clients/kvno/kvno.c34
4 files changed, 56 insertions, 10 deletions
diff --git a/src/clients/kinit/ChangeLog b/src/clients/kinit/ChangeLog
index 63d53ffa9..6b97d7a2b 100644
--- a/src/clients/kinit/ChangeLog
+++ b/src/clients/kinit/ChangeLog
@@ -1,3 +1,11 @@
+2006-03-26 Ken Raeburn <raeburn@mit.edu>
+
+ * kinit.c (extended_com_err_fn): New function.
+ (errctx): New variable.
+ (k5_begin): Set errctx.
+ (k5_end): Clear it.
+ (main): Call set_com_err_hook.
+
2004-07-01 Ken Raeburn <raeburn@mit.edu>
* kinit.c (k5_kinit): Don't free addresses after calling
diff --git a/src/clients/kinit/kinit.c b/src/clients/kinit/kinit.c
index 6ffebadd4..8160822da 100644
--- a/src/clients/kinit/kinit.c
+++ b/src/clients/kinit/kinit.c
@@ -268,6 +268,18 @@ fprintf(stderr, USAGE_OPT_FMT, indent, col1)
exit(2);
}
+static krb5_context errctx;
+static void extended_com_err_fn (const char *myprog, errcode_t code,
+ const char *fmt, va_list args)
+{
+ const char *emsg;
+ emsg = krb5_get_error_message (errctx, code);
+ fprintf (stderr, "%s: %s ", myprog, emsg);
+ krb5_free_error_message (errctx, emsg);
+ vfprintf (stderr, fmt, args);
+ fprintf (stderr, "\n");
+}
+
static char *
parse_options(argc, argv, opts, progname)
int argc;
@@ -494,6 +506,7 @@ struct k4_data* k4;
com_err(progname, code, "while initializing Kerberos 5 library");
return 0;
}
+ errctx = k5->ctx;
if (opts->k5_cache_name)
{
code = krb5_cc_resolve(k5->ctx, opts->k5_cache_name, &k5->cc);
@@ -591,6 +604,7 @@ k5_end(k5)
krb5_cc_close(k5->ctx, k5->cc);
if (k5->ctx)
krb5_free_context(k5->ctx);
+ errctx = NULL;
memset(k5, 0, sizeof(*k5));
}
@@ -1098,6 +1112,8 @@ main(argc, argv)
memset(&k5, 0, sizeof(k5));
memset(&k4, 0, sizeof(k4));
+ set_com_err_hook (extended_com_err_fn);
+
parse_options(argc, argv, &opts, progname);
got_k5 = k5_begin(&opts, &k5, &k4);
diff --git a/src/clients/kvno/ChangeLog b/src/clients/kvno/ChangeLog
index 0a81427ff..0982dd036 100644
--- a/src/clients/kvno/ChangeLog
+++ b/src/clients/kvno/ChangeLog
@@ -1,3 +1,11 @@
+2006-03-26 Ken Raeburn <raeburn@mit.edu>
+
+ * kvno.c: Include com_err.h.
+ (extended_com_err_fn): New function.
+ (context): New variable.
+ (main): Call set_com_err_hook.
+ (do_v5_kvno): Call com_err instead of fprintf+error_message.
+
2004-08-31 Tom Yu <tlyu@mit.edu>
* kvno.M: Update usage.
diff --git a/src/clients/kvno/kvno.c b/src/clients/kvno/kvno.c
index c860eb7d4..4accdb4a9 100644
--- a/src/clients/kvno/kvno.c
+++ b/src/clients/kvno/kvno.c
@@ -55,12 +55,18 @@ static void do_v4_kvno (int argc, char *argv[]);
static void do_v5_kvno (int argc, char *argv[],
char *ccachestr, char *etypestr);
+#include <com_err.h>
+static void extended_com_err_fn (const char *, errcode_t, const char *,
+ va_list);
+
int main(int argc, char *argv[])
{
int option;
char *etypestr = 0, *ccachestr = 0;
int v4 = 0;
+ set_com_err_hook (extended_com_err_fn);
+
prog = strrchr(argv[0], '/');
prog = prog ? (prog + 1) : argv[0];
@@ -149,10 +155,21 @@ static void do_v4_kvno (int count, char *names[])
}
#include <krb5.h>
+static krb5_context context;
+static void extended_com_err_fn (const char *myprog, errcode_t code,
+ const char *fmt, va_list args)
+{
+ const char *emsg;
+ emsg = krb5_get_error_message (context, code);
+ fprintf (stderr, "%s: %s ", myprog, emsg);
+ krb5_free_error_message (context, emsg);
+ vfprintf (stderr, fmt, args);
+ fprintf (stderr, "\n");
+}
+
static void do_v5_kvno (int count, char *names[],
char * ccachestr, char *etypestr)
{
- krb5_context context;
krb5_error_code ret;
int i, errors;
krb5_enctype etype;
@@ -203,16 +220,16 @@ static void do_v5_kvno (int count, char *names[],
ret = krb5_parse_name(context, names[i], &in_creds.server);
if (ret) {
if (!quiet)
- fprintf(stderr, "%s: %s while parsing principal name\n",
- names[i], error_message(ret));
+ com_err(prog, ret, "while parsing principal name %s", names[i]);
errors++;
continue;
}
ret = krb5_unparse_name(context, in_creds.server, &princ);
if (ret) {
- fprintf(stderr, "%s: %s while printing principal name\n",
- names[i], error_message(ret));
+ com_err(prog, ret,
+ "while formatting parsed principal name for '%s'",
+ names[i]);
errors++;
continue;
}
@@ -224,8 +241,7 @@ static void do_v5_kvno (int count, char *names[],
krb5_free_principal(context, in_creds.server);
if (ret) {
- fprintf(stderr, "%s: %s while getting credentials\n",
- princ, error_message(ret));
+ com_err(prog, ret, "while getting credentials for %s", princ);
krb5_free_unparsed_name(context, princ);
@@ -236,9 +252,7 @@ static void do_v5_kvno (int count, char *names[],
/* we need a native ticket */
ret = krb5_decode_ticket(&out_creds->ticket, &ticket);
if (ret) {
- fprintf(stderr, "%s: %s while decoding ticket\n",
- princ, error_message(ret));
-
+ com_err(prog, ret, "while decoding ticket for %s", princ);
krb5_free_creds(context, out_creds);
krb5_free_unparsed_name(context, princ);