From 859a69628094b254f865f63e4afd7352332e6001 Mon Sep 17 00:00:00 2001 From: John Kohl Date: Tue, 30 Apr 1991 15:01:30 +0000 Subject: [PATCH] use new principal building routines git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@2070 dc483132-0cff-0310-8789-dd5450dbe970 --- src/clients/kinit/kinit.c | 18 ++++++++++++------ src/lib/krb425/get_cred.c | 23 ++++++++++++----------- src/lib/krb425/mk_req.c | 19 +++++++++---------- src/lib/krb425/rd_req.c | 25 ++++++++++++------------- 4 files changed, 45 insertions(+), 40 deletions(-) diff --git a/src/clients/kinit/kinit.c b/src/clients/kinit/kinit.c index 8e3bcd8ae..3b9061f8b 100644 --- a/src/clients/kinit/kinit.c +++ b/src/clients/kinit/kinit.c @@ -60,7 +60,7 @@ main(argc, argv) krb5_address **my_addresses; krb5_error_code code; krb5_principal me; - krb5_data *server[4]; + krb5_principal server; krb5_creds my_creds; krb5_timestamp now; @@ -140,12 +140,17 @@ main(argc, argv) memset((char *)&my_creds, 0, sizeof(my_creds)); my_creds.client = me; - my_creds.server = server; - server[0] = me[0]; /* realm name */ - server[1] = &tgtname; - server[2] = me[0]; - server[3] = 0; + if (code = krb5_build_principal_ext(&server, + me[0]->length, me[0]->data, + tgtname.length, tgtname.data, + me[0]->length, me[0]->data, + 0)) { + com_err(argv[0], code, "while building server name"); + exit(1); + } + + my_creds.server = server; code = krb5_os_localaddr(&my_addresses); if (code != 0) { @@ -170,6 +175,7 @@ main(argc, argv) 0, /* let lib read pwd from kbd */ ccache, &my_creds); + krb5_free_principal(server); if (code != 0) { com_err (argv[0], code, "while getting initial credentials"); exit(1); diff --git a/src/lib/krb425/get_cred.c b/src/lib/krb425/get_cred.c index 69bfe6f57..e4e0aa600 100644 --- a/src/lib/krb425/get_cred.c +++ b/src/lib/krb425/get_cred.c @@ -28,19 +28,18 @@ CREDENTIALS *c; static krb5_principal client_principal = { 0 }; krb5_creds creds; - krb5_data *server[4]; + krb5_principal server; krb5_data srvdata[3]; krb5_error_code r; krb5_ticket *ticket; - set_data5(srvdata[0], realm); - set_data5(srvdata[1], service); - set_data5(srvdata[2], instance); - - server[0] = &srvdata[0]; - server[1] = &srvdata[1]; - server[2] = &srvdata[2]; - server[3] = 0; + if (r = krb5_build_principal(&server, + strlen(realm), realm, + service, + instance, + 0)) { + return(krb425error(r)); + } if (!_krb425_ccache) krb5_cc_default(&_krb425_ccache); @@ -53,8 +52,10 @@ CREDENTIALS *c; creds.times.endtime = 0; creds.keyblock.keytype = KEYTYPE_DES; - if (r = krb5_get_credentials(0, _krb425_ccache, &creds)) - return(krb425error(r)); + r = krb5_get_credentials(0, _krb425_ccache, &creds); + krb5_free_principal(server); + if (r) + return(krb425error(r)); #ifdef EBUG { diff --git a/src/lib/krb425/mk_req.c b/src/lib/krb425/mk_req.c index 188f6b641..ea748df14 100644 --- a/src/lib/krb425/mk_req.c +++ b/src/lib/krb425/mk_req.c @@ -26,20 +26,18 @@ char *instance; char *realm; u_long checksum; { - krb5_data *server[4]; - krb5_data srvdata[3]; + krb5_principal server; krb5_error_code r; krb5_data outbuf; krb5_checksum ck; - set_data5(srvdata[0], realm); - set_data5(srvdata[1], service); - set_data5(srvdata[2], instance); - - server[0] = &srvdata[0]; - server[1] = &srvdata[1]; - server[2] = &srvdata[2]; - server[3] = 0; + if (r = krb5_build_principal(&server, + strlen(realm), realm, + service, + instance, + 0)) { + return(krb425error(r)); + } if (!_krb425_ccache) krb5_cc_default(&_krb425_ccache); @@ -62,6 +60,7 @@ u_long checksum; if (r) ERROR(r) #endif + krb5_free_principal(server); if (!r) { if (outbuf.length > MAX_KTXT_LEN) { #ifdef EBUG diff --git a/src/lib/krb425/rd_req.c b/src/lib/krb425/rd_req.c index baf041b02..797eeb260 100644 --- a/src/lib/krb425/rd_req.c +++ b/src/lib/krb425/rd_req.c @@ -43,8 +43,7 @@ char *fn; krb5_address peer; krb5_tkt_authent *authdat; char addr[4]; - krb5_data *server[4]; - krb5_data srvdata[3]; + krb5_principal server; krb5_error_code r; krb5_data authe; extern int gethostname(); @@ -81,15 +80,14 @@ char *fn; } instance = hostname; } - set_data5(srvdata[0], _krb425_local_realm); - set_data5(srvdata[1], service); - set_data5(srvdata[2], instance); - - server[0] = &srvdata[0]; - server[1] = &srvdata[1]; - server[2] = &srvdata[2]; - server[3] = 0; - + if (r = krb5_build_principal(&server, + strlen(_krb425_local_realm), + _krb425_local_realm, + service, + instance, + 0)) { + return(krb425error(r)); + } authe.length = authent->length; authe.data = (char *)authent->dat; @@ -129,16 +127,17 @@ char *fn; /* ? : will break some compilers when dealing with function pointers */ if (use_set_key) r = krb5_rd_req(&authe, - (krb5_principal)server, + server, from_addr ? &peer : 0, fn, setkey_key_proc, 0, 0, &authdat); else r = krb5_rd_req(&authe, - (krb5_principal)server, + server, from_addr ? &peer : 0, fn, 0, 0, 0, &authdat); + krb5_free_principal(server); if (r) { #ifdef EBUG ERROR(r) -- 2.26.2