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 e9802a3fd..ed598ce35 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);
@@ -1800,6 +1817,13 @@ mm_get_kex(Buffer *m)
1800 kex->kex[KEX_DH_GEX_SHA1] = kexgex_server; 1817 kex->kex[KEX_DH_GEX_SHA1] = kexgex_server;
1801 kex->kex[KEX_DH_GEX_SHA256] = kexgex_server; 1818 kex->kex[KEX_DH_GEX_SHA256] = kexgex_server;
1802 kex->kex[KEX_ECDH_SHA2] = kexecdh_server; 1819 kex->kex[KEX_ECDH_SHA2] = kexecdh_server;
1820#ifdef GSSAPI
1821 if (options.gss_keyex) {
1822 kex->kex[KEX_GSS_GRP1_SHA1] = kexgss_server;
1823 kex->kex[KEX_GSS_GRP14_SHA1] = kexgss_server;
1824 kex->kex[KEX_GSS_GEX_SHA1] = kexgss_server;
1825 }
1826#endif
1803 kex->server = 1; 1827 kex->server = 1;
1804 kex->hostkey_type = buffer_get_int(m); 1828 kex->hostkey_type = buffer_get_int(m);
1805 kex->kex_type = buffer_get_int(m); 1829 kex->kex_type = buffer_get_int(m);
@@ -2006,6 +2030,9 @@ mm_answer_gss_setup_ctx(int sock, Buffer *m)
2006 OM_uint32 major; 2030 OM_uint32 major;
2007 u_int len; 2031 u_int len;
2008 2032
2033 if (!options.gss_authentication && !options.gss_keyex)
2034 fatal("In GSSAPI monitor when GSSAPI is disabled");
2035
2009 goid.elements = buffer_get_string(m, &len); 2036 goid.elements = buffer_get_string(m, &len);
2010 goid.length = len; 2037 goid.length = len;
2011 2038
@@ -2033,6 +2060,9 @@ mm_answer_gss_accept_ctx(int sock, Buffer *m)
2033 OM_uint32 flags = 0; /* GSI needs this */ 2060 OM_uint32 flags = 0; /* GSI needs this */
2034 u_int len; 2061 u_int len;
2035 2062
2063 if (!options.gss_authentication && !options.gss_keyex)
2064 fatal("In GSSAPI monitor when GSSAPI is disabled");
2065
2036 in.value = buffer_get_string(m, &len); 2066 in.value = buffer_get_string(m, &len);
2037 in.length = len; 2067 in.length = len;
2038 major = ssh_gssapi_accept_ctx(gsscontext, &in, &out, &flags); 2068 major = ssh_gssapi_accept_ctx(gsscontext, &in, &out, &flags);
@@ -2050,6 +2080,7 @@ mm_answer_gss_accept_ctx(int sock, Buffer *m)
2050 monitor_permit(mon_dispatch, MONITOR_REQ_GSSSTEP, 0); 2080 monitor_permit(mon_dispatch, MONITOR_REQ_GSSSTEP, 0);
2051 monitor_permit(mon_dispatch, MONITOR_REQ_GSSUSEROK, 1); 2081 monitor_permit(mon_dispatch, MONITOR_REQ_GSSUSEROK, 1);
2052 monitor_permit(mon_dispatch, MONITOR_REQ_GSSCHECKMIC, 1); 2082 monitor_permit(mon_dispatch, MONITOR_REQ_GSSCHECKMIC, 1);
2083 monitor_permit(mon_dispatch, MONITOR_REQ_GSSSIGN, 1);
2053 } 2084 }
2054 return (0); 2085 return (0);
2055} 2086}
@@ -2061,6 +2092,9 @@ mm_answer_gss_checkmic(int sock, Buffer *m)
2061 OM_uint32 ret; 2092 OM_uint32 ret;
2062 u_int len; 2093 u_int len;
2063 2094
2095 if (!options.gss_authentication && !options.gss_keyex)
2096 fatal("In GSSAPI monitor when GSSAPI is disabled");
2097
2064 gssbuf.value = buffer_get_string(m, &len); 2098 gssbuf.value = buffer_get_string(m, &len);
2065 gssbuf.length = len; 2099 gssbuf.length = len;
2066 mic.value = buffer_get_string(m, &len); 2100 mic.value = buffer_get_string(m, &len);
@@ -2087,7 +2121,11 @@ mm_answer_gss_userok(int sock, Buffer *m)
2087{ 2121{
2088 int authenticated; 2122 int authenticated;
2089 2123
2090 authenticated = authctxt->valid && ssh_gssapi_userok(authctxt->user); 2124 if (!options.gss_authentication && !options.gss_keyex)
2125 fatal("In GSSAPI monitor when GSSAPI is disabled");
2126
2127 authenticated = authctxt->valid &&
2128 ssh_gssapi_userok(authctxt->user, authctxt->pw);
2091 2129
2092 buffer_clear(m); 2130 buffer_clear(m);
2093 buffer_put_int(m, authenticated); 2131 buffer_put_int(m, authenticated);
@@ -2100,6 +2138,74 @@ mm_answer_gss_userok(int sock, Buffer *m)
2100 /* Monitor loop will terminate if authenticated */ 2138 /* Monitor loop will terminate if authenticated */
2101 return (authenticated); 2139 return (authenticated);
2102} 2140}
2141
2142int
2143mm_answer_gss_sign(int socket, Buffer *m)
2144{
2145 gss_buffer_desc data;
2146 gss_buffer_desc hash = GSS_C_EMPTY_BUFFER;
2147 OM_uint32 major, minor;
2148 u_int len;
2149
2150 if (!options.gss_authentication && !options.gss_keyex)
2151 fatal("In GSSAPI monitor when GSSAPI is disabled");
2152
2153 data.value = buffer_get_string(m, &len);
2154 data.length = len;
2155 if (data.length != 20)
2156 fatal("%s: data length incorrect: %d", __func__,
2157 (int) data.length);
2158
2159 /* Save the session ID on the first time around */
2160 if (session_id2_len == 0) {
2161 session_id2_len = data.length;
2162 session_id2 = xmalloc(session_id2_len);
2163 memcpy(session_id2, data.value, session_id2_len);
2164 }
2165 major = ssh_gssapi_sign(gsscontext, &data, &hash);
2166
2167 xfree(data.value);
2168
2169 buffer_clear(m);
2170 buffer_put_int(m, major);
2171 buffer_put_string(m, hash.value, hash.length);
2172
2173 mm_request_send(socket, MONITOR_ANS_GSSSIGN, m);
2174
2175 gss_release_buffer(&minor, &hash);
2176
2177 /* Turn on getpwnam permissions */
2178 monitor_permit(mon_dispatch, MONITOR_REQ_PWNAM, 1);
2179
2180 /* And credential updating, for when rekeying */
2181 monitor_permit(mon_dispatch, MONITOR_REQ_GSSUPCREDS, 1);
2182
2183 return (0);
2184}
2185
2186int
2187mm_answer_gss_updatecreds(int socket, Buffer *m) {
2188 ssh_gssapi_ccache store;
2189 int ok;
2190
2191 store.filename = buffer_get_string(m, NULL);
2192 store.envvar = buffer_get_string(m, NULL);
2193 store.envval = buffer_get_string(m, NULL);
2194
2195 ok = ssh_gssapi_update_creds(&store);
2196
2197 xfree(store.filename);
2198 xfree(store.envvar);
2199 xfree(store.envval);
2200
2201 buffer_clear(m);
2202 buffer_put_int(m, ok);
2203
2204 mm_request_send(socket, MONITOR_ANS_GSSUPCREDS, m);
2205
2206 return(0);
2207}
2208
2103#endif /* GSSAPI */ 2209#endif /* GSSAPI */
2104 2210
2105#ifdef JPAKE 2211#ifdef JPAKE