diff options
Diffstat (limited to 'monitor.c')
-rw-r--r-- | monitor.c | 89 |
1 files changed, 87 insertions, 2 deletions
@@ -134,6 +134,7 @@ int mm_answer_sign(int, Buffer *); | |||
134 | int mm_answer_pwnamallow(int, Buffer *); | 134 | int mm_answer_pwnamallow(int, Buffer *); |
135 | int mm_answer_auth2_read_banner(int, Buffer *); | 135 | int mm_answer_auth2_read_banner(int, Buffer *); |
136 | int mm_answer_authserv(int, Buffer *); | 136 | int mm_answer_authserv(int, Buffer *); |
137 | int mm_answer_authrole(int, Buffer *); | ||
137 | int mm_answer_authpassword(int, Buffer *); | 138 | int mm_answer_authpassword(int, Buffer *); |
138 | int mm_answer_bsdauthquery(int, Buffer *); | 139 | int mm_answer_bsdauthquery(int, Buffer *); |
139 | int mm_answer_bsdauthrespond(int, Buffer *); | 140 | int mm_answer_bsdauthrespond(int, Buffer *); |
@@ -164,6 +165,7 @@ int mm_answer_gss_setup_ctx(int, Buffer *); | |||
164 | int mm_answer_gss_accept_ctx(int, Buffer *); | 165 | int mm_answer_gss_accept_ctx(int, Buffer *); |
165 | int mm_answer_gss_userok(int, Buffer *); | 166 | int mm_answer_gss_userok(int, Buffer *); |
166 | int mm_answer_gss_checkmic(int, Buffer *); | 167 | int mm_answer_gss_checkmic(int, Buffer *); |
168 | int mm_answer_gss_sign(int, Buffer *); | ||
167 | #endif | 169 | #endif |
168 | 170 | ||
169 | #ifdef SSH_AUDIT_EVENTS | 171 | #ifdef SSH_AUDIT_EVENTS |
@@ -205,6 +207,7 @@ struct mon_table mon_dispatch_proto20[] = { | |||
205 | {MONITOR_REQ_SIGN, MON_ONCE, mm_answer_sign}, | 207 | {MONITOR_REQ_SIGN, MON_ONCE, mm_answer_sign}, |
206 | {MONITOR_REQ_PWNAM, MON_ONCE, mm_answer_pwnamallow}, | 208 | {MONITOR_REQ_PWNAM, MON_ONCE, mm_answer_pwnamallow}, |
207 | {MONITOR_REQ_AUTHSERV, MON_ONCE, mm_answer_authserv}, | 209 | {MONITOR_REQ_AUTHSERV, MON_ONCE, mm_answer_authserv}, |
210 | {MONITOR_REQ_AUTHROLE, MON_ONCE, mm_answer_authrole}, | ||
208 | {MONITOR_REQ_AUTH2_READ_BANNER, MON_ONCE, mm_answer_auth2_read_banner}, | 211 | {MONITOR_REQ_AUTH2_READ_BANNER, MON_ONCE, mm_answer_auth2_read_banner}, |
209 | {MONITOR_REQ_AUTHPASSWORD, MON_AUTH, mm_answer_authpassword}, | 212 | {MONITOR_REQ_AUTHPASSWORD, MON_AUTH, mm_answer_authpassword}, |
210 | #ifdef USE_PAM | 213 | #ifdef USE_PAM |
@@ -233,11 +236,17 @@ struct mon_table mon_dispatch_proto20[] = { | |||
233 | {MONITOR_REQ_GSSSTEP, MON_ISAUTH, mm_answer_gss_accept_ctx}, | 236 | {MONITOR_REQ_GSSSTEP, MON_ISAUTH, mm_answer_gss_accept_ctx}, |
234 | {MONITOR_REQ_GSSUSEROK, MON_AUTH, mm_answer_gss_userok}, | 237 | {MONITOR_REQ_GSSUSEROK, MON_AUTH, mm_answer_gss_userok}, |
235 | {MONITOR_REQ_GSSCHECKMIC, MON_ISAUTH, mm_answer_gss_checkmic}, | 238 | {MONITOR_REQ_GSSCHECKMIC, MON_ISAUTH, mm_answer_gss_checkmic}, |
239 | {MONITOR_REQ_GSSSIGN, MON_ONCE, mm_answer_gss_sign}, | ||
236 | #endif | 240 | #endif |
237 | {0, 0, NULL} | 241 | {0, 0, NULL} |
238 | }; | 242 | }; |
239 | 243 | ||
240 | struct mon_table mon_dispatch_postauth20[] = { | 244 | struct mon_table mon_dispatch_postauth20[] = { |
245 | #ifdef GSSAPI | ||
246 | {MONITOR_REQ_GSSSETUP, 0, mm_answer_gss_setup_ctx}, | ||
247 | {MONITOR_REQ_GSSSTEP, 0, mm_answer_gss_accept_ctx}, | ||
248 | {MONITOR_REQ_GSSSIGN, 0, mm_answer_gss_sign}, | ||
249 | #endif | ||
241 | {MONITOR_REQ_MODULI, 0, mm_answer_moduli}, | 250 | {MONITOR_REQ_MODULI, 0, mm_answer_moduli}, |
242 | {MONITOR_REQ_SIGN, 0, mm_answer_sign}, | 251 | {MONITOR_REQ_SIGN, 0, mm_answer_sign}, |
243 | {MONITOR_REQ_PTY, 0, mm_answer_pty}, | 252 | {MONITOR_REQ_PTY, 0, mm_answer_pty}, |
@@ -342,6 +351,10 @@ monitor_child_preauth(Authctxt *_authctxt, struct monitor *pmonitor) | |||
342 | /* Permit requests for moduli and signatures */ | 351 | /* Permit requests for moduli and signatures */ |
343 | monitor_permit(mon_dispatch, MONITOR_REQ_MODULI, 1); | 352 | monitor_permit(mon_dispatch, MONITOR_REQ_MODULI, 1); |
344 | monitor_permit(mon_dispatch, MONITOR_REQ_SIGN, 1); | 353 | monitor_permit(mon_dispatch, MONITOR_REQ_SIGN, 1); |
354 | #ifdef GSSAPI | ||
355 | /* and for the GSSAPI key exchange */ | ||
356 | monitor_permit(mon_dispatch, MONITOR_REQ_GSSSETUP, 1); | ||
357 | #endif | ||
345 | } else { | 358 | } else { |
346 | mon_dispatch = mon_dispatch_proto15; | 359 | mon_dispatch = mon_dispatch_proto15; |
347 | 360 | ||
@@ -419,6 +432,10 @@ monitor_child_postauth(struct monitor *pmonitor) | |||
419 | monitor_permit(mon_dispatch, MONITOR_REQ_MODULI, 1); | 432 | monitor_permit(mon_dispatch, MONITOR_REQ_MODULI, 1); |
420 | monitor_permit(mon_dispatch, MONITOR_REQ_SIGN, 1); | 433 | monitor_permit(mon_dispatch, MONITOR_REQ_SIGN, 1); |
421 | monitor_permit(mon_dispatch, MONITOR_REQ_TERM, 1); | 434 | monitor_permit(mon_dispatch, MONITOR_REQ_TERM, 1); |
435 | #ifdef GSSAPI | ||
436 | /* and for the GSSAPI key exchange */ | ||
437 | monitor_permit(mon_dispatch, MONITOR_REQ_GSSSETUP, 1); | ||
438 | #endif | ||
422 | } else { | 439 | } else { |
423 | mon_dispatch = mon_dispatch_postauth15; | 440 | mon_dispatch = mon_dispatch_postauth15; |
424 | monitor_permit(mon_dispatch, MONITOR_REQ_TERM, 1); | 441 | monitor_permit(mon_dispatch, MONITOR_REQ_TERM, 1); |
@@ -658,6 +675,7 @@ mm_answer_pwnamallow(int sock, Buffer *m) | |||
658 | else { | 675 | else { |
659 | /* Allow service/style information on the auth context */ | 676 | /* Allow service/style information on the auth context */ |
660 | monitor_permit(mon_dispatch, MONITOR_REQ_AUTHSERV, 1); | 677 | monitor_permit(mon_dispatch, MONITOR_REQ_AUTHSERV, 1); |
678 | monitor_permit(mon_dispatch, MONITOR_REQ_AUTHROLE, 1); | ||
661 | monitor_permit(mon_dispatch, MONITOR_REQ_AUTH2_READ_BANNER, 1); | 679 | monitor_permit(mon_dispatch, MONITOR_REQ_AUTH2_READ_BANNER, 1); |
662 | } | 680 | } |
663 | 681 | ||
@@ -691,14 +709,37 @@ mm_answer_authserv(int sock, Buffer *m) | |||
691 | 709 | ||
692 | authctxt->service = buffer_get_string(m, NULL); | 710 | authctxt->service = buffer_get_string(m, NULL); |
693 | authctxt->style = buffer_get_string(m, NULL); | 711 | authctxt->style = buffer_get_string(m, NULL); |
694 | debug3("%s: service=%s, style=%s", | 712 | authctxt->role = buffer_get_string(m, NULL); |
695 | __func__, authctxt->service, authctxt->style); | 713 | debug3("%s: service=%s, style=%s, role=%s", |
714 | __func__, authctxt->service, authctxt->style, authctxt->role); | ||
696 | 715 | ||
697 | if (strlen(authctxt->style) == 0) { | 716 | if (strlen(authctxt->style) == 0) { |
698 | xfree(authctxt->style); | 717 | xfree(authctxt->style); |
699 | authctxt->style = NULL; | 718 | authctxt->style = NULL; |
700 | } | 719 | } |
701 | 720 | ||
721 | if (strlen(authctxt->role) == 0) { | ||
722 | xfree(authctxt->role); | ||
723 | authctxt->role = NULL; | ||
724 | } | ||
725 | |||
726 | return (0); | ||
727 | } | ||
728 | |||
729 | int | ||
730 | mm_answer_authrole(int sock, Buffer *m) | ||
731 | { | ||
732 | monitor_permit_authentications(1); | ||
733 | |||
734 | authctxt->role = buffer_get_string(m, NULL); | ||
735 | debug3("%s: role=%s", | ||
736 | __func__, authctxt->role); | ||
737 | |||
738 | if (strlen(authctxt->role) == 0) { | ||
739 | xfree(authctxt->role); | ||
740 | authctxt->role = NULL; | ||
741 | } | ||
742 | |||
702 | return (0); | 743 | return (0); |
703 | } | 744 | } |
704 | 745 | ||
@@ -1675,6 +1716,11 @@ mm_get_kex(Buffer *m) | |||
1675 | kex->kex[KEX_DH_GRP14_SHA1] = kexdh_server; | 1716 | kex->kex[KEX_DH_GRP14_SHA1] = kexdh_server; |
1676 | kex->kex[KEX_DH_GEX_SHA1] = kexgex_server; | 1717 | kex->kex[KEX_DH_GEX_SHA1] = kexgex_server; |
1677 | kex->kex[KEX_DH_GEX_SHA256] = kexgex_server; | 1718 | kex->kex[KEX_DH_GEX_SHA256] = kexgex_server; |
1719 | #ifdef GSSAPI | ||
1720 | kex->kex[KEX_GSS_GRP1_SHA1] = kexgss_server; | ||
1721 | kex->kex[KEX_GSS_GRP14_SHA1] = kexgss_server; | ||
1722 | kex->kex[KEX_GSS_GEX_SHA1] = kexgss_server; | ||
1723 | #endif | ||
1678 | kex->server = 1; | 1724 | kex->server = 1; |
1679 | kex->hostkey_type = buffer_get_int(m); | 1725 | kex->hostkey_type = buffer_get_int(m); |
1680 | kex->kex_type = buffer_get_int(m); | 1726 | kex->kex_type = buffer_get_int(m); |
@@ -1918,6 +1964,7 @@ mm_answer_gss_accept_ctx(int sock, Buffer *m) | |||
1918 | monitor_permit(mon_dispatch, MONITOR_REQ_GSSSTEP, 0); | 1964 | monitor_permit(mon_dispatch, MONITOR_REQ_GSSSTEP, 0); |
1919 | monitor_permit(mon_dispatch, MONITOR_REQ_GSSUSEROK, 1); | 1965 | monitor_permit(mon_dispatch, MONITOR_REQ_GSSUSEROK, 1); |
1920 | monitor_permit(mon_dispatch, MONITOR_REQ_GSSCHECKMIC, 1); | 1966 | monitor_permit(mon_dispatch, MONITOR_REQ_GSSCHECKMIC, 1); |
1967 | monitor_permit(mon_dispatch, MONITOR_REQ_GSSSIGN, 1); | ||
1921 | } | 1968 | } |
1922 | return (0); | 1969 | return (0); |
1923 | } | 1970 | } |
@@ -1968,4 +2015,42 @@ mm_answer_gss_userok(int sock, Buffer *m) | |||
1968 | /* Monitor loop will terminate if authenticated */ | 2015 | /* Monitor loop will terminate if authenticated */ |
1969 | return (authenticated); | 2016 | return (authenticated); |
1970 | } | 2017 | } |
2018 | |||
2019 | int | ||
2020 | mm_answer_gss_sign(int socket, Buffer *m) | ||
2021 | { | ||
2022 | gss_buffer_desc data; | ||
2023 | gss_buffer_desc hash = GSS_C_EMPTY_BUFFER; | ||
2024 | OM_uint32 major, minor; | ||
2025 | u_int len; | ||
2026 | |||
2027 | data.value = buffer_get_string(m, &len); | ||
2028 | data.length = len; | ||
2029 | if (data.length != 20) | ||
2030 | fatal("%s: data length incorrect: %d", __func__, data.length); | ||
2031 | |||
2032 | /* Save the session ID on the first time around */ | ||
2033 | if (session_id2_len == 0) { | ||
2034 | session_id2_len = data.length; | ||
2035 | session_id2 = xmalloc(session_id2_len); | ||
2036 | memcpy(session_id2, data.value, session_id2_len); | ||
2037 | } | ||
2038 | major = ssh_gssapi_sign(gsscontext, &data, &hash); | ||
2039 | |||
2040 | xfree(data.value); | ||
2041 | |||
2042 | buffer_clear(m); | ||
2043 | buffer_put_int(m, major); | ||
2044 | buffer_put_string(m, hash.value, hash.length); | ||
2045 | |||
2046 | mm_request_send(socket, MONITOR_ANS_GSSSIGN, m); | ||
2047 | |||
2048 | gss_release_buffer(&minor, &hash); | ||
2049 | |||
2050 | /* Turn on getpwnam permissions */ | ||
2051 | monitor_permit(mon_dispatch, MONITOR_REQ_PWNAM, 1); | ||
2052 | |||
2053 | return (0); | ||
2054 | } | ||
2055 | |||
1971 | #endif /* GSSAPI */ | 2056 | #endif /* GSSAPI */ |