From 2726d8dd9c780485c5c2fbbb4e342d935d061872 Mon Sep 17 00:00:00 2001 From: Chris Provenzano Date: Mon, 27 Mar 1995 14:30:55 +0000 Subject: [PATCH] * sim_server.c: Use new calling convention for krb5_rd_req(), krb5_rd_safe(), and krb5_rd_priv(). git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@5256 dc483132-0cff-0310-8789-dd5450dbe970 --- src/appl/simple/server/ChangeLog | 7 ++- src/appl/simple/server/sim_server.c | 77 ++++++++++------------------- 2 files changed, 31 insertions(+), 53 deletions(-) diff --git a/src/appl/simple/server/ChangeLog b/src/appl/simple/server/ChangeLog index 92e0ffe0b..a57c3a520 100644 --- a/src/appl/simple/server/ChangeLog +++ b/src/appl/simple/server/ChangeLog @@ -1,3 +1,8 @@ +Mon Mar 27 07:56:26 1995 Chris Provenzano (proven@mit.edu) + + * sim_server.c: Use new calling convention for krb5_rd_req(), + krb5_rd_safe(), and krb5_rd_priv(). + Thu Mar 2 12:27:03 1995 Theodore Y. Ts'o * Makefile.in (ISODELIB): Remove reference to $(ISODELIB). @@ -13,7 +18,7 @@ Tue Feb 28 02:01:53 1995 John Gilmore (gnu at toad.com) Fri Jan 13 15:23:47 1995 Chris Provenzano (proven@mit.edu) - * Added krb5_context to all krb5_routines + * Added krb5_context to all krb5_routines Thu Sep 29 22:46:51 1994 Theodore Y. Ts'o (tytso@dcl) diff --git a/src/appl/simple/server/sim_server.c b/src/appl/simple/server/sim_server.c index b97f0f01c..b0aff669b 100644 --- a/src/appl/simple/server/sim_server.c +++ b/src/appl/simple/server/sim_server.c @@ -65,10 +65,10 @@ char *argv[]; krb5_data packet, message; unsigned char pktbuf[BUFSIZ]; krb5_address foreign_addr, *portforeign_addr; - krb5_rcache rcache; krb5_principal sprinc; krb5_context context; - krb5_tkt_authent *ad; + krb5_auth_context *auth_context = NULL; + krb5_ticket *ticket = NULL; if (argc != 2) { fprintf(stderr, "usage: %s \n",PROGNAME); @@ -136,27 +136,38 @@ char *argv[]; packet.length = i; packet.data = (krb5_pointer) pktbuf; - foreign_addr.addrtype = c_sock.sin_family; - foreign_addr.length = sizeof(c_sock.sin_addr); - foreign_addr.contents = (krb5_octet *)&c_sock.sin_addr; - /* Check authentication info */ - if (retval = krb5_rd_req_simple(context, &packet, sprinc, - &foreign_addr, - &ad)) { + if (retval = krb5_rd_req(context, &auth_context, &packet, + sprinc, NULL, NULL, &ticket)) { com_err(PROGNAME, retval, "while reading request"); exit(1); } - if (retval = krb5_unparse_name(context,ad->ticket->enc_part2->client,&cp)) { + if (retval = krb5_unparse_name(context, ticket->enc_part2->client, &cp)) { com_err(PROGNAME, retval, "while unparsing client name"); exit(1); } printf("Got authentication info from %s\n", cp); - free(cp); - /* GET KRB_MK_SAFE MESSAGE */ + /* Set foreign_addr for rd_safe() and rd_priv() */ + foreign_addr.contents = (krb5_octet *)&c_sock.sin_addr; + foreign_addr.length = sizeof(c_sock.sin_addr); + foreign_addr.addrtype = c_sock.sin_family; + if (retval = krb5_gen_portaddr(context, &foreign_addr, + (krb5_pointer) &c_sock.sin_port, + &portforeign_addr)) { + com_err(PROGNAME, retval, "while generating port address"); + exit(1); + } + + if (retval = krb5_auth_con_setaddrs(context, auth_context, NULL, + portforeign_addr)) { + com_err(PROGNAME, retval, "while setting foreign addr"); + exit(1); + } + + /* GET KRB_MK_SAFE MESSAGE */ /* use "recvfrom" so we know client's address */ i = sizeof(c_sock); @@ -174,36 +185,13 @@ char *argv[]; packet.length = i; packet.data = (krb5_pointer) pktbuf; - foreign_addr.addrtype = c_sock.sin_family; - foreign_addr.length = sizeof(c_sock.sin_addr); - foreign_addr.contents = (krb5_octet *)&c_sock.sin_addr; - - if (retval = krb5_gen_portaddr(context, &foreign_addr, - (krb5_pointer) &c_sock.sin_port, - &portforeign_addr)) { - com_err(PROGNAME, retval, "while generating port address"); - exit(1); - } - - if (retval = krb5_get_server_rcache(context, - krb5_princ_component(context,sprinc,0), - &rcache)) { - com_err(PROGNAME, retval, "while opening replay cache"); - exit(1); - } - - if (retval = krb5_rd_safe(context, &packet, ad->ticket->enc_part2->session, - portforeign_addr, 0, 0, 0, - rcache, - &message)) { + if (retval = krb5_rd_safe(context, auth_context, &packet, &message, NULL)) { com_err(PROGNAME, retval, "while verifying SAFE message"); - (void) krb5_rc_close(context, rcache); exit(1); } printf("Safe message is: '%.*s'\n", message.length, message.data); krb5_xfree(message.data); - krb5_free_address(context, portforeign_addr); /* NOW GET ENCRYPTED MESSAGE */ @@ -213,7 +201,6 @@ char *argv[]; (struct sockaddr *)&c_sock, &i); if (i < 0) { perror("receiving datagram"); - (void) krb5_rc_close(context, rcache); exit(1); } printf("Received %d bytes\n", i); @@ -221,25 +208,11 @@ char *argv[]; packet.length = i; packet.data = (krb5_pointer) pktbuf; - if (retval = krb5_gen_portaddr(context, &foreign_addr, - (krb5_pointer) &c_sock.sin_port, - &portforeign_addr)) { - com_err(PROGNAME, retval, "while generating port address"); - (void) krb5_rc_close(context, rcache); - exit(1); - } - - if (retval = krb5_rd_priv(context, &packet, ad->ticket->enc_part2->session, - portforeign_addr, 0, 0, 0, 0, - rcache, - &message)) { + if (retval = krb5_rd_priv(context, auth_context, &packet, &message, NULL)) { com_err(PROGNAME, retval, "while verifying PRIV message"); - (void) krb5_rc_close(context, rcache); exit(1); } printf("Decrypted message is: '%.*s'\n", message.length, message.data); - (void) krb5_rc_close(context, rcache); - exit(0); } -- 2.26.2