diff options
Diffstat (limited to 'sshd.c')
-rw-r--r-- | sshd.c | 112 |
1 files changed, 111 insertions, 1 deletions
@@ -123,6 +123,10 @@ | |||
123 | #include "version.h" | 123 | #include "version.h" |
124 | #include "ssherr.h" | 124 | #include "ssherr.h" |
125 | 125 | ||
126 | #ifdef USE_SECURITY_SESSION_API | ||
127 | #include <Security/AuthSession.h> | ||
128 | #endif | ||
129 | |||
126 | /* Re-exec fds */ | 130 | /* Re-exec fds */ |
127 | #define REEXEC_DEVCRYPTO_RESERVED_FD (STDERR_FILENO + 1) | 131 | #define REEXEC_DEVCRYPTO_RESERVED_FD (STDERR_FILENO + 1) |
128 | #define REEXEC_STARTUP_PIPE_FD (STDERR_FILENO + 2) | 132 | #define REEXEC_STARTUP_PIPE_FD (STDERR_FILENO + 2) |
@@ -536,7 +540,7 @@ privsep_preauth_child(void) | |||
536 | 540 | ||
537 | #ifdef GSSAPI | 541 | #ifdef GSSAPI |
538 | /* Cache supported mechanism OIDs for later use */ | 542 | /* Cache supported mechanism OIDs for later use */ |
539 | if (options.gss_authentication) | 543 | if (options.gss_authentication || options.gss_keyex) |
540 | ssh_gssapi_prepare_supported_oids(); | 544 | ssh_gssapi_prepare_supported_oids(); |
541 | #endif | 545 | #endif |
542 | 546 | ||
@@ -1811,10 +1815,13 @@ main(int ac, char **av) | |||
1811 | free(fp); | 1815 | free(fp); |
1812 | } | 1816 | } |
1813 | accumulate_host_timing_secret(cfg, NULL); | 1817 | accumulate_host_timing_secret(cfg, NULL); |
1818 | #ifndef GSSAPI | ||
1819 | /* The GSSAPI key exchange can run without a host key */ | ||
1814 | if (!sensitive_data.have_ssh2_key) { | 1820 | if (!sensitive_data.have_ssh2_key) { |
1815 | logit("sshd: no hostkeys available -- exiting."); | 1821 | logit("sshd: no hostkeys available -- exiting."); |
1816 | exit(1); | 1822 | exit(1); |
1817 | } | 1823 | } |
1824 | #endif | ||
1818 | 1825 | ||
1819 | /* | 1826 | /* |
1820 | * Load certificates. They are stored in an array at identical | 1827 | * Load certificates. They are stored in an array at identical |
@@ -2105,6 +2112,60 @@ main(int ac, char **av) | |||
2105 | rdomain == NULL ? "" : "\""); | 2112 | rdomain == NULL ? "" : "\""); |
2106 | free(laddr); | 2113 | free(laddr); |
2107 | 2114 | ||
2115 | #ifdef USE_SECURITY_SESSION_API | ||
2116 | /* | ||
2117 | * Create a new security session for use by the new user login if | ||
2118 | * the current session is the root session or we are not launched | ||
2119 | * by inetd (eg: debugging mode or server mode). We do not | ||
2120 | * necessarily need to create a session if we are launched from | ||
2121 | * inetd because Panther xinetd will create a session for us. | ||
2122 | * | ||
2123 | * The only case where this logic will fail is if there is an | ||
2124 | * inetd running in a non-root session which is not creating | ||
2125 | * new sessions for us. Then all the users will end up in the | ||
2126 | * same session (bad). | ||
2127 | * | ||
2128 | * When the client exits, the session will be destroyed for us | ||
2129 | * automatically. | ||
2130 | * | ||
2131 | * We must create the session before any credentials are stored | ||
2132 | * (including AFS pags, which happens a few lines below). | ||
2133 | */ | ||
2134 | { | ||
2135 | OSStatus err = 0; | ||
2136 | SecuritySessionId sid = 0; | ||
2137 | SessionAttributeBits sattrs = 0; | ||
2138 | |||
2139 | err = SessionGetInfo(callerSecuritySession, &sid, &sattrs); | ||
2140 | if (err) | ||
2141 | error("SessionGetInfo() failed with error %.8X", | ||
2142 | (unsigned) err); | ||
2143 | else | ||
2144 | debug("Current Session ID is %.8X / Session Attributes are %.8X", | ||
2145 | (unsigned) sid, (unsigned) sattrs); | ||
2146 | |||
2147 | if (inetd_flag && !(sattrs & sessionIsRoot)) | ||
2148 | debug("Running in inetd mode in a non-root session... " | ||
2149 | "assuming inetd created the session for us."); | ||
2150 | else { | ||
2151 | debug("Creating new security session..."); | ||
2152 | err = SessionCreate(0, sessionHasTTY | sessionIsRemote); | ||
2153 | if (err) | ||
2154 | error("SessionCreate() failed with error %.8X", | ||
2155 | (unsigned) err); | ||
2156 | |||
2157 | err = SessionGetInfo(callerSecuritySession, &sid, | ||
2158 | &sattrs); | ||
2159 | if (err) | ||
2160 | error("SessionGetInfo() failed with error %.8X", | ||
2161 | (unsigned) err); | ||
2162 | else | ||
2163 | debug("New Session ID is %.8X / Session Attributes are %.8X", | ||
2164 | (unsigned) sid, (unsigned) sattrs); | ||
2165 | } | ||
2166 | } | ||
2167 | #endif | ||
2168 | |||
2108 | /* | 2169 | /* |
2109 | * We don't want to listen forever unless the other side | 2170 | * We don't want to listen forever unless the other side |
2110 | * successfully authenticates itself. So we set up an alarm which is | 2171 | * successfully authenticates itself. So we set up an alarm which is |
@@ -2288,6 +2349,48 @@ do_ssh2_kex(void) | |||
2288 | myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS] = compat_pkalg_proposal( | 2349 | myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS] = compat_pkalg_proposal( |
2289 | list_hostkey_types()); | 2350 | list_hostkey_types()); |
2290 | 2351 | ||
2352 | #ifdef GSSAPI | ||
2353 | { | ||
2354 | char *orig; | ||
2355 | char *gss = NULL; | ||
2356 | char *newstr = NULL; | ||
2357 | orig = myproposal[PROPOSAL_KEX_ALGS]; | ||
2358 | |||
2359 | /* | ||
2360 | * If we don't have a host key, then there's no point advertising | ||
2361 | * the other key exchange algorithms | ||
2362 | */ | ||
2363 | |||
2364 | if (strlen(myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS]) == 0) | ||
2365 | orig = NULL; | ||
2366 | |||
2367 | if (options.gss_keyex) | ||
2368 | gss = ssh_gssapi_server_mechanisms(); | ||
2369 | else | ||
2370 | gss = NULL; | ||
2371 | |||
2372 | if (gss && orig) | ||
2373 | xasprintf(&newstr, "%s,%s", gss, orig); | ||
2374 | else if (gss) | ||
2375 | newstr = gss; | ||
2376 | else if (orig) | ||
2377 | newstr = orig; | ||
2378 | |||
2379 | /* | ||
2380 | * If we've got GSSAPI mechanisms, then we've got the 'null' host | ||
2381 | * key alg, but we can't tell people about it unless its the only | ||
2382 | * host key algorithm we support | ||
2383 | */ | ||
2384 | if (gss && (strlen(myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS])) == 0) | ||
2385 | myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS] = "null"; | ||
2386 | |||
2387 | if (newstr) | ||
2388 | myproposal[PROPOSAL_KEX_ALGS] = newstr; | ||
2389 | else | ||
2390 | fatal("No supported key exchange algorithms"); | ||
2391 | } | ||
2392 | #endif | ||
2393 | |||
2291 | /* start key exchange */ | 2394 | /* start key exchange */ |
2292 | if ((r = kex_setup(active_state, myproposal)) != 0) | 2395 | if ((r = kex_setup(active_state, myproposal)) != 0) |
2293 | fatal("kex_setup: %s", ssh_err(r)); | 2396 | fatal("kex_setup: %s", ssh_err(r)); |
@@ -2305,6 +2408,13 @@ do_ssh2_kex(void) | |||
2305 | # endif | 2408 | # endif |
2306 | #endif | 2409 | #endif |
2307 | kex->kex[KEX_C25519_SHA256] = kexc25519_server; | 2410 | kex->kex[KEX_C25519_SHA256] = kexc25519_server; |
2411 | #ifdef GSSAPI | ||
2412 | if (options.gss_keyex) { | ||
2413 | kex->kex[KEX_GSS_GRP1_SHA1] = kexgss_server; | ||
2414 | kex->kex[KEX_GSS_GRP14_SHA1] = kexgss_server; | ||
2415 | kex->kex[KEX_GSS_GEX_SHA1] = kexgss_server; | ||
2416 | } | ||
2417 | #endif | ||
2308 | kex->server = 1; | 2418 | kex->server = 1; |
2309 | kex->client_version_string=client_version_string; | 2419 | kex->client_version_string=client_version_string; |
2310 | kex->server_version_string=server_version_string; | 2420 | kex->server_version_string=server_version_string; |