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 9aff5e8af..6b2f59220 100644
--- a/sshd.c
+++ b/sshd.c
@@ -121,6 +121,10 @@
121#include "ssh-sandbox.h" 121#include "ssh-sandbox.h"
122#include "version.h" 122#include "version.h"
123 123
124#ifdef USE_SECURITY_SESSION_API
125#include <Security/AuthSession.h>
126#endif
127
124#ifdef LIBWRAP 128#ifdef LIBWRAP
125#include <tcpd.h> 129#include <tcpd.h>
126#include <syslog.h> 130#include <syslog.h>
@@ -1607,10 +1611,13 @@ main(int ac, char **av)
1607 logit("Disabling protocol version 1. Could not load host key"); 1611 logit("Disabling protocol version 1. Could not load host key");
1608 options.protocol &= ~SSH_PROTO_1; 1612 options.protocol &= ~SSH_PROTO_1;
1609 } 1613 }
1614#ifndef GSSAPI
1615 /* The GSSAPI key exchange can run without a host key */
1610 if ((options.protocol & SSH_PROTO_2) && !sensitive_data.have_ssh2_key) { 1616 if ((options.protocol & SSH_PROTO_2) && !sensitive_data.have_ssh2_key) {
1611 logit("Disabling protocol version 2. Could not load host key"); 1617 logit("Disabling protocol version 2. Could not load host key");
1612 options.protocol &= ~SSH_PROTO_2; 1618 options.protocol &= ~SSH_PROTO_2;
1613 } 1619 }
1620#endif
1614 if (!(options.protocol & (SSH_PROTO_1|SSH_PROTO_2))) { 1621 if (!(options.protocol & (SSH_PROTO_1|SSH_PROTO_2))) {
1615 logit("sshd: no hostkeys available -- exiting."); 1622 logit("sshd: no hostkeys available -- exiting.");
1616 exit(1); 1623 exit(1);
@@ -1938,6 +1945,60 @@ main(int ac, char **av)
1938 /* Log the connection. */ 1945 /* Log the connection. */
1939 verbose("Connection from %.500s port %d", remote_ip, remote_port); 1946 verbose("Connection from %.500s port %d", remote_ip, remote_port);
1940 1947
1948#ifdef USE_SECURITY_SESSION_API
1949 /*
1950 * Create a new security session for use by the new user login if
1951 * the current session is the root session or we are not launched
1952 * by inetd (eg: debugging mode or server mode). We do not
1953 * necessarily need to create a session if we are launched from
1954 * inetd because Panther xinetd will create a session for us.
1955 *
1956 * The only case where this logic will fail is if there is an
1957 * inetd running in a non-root session which is not creating
1958 * new sessions for us. Then all the users will end up in the
1959 * same session (bad).
1960 *
1961 * When the client exits, the session will be destroyed for us
1962 * automatically.
1963 *
1964 * We must create the session before any credentials are stored
1965 * (including AFS pags, which happens a few lines below).
1966 */
1967 {
1968 OSStatus err = 0;
1969 SecuritySessionId sid = 0;
1970 SessionAttributeBits sattrs = 0;
1971
1972 err = SessionGetInfo(callerSecuritySession, &sid, &sattrs);
1973 if (err)
1974 error("SessionGetInfo() failed with error %.8X",
1975 (unsigned) err);
1976 else
1977 debug("Current Session ID is %.8X / Session Attributes are %.8X",
1978 (unsigned) sid, (unsigned) sattrs);
1979
1980 if (inetd_flag && !(sattrs & sessionIsRoot))
1981 debug("Running in inetd mode in a non-root session... "
1982 "assuming inetd created the session for us.");
1983 else {
1984 debug("Creating new security session...");
1985 err = SessionCreate(0, sessionHasTTY | sessionIsRemote);
1986 if (err)
1987 error("SessionCreate() failed with error %.8X",
1988 (unsigned) err);
1989
1990 err = SessionGetInfo(callerSecuritySession, &sid,
1991 &sattrs);
1992 if (err)
1993 error("SessionGetInfo() failed with error %.8X",
1994 (unsigned) err);
1995 else
1996 debug("New Session ID is %.8X / Session Attributes are %.8X",
1997 (unsigned) sid, (unsigned) sattrs);
1998 }
1999 }
2000#endif
2001
1941 /* 2002 /*
1942 * We don't want to listen forever unless the other side 2003 * We don't want to listen forever unless the other side
1943 * successfully authenticates itself. So we set up an alarm which is 2004 * successfully authenticates itself. So we set up an alarm which is
@@ -2319,6 +2380,48 @@ do_ssh2_kex(void)
2319 2380
2320 myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS] = list_hostkey_types(); 2381 myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS] = list_hostkey_types();
2321 2382
2383#ifdef GSSAPI
2384 {
2385 char *orig;
2386 char *gss = NULL;
2387 char *newstr = NULL;
2388 orig = myproposal[PROPOSAL_KEX_ALGS];
2389
2390 /*
2391 * If we don't have a host key, then there's no point advertising
2392 * the other key exchange algorithms
2393 */
2394
2395 if (strlen(myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS]) == 0)
2396 orig = NULL;
2397
2398 if (options.gss_keyex)
2399 gss = ssh_gssapi_server_mechanisms();
2400 else
2401 gss = NULL;
2402
2403 if (gss && orig)
2404 xasprintf(&newstr, "%s,%s", gss, orig);
2405 else if (gss)
2406 newstr = gss;
2407 else if (orig)
2408 newstr = orig;
2409
2410 /*
2411 * If we've got GSSAPI mechanisms, then we've got the 'null' host
2412 * key alg, but we can't tell people about it unless its the only
2413 * host key algorithm we support
2414 */
2415 if (gss && (strlen(myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS])) == 0)
2416 myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS] = "null";
2417
2418 if (newstr)
2419 myproposal[PROPOSAL_KEX_ALGS] = newstr;
2420 else
2421 fatal("No supported key exchange algorithms");
2422 }
2423#endif
2424
2322 /* start key exchange */ 2425 /* start key exchange */
2323 kex = kex_setup(myproposal); 2426 kex = kex_setup(myproposal);
2324 kex->kex[KEX_DH_GRP1_SHA1] = kexdh_server; 2427 kex->kex[KEX_DH_GRP1_SHA1] = kexdh_server;
@@ -2326,6 +2429,13 @@ do_ssh2_kex(void)
2326 kex->kex[KEX_DH_GEX_SHA1] = kexgex_server; 2429 kex->kex[KEX_DH_GEX_SHA1] = kexgex_server;
2327 kex->kex[KEX_DH_GEX_SHA256] = kexgex_server; 2430 kex->kex[KEX_DH_GEX_SHA256] = kexgex_server;
2328 kex->kex[KEX_ECDH_SHA2] = kexecdh_server; 2431 kex->kex[KEX_ECDH_SHA2] = kexecdh_server;
2432#ifdef GSSAPI
2433 if (options.gss_keyex) {
2434 kex->kex[KEX_GSS_GRP1_SHA1] = kexgss_server;
2435 kex->kex[KEX_GSS_GRP14_SHA1] = kexgss_server;
2436 kex->kex[KEX_GSS_GEX_SHA1] = kexgss_server;
2437 }
2438#endif
2329 kex->server = 1; 2439 kex->server = 1;
2330 kex->client_version_string=client_version_string; 2440 kex->client_version_string=client_version_string;
2331 kex->server_version_string=server_version_string; 2441 kex->server_version_string=server_version_string;