summaryrefslogtreecommitdiff
path: root/monitor.c
diff options
context:
space:
mode:
Diffstat (limited to 'monitor.c')
-rw-r--r--monitor.c108
1 files changed, 107 insertions, 1 deletions
diff --git a/monitor.c b/monitor.c
index a166fed2e..2d46b7b79 100644
--- a/monitor.c
+++ b/monitor.c
@@ -180,6 +180,8 @@ int mm_answer_gss_setup_ctx(int, Buffer *);
180int mm_answer_gss_accept_ctx(int, Buffer *); 180int mm_answer_gss_accept_ctx(int, Buffer *);
181int mm_answer_gss_userok(int, Buffer *); 181int mm_answer_gss_userok(int, Buffer *);
182int mm_answer_gss_checkmic(int, Buffer *); 182int mm_answer_gss_checkmic(int, Buffer *);
183int mm_answer_gss_sign(int, Buffer *);
184int mm_answer_gss_updatecreds(int, Buffer *);
183#endif 185#endif
184 186
185#ifdef SSH_AUDIT_EVENTS 187#ifdef SSH_AUDIT_EVENTS
@@ -251,6 +253,7 @@ struct mon_table mon_dispatch_proto20[] = {
251 {MONITOR_REQ_GSSSTEP, MON_ISAUTH, mm_answer_gss_accept_ctx}, 253 {MONITOR_REQ_GSSSTEP, MON_ISAUTH, mm_answer_gss_accept_ctx},
252 {MONITOR_REQ_GSSUSEROK, MON_AUTH, mm_answer_gss_userok}, 254 {MONITOR_REQ_GSSUSEROK, MON_AUTH, mm_answer_gss_userok},
253 {MONITOR_REQ_GSSCHECKMIC, MON_ISAUTH, mm_answer_gss_checkmic}, 255 {MONITOR_REQ_GSSCHECKMIC, MON_ISAUTH, mm_answer_gss_checkmic},
256 {MONITOR_REQ_GSSSIGN, MON_ONCE, mm_answer_gss_sign},
254#endif 257#endif
255#ifdef JPAKE 258#ifdef JPAKE
256 {MONITOR_REQ_JPAKE_GET_PWDATA, MON_ONCE, mm_answer_jpake_get_pwdata}, 259 {MONITOR_REQ_JPAKE_GET_PWDATA, MON_ONCE, mm_answer_jpake_get_pwdata},
@@ -263,6 +266,12 @@ struct mon_table mon_dispatch_proto20[] = {
263}; 266};
264 267
265struct mon_table mon_dispatch_postauth20[] = { 268struct mon_table mon_dispatch_postauth20[] = {
269#ifdef GSSAPI
270 {MONITOR_REQ_GSSSETUP, 0, mm_answer_gss_setup_ctx},
271 {MONITOR_REQ_GSSSTEP, 0, mm_answer_gss_accept_ctx},
272 {MONITOR_REQ_GSSSIGN, 0, mm_answer_gss_sign},
273 {MONITOR_REQ_GSSUPCREDS, 0, mm_answer_gss_updatecreds},
274#endif
266 {MONITOR_REQ_MODULI, 0, mm_answer_moduli}, 275 {MONITOR_REQ_MODULI, 0, mm_answer_moduli},
267 {MONITOR_REQ_SIGN, 0, mm_answer_sign}, 276 {MONITOR_REQ_SIGN, 0, mm_answer_sign},
268 {MONITOR_REQ_PTY, 0, mm_answer_pty}, 277 {MONITOR_REQ_PTY, 0, mm_answer_pty},
@@ -371,6 +380,10 @@ monitor_child_preauth(Authctxt *_authctxt, struct monitor *pmonitor)
371 /* Permit requests for moduli and signatures */ 380 /* Permit requests for moduli and signatures */
372 monitor_permit(mon_dispatch, MONITOR_REQ_MODULI, 1); 381 monitor_permit(mon_dispatch, MONITOR_REQ_MODULI, 1);
373 monitor_permit(mon_dispatch, MONITOR_REQ_SIGN, 1); 382 monitor_permit(mon_dispatch, MONITOR_REQ_SIGN, 1);
383#ifdef GSSAPI
384 /* and for the GSSAPI key exchange */
385 monitor_permit(mon_dispatch, MONITOR_REQ_GSSSETUP, 1);
386#endif
374 } else { 387 } else {
375 mon_dispatch = mon_dispatch_proto15; 388 mon_dispatch = mon_dispatch_proto15;
376 389
@@ -468,6 +481,10 @@ monitor_child_postauth(struct monitor *pmonitor)
468 monitor_permit(mon_dispatch, MONITOR_REQ_MODULI, 1); 481 monitor_permit(mon_dispatch, MONITOR_REQ_MODULI, 1);
469 monitor_permit(mon_dispatch, MONITOR_REQ_SIGN, 1); 482 monitor_permit(mon_dispatch, MONITOR_REQ_SIGN, 1);
470 monitor_permit(mon_dispatch, MONITOR_REQ_TERM, 1); 483 monitor_permit(mon_dispatch, MONITOR_REQ_TERM, 1);
484#ifdef GSSAPI
485 /* and for the GSSAPI key exchange */
486 monitor_permit(mon_dispatch, MONITOR_REQ_GSSSETUP, 1);
487#endif
471 } else { 488 } else {
472 mon_dispatch = mon_dispatch_postauth15; 489 mon_dispatch = mon_dispatch_postauth15;
473 monitor_permit(mon_dispatch, MONITOR_REQ_TERM, 1); 490 monitor_permit(mon_dispatch, MONITOR_REQ_TERM, 1);
@@ -1802,6 +1819,13 @@ mm_get_kex(Buffer *m)
1802 kex->kex[KEX_DH_GEX_SHA1] = kexgex_server; 1819 kex->kex[KEX_DH_GEX_SHA1] = kexgex_server;
1803 kex->kex[KEX_DH_GEX_SHA256] = kexgex_server; 1820 kex->kex[KEX_DH_GEX_SHA256] = kexgex_server;
1804 kex->kex[KEX_ECDH_SHA2] = kexecdh_server; 1821 kex->kex[KEX_ECDH_SHA2] = kexecdh_server;
1822#ifdef GSSAPI
1823 if (options.gss_keyex) {
1824 kex->kex[KEX_GSS_GRP1_SHA1] = kexgss_server;
1825 kex->kex[KEX_GSS_GRP14_SHA1] = kexgss_server;
1826 kex->kex[KEX_GSS_GEX_SHA1] = kexgss_server;
1827 }
1828#endif
1805 kex->server = 1; 1829 kex->server = 1;
1806 kex->hostkey_type = buffer_get_int(m); 1830 kex->hostkey_type = buffer_get_int(m);
1807 kex->kex_type = buffer_get_int(m); 1831 kex->kex_type = buffer_get_int(m);
@@ -2008,6 +2032,9 @@ mm_answer_gss_setup_ctx(int sock, Buffer *m)
2008 OM_uint32 major; 2032 OM_uint32 major;
2009 u_int len; 2033 u_int len;
2010 2034
2035 if (!options.gss_authentication && !options.gss_keyex)
2036 fatal("In GSSAPI monitor when GSSAPI is disabled");
2037
2011 goid.elements = buffer_get_string(m, &len); 2038 goid.elements = buffer_get_string(m, &len);
2012 goid.length = len; 2039 goid.length = len;
2013 2040
@@ -2035,6 +2062,9 @@ mm_answer_gss_accept_ctx(int sock, Buffer *m)
2035 OM_uint32 flags = 0; /* GSI needs this */ 2062 OM_uint32 flags = 0; /* GSI needs this */
2036 u_int len; 2063 u_int len;
2037 2064
2065 if (!options.gss_authentication && !options.gss_keyex)
2066 fatal("In GSSAPI monitor when GSSAPI is disabled");
2067
2038 in.value = buffer_get_string(m, &len); 2068 in.value = buffer_get_string(m, &len);
2039 in.length = len; 2069 in.length = len;
2040 major = ssh_gssapi_accept_ctx(gsscontext, &in, &out, &flags); 2070 major = ssh_gssapi_accept_ctx(gsscontext, &in, &out, &flags);
@@ -2052,6 +2082,7 @@ mm_answer_gss_accept_ctx(int sock, Buffer *m)
2052 monitor_permit(mon_dispatch, MONITOR_REQ_GSSSTEP, 0); 2082 monitor_permit(mon_dispatch, MONITOR_REQ_GSSSTEP, 0);
2053 monitor_permit(mon_dispatch, MONITOR_REQ_GSSUSEROK, 1); 2083 monitor_permit(mon_dispatch, MONITOR_REQ_GSSUSEROK, 1);
2054 monitor_permit(mon_dispatch, MONITOR_REQ_GSSCHECKMIC, 1); 2084 monitor_permit(mon_dispatch, MONITOR_REQ_GSSCHECKMIC, 1);
2085 monitor_permit(mon_dispatch, MONITOR_REQ_GSSSIGN, 1);
2055 } 2086 }
2056 return (0); 2087 return (0);
2057} 2088}
@@ -2063,6 +2094,9 @@ mm_answer_gss_checkmic(int sock, Buffer *m)
2063 OM_uint32 ret; 2094 OM_uint32 ret;
2064 u_int len; 2095 u_int len;
2065 2096
2097 if (!options.gss_authentication && !options.gss_keyex)
2098 fatal("In GSSAPI monitor when GSSAPI is disabled");
2099
2066 gssbuf.value = buffer_get_string(m, &len); 2100 gssbuf.value = buffer_get_string(m, &len);
2067 gssbuf.length = len; 2101 gssbuf.length = len;
2068 mic.value = buffer_get_string(m, &len); 2102 mic.value = buffer_get_string(m, &len);
@@ -2089,7 +2123,11 @@ mm_answer_gss_userok(int sock, Buffer *m)
2089{ 2123{
2090 int authenticated; 2124 int authenticated;
2091 2125
2092 authenticated = authctxt->valid && ssh_gssapi_userok(authctxt->user); 2126 if (!options.gss_authentication && !options.gss_keyex)
2127 fatal("In GSSAPI monitor when GSSAPI is disabled");
2128
2129 authenticated = authctxt->valid &&
2130 ssh_gssapi_userok(authctxt->user, authctxt->pw);
2093 2131
2094 buffer_clear(m); 2132 buffer_clear(m);
2095 buffer_put_int(m, authenticated); 2133 buffer_put_int(m, authenticated);
@@ -2102,6 +2140,74 @@ mm_answer_gss_userok(int sock, Buffer *m)
2102 /* Monitor loop will terminate if authenticated */ 2140 /* Monitor loop will terminate if authenticated */
2103 return (authenticated); 2141 return (authenticated);
2104} 2142}
2143
2144int
2145mm_answer_gss_sign(int socket, Buffer *m)
2146{
2147 gss_buffer_desc data;
2148 gss_buffer_desc hash = GSS_C_EMPTY_BUFFER;
2149 OM_uint32 major, minor;
2150 u_int len;
2151
2152 if (!options.gss_authentication && !options.gss_keyex)
2153 fatal("In GSSAPI monitor when GSSAPI is disabled");
2154
2155 data.value = buffer_get_string(m, &len);
2156 data.length = len;
2157 if (data.length != 20)
2158 fatal("%s: data length incorrect: %d", __func__,
2159 (int) data.length);
2160
2161 /* Save the session ID on the first time around */
2162 if (session_id2_len == 0) {
2163 session_id2_len = data.length;
2164 session_id2 = xmalloc(session_id2_len);
2165 memcpy(session_id2, data.value, session_id2_len);
2166 }
2167 major = ssh_gssapi_sign(gsscontext, &data, &hash);
2168
2169 xfree(data.value);
2170
2171 buffer_clear(m);
2172 buffer_put_int(m, major);
2173 buffer_put_string(m, hash.value, hash.length);
2174
2175 mm_request_send(socket, MONITOR_ANS_GSSSIGN, m);
2176
2177 gss_release_buffer(&minor, &hash);
2178
2179 /* Turn on getpwnam permissions */
2180 monitor_permit(mon_dispatch, MONITOR_REQ_PWNAM, 1);
2181
2182 /* And credential updating, for when rekeying */
2183 monitor_permit(mon_dispatch, MONITOR_REQ_GSSUPCREDS, 1);
2184
2185 return (0);
2186}
2187
2188int
2189mm_answer_gss_updatecreds(int socket, Buffer *m) {
2190 ssh_gssapi_ccache store;
2191 int ok;
2192
2193 store.filename = buffer_get_string(m, NULL);
2194 store.envvar = buffer_get_string(m, NULL);
2195 store.envval = buffer_get_string(m, NULL);
2196
2197 ok = ssh_gssapi_update_creds(&store);
2198
2199 xfree(store.filename);
2200 xfree(store.envvar);
2201 xfree(store.envval);
2202
2203 buffer_clear(m);
2204 buffer_put_int(m, ok);
2205
2206 mm_request_send(socket, MONITOR_ANS_GSSUPCREDS, m);
2207
2208 return(0);
2209}
2210
2105#endif /* GSSAPI */ 2211#endif /* GSSAPI */
2106 2212
2107#ifdef JPAKE 2213#ifdef JPAKE