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 b63aaa428..9d21b30f3 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>
@@ -1616,10 +1620,13 @@ main(int ac, char **av)
1616 logit("Disabling protocol version 1. Could not load host key"); 1620 logit("Disabling protocol version 1. Could not load host key");
1617 options.protocol &= ~SSH_PROTO_1; 1621 options.protocol &= ~SSH_PROTO_1;
1618 } 1622 }
1623#ifndef GSSAPI
1624 /* The GSSAPI key exchange can run without a host key */
1619 if ((options.protocol & SSH_PROTO_2) && !sensitive_data.have_ssh2_key) { 1625 if ((options.protocol & SSH_PROTO_2) && !sensitive_data.have_ssh2_key) {
1620 logit("Disabling protocol version 2. Could not load host key"); 1626 logit("Disabling protocol version 2. Could not load host key");
1621 options.protocol &= ~SSH_PROTO_2; 1627 options.protocol &= ~SSH_PROTO_2;
1622 } 1628 }
1629#endif
1623 if (!(options.protocol & (SSH_PROTO_1|SSH_PROTO_2))) { 1630 if (!(options.protocol & (SSH_PROTO_1|SSH_PROTO_2))) {
1624 logit("sshd: no hostkeys available -- exiting."); 1631 logit("sshd: no hostkeys available -- exiting.");
1625 exit(1); 1632 exit(1);
@@ -1948,6 +1955,60 @@ main(int ac, char **av)
1948 /* Log the connection. */ 1955 /* Log the connection. */
1949 verbose("Connection from %.500s port %d", remote_ip, remote_port); 1956 verbose("Connection from %.500s port %d", remote_ip, remote_port);
1950 1957
1958#ifdef USE_SECURITY_SESSION_API
1959 /*
1960 * Create a new security session for use by the new user login if
1961 * the current session is the root session or we are not launched
1962 * by inetd (eg: debugging mode or server mode). We do not
1963 * necessarily need to create a session if we are launched from
1964 * inetd because Panther xinetd will create a session for us.
1965 *
1966 * The only case where this logic will fail is if there is an
1967 * inetd running in a non-root session which is not creating
1968 * new sessions for us. Then all the users will end up in the
1969 * same session (bad).
1970 *
1971 * When the client exits, the session will be destroyed for us
1972 * automatically.
1973 *
1974 * We must create the session before any credentials are stored
1975 * (including AFS pags, which happens a few lines below).
1976 */
1977 {
1978 OSStatus err = 0;
1979 SecuritySessionId sid = 0;
1980 SessionAttributeBits sattrs = 0;
1981
1982 err = SessionGetInfo(callerSecuritySession, &sid, &sattrs);
1983 if (err)
1984 error("SessionGetInfo() failed with error %.8X",
1985 (unsigned) err);
1986 else
1987 debug("Current Session ID is %.8X / Session Attributes are %.8X",
1988 (unsigned) sid, (unsigned) sattrs);
1989
1990 if (inetd_flag && !(sattrs & sessionIsRoot))
1991 debug("Running in inetd mode in a non-root session... "
1992 "assuming inetd created the session for us.");
1993 else {
1994 debug("Creating new security session...");
1995 err = SessionCreate(0, sessionHasTTY | sessionIsRemote);
1996 if (err)
1997 error("SessionCreate() failed with error %.8X",
1998 (unsigned) err);
1999
2000 err = SessionGetInfo(callerSecuritySession, &sid,
2001 &sattrs);
2002 if (err)
2003 error("SessionGetInfo() failed with error %.8X",
2004 (unsigned) err);
2005 else
2006 debug("New Session ID is %.8X / Session Attributes are %.8X",
2007 (unsigned) sid, (unsigned) sattrs);
2008 }
2009 }
2010#endif
2011
1951 /* 2012 /*
1952 * We don't want to listen forever unless the other side 2013 * We don't want to listen forever unless the other side
1953 * successfully authenticates itself. So we set up an alarm which is 2014 * successfully authenticates itself. So we set up an alarm which is
@@ -2329,6 +2390,48 @@ do_ssh2_kex(void)
2329 2390
2330 myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS] = list_hostkey_types(); 2391 myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS] = list_hostkey_types();
2331 2392
2393#ifdef GSSAPI
2394 {
2395 char *orig;
2396 char *gss = NULL;
2397 char *newstr = NULL;
2398 orig = myproposal[PROPOSAL_KEX_ALGS];
2399
2400 /*
2401 * If we don't have a host key, then there's no point advertising
2402 * the other key exchange algorithms
2403 */
2404
2405 if (strlen(myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS]) == 0)
2406 orig = NULL;
2407
2408 if (options.gss_keyex)
2409 gss = ssh_gssapi_server_mechanisms();
2410 else
2411 gss = NULL;
2412
2413 if (gss && orig)
2414 xasprintf(&newstr, "%s,%s", gss, orig);
2415 else if (gss)
2416 newstr = gss;
2417 else if (orig)
2418 newstr = orig;
2419
2420 /*
2421 * If we've got GSSAPI mechanisms, then we've got the 'null' host
2422 * key alg, but we can't tell people about it unless its the only
2423 * host key algorithm we support
2424 */
2425 if (gss && (strlen(myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS])) == 0)
2426 myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS] = "null";
2427
2428 if (newstr)
2429 myproposal[PROPOSAL_KEX_ALGS] = newstr;
2430 else
2431 fatal("No supported key exchange algorithms");
2432 }
2433#endif
2434
2332 /* start key exchange */ 2435 /* start key exchange */
2333 kex = kex_setup(myproposal); 2436 kex = kex_setup(myproposal);
2334 kex->kex[KEX_DH_GRP1_SHA1] = kexdh_server; 2437 kex->kex[KEX_DH_GRP1_SHA1] = kexdh_server;
@@ -2336,6 +2439,13 @@ do_ssh2_kex(void)
2336 kex->kex[KEX_DH_GEX_SHA1] = kexgex_server; 2439 kex->kex[KEX_DH_GEX_SHA1] = kexgex_server;
2337 kex->kex[KEX_DH_GEX_SHA256] = kexgex_server; 2440 kex->kex[KEX_DH_GEX_SHA256] = kexgex_server;
2338 kex->kex[KEX_ECDH_SHA2] = kexecdh_server; 2441 kex->kex[KEX_ECDH_SHA2] = kexecdh_server;
2442#ifdef GSSAPI
2443 if (options.gss_keyex) {
2444 kex->kex[KEX_GSS_GRP1_SHA1] = kexgss_server;
2445 kex->kex[KEX_GSS_GRP14_SHA1] = kexgss_server;
2446 kex->kex[KEX_GSS_GEX_SHA1] = kexgss_server;
2447 }
2448#endif
2339 kex->server = 1; 2449 kex->server = 1;
2340 kex->client_version_string=client_version_string; 2450 kex->client_version_string=client_version_string;
2341 kex->server_version_string=server_version_string; 2451 kex->server_version_string=server_version_string;