From: Richard Basch Date: Fri, 9 Feb 1996 00:52:44 +0000 (+0000) Subject: * kinit.c X-Git-Tag: krb5-1.0-beta6~521 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=f79a78e7d1273c7a8ed20e04cb038b8c26d346d3;p=krb5.git * kinit.c Only initialize the credentials cache if credentials were obtained. This means you won't blow away the old cache if an incorrect password was entered, and it also allows for the os_context time offset to be set properly in the credentials cache. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@7463 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/clients/kinit/kinit.c b/src/clients/kinit/kinit.c index 234fd0b88..1e3a802b6 100644 --- a/src/clients/kinit/kinit.c +++ b/src/clients/kinit/kinit.c @@ -70,6 +70,8 @@ main(argc, argv) krb5_principal server; krb5_creds my_creds; krb5_timestamp now; + krb5_address *null_addr = (krb5_address *)0; + krb5_address **addrs = (krb5_address **)0; int use_keytab = 0; /* -k option */ krb5_keytab keytab = NULL; struct passwd *pw = 0; @@ -214,13 +216,6 @@ main(argc, argv) exit(1); } - code = krb5_cc_initialize (kcontext, ccache, me); - if (code != 0) { - com_err (argv[0], code, "when initializing cache %s", - cache_name?cache_name:""); - exit(1); - } - memset((char *)&my_creds, 0, sizeof(my_creds)); my_creds.client = me; @@ -266,14 +261,14 @@ main(argc, argv) exit(1); } - code = krb5_get_in_tkt_with_password(kcontext, options, 0, - NULL, preauth, password, ccache, + code = krb5_get_in_tkt_with_password(kcontext, options, addrs, + NULL, preauth, password, 0, &my_creds, 0); memset(password, 0, sizeof(password)); #ifndef NO_KEYTAB } else { - code = krb5_get_in_tkt_with_keytab(kcontext, options, 0, - NULL, preauth, keytab, ccache, + code = krb5_get_in_tkt_with_keytab(kcontext, options, addrs, + NULL, preauth, keytab, 0, &my_creds, 0); #endif } @@ -287,5 +282,19 @@ main(argc, argv) com_err (argv[0], code, "while getting initial credentials"); exit(1); } + + code = krb5_cc_initialize (kcontext, ccache, me); + if (code != 0) { + com_err (argv[0], code, "when initializing cache %s", + cache_name?cache_name:""); + exit(1); + } + + code = krb5_cc_store_cred(kcontext, ccache, &my_creds); + if (code) { + com_err (argv[0], code, "while storing credentials"); + exit(1); + } + exit(0); }