diff options
author | Jeffrey Altman <jaltman@secure-endpoints.com> | 2004-08-21 17:25:29 +0000 |
---|---|---|
committer | Jeffrey Altman <jaltman@secure-endpoints.com> | 2004-08-21 17:25:29 +0000 |
commit | c0201c632f35068ee6eef6fe4e71f190bd7da4a6 (patch) | |
tree | 91fd5fc51e03e6401af47ed8b6e78ce4589292af /src/clients | |
parent | 89935bbb152e2bc52f57d91a9418b034ade2a9fc (diff) | |
download | krb5-c0201c632f35068ee6eef6fe4e71f190bd7da4a6.zip krb5-c0201c632f35068ee6eef6fe4e71f190bd7da4a6.tar.gz krb5-c0201c632f35068ee6eef6fe4e71f190bd7da4a6.tar.bz2 |
kvno: add -c ccache command line parameter
call krb5_free_unparsed_name() instead of free() to prevent
crashes on Windows.
ticket: new
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@16680 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/clients')
-rw-r--r-- | src/clients/kvno/ChangeLog | 5 | ||||
-rw-r--r-- | src/clients/kvno/kvno.c | 33 |
2 files changed, 27 insertions, 11 deletions
diff --git a/src/clients/kvno/ChangeLog b/src/clients/kvno/ChangeLog index 8ad50fc..7e99fe9 100644 --- a/src/clients/kvno/ChangeLog +++ b/src/clients/kvno/ChangeLog @@ -1,3 +1,8 @@ +2004-08-20 Jeffrey Altman <jaltman@mit.edu> + + * kvno.c: Add -c ccache command line option + use krb5_free_unparsed_name() instead of free() + 2004-06-16 Ken Raeburn <raeburn@mit.edu> * Makefile.in (all-mac): Target deleted. diff --git a/src/clients/kvno/kvno.c b/src/clients/kvno/kvno.c index 505a73c..71fbcde 100644 --- a/src/clients/kvno/kvno.c +++ b/src/clients/kvno/kvno.c @@ -39,9 +39,12 @@ static char *prog; static void xusage() { #ifdef KRB5_KRB4_COMPAT - fprintf(stderr, "xusage: %s [-4 | -e etype] service1 service2 ...\n", prog); + fprintf(stderr, + "xusage: %s [-4 | -c ccache -e etype] service1 service2 ...\n", + prog); #else - fprintf(stderr, "xusage: %s [-e etype] service1 service2 ...\n", prog); + fprintf(stderr, "xusage: %s [-c ccache -e etype] service1 service2 ...\n", + prog); #endif exit(1); } @@ -49,19 +52,23 @@ static void xusage() int quiet = 0; static void do_v4_kvno (int argc, char *argv[]); -static void do_v5_kvno (int argc, char *argv[], char *etypestr); +static void do_v5_kvno (int argc, char *argv[], + char *ccachestr, char *etypestr); int main(int argc, char *argv[]) { int option; - char *etypestr = 0; + char *etypestr = 0, *ccachestr = 0; int v4 = 0; prog = strrchr(argv[0], '/'); prog = prog ? (prog + 1) : argv[0]; - while ((option = getopt(argc, argv, "e:hq4")) != -1) { + while ((option = getopt(argc, argv, "c:e:hq4")) != -1) { switch (option) { + case 'c': + ccachestr = optarg; + break; case 'e': etypestr = optarg; break; @@ -83,13 +90,13 @@ int main(int argc, char *argv[]) if ((argc - optind) < 1) xusage(); - if (etypestr != 0 && v4) + if ((ccachestr != 0 || etypestr != 0) && v4) xusage(); if (v4) do_v4_kvno(argc - optind, argv + optind); else - do_v5_kvno(argc - optind, argv + optind, etypestr); + do_v5_kvno(argc - optind, argv + optind, ccachestr, etypestr); return 0; } @@ -142,7 +149,8 @@ static void do_v4_kvno (int count, char *names[]) } #include <krb5.h> -static void do_v5_kvno (int count, char *names[], char *etypestr) +static void do_v5_kvno (int count, char *names[], + char * ccachestr, char *etypestr) { krb5_context context; krb5_error_code ret; @@ -170,7 +178,10 @@ static void do_v5_kvno (int count, char *names[], char *etypestr) etype = 0; } - ret = krb5_cc_default(context, &ccache); + if (ccachestr) + ret = krb5_cc_resolve(context, ccachestr, &ccache); + else + ret = krb5_cc_default(context, &ccache); if (ret) { com_err(prog, ret, "while opening ccache"); exit(1); @@ -216,7 +227,7 @@ static void do_v5_kvno (int count, char *names[], char *etypestr) fprintf(stderr, "%s: %s while getting credentials\n", princ, error_message(ret)); - free(princ); + krb5_free_unparsed_name(context, princ); errors++; continue; @@ -229,7 +240,7 @@ static void do_v5_kvno (int count, char *names[], char *etypestr) princ, error_message(ret)); krb5_free_creds(context, out_creds); - free(princ); + krb5_free_unparsed_name(context, princ); errors++; continue; |