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 3e9d17640..d8faaebd5 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>
@@ -1645,10 +1649,13 @@ main(int ac, char **av)
1645 logit("Disabling protocol version 1. Could not load host key"); 1649 logit("Disabling protocol version 1. Could not load host key");
1646 options.protocol &= ~SSH_PROTO_1; 1650 options.protocol &= ~SSH_PROTO_1;
1647 } 1651 }
1652#ifndef GSSAPI
1653 /* The GSSAPI key exchange can run without a host key */
1648 if ((options.protocol & SSH_PROTO_2) && !sensitive_data.have_ssh2_key) { 1654 if ((options.protocol & SSH_PROTO_2) && !sensitive_data.have_ssh2_key) {
1649 logit("Disabling protocol version 2. Could not load host key"); 1655 logit("Disabling protocol version 2. Could not load host key");
1650 options.protocol &= ~SSH_PROTO_2; 1656 options.protocol &= ~SSH_PROTO_2;
1651 } 1657 }
1658#endif
1652 if (!(options.protocol & (SSH_PROTO_1|SSH_PROTO_2))) { 1659 if (!(options.protocol & (SSH_PROTO_1|SSH_PROTO_2))) {
1653 logit("sshd: no hostkeys available -- exiting."); 1660 logit("sshd: no hostkeys available -- exiting.");
1654 exit(1); 1661 exit(1);
@@ -1976,6 +1983,60 @@ main(int ac, char **av)
1976 /* Log the connection. */ 1983 /* Log the connection. */
1977 verbose("Connection from %.500s port %d", remote_ip, remote_port); 1984 verbose("Connection from %.500s port %d", remote_ip, remote_port);
1978 1985
1986#ifdef USE_SECURITY_SESSION_API
1987 /*
1988 * Create a new security session for use by the new user login if
1989 * the current session is the root session or we are not launched
1990 * by inetd (eg: debugging mode or server mode). We do not
1991 * necessarily need to create a session if we are launched from
1992 * inetd because Panther xinetd will create a session for us.
1993 *
1994 * The only case where this logic will fail is if there is an
1995 * inetd running in a non-root session which is not creating
1996 * new sessions for us. Then all the users will end up in the
1997 * same session (bad).
1998 *
1999 * When the client exits, the session will be destroyed for us
2000 * automatically.
2001 *
2002 * We must create the session before any credentials are stored
2003 * (including AFS pags, which happens a few lines below).
2004 */
2005 {
2006 OSStatus err = 0;
2007 SecuritySessionId sid = 0;
2008 SessionAttributeBits sattrs = 0;
2009
2010 err = SessionGetInfo(callerSecuritySession, &sid, &sattrs);
2011 if (err)
2012 error("SessionGetInfo() failed with error %.8X",
2013 (unsigned) err);
2014 else
2015 debug("Current Session ID is %.8X / Session Attributes are %.8X",
2016 (unsigned) sid, (unsigned) sattrs);
2017
2018 if (inetd_flag && !(sattrs & sessionIsRoot))
2019 debug("Running in inetd mode in a non-root session... "
2020 "assuming inetd created the session for us.");
2021 else {
2022 debug("Creating new security session...");
2023 err = SessionCreate(0, sessionHasTTY | sessionIsRemote);
2024 if (err)
2025 error("SessionCreate() failed with error %.8X",
2026 (unsigned) err);
2027
2028 err = SessionGetInfo(callerSecuritySession, &sid,
2029 &sattrs);
2030 if (err)
2031 error("SessionGetInfo() failed with error %.8X",
2032 (unsigned) err);
2033 else
2034 debug("New Session ID is %.8X / Session Attributes are %.8X",
2035 (unsigned) sid, (unsigned) sattrs);
2036 }
2037 }
2038#endif
2039
1979 /* 2040 /*
1980 * We don't want to listen forever unless the other side 2041 * We don't want to listen forever unless the other side
1981 * successfully authenticates itself. So we set up an alarm which is 2042 * successfully authenticates itself. So we set up an alarm which is
@@ -2357,6 +2418,48 @@ do_ssh2_kex(void)
2357 2418
2358 myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS] = list_hostkey_types(); 2419 myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS] = list_hostkey_types();
2359 2420
2421#ifdef GSSAPI
2422 {
2423 char *orig;
2424 char *gss = NULL;
2425 char *newstr = NULL;
2426 orig = myproposal[PROPOSAL_KEX_ALGS];
2427
2428 /*
2429 * If we don't have a host key, then there's no point advertising
2430 * the other key exchange algorithms
2431 */
2432
2433 if (strlen(myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS]) == 0)
2434 orig = NULL;
2435
2436 if (options.gss_keyex)
2437 gss = ssh_gssapi_server_mechanisms();
2438 else
2439 gss = NULL;
2440
2441 if (gss && orig)
2442 xasprintf(&newstr, "%s,%s", gss, orig);
2443 else if (gss)
2444 newstr = gss;
2445 else if (orig)
2446 newstr = orig;
2447
2448 /*
2449 * If we've got GSSAPI mechanisms, then we've got the 'null' host
2450 * key alg, but we can't tell people about it unless its the only
2451 * host key algorithm we support
2452 */
2453 if (gss && (strlen(myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS])) == 0)
2454 myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS] = "null";
2455
2456 if (newstr)
2457 myproposal[PROPOSAL_KEX_ALGS] = newstr;
2458 else
2459 fatal("No supported key exchange algorithms");
2460 }
2461#endif
2462
2360 /* start key exchange */ 2463 /* start key exchange */
2361 kex = kex_setup(myproposal); 2464 kex = kex_setup(myproposal);
2362 kex->kex[KEX_DH_GRP1_SHA1] = kexdh_server; 2465 kex->kex[KEX_DH_GRP1_SHA1] = kexdh_server;
@@ -2364,6 +2467,13 @@ do_ssh2_kex(void)
2364 kex->kex[KEX_DH_GEX_SHA1] = kexgex_server; 2467 kex->kex[KEX_DH_GEX_SHA1] = kexgex_server;
2365 kex->kex[KEX_DH_GEX_SHA256] = kexgex_server; 2468 kex->kex[KEX_DH_GEX_SHA256] = kexgex_server;
2366 kex->kex[KEX_ECDH_SHA2] = kexecdh_server; 2469 kex->kex[KEX_ECDH_SHA2] = kexecdh_server;
2470#ifdef GSSAPI
2471 if (options.gss_keyex) {
2472 kex->kex[KEX_GSS_GRP1_SHA1] = kexgss_server;
2473 kex->kex[KEX_GSS_GRP14_SHA1] = kexgss_server;
2474 kex->kex[KEX_GSS_GEX_SHA1] = kexgss_server;
2475 }
2476#endif
2367 kex->server = 1; 2477 kex->server = 1;
2368 kex->client_version_string=client_version_string; 2478 kex->client_version_string=client_version_string;
2369 kex->server_version_string=server_version_string; 2479 kex->server_version_string=server_version_string;