summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2002-09-27 13:25:58 +1000
committerDamien Miller <djm@mindrot.org>2002-09-27 13:25:58 +1000
commitd94e549ea8c622c8a75023b649a5d4c051aacf7f (patch)
tree84b39347f655ba0e33b7a9b6c3d23011a5befdad
parentd27a76de65d557e36420046e44a014d3190f89cb (diff)
- markus@cvs.openbsd.org 2002/09/26 11:38:43
[auth1.c auth.h auth-krb4.c monitor.c monitor.h monitor_wrap.c] [monitor_wrap.h] krb4 + privsep; ok dugsong@, deraadt@
-rw-r--r--ChangeLog6
-rw-r--r--auth-krb4.c18
-rw-r--r--auth.h4
-rw-r--r--auth1.c15
-rw-r--r--monitor.c53
-rw-r--r--monitor.h3
-rw-r--r--monitor_wrap.c38
-rw-r--r--monitor_wrap.h7
8 files changed, 120 insertions, 24 deletions
diff --git a/ChangeLog b/ChangeLog
index 3f62f5740..2da8c824a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,6 +6,10 @@
6 - markus@cvs.openbsd.org 2002/09/25 15:19:02 6 - markus@cvs.openbsd.org 2002/09/25 15:19:02
7 [sshd.c] 7 [sshd.c]
8 typo; pilot@monkey.org 8 typo; pilot@monkey.org
9 - markus@cvs.openbsd.org 2002/09/26 11:38:43
10 [auth1.c auth.h auth-krb4.c monitor.c monitor.h monitor_wrap.c]
11 [monitor_wrap.h]
12 krb4 + privsep; ok dugsong@, deraadt@
9 13
1020020925 1420020925
11 - (bal) Fix issue where successfull login does not clear failure counts 15 - (bal) Fix issue where successfull login does not clear failure counts
@@ -730,4 +734,4 @@
730 save auth method before monitor_reset_key_state(); bugzilla bug #284; 734 save auth method before monitor_reset_key_state(); bugzilla bug #284;
731 ok provos@ 735 ok provos@
732 736
733$Id: ChangeLog,v 1.2484 2002/09/27 03:22:31 djm Exp $ 737$Id: ChangeLog,v 1.2485 2002/09/27 03:25:58 djm Exp $
diff --git a/auth-krb4.c b/auth-krb4.c
index 1cc528aa0..b86ce7e49 100644
--- a/auth-krb4.c
+++ b/auth-krb4.c
@@ -23,7 +23,7 @@
23 */ 23 */
24 24
25#include "includes.h" 25#include "includes.h"
26RCSID("$OpenBSD: auth-krb4.c,v 1.27 2002/06/11 05:46:20 mpech Exp $"); 26RCSID("$OpenBSD: auth-krb4.c,v 1.28 2002/09/26 11:38:43 markus Exp $");
27 27
28#include "ssh.h" 28#include "ssh.h"
29#include "ssh1.h" 29#include "ssh1.h"
@@ -210,10 +210,9 @@ krb4_cleanup_proc(void *context)
210} 210}
211 211
212int 212int
213auth_krb4(Authctxt *authctxt, KTEXT auth, char **client) 213auth_krb4(Authctxt *authctxt, KTEXT auth, char **client, KTEXT reply)
214{ 214{
215 AUTH_DAT adat = {0}; 215 AUTH_DAT adat = {0};
216 KTEXT_ST reply;
217 Key_schedule schedule; 216 Key_schedule schedule;
218 struct sockaddr_in local, foreign; 217 struct sockaddr_in local, foreign;
219 char instance[INST_SZ]; 218 char instance[INST_SZ];
@@ -263,21 +262,16 @@ auth_krb4(Authctxt *authctxt, KTEXT auth, char **client)
263 262
264 /* If we can't successfully encrypt the checksum, we send back an 263 /* If we can't successfully encrypt the checksum, we send back an
265 empty message, admitting our failure. */ 264 empty message, admitting our failure. */
266 if ((r = krb_mk_priv((u_char *) & cksum, reply.dat, sizeof(cksum) + 1, 265 if ((r = krb_mk_priv((u_char *) & cksum, reply->dat, sizeof(cksum) + 1,
267 schedule, &adat.session, &local, &foreign)) < 0) { 266 schedule, &adat.session, &local, &foreign)) < 0) {
268 debug("Kerberos v4 mk_priv: (%d) %s", r, krb_err_txt[r]); 267 debug("Kerberos v4 mk_priv: (%d) %s", r, krb_err_txt[r]);
269 reply.dat[0] = 0; 268 reply->dat[0] = 0;
270 reply.length = 0; 269 reply->length = 0;
271 } else 270 } else
272 reply.length = r; 271 reply->length = r;
273 272
274 /* Clear session key. */ 273 /* Clear session key. */
275 memset(&adat.session, 0, sizeof(&adat.session)); 274 memset(&adat.session, 0, sizeof(&adat.session));
276
277 packet_start(SSH_SMSG_AUTH_KERBEROS_RESPONSE);
278 packet_put_string((char *) reply.dat, reply.length);
279 packet_send();
280 packet_write_wait();
281 return (1); 275 return (1);
282} 276}
283#endif /* KRB4 */ 277#endif /* KRB4 */
diff --git a/auth.h b/auth.h
index 82d9987ae..c75d75366 100644
--- a/auth.h
+++ b/auth.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: auth.h,v 1.40 2002/09/09 06:48:06 itojun Exp $ */ 1/* $OpenBSD: auth.h,v 1.41 2002/09/26 11:38:43 markus Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2000 Markus Friedl. All rights reserved. 4 * Copyright (c) 2000 Markus Friedl. All rights reserved.
@@ -113,7 +113,7 @@ int user_key_allowed(struct passwd *, Key *);
113 113
114#ifdef KRB4 114#ifdef KRB4
115#include <krb.h> 115#include <krb.h>
116int auth_krb4(Authctxt *, KTEXT, char **); 116int auth_krb4(Authctxt *, KTEXT, char **, KTEXT);
117int auth_krb4_password(Authctxt *, const char *); 117int auth_krb4_password(Authctxt *, const char *);
118void krb4_cleanup_proc(void *); 118void krb4_cleanup_proc(void *);
119 119
diff --git a/auth1.c b/auth1.c
index 676c8a667..9527ba004 100644
--- a/auth1.c
+++ b/auth1.c
@@ -10,7 +10,7 @@
10 */ 10 */
11 11
12#include "includes.h" 12#include "includes.h"
13RCSID("$OpenBSD: auth1.c,v 1.43 2002/09/09 06:48:06 itojun Exp $"); 13RCSID("$OpenBSD: auth1.c,v 1.44 2002/09/26 11:38:43 markus Exp $");
14 14
15#include "xmalloc.h" 15#include "xmalloc.h"
16#include "rsa.h" 16#include "rsa.h"
@@ -118,17 +118,24 @@ do_authloop(Authctxt *authctxt)
118 118
119 if (kdata[0] == 4) { /* KRB_PROT_VERSION */ 119 if (kdata[0] == 4) { /* KRB_PROT_VERSION */
120#ifdef KRB4 120#ifdef KRB4
121 KTEXT_ST tkt; 121 KTEXT_ST tkt, reply;
122
123 tkt.length = dlen; 122 tkt.length = dlen;
124 if (tkt.length < MAX_KTXT_LEN) 123 if (tkt.length < MAX_KTXT_LEN)
125 memcpy(tkt.dat, kdata, tkt.length); 124 memcpy(tkt.dat, kdata, tkt.length);
126 125
127 if (auth_krb4(authctxt, &tkt, &client_user)) { 126 if (PRIVSEP(auth_krb4(authctxt, &tkt,
127 &client_user, &reply))) {
128 authenticated = 1; 128 authenticated = 1;
129 snprintf(info, sizeof(info), 129 snprintf(info, sizeof(info),
130 " tktuser %.100s", 130 " tktuser %.100s",
131 client_user); 131 client_user);
132
133 packet_start(
134 SSH_SMSG_AUTH_KERBEROS_RESPONSE);
135 packet_put_string((char *)
136 reply.dat, reply.length);
137 packet_send();
138 packet_write_wait();
132 } 139 }
133#endif /* KRB4 */ 140#endif /* KRB4 */
134 } else { 141 } else {
diff --git a/monitor.c b/monitor.c
index e07e97eac..4ad3f3d21 100644
--- a/monitor.c
+++ b/monitor.c
@@ -25,7 +25,7 @@
25 */ 25 */
26 26
27#include "includes.h" 27#include "includes.h"
28RCSID("$OpenBSD: monitor.c,v 1.28 2002/09/24 08:46:04 markus Exp $"); 28RCSID("$OpenBSD: monitor.c,v 1.29 2002/09/26 11:38:43 markus Exp $");
29 29
30#include <openssl/dh.h> 30#include <openssl/dh.h>
31 31
@@ -120,6 +120,9 @@ int mm_answer_sessid(int, Buffer *);
120int mm_answer_pam_start(int, Buffer *); 120int mm_answer_pam_start(int, Buffer *);
121#endif 121#endif
122 122
123#ifdef KRB4
124int mm_answer_krb4(int, Buffer *);
125#endif
123#ifdef KRB5 126#ifdef KRB5
124int mm_answer_krb5(int, Buffer *); 127int mm_answer_krb5(int, Buffer *);
125#endif 128#endif
@@ -203,6 +206,9 @@ struct mon_table mon_dispatch_proto15[] = {
203#ifdef USE_PAM 206#ifdef USE_PAM
204 {MONITOR_REQ_PAM_START, MON_ONCE, mm_answer_pam_start}, 207 {MONITOR_REQ_PAM_START, MON_ONCE, mm_answer_pam_start},
205#endif 208#endif
209#ifdef KRB4
210 {MONITOR_REQ_KRB4, MON_ONCE|MON_AUTH, mm_answer_krb4},
211#endif
206#ifdef KRB5 212#ifdef KRB5
207 {MONITOR_REQ_KRB5, MON_ONCE|MON_AUTH, mm_answer_krb5}, 213 {MONITOR_REQ_KRB5, MON_ONCE|MON_AUTH, mm_answer_krb5},
208#endif 214#endif
@@ -1285,6 +1291,51 @@ mm_answer_rsa_response(int socket, Buffer *m)
1285 return (success); 1291 return (success);
1286} 1292}
1287 1293
1294#ifdef KRB4
1295int
1296mm_answer_krb4(int socket, Buffer *m)
1297{
1298 KTEXT_ST auth, reply;
1299 char *client, *p;
1300 int success;
1301 u_int alen;
1302
1303 reply.length = auth.length = 0;
1304
1305 p = buffer_get_string(m, &alen);
1306 if (alen >= MAX_KTXT_LEN)
1307 fatal("%s: auth too large", __func__);
1308 memcpy(auth.dat, p, alen);
1309 auth.length = alen;
1310 memset(p, 0, alen);
1311 xfree(p);
1312
1313 success = options.kerberos_authentication &&
1314 authctxt->valid &&
1315 auth_krb4(authctxt, &auth, &client, &reply);
1316
1317 memset(auth.dat, 0, alen);
1318 buffer_clear(m);
1319 buffer_put_int(m, success);
1320
1321 if (success) {
1322 buffer_put_cstring(m, client);
1323 buffer_put_string(m, reply.dat, reply.length);
1324 if (client)
1325 xfree(client);
1326 if (reply.length)
1327 memset(reply.dat, 0, reply.length);
1328 }
1329
1330 debug3("%s: sending result %d", __func__, success);
1331 mm_request_send(socket, MONITOR_ANS_KRB4, m);
1332
1333 auth_method = "kerberos";
1334
1335 /* Causes monitor loop to terminate if authenticated */
1336 return (success);
1337}
1338#endif
1288 1339
1289#ifdef KRB5 1340#ifdef KRB5
1290int 1341int
diff --git a/monitor.h b/monitor.h
index 553131997..668ac9897 100644
--- a/monitor.h
+++ b/monitor.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: monitor.h,v 1.7 2002/09/09 06:48:06 itojun Exp $ */ 1/* $OpenBSD: monitor.h,v 1.8 2002/09/26 11:38:43 markus Exp $ */
2 2
3/* 3/*
4 * Copyright 2002 Niels Provos <provos@citi.umich.edu> 4 * Copyright 2002 Niels Provos <provos@citi.umich.edu>
@@ -49,6 +49,7 @@ enum monitor_reqtype {
49 MONITOR_REQ_RSAKEYALLOWED, MONITOR_ANS_RSAKEYALLOWED, 49 MONITOR_REQ_RSAKEYALLOWED, MONITOR_ANS_RSAKEYALLOWED,
50 MONITOR_REQ_RSACHALLENGE, MONITOR_ANS_RSACHALLENGE, 50 MONITOR_REQ_RSACHALLENGE, MONITOR_ANS_RSACHALLENGE,
51 MONITOR_REQ_RSARESPONSE, MONITOR_ANS_RSARESPONSE, 51 MONITOR_REQ_RSARESPONSE, MONITOR_ANS_RSARESPONSE,
52 MONITOR_REQ_KRB4, MONITOR_ANS_KRB4,
52 MONITOR_REQ_KRB5, MONITOR_ANS_KRB5, 53 MONITOR_REQ_KRB5, MONITOR_ANS_KRB5,
53 MONITOR_REQ_PAM_START, 54 MONITOR_REQ_PAM_START,
54 MONITOR_REQ_TERM 55 MONITOR_REQ_TERM
diff --git a/monitor_wrap.c b/monitor_wrap.c
index 5d11a6593..4c53bfd13 100644
--- a/monitor_wrap.c
+++ b/monitor_wrap.c
@@ -25,7 +25,7 @@
25 */ 25 */
26 26
27#include "includes.h" 27#include "includes.h"
28RCSID("$OpenBSD: monitor_wrap.c,v 1.18 2002/09/09 14:54:15 markus Exp $"); 28RCSID("$OpenBSD: monitor_wrap.c,v 1.19 2002/09/26 11:38:43 markus Exp $");
29 29
30#include <openssl/bn.h> 30#include <openssl/bn.h>
31#include <openssl/dh.h> 31#include <openssl/dh.h>
@@ -937,6 +937,42 @@ mm_auth_rsa_verify_response(Key *key, BIGNUM *p, u_char response[16])
937 return (success); 937 return (success);
938} 938}
939 939
940#ifdef KRB4
941int
942mm_auth_krb4(Authctxt *authctxt, void *_auth, char **client, void *_reply)
943{
944 KTEXT auth, reply;
945 Buffer m;
946 u_int rlen;
947 int success = 0;
948 char *p;
949
950 debug3("%s entering", __func__);
951 auth = _auth;
952 reply = _reply;
953
954 buffer_init(&m);
955 buffer_put_string(&m, auth->dat, auth->length);
956
957 mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_KRB4, &m);
958 mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_KRB4, &m);
959
960 success = buffer_get_int(&m);
961 if (success) {
962 *client = buffer_get_string(&m, NULL);
963 p = buffer_get_string(&m, &rlen);
964 if (rlen >= MAX_KTXT_LEN)
965 fatal("%s: reply from monitor too large", __func__);
966 reply->length = rlen;
967 memcpy(reply->dat, p, rlen);
968 memset(p, 0, rlen);
969 xfree(p);
970 }
971 buffer_free(&m);
972 return (success);
973}
974#endif
975
940#ifdef KRB5 976#ifdef KRB5
941int 977int
942mm_auth_krb5(void *ctx, void *argp, char **userp, void *resp) 978mm_auth_krb5(void *ctx, void *argp, char **userp, void *resp)
diff --git a/monitor_wrap.h b/monitor_wrap.h
index 5e583e15b..d960a3d0b 100644
--- a/monitor_wrap.h
+++ b/monitor_wrap.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: monitor_wrap.h,v 1.7 2002/09/09 06:48:06 itojun Exp $ */ 1/* $OpenBSD: monitor_wrap.h,v 1.8 2002/09/26 11:38:43 markus Exp $ */
2 2
3/* 3/*
4 * Copyright 2002 Niels Provos <provos@citi.umich.edu> 4 * Copyright 2002 Niels Provos <provos@citi.umich.edu>
@@ -83,7 +83,10 @@ int mm_bsdauth_respond(void *, u_int, char **);
83int mm_skey_query(void *, char **, char **, u_int *, char ***, u_int **); 83int mm_skey_query(void *, char **, char **, u_int *, char ***, u_int **);
84int mm_skey_respond(void *, u_int, char **); 84int mm_skey_respond(void *, u_int, char **);
85 85
86/* auth_krb5 */ 86/* auth_krb */
87#ifdef KRB4
88int mm_auth_krb4(struct Authctxt *, void *, char **, void *);
89#endif
87#ifdef KRB5 90#ifdef KRB5
88/* auth and reply are really krb5_data objects, but we don't want to 91/* auth and reply are really krb5_data objects, but we don't want to
89 * include all of the krb5 headers here */ 92 * include all of the krb5 headers here */