From 5b598fa4bc6a4bf0df9b9c0ed2fdda0fd7af2c59 Mon Sep 17 00:00:00 2001 From: Tom Yu Date: Fri, 31 Aug 2007 21:38:55 +0000 Subject: [PATCH] pull up r19894 from trunk r19894@cathode-dark-space: tlyu | 2007-08-29 16:28:06 -0400 ticket: new target_version: 1.6.3 subject: -S sname option for kvno tags: pullup component: krb5-clients New option to use krb5_sname_to_principal() for building principal names, which is useful for testing referrals. ticket: 5700 version_fixed: 1.6.3 git-svn-id: svn://anonsvn.mit.edu/krb5/branches/krb5-1-6@19908 dc483132-0cff-0310-8789-dd5450dbe970 --- src/clients/kvno/kvno.M | 9 +++++++++ src/clients/kvno/kvno.c | 30 +++++++++++++++++++++++------- 2 files changed, 32 insertions(+), 7 deletions(-) diff --git a/src/clients/kvno/kvno.M b/src/clients/kvno/kvno.M index 864f75ec2..ad2cb4818 100644 --- a/src/clients/kvno/kvno.M +++ b/src/clients/kvno/kvno.M @@ -55,6 +55,15 @@ prints a usage statement and exits specifies that Kerberos version 4 tickets should be acquired and described. This option is only available if Kerberos 4 support was enabled at compilation time. +.TP +.B \-S sname +specifies that krb5_sname_to_principal() will be used to build +principal names. If this flag is specified, the +.B service1 service2 ... +arguments are interpreted as hostnames (rather than principal names), +and +.B sname +is interpreted as the service name. .SH ENVIRONMENT .B Kvno uses the following environment variable: diff --git a/src/clients/kvno/kvno.c b/src/clients/kvno/kvno.c index 3b227474a..1598bf58f 100644 --- a/src/clients/kvno/kvno.c +++ b/src/clients/kvno/kvno.c @@ -41,10 +41,10 @@ static void xusage() { #ifdef KRB5_KRB4_COMPAT fprintf(stderr, - "usage: %s [-4 | [-c ccache] [-e etype] [-k keytab]] service1 service2 ...\n", + "usage: %s [-4 | [-c ccache] [-e etype] [-k keytab] [-S sname]] service1 service2 ...\n", prog); #else - fprintf(stderr, "usage: %s [-c ccache] [-e etype] [-k keytab] service1 service2 ...\n", + fprintf(stderr, "usage: %s [-c ccache] [-e etype] [-k keytab] [-S sname] service1 service2 ...\n", prog); #endif exit(1); @@ -54,7 +54,8 @@ int quiet = 0; static void do_v4_kvno (int argc, char *argv[]); static void do_v5_kvno (int argc, char *argv[], - char *ccachestr, char *etypestr, char *keytab_name); + char *ccachestr, char *etypestr, char *keytab_name, + char *sname); #include static void extended_com_err_fn (const char *, errcode_t, const char *, @@ -64,6 +65,7 @@ int main(int argc, char *argv[]) { int option; char *etypestr = NULL, *ccachestr = NULL, *keytab_name = NULL; + char *sname = NULL; int v4 = 0; set_com_err_hook (extended_com_err_fn); @@ -71,7 +73,7 @@ int main(int argc, char *argv[]) prog = strrchr(argv[0], '/'); prog = prog ? (prog + 1) : argv[0]; - while ((option = getopt(argc, argv, "c:e:hk:q4")) != -1) { + while ((option = getopt(argc, argv, "c:e:hk:q4S:")) != -1) { switch (option) { case 'c': ccachestr = optarg; @@ -91,6 +93,9 @@ int main(int argc, char *argv[]) case '4': v4 = 1; break; + case 'S': + sname = optarg; + break; default: xusage(); break; @@ -103,10 +108,14 @@ int main(int argc, char *argv[]) if ((ccachestr != NULL || etypestr != NULL || keytab_name != NULL) && v4) xusage(); + if (sname != NULL && v4) + xusage(); + if (v4) do_v4_kvno(argc - optind, argv + optind); else - do_v5_kvno(argc - optind, argv + optind, ccachestr, etypestr, keytab_name); + do_v5_kvno(argc - optind, argv + optind, + ccachestr, etypestr, keytab_name, sname); return 0; } @@ -172,7 +181,8 @@ static void extended_com_err_fn (const char *myprog, errcode_t code, } static void do_v5_kvno (int count, char *names[], - char * ccachestr, char *etypestr, char *keytab_name) + char * ccachestr, char *etypestr, char *keytab_name, + char *sname) { krb5_error_code ret; int i, errors; @@ -230,7 +240,13 @@ static void do_v5_kvno (int count, char *names[], in_creds.client = me; - ret = krb5_parse_name(context, names[i], &in_creds.server); + if (sname != NULL) { + ret = krb5_sname_to_principal(context, names[i], + sname, KRB5_NT_SRV_HST, + &in_creds.server); + } else { + ret = krb5_parse_name(context, names[i], &in_creds.server); + } if (ret) { if (!quiet) com_err(prog, ret, "while parsing principal name %s", names[i]); -- 2.26.2