diff options
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | auth-krb5.c | 20 | ||||
-rw-r--r-- | auth.h | 4 | ||||
-rw-r--r-- | auth1.c | 18 | ||||
-rw-r--r-- | monitor.c | 45 | ||||
-rw-r--r-- | monitor.h | 3 | ||||
-rw-r--r-- | monitor_wrap.c | 37 | ||||
-rw-r--r-- | monitor_wrap.h | 9 |
8 files changed, 121 insertions, 22 deletions
@@ -3,6 +3,11 @@ | |||
3 | - markus@cvs.openbsd.org 2002/09/08 20:24:08 | 3 | - markus@cvs.openbsd.org 2002/09/08 20:24:08 |
4 | [hostfile.h] | 4 | [hostfile.h] |
5 | no comma at end of enumerator list | 5 | no comma at end of enumerator list |
6 | - itojun@cvs.openbsd.org 2002/09/09 06:48:06 | ||
7 | [auth1.c auth.h auth-krb5.c monitor.c monitor.h] | ||
8 | [monitor_wrap.c monitor_wrap.h] | ||
9 | kerberos support for privsep. confirmed to work by lha@stacken.kth.se | ||
10 | patch from markus | ||
6 | 11 | ||
7 | 20020911 | 12 | 20020911 |
8 | - (djm) Sync openbsd-compat with OpenBSD -current | 13 | - (djm) Sync openbsd-compat with OpenBSD -current |
@@ -1623,4 +1628,4 @@ | |||
1623 | - (stevesk) entropy.c: typo in debug message | 1628 | - (stevesk) entropy.c: typo in debug message |
1624 | - (djm) ssh-keygen -i needs seeded RNG; report from markus@ | 1629 | - (djm) ssh-keygen -i needs seeded RNG; report from markus@ |
1625 | 1630 | ||
1626 | $Id: ChangeLog,v 1.2452 2002/09/11 23:43:56 djm Exp $ | 1631 | $Id: ChangeLog,v 1.2453 2002/09/11 23:47:29 djm Exp $ |
diff --git a/auth-krb5.c b/auth-krb5.c index 308a6d5f9..512f70b78 100644 --- a/auth-krb5.c +++ b/auth-krb5.c | |||
@@ -28,7 +28,7 @@ | |||
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include "includes.h" | 30 | #include "includes.h" |
31 | RCSID("$OpenBSD: auth-krb5.c,v 1.8 2002/03/19 10:49:35 markus Exp $"); | 31 | RCSID("$OpenBSD: auth-krb5.c,v 1.9 2002/09/09 06:48:06 itojun Exp $"); |
32 | 32 | ||
33 | #include "ssh.h" | 33 | #include "ssh.h" |
34 | #include "ssh1.h" | 34 | #include "ssh1.h" |
@@ -73,18 +73,17 @@ krb5_init(void *context) | |||
73 | * from the ticket | 73 | * from the ticket |
74 | */ | 74 | */ |
75 | int | 75 | int |
76 | auth_krb5(Authctxt *authctxt, krb5_data *auth, char **client) | 76 | auth_krb5(Authctxt *authctxt, krb5_data *auth, char **client, krb5_data *reply) |
77 | { | 77 | { |
78 | krb5_error_code problem; | 78 | krb5_error_code problem; |
79 | krb5_principal server; | 79 | krb5_principal server; |
80 | krb5_data reply; | ||
81 | krb5_ticket *ticket; | 80 | krb5_ticket *ticket; |
82 | int fd, ret; | 81 | int fd, ret; |
83 | 82 | ||
84 | ret = 0; | 83 | ret = 0; |
85 | server = NULL; | 84 | server = NULL; |
86 | ticket = NULL; | 85 | ticket = NULL; |
87 | reply.length = 0; | 86 | reply->length = 0; |
88 | 87 | ||
89 | problem = krb5_init(authctxt); | 88 | problem = krb5_init(authctxt); |
90 | if (problem) | 89 | if (problem) |
@@ -131,7 +130,7 @@ auth_krb5(Authctxt *authctxt, krb5_data *auth, char **client) | |||
131 | 130 | ||
132 | /* if client wants mutual auth */ | 131 | /* if client wants mutual auth */ |
133 | problem = krb5_mk_rep(authctxt->krb5_ctx, authctxt->krb5_auth_ctx, | 132 | problem = krb5_mk_rep(authctxt->krb5_ctx, authctxt->krb5_auth_ctx, |
134 | &reply); | 133 | reply); |
135 | if (problem) | 134 | if (problem) |
136 | goto err; | 135 | goto err; |
137 | 136 | ||
@@ -144,19 +143,16 @@ auth_krb5(Authctxt *authctxt, krb5_data *auth, char **client) | |||
144 | krb5_unparse_name(authctxt->krb5_ctx, authctxt->krb5_user, | 143 | krb5_unparse_name(authctxt->krb5_ctx, authctxt->krb5_user, |
145 | client); | 144 | client); |
146 | 145 | ||
147 | packet_start(SSH_SMSG_AUTH_KERBEROS_RESPONSE); | ||
148 | packet_put_string((char *) reply.data, reply.length); | ||
149 | packet_send(); | ||
150 | packet_write_wait(); | ||
151 | |||
152 | ret = 1; | 146 | ret = 1; |
153 | err: | 147 | err: |
154 | if (server) | 148 | if (server) |
155 | krb5_free_principal(authctxt->krb5_ctx, server); | 149 | krb5_free_principal(authctxt->krb5_ctx, server); |
156 | if (ticket) | 150 | if (ticket) |
157 | krb5_free_ticket(authctxt->krb5_ctx, ticket); | 151 | krb5_free_ticket(authctxt->krb5_ctx, ticket); |
158 | if (reply.length) | 152 | if (!ret && reply->length) { |
159 | xfree(reply.data); | 153 | xfree(reply->data); |
154 | memset(reply, 0, sizeof(*reply)); | ||
155 | } | ||
160 | 156 | ||
161 | if (problem) { | 157 | if (problem) { |
162 | if (authctxt->krb5_ctx != NULL) | 158 | if (authctxt->krb5_ctx != NULL) |
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: auth.h,v 1.39 2002/05/31 11:35:15 markus Exp $ */ | 1 | /* $OpenBSD: auth.h,v 1.40 2002/09/09 06:48:06 itojun Exp $ */ |
2 | 2 | ||
3 | /* | 3 | /* |
4 | * Copyright (c) 2000 Markus Friedl. All rights reserved. | 4 | * Copyright (c) 2000 Markus Friedl. All rights reserved. |
@@ -126,7 +126,7 @@ int auth_afs_token(Authctxt *, const char *); | |||
126 | #endif /* KRB4 */ | 126 | #endif /* KRB4 */ |
127 | 127 | ||
128 | #ifdef KRB5 | 128 | #ifdef KRB5 |
129 | int auth_krb5(Authctxt *authctxt, krb5_data *auth, char **client); | 129 | int auth_krb5(Authctxt *authctxt, krb5_data *auth, char **client, krb5_data *); |
130 | int auth_krb5_tgt(Authctxt *authctxt, krb5_data *tgt); | 130 | int auth_krb5_tgt(Authctxt *authctxt, krb5_data *tgt); |
131 | int auth_krb5_password(Authctxt *authctxt, const char *password); | 131 | int auth_krb5_password(Authctxt *authctxt, const char *password); |
132 | void krb5_cleanup_proc(void *authctxt); | 132 | void krb5_cleanup_proc(void *authctxt); |
@@ -10,7 +10,7 @@ | |||
10 | */ | 10 | */ |
11 | 11 | ||
12 | #include "includes.h" | 12 | #include "includes.h" |
13 | RCSID("$OpenBSD: auth1.c,v 1.42 2002/08/22 21:33:58 markus Exp $"); | 13 | RCSID("$OpenBSD: auth1.c,v 1.43 2002/09/09 06:48:06 itojun Exp $"); |
14 | 14 | ||
15 | #include "xmalloc.h" | 15 | #include "xmalloc.h" |
16 | #include "rsa.h" | 16 | #include "rsa.h" |
@@ -133,15 +133,27 @@ do_authloop(Authctxt *authctxt) | |||
133 | #endif /* KRB4 */ | 133 | #endif /* KRB4 */ |
134 | } else { | 134 | } else { |
135 | #ifdef KRB5 | 135 | #ifdef KRB5 |
136 | krb5_data tkt; | 136 | krb5_data tkt, reply; |
137 | tkt.length = dlen; | 137 | tkt.length = dlen; |
138 | tkt.data = kdata; | 138 | tkt.data = kdata; |
139 | 139 | ||
140 | if (auth_krb5(authctxt, &tkt, &client_user)) { | 140 | if (PRIVSEP(auth_krb5(authctxt, &tkt, |
141 | &client_user, &reply))) { | ||
141 | authenticated = 1; | 142 | authenticated = 1; |
142 | snprintf(info, sizeof(info), | 143 | snprintf(info, sizeof(info), |
143 | " tktuser %.100s", | 144 | " tktuser %.100s", |
144 | client_user); | 145 | client_user); |
146 | |||
147 | /* Send response to client */ | ||
148 | packet_start( | ||
149 | SSH_SMSG_AUTH_KERBEROS_RESPONSE); | ||
150 | packet_put_string((char *) | ||
151 | reply.data, reply.length); | ||
152 | packet_send(); | ||
153 | packet_write_wait(); | ||
154 | |||
155 | if (reply.length) | ||
156 | xfree(reply.data); | ||
145 | } | 157 | } |
146 | #endif /* KRB5 */ | 158 | #endif /* KRB5 */ |
147 | } | 159 | } |
@@ -25,7 +25,7 @@ | |||
25 | */ | 25 | */ |
26 | 26 | ||
27 | #include "includes.h" | 27 | #include "includes.h" |
28 | RCSID("$OpenBSD: monitor.c,v 1.24 2002/08/29 15:57:25 stevesk Exp $"); | 28 | RCSID("$OpenBSD: monitor.c,v 1.25 2002/09/09 06:48:06 itojun Exp $"); |
29 | 29 | ||
30 | #include <openssl/dh.h> | 30 | #include <openssl/dh.h> |
31 | 31 | ||
@@ -120,6 +120,10 @@ int mm_answer_sessid(int, Buffer *); | |||
120 | int mm_answer_pam_start(int, Buffer *); | 120 | int mm_answer_pam_start(int, Buffer *); |
121 | #endif | 121 | #endif |
122 | 122 | ||
123 | #ifdef KRB5 | ||
124 | int mm_answer_krb5(int, Buffer *); | ||
125 | #endif | ||
126 | |||
123 | static Authctxt *authctxt; | 127 | static Authctxt *authctxt; |
124 | static BIGNUM *ssh1_challenge = NULL; /* used for ssh1 rsa auth */ | 128 | static BIGNUM *ssh1_challenge = NULL; /* used for ssh1 rsa auth */ |
125 | 129 | ||
@@ -199,6 +203,9 @@ struct mon_table mon_dispatch_proto15[] = { | |||
199 | #ifdef USE_PAM | 203 | #ifdef USE_PAM |
200 | {MONITOR_REQ_PAM_START, MON_ONCE, mm_answer_pam_start}, | 204 | {MONITOR_REQ_PAM_START, MON_ONCE, mm_answer_pam_start}, |
201 | #endif | 205 | #endif |
206 | #ifdef KRB5 | ||
207 | {MONITOR_REQ_KRB5, MON_ONCE|MON_AUTH, mm_answer_krb5}, | ||
208 | #endif | ||
202 | {0, 0, NULL} | 209 | {0, 0, NULL} |
203 | }; | 210 | }; |
204 | 211 | ||
@@ -1277,6 +1284,42 @@ mm_answer_rsa_response(int socket, Buffer *m) | |||
1277 | return (success); | 1284 | return (success); |
1278 | } | 1285 | } |
1279 | 1286 | ||
1287 | |||
1288 | #ifdef KRB5 | ||
1289 | int | ||
1290 | mm_answer_krb5(int socket, Buffer *m) | ||
1291 | { | ||
1292 | krb5_data tkt, reply; | ||
1293 | char *client_user; | ||
1294 | u_int len; | ||
1295 | int success; | ||
1296 | |||
1297 | /* use temporary var to avoid size issues on 64bit arch */ | ||
1298 | tkt.data = buffer_get_string(m, &len); | ||
1299 | tkt.length = len; | ||
1300 | |||
1301 | success = auth_krb5(authctxt, &tkt, &client_user, &reply); | ||
1302 | |||
1303 | if (tkt.length) | ||
1304 | xfree(tkt.data); | ||
1305 | |||
1306 | buffer_clear(m); | ||
1307 | buffer_put_int(m, success); | ||
1308 | |||
1309 | if (success) { | ||
1310 | buffer_put_cstring(m, client_user); | ||
1311 | buffer_put_string(m, reply.data, reply.length); | ||
1312 | if (client_user) | ||
1313 | xfree(client_user); | ||
1314 | if (reply.length) | ||
1315 | xfree(reply.data); | ||
1316 | } | ||
1317 | mm_request_send(socket, MONITOR_ANS_KRB5, m); | ||
1318 | |||
1319 | return success; | ||
1320 | } | ||
1321 | #endif | ||
1322 | |||
1280 | int | 1323 | int |
1281 | mm_answer_term(int socket, Buffer *req) | 1324 | mm_answer_term(int socket, Buffer *req) |
1282 | { | 1325 | { |
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: monitor.h,v 1.6 2002/06/11 05:46:20 mpech Exp $ */ | 1 | /* $OpenBSD: monitor.h,v 1.7 2002/09/09 06:48:06 itojun 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_KRB5, MONITOR_ANS_KRB5, | ||
52 | MONITOR_REQ_PAM_START, | 53 | MONITOR_REQ_PAM_START, |
53 | MONITOR_REQ_TERM | 54 | MONITOR_REQ_TERM |
54 | }; | 55 | }; |
diff --git a/monitor_wrap.c b/monitor_wrap.c index 78be2915f..ed1c50ff9 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" |
28 | RCSID("$OpenBSD: monitor_wrap.c,v 1.16 2002/07/04 10:41:47 markus Exp $"); | 28 | RCSID("$OpenBSD: monitor_wrap.c,v 1.17 2002/09/09 06:48:06 itojun Exp $"); |
29 | 29 | ||
30 | #include <openssl/bn.h> | 30 | #include <openssl/bn.h> |
31 | #include <openssl/dh.h> | 31 | #include <openssl/dh.h> |
@@ -936,3 +936,38 @@ mm_auth_rsa_verify_response(Key *key, BIGNUM *p, u_char response[16]) | |||
936 | 936 | ||
937 | return (success); | 937 | return (success); |
938 | } | 938 | } |
939 | |||
940 | #ifdef KRB5 | ||
941 | int | ||
942 | mm_auth_krb5(void *ctx, void *argp, char **userp, void *resp) | ||
943 | { | ||
944 | krb5_data *tkt, *reply; | ||
945 | Buffer m; | ||
946 | int success; | ||
947 | |||
948 | debug3("%s entering", __func__); | ||
949 | tkt = (krb5_data *) argp; | ||
950 | reply = (krb5_data *) resp; | ||
951 | |||
952 | buffer_init(&m); | ||
953 | buffer_put_string(&m, tkt->data, tkt->length); | ||
954 | |||
955 | mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_KRB5, &m); | ||
956 | mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_KRB5, &m); | ||
957 | |||
958 | success = buffer_get_int(&m); | ||
959 | if (success) { | ||
960 | u_int len; | ||
961 | |||
962 | *userp = buffer_get_string(&m, NULL); | ||
963 | reply->data = buffer_get_string(&m, &len); | ||
964 | reply->length = len; | ||
965 | } else { | ||
966 | memset(reply, 0, sizeof(*reply)); | ||
967 | *userp = NULL; | ||
968 | } | ||
969 | |||
970 | buffer_free(&m); | ||
971 | return (success); | ||
972 | } | ||
973 | #endif | ||
diff --git a/monitor_wrap.h b/monitor_wrap.h index f97862b5b..5e583e15b 100644 --- a/monitor_wrap.h +++ b/monitor_wrap.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: monitor_wrap.h,v 1.6 2002/06/30 21:59:45 deraadt Exp $ */ | 1 | /* $OpenBSD: monitor_wrap.h,v 1.7 2002/09/09 06:48:06 itojun Exp $ */ |
2 | 2 | ||
3 | /* | 3 | /* |
4 | * Copyright 2002 Niels Provos <provos@citi.umich.edu> | 4 | * Copyright 2002 Niels Provos <provos@citi.umich.edu> |
@@ -83,6 +83,13 @@ int mm_bsdauth_respond(void *, u_int, char **); | |||
83 | int mm_skey_query(void *, char **, char **, u_int *, char ***, u_int **); | 83 | int mm_skey_query(void *, char **, char **, u_int *, char ***, u_int **); |
84 | int mm_skey_respond(void *, u_int, char **); | 84 | int mm_skey_respond(void *, u_int, char **); |
85 | 85 | ||
86 | /* auth_krb5 */ | ||
87 | #ifdef KRB5 | ||
88 | /* auth and reply are really krb5_data objects, but we don't want to | ||
89 | * include all of the krb5 headers here */ | ||
90 | int mm_auth_krb5(void *authctxt, void *auth, char **client, void *reply); | ||
91 | #endif | ||
92 | |||
86 | /* zlib allocation hooks */ | 93 | /* zlib allocation hooks */ |
87 | 94 | ||
88 | void *mm_zalloc(struct mm_master *, u_int, u_int); | 95 | void *mm_zalloc(struct mm_master *, u_int, u_int); |