diff options
author | Theodore Tso <tytso@mit.edu> | 1993-06-03 19:29:40 +0000 |
---|---|---|
committer | Theodore Tso <tytso@mit.edu> | 1993-06-03 19:29:40 +0000 |
commit | 746386f12e01102acbe5637aac6f1259c74bb552 (patch) | |
tree | 715df6527f739854dc978c588047607e1907e9e9 /src/krb524/conv_tkt.c | |
parent | acbed92e113f54d33789d427e697a23a0f07ab64 (diff) | |
download | krb5-746386f12e01102acbe5637aac6f1259c74bb552.tar.gz krb5-746386f12e01102acbe5637aac6f1259c74bb552.tar.xz krb5-746386f12e01102acbe5637aac6f1259c74bb552.zip |
Initial revision
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@2611 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/krb524/conv_tkt.c')
-rw-r--r-- | src/krb524/conv_tkt.c | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/src/krb524/conv_tkt.c b/src/krb524/conv_tkt.c new file mode 100644 index 000000000..1332a23cd --- /dev/null +++ b/src/krb524/conv_tkt.c @@ -0,0 +1,86 @@ +/* + * Copyright 1993 by Geer Zolot Associates. All Rights Reserved. + * + * Export of this software from the United States of America is assumed + * to require a specific license from the United States Government. It + * is the responsibility of any person or organization contemplating + * export to obtain such a license before exporting. + * + * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and + * distribute this software and its documentation for any purpose and + * without fee is hereby granted, provided that the above copyright + * notice appear in all copies and that both that copyright notice and + * this permission notice appear in supporting documentation, and that + * the name of Geer Zolot Associates not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. Geer Zolot Associates makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +#if !defined(lint) && !defined(SABER) +static char rcs_id[] = "$Id$"; +#endif + +#include <stdio.h> +#include <sys/types.h> +#include <sys/socket.h> +#include <netinet/in.h> +#include <netdb.h> + +#include <krb5/krb5.h> +#include <krb.h> + +#include "krb524.h" + +/* + * krb524_convert_tkt. Open a network connection to krb524d, send it + * the V5 ticket, receive the V4 ticket in response. + */ +int krb524_convert_tkt(krb5_principal server, krb5_data *v5tkt, + KTEXT_ST *v4tkt, + int *kvno, + struct sockaddr_in *saddr) +{ + char *p; + krb5_data reply; + struct servent *serv; + int ret, status; + + reply.data = NULL; + + if (saddr->sin_port == 0) { + serv = getservbyname(KRB524_SERVICE, "udp"); + if (serv) + saddr->sin_port = serv->s_port; + else + saddr->sin_port = htons(KRB524_PORT); + } + + if (ret = krb524_send_message(saddr, v5tkt, &reply)) + goto fail; + + p = reply.data; + status = ntohl(*((krb5_error_code *) p)); + p += sizeof(krb5_error_code); + reply.length -= sizeof(krb5_error_code); + if (status) { + ret = status; + goto fail; + } + *kvno = ntohl(*((krb5_error_code *) p)); + p += sizeof(int); + reply.length -= sizeof(int); + ret = decode_v4tkt(v4tkt, p, &reply.length); + +fail: + if (ret) { + if (reply.data) + free(reply.data); + reply.data = NULL; + reply.length = 0; + } + + return ret; +} + |