summaryrefslogtreecommitdiff
path: root/sshd.c
diff options
context:
space:
mode:
Diffstat (limited to 'sshd.c')
-rw-r--r--sshd.c110
1 files changed, 110 insertions, 0 deletions
diff --git a/sshd.c b/sshd.c
index bc0d2753f..eb48e791d 100644
--- a/sshd.c
+++ b/sshd.c
@@ -120,6 +120,10 @@
120#include "roaming.h" 120#include "roaming.h"
121#include "version.h" 121#include "version.h"
122 122
123#ifdef USE_SECURITY_SESSION_API
124#include <Security/AuthSession.h>
125#endif
126
123#ifdef LIBWRAP 127#ifdef LIBWRAP
124#include <tcpd.h> 128#include <tcpd.h>
125#include <syslog.h> 129#include <syslog.h>
@@ -1577,10 +1581,13 @@ main(int ac, char **av)
1577 logit("Disabling protocol version 1. Could not load host key"); 1581 logit("Disabling protocol version 1. Could not load host key");
1578 options.protocol &= ~SSH_PROTO_1; 1582 options.protocol &= ~SSH_PROTO_1;
1579 } 1583 }
1584#ifndef GSSAPI
1585 /* The GSSAPI key exchange can run without a host key */
1580 if ((options.protocol & SSH_PROTO_2) && !sensitive_data.have_ssh2_key) { 1586 if ((options.protocol & SSH_PROTO_2) && !sensitive_data.have_ssh2_key) {
1581 logit("Disabling protocol version 2. Could not load host key"); 1587 logit("Disabling protocol version 2. Could not load host key");
1582 options.protocol &= ~SSH_PROTO_2; 1588 options.protocol &= ~SSH_PROTO_2;
1583 } 1589 }
1590#endif
1584 if (!(options.protocol & (SSH_PROTO_1|SSH_PROTO_2))) { 1591 if (!(options.protocol & (SSH_PROTO_1|SSH_PROTO_2))) {
1585 logit("sshd: no hostkeys available -- exiting."); 1592 logit("sshd: no hostkeys available -- exiting.");
1586 exit(1); 1593 exit(1);
@@ -1909,6 +1916,60 @@ main(int ac, char **av)
1909 /* Log the connection. */ 1916 /* Log the connection. */
1910 verbose("Connection from %.500s port %d", remote_ip, remote_port); 1917 verbose("Connection from %.500s port %d", remote_ip, remote_port);
1911 1918
1919#ifdef USE_SECURITY_SESSION_API
1920 /*
1921 * Create a new security session for use by the new user login if
1922 * the current session is the root session or we are not launched
1923 * by inetd (eg: debugging mode or server mode). We do not
1924 * necessarily need to create a session if we are launched from
1925 * inetd because Panther xinetd will create a session for us.
1926 *
1927 * The only case where this logic will fail is if there is an
1928 * inetd running in a non-root session which is not creating
1929 * new sessions for us. Then all the users will end up in the
1930 * same session (bad).
1931 *
1932 * When the client exits, the session will be destroyed for us
1933 * automatically.
1934 *
1935 * We must create the session before any credentials are stored
1936 * (including AFS pags, which happens a few lines below).
1937 */
1938 {
1939 OSStatus err = 0;
1940 SecuritySessionId sid = 0;
1941 SessionAttributeBits sattrs = 0;
1942
1943 err = SessionGetInfo(callerSecuritySession, &sid, &sattrs);
1944 if (err)
1945 error("SessionGetInfo() failed with error %.8X",
1946 (unsigned) err);
1947 else
1948 debug("Current Session ID is %.8X / Session Attributes are %.8X",
1949 (unsigned) sid, (unsigned) sattrs);
1950
1951 if (inetd_flag && !(sattrs & sessionIsRoot))
1952 debug("Running in inetd mode in a non-root session... "
1953 "assuming inetd created the session for us.");
1954 else {
1955 debug("Creating new security session...");
1956 err = SessionCreate(0, sessionHasTTY | sessionIsRemote);
1957 if (err)
1958 error("SessionCreate() failed with error %.8X",
1959 (unsigned) err);
1960
1961 err = SessionGetInfo(callerSecuritySession, &sid,
1962 &sattrs);
1963 if (err)
1964 error("SessionGetInfo() failed with error %.8X",
1965 (unsigned) err);
1966 else
1967 debug("New Session ID is %.8X / Session Attributes are %.8X",
1968 (unsigned) sid, (unsigned) sattrs);
1969 }
1970 }
1971#endif
1972
1912 /* 1973 /*
1913 * We don't want to listen forever unless the other side 1974 * We don't want to listen forever unless the other side
1914 * successfully authenticates itself. So we set up an alarm which is 1975 * successfully authenticates itself. So we set up an alarm which is
@@ -2287,12 +2348,61 @@ do_ssh2_kex(void)
2287 2348
2288 myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS] = list_hostkey_types(); 2349 myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS] = list_hostkey_types();
2289 2350
2351#ifdef GSSAPI
2352 {
2353 char *orig;
2354 char *gss = NULL;
2355 char *newstr = NULL;
2356 orig = myproposal[PROPOSAL_KEX_ALGS];
2357
2358 /*
2359 * If we don't have a host key, then there's no point advertising
2360 * the other key exchange algorithms
2361 */
2362
2363 if (strlen(myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS]) == 0)
2364 orig = NULL;
2365
2366 if (options.gss_keyex)
2367 gss = ssh_gssapi_server_mechanisms();
2368 else
2369 gss = NULL;
2370
2371 if (gss && orig)
2372 xasprintf(&newstr, "%s,%s", gss, orig);
2373 else if (gss)
2374 newstr = gss;
2375 else if (orig)
2376 newstr = orig;
2377
2378 /*
2379 * If we've got GSSAPI mechanisms, then we've got the 'null' host
2380 * key alg, but we can't tell people about it unless its the only
2381 * host key algorithm we support
2382 */
2383 if (gss && (strlen(myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS])) == 0)
2384 myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS] = "null";
2385
2386 if (newstr)
2387 myproposal[PROPOSAL_KEX_ALGS] = newstr;
2388 else
2389 fatal("No supported key exchange algorithms");
2390 }
2391#endif
2392
2290 /* start key exchange */ 2393 /* start key exchange */
2291 kex = kex_setup(myproposal); 2394 kex = kex_setup(myproposal);
2292 kex->kex[KEX_DH_GRP1_SHA1] = kexdh_server; 2395 kex->kex[KEX_DH_GRP1_SHA1] = kexdh_server;
2293 kex->kex[KEX_DH_GRP14_SHA1] = kexdh_server; 2396 kex->kex[KEX_DH_GRP14_SHA1] = kexdh_server;
2294 kex->kex[KEX_DH_GEX_SHA1] = kexgex_server; 2397 kex->kex[KEX_DH_GEX_SHA1] = kexgex_server;
2295 kex->kex[KEX_DH_GEX_SHA256] = kexgex_server; 2398 kex->kex[KEX_DH_GEX_SHA256] = kexgex_server;
2399#ifdef GSSAPI
2400 if (options.gss_keyex) {
2401 kex->kex[KEX_GSS_GRP1_SHA1] = kexgss_server;
2402 kex->kex[KEX_GSS_GRP14_SHA1] = kexgss_server;
2403 kex->kex[KEX_GSS_GEX_SHA1] = kexgss_server;
2404 }
2405#endif
2296 kex->server = 1; 2406 kex->server = 1;
2297 kex->client_version_string=client_version_string; 2407 kex->client_version_string=client_version_string;
2298 kex->server_version_string=server_version_string; 2408 kex->server_version_string=server_version_string;