summaryrefslogtreecommitdiff
path: root/monitor.c
diff options
context:
space:
mode:
authorColin Watson <cjwatson@debian.org>2005-09-14 15:20:11 +0000
committerColin Watson <cjwatson@debian.org>2005-09-14 15:20:11 +0000
commitf88d86e05895671b9d036c26566a41752ec86c31 (patch)
tree383ab296992965df981866a84ad9cbd5f18866e3 /monitor.c
parent2a6f54a2f2f0efe713ee5f6eb9e2099aef0ed516 (diff)
* Add remaining pieces of Kerberos support (closes: #275472):
- Add GSSAPI key exchange support from http://www.sxw.org.uk/computing/patches/openssh.html (thanks, Stephen Frost).
Diffstat (limited to 'monitor.c')
-rw-r--r--monitor.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/monitor.c b/monitor.c
index 081aabbdc..0d100ab56 100644
--- a/monitor.c
+++ b/monitor.c
@@ -141,6 +141,7 @@ int mm_answer_gss_setup_ctx(int, Buffer *);
141int mm_answer_gss_accept_ctx(int, Buffer *); 141int mm_answer_gss_accept_ctx(int, Buffer *);
142int mm_answer_gss_userok(int, Buffer *); 142int mm_answer_gss_userok(int, Buffer *);
143int mm_answer_gss_checkmic(int, Buffer *); 143int mm_answer_gss_checkmic(int, Buffer *);
144int mm_answer_gss_sign(int, Buffer *);
144#endif 145#endif
145 146
146#ifdef SSH_AUDIT_EVENTS 147#ifdef SSH_AUDIT_EVENTS
@@ -209,11 +210,17 @@ struct mon_table mon_dispatch_proto20[] = {
209 {MONITOR_REQ_GSSSTEP, MON_ISAUTH, mm_answer_gss_accept_ctx}, 210 {MONITOR_REQ_GSSSTEP, MON_ISAUTH, mm_answer_gss_accept_ctx},
210 {MONITOR_REQ_GSSUSEROK, MON_AUTH, mm_answer_gss_userok}, 211 {MONITOR_REQ_GSSUSEROK, MON_AUTH, mm_answer_gss_userok},
211 {MONITOR_REQ_GSSCHECKMIC, MON_ISAUTH, mm_answer_gss_checkmic}, 212 {MONITOR_REQ_GSSCHECKMIC, MON_ISAUTH, mm_answer_gss_checkmic},
213 {MONITOR_REQ_GSSSIGN, MON_ONCE, mm_answer_gss_sign},
212#endif 214#endif
213 {0, 0, NULL} 215 {0, 0, NULL}
214}; 216};
215 217
216struct mon_table mon_dispatch_postauth20[] = { 218struct mon_table mon_dispatch_postauth20[] = {
219#ifdef GSSAPI
220 {MONITOR_REQ_GSSSETUP, 0, mm_answer_gss_setup_ctx},
221 {MONITOR_REQ_GSSSTEP, 0, mm_answer_gss_accept_ctx},
222 {MONITOR_REQ_GSSSIGN, 0, mm_answer_gss_sign},
223#endif
217 {MONITOR_REQ_MODULI, 0, mm_answer_moduli}, 224 {MONITOR_REQ_MODULI, 0, mm_answer_moduli},
218 {MONITOR_REQ_SIGN, 0, mm_answer_sign}, 225 {MONITOR_REQ_SIGN, 0, mm_answer_sign},
219 {MONITOR_REQ_PTY, 0, mm_answer_pty}, 226 {MONITOR_REQ_PTY, 0, mm_answer_pty},
@@ -318,6 +325,10 @@ monitor_child_preauth(Authctxt *_authctxt, struct monitor *pmonitor)
318 /* Permit requests for moduli and signatures */ 325 /* Permit requests for moduli and signatures */
319 monitor_permit(mon_dispatch, MONITOR_REQ_MODULI, 1); 326 monitor_permit(mon_dispatch, MONITOR_REQ_MODULI, 1);
320 monitor_permit(mon_dispatch, MONITOR_REQ_SIGN, 1); 327 monitor_permit(mon_dispatch, MONITOR_REQ_SIGN, 1);
328#ifdef GSSAPI
329 /* and for the GSSAPI key exchange */
330 monitor_permit(mon_dispatch, MONITOR_REQ_GSSSETUP, 1);
331#endif
321 } else { 332 } else {
322 mon_dispatch = mon_dispatch_proto15; 333 mon_dispatch = mon_dispatch_proto15;
323 334
@@ -391,6 +402,10 @@ monitor_child_postauth(struct monitor *pmonitor)
391 monitor_permit(mon_dispatch, MONITOR_REQ_MODULI, 1); 402 monitor_permit(mon_dispatch, MONITOR_REQ_MODULI, 1);
392 monitor_permit(mon_dispatch, MONITOR_REQ_SIGN, 1); 403 monitor_permit(mon_dispatch, MONITOR_REQ_SIGN, 1);
393 monitor_permit(mon_dispatch, MONITOR_REQ_TERM, 1); 404 monitor_permit(mon_dispatch, MONITOR_REQ_TERM, 1);
405#ifdef GSSAPI
406 /* and for the GSSAPI key exchange */
407 monitor_permit(mon_dispatch, MONITOR_REQ_GSSSETUP, 1);
408#endif
394 } else { 409 } else {
395 mon_dispatch = mon_dispatch_postauth15; 410 mon_dispatch = mon_dispatch_postauth15;
396 monitor_permit(mon_dispatch, MONITOR_REQ_TERM, 1); 411 monitor_permit(mon_dispatch, MONITOR_REQ_TERM, 1);
@@ -1629,6 +1644,9 @@ mm_get_kex(Buffer *m)
1629 kex->kex[KEX_DH_GRP1_SHA1] = kexdh_server; 1644 kex->kex[KEX_DH_GRP1_SHA1] = kexdh_server;
1630 kex->kex[KEX_DH_GRP14_SHA1] = kexdh_server; 1645 kex->kex[KEX_DH_GRP14_SHA1] = kexdh_server;
1631 kex->kex[KEX_DH_GEX_SHA1] = kexgex_server; 1646 kex->kex[KEX_DH_GEX_SHA1] = kexgex_server;
1647#ifdef GSSAPI
1648 kex->kex[KEX_GSS_GRP1_SHA1] = kexgss_server;
1649#endif
1632 kex->server = 1; 1650 kex->server = 1;
1633 kex->hostkey_type = buffer_get_int(m); 1651 kex->hostkey_type = buffer_get_int(m);
1634 kex->kex_type = buffer_get_int(m); 1652 kex->kex_type = buffer_get_int(m);
@@ -1871,6 +1889,7 @@ mm_answer_gss_accept_ctx(int sock, Buffer *m)
1871 monitor_permit(mon_dispatch, MONITOR_REQ_GSSSTEP, 0); 1889 monitor_permit(mon_dispatch, MONITOR_REQ_GSSSTEP, 0);
1872 monitor_permit(mon_dispatch, MONITOR_REQ_GSSUSEROK, 1); 1890 monitor_permit(mon_dispatch, MONITOR_REQ_GSSUSEROK, 1);
1873 monitor_permit(mon_dispatch, MONITOR_REQ_GSSCHECKMIC, 1); 1891 monitor_permit(mon_dispatch, MONITOR_REQ_GSSCHECKMIC, 1);
1892 monitor_permit(mon_dispatch, MONITOR_REQ_GSSSIGN, 1);
1874 } 1893 }
1875 return (0); 1894 return (0);
1876} 1895}
@@ -1921,4 +1940,39 @@ mm_answer_gss_userok(int sock, Buffer *m)
1921 /* Monitor loop will terminate if authenticated */ 1940 /* Monitor loop will terminate if authenticated */
1922 return (authenticated); 1941 return (authenticated);
1923} 1942}
1943
1944int
1945mm_answer_gss_sign(int socket, Buffer *m)
1946{
1947 gss_buffer_desc data, hash;
1948 OM_uint32 major, minor;
1949
1950 data.value = buffer_get_string(m, &data.length);
1951 if (data.length != 20)
1952 fatal("%s: data length incorrect: %d", __func__, data.length);
1953
1954 /* Save the session ID on the first time around */
1955 if (session_id2_len == 0) {
1956 session_id2_len = data.length;
1957 session_id2 = xmalloc(session_id2_len);
1958 memcpy(session_id2, data.value, session_id2_len);
1959 }
1960 major = ssh_gssapi_sign(gsscontext, &data, &hash);
1961
1962 xfree(data.value);
1963
1964 buffer_clear(m);
1965 buffer_put_int(m, major);
1966 buffer_put_string(m, hash.value, hash.length);
1967
1968 mm_request_send(socket, MONITOR_ANS_GSSSIGN, m);
1969
1970 gss_release_buffer(&minor, &hash);
1971
1972 /* Turn on getpwnam permissions */
1973 monitor_permit(mon_dispatch, MONITOR_REQ_PWNAM, 1);
1974
1975 return (0);
1976}
1977
1924#endif /* GSSAPI */ 1978#endif /* GSSAPI */