Deleted Added
sdiff udiff text old ( 120945 ) new ( 142403 )
full compact
1/*-
2 * Copyright (c) 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 39 unchanged lines hidden (view full) ---

48 * to distribution of the software without specific, written prior
49 * permission. M.I.T. makes no representations about the suitability of
50 * this software for any purpose. It is provided "as is" without express
51 * or implied warranty.
52 */
53
54#include <config.h>
55
56RCSID("$Id: kerberos5.c,v 1.53.2.1 2004/06/21 08:21:07 lha Exp $");
57
58#ifdef KRB5
59
60#include <arpa/telnet.h>
61#include <stdio.h>
62#include <stdlib.h>
63#include <string.h>
64#include <unistd.h>

--- 27 unchanged lines hidden (view full) ---

92/* These values need to be the same as those defined in telnet/main.c. */
93/* Either define them in both places, or put in some common header file. */
94#define OPTS_FORWARD_CREDS 0x00000002
95#define OPTS_FORWARDABLE_CREDS 0x00000001
96
97
98void kerberos5_forward (Authenticator *);
99
100static unsigned char str_data[4] = { IAC, SB, TELOPT_AUTHENTICATION, 0 };
101
102#define KRB_AUTH 0 /* Authentication data follows */
103#define KRB_REJECT 1 /* Rejected (reason might follow) */
104#define KRB_ACCEPT 2 /* Accepted */
105#define KRB_RESPONSE 3 /* Response for mutual auth. */
106
107#define KRB_FORWARD 4 /* Forwarded credentials follow */
108#define KRB_FORWARD_ACCEPT 5 /* Forwarded credentials accepted */
109#define KRB_FORWARD_REJECT 6 /* Forwarded credentials rejected */
110
111static krb5_data auth;
112static krb5_ticket *ticket;
113
114static krb5_context context;
115static krb5_auth_context auth_context;
116
117static int
118Data(Authenticator *ap, int type, void *d, int c)
119{
120 unsigned char *cd = (unsigned char *)d;
121 unsigned char *p0, *p;
122 size_t len = sizeof(str_data) + 3 + 2;
123 int ret;
124
125 if (c == -1)
126 c = strlen((char*)cd);
127
128 for (p = cd; p - cd < c; p++, len++)
129 if (*p == IAC)
130 len++;
131
132 p0 = malloc(len);
133 if (p0 == NULL)
134 return 0;
135
136 memcpy(p0, str_data, sizeof(str_data));
137 p = p0 + sizeof(str_data);
138
139 if (auth_debug_mode) {
140 printf("%s:%d: [%d] (%d)",
141 str_data[3] == TELQUAL_IS ? ">>>IS" : ">>>REPLY",
142 str_data[3],
143 type, c);
144 printd(d, c);
145 printf("\r\n");
146 }
147 *p++ = ap->type;
148 *p++ = ap->way;
149 *p++ = type;
150 while (c-- > 0) {
151 if ((*p++ = *cd++) == IAC)
152 *p++ = IAC;
153 }
154 *p++ = IAC;
155 *p++ = SE;
156 if (str_data[3] == TELQUAL_IS)
157 printsub('>', &p0[2], len - 2);
158 ret = telnet_net_write(p0, len);
159 free(p0);
160 return ret;
161}
162
163int
164kerberos5_init(Authenticator *ap, int server)
165{
166 krb5_error_code ret;
167
168 ret = krb5_init_context(&context);

--- 713 unchanged lines hidden ---