kerberos5.c (120945) | kerberos5.c (142403) |
---|---|
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 | 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 2002/09/20 14:37:46 joda Exp $"); | 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 | 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[1024] = { IAC, SB, TELOPT_AUTHENTICATION, 0, 101 AUTHTYPE_KERBEROS_V5, }; | 100static unsigned char str_data[4] = { IAC, SB, TELOPT_AUTHENTICATION, 0 }; |
102 103#define KRB_AUTH 0 /* Authentication data follows */ 104#define KRB_REJECT 1 /* Rejected (reason might follow) */ 105#define KRB_ACCEPT 2 /* Accepted */ 106#define KRB_RESPONSE 3 /* Response for mutual auth. */ 107 108#define KRB_FORWARD 4 /* Forwarded credentials follow */ 109#define KRB_FORWARD_ACCEPT 5 /* Forwarded credentials accepted */ 110#define KRB_FORWARD_REJECT 6 /* Forwarded credentials rejected */ 111 112static krb5_data auth; 113static krb5_ticket *ticket; 114 115static krb5_context context; 116static krb5_auth_context auth_context; 117 118static int 119Data(Authenticator *ap, int type, void *d, int c) 120{ | 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{ |
121 unsigned char *p = str_data + 4; | |
122 unsigned char *cd = (unsigned char *)d; | 120 unsigned char *cd = (unsigned char *)d; |
121 unsigned char *p0, *p; 122 size_t len = sizeof(str_data) + 3 + 2; 123 int ret; |
|
123 124 if (c == -1) 125 c = strlen((char*)cd); 126 | 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 |
|
127 if (auth_debug_mode) { 128 printf("%s:%d: [%d] (%d)", 129 str_data[3] == TELQUAL_IS ? ">>>IS" : ">>>REPLY", 130 str_data[3], 131 type, c); 132 printd(d, c); 133 printf("\r\n"); 134 } 135 *p++ = ap->type; 136 *p++ = ap->way; 137 *p++ = type; 138 while (c-- > 0) { 139 if ((*p++ = *cd++) == IAC) 140 *p++ = IAC; 141 } 142 *p++ = IAC; 143 *p++ = SE; 144 if (str_data[3] == TELQUAL_IS) | 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) |
145 printsub('>', &str_data[2], p - &str_data[2]); 146 return(telnet_net_write(str_data, p - str_data)); | 157 printsub('>', &p0[2], len - 2); 158 ret = telnet_net_write(p0, len); 159 free(p0); 160 return ret; |
147} 148 149int 150kerberos5_init(Authenticator *ap, int server) 151{ 152 krb5_error_code ret; 153 154 ret = krb5_init_context(&context); --- 713 unchanged lines hidden --- | 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 --- |