summaryrefslogtreecommitdiff
path: root/sshd.c
diff options
context:
space:
mode:
Diffstat (limited to 'sshd.c')
-rw-r--r--sshd.c108
1 files changed, 108 insertions, 0 deletions
diff --git a/sshd.c b/sshd.c
index 0a76f2d3a..bfbaa52ca 100644
--- a/sshd.c
+++ b/sshd.c
@@ -117,6 +117,10 @@
117#include "monitor_fdpass.h" 117#include "monitor_fdpass.h"
118#include "version.h" 118#include "version.h"
119 119
120#ifdef USE_SECURITY_SESSION_API
121#include <Security/AuthSession.h>
122#endif
123
120#ifdef LIBWRAP 124#ifdef LIBWRAP
121#include <tcpd.h> 125#include <tcpd.h>
122#include <syslog.h> 126#include <syslog.h>
@@ -1477,10 +1481,13 @@ main(int ac, char **av)
1477 logit("Disabling protocol version 1. Could not load host key"); 1481 logit("Disabling protocol version 1. Could not load host key");
1478 options.protocol &= ~SSH_PROTO_1; 1482 options.protocol &= ~SSH_PROTO_1;
1479 } 1483 }
1484#ifndef GSSAPI
1485 /* The GSSAPI key exchange can run without a host key */
1480 if ((options.protocol & SSH_PROTO_2) && !sensitive_data.have_ssh2_key) { 1486 if ((options.protocol & SSH_PROTO_2) && !sensitive_data.have_ssh2_key) {
1481 logit("Disabling protocol version 2. Could not load host key"); 1487 logit("Disabling protocol version 2. Could not load host key");
1482 options.protocol &= ~SSH_PROTO_2; 1488 options.protocol &= ~SSH_PROTO_2;
1483 } 1489 }
1490#endif
1484 if (!(options.protocol & (SSH_PROTO_1|SSH_PROTO_2))) { 1491 if (!(options.protocol & (SSH_PROTO_1|SSH_PROTO_2))) {
1485 logit("sshd: no hostkeys available -- exiting."); 1492 logit("sshd: no hostkeys available -- exiting.");
1486 exit(1); 1493 exit(1);
@@ -1755,6 +1762,60 @@ main(int ac, char **av)
1755 /* Log the connection. */ 1762 /* Log the connection. */
1756 verbose("Connection from %.500s port %d", remote_ip, remote_port); 1763 verbose("Connection from %.500s port %d", remote_ip, remote_port);
1757 1764
1765#ifdef USE_SECURITY_SESSION_API
1766 /*
1767 * Create a new security session for use by the new user login if
1768 * the current session is the root session or we are not launched
1769 * by inetd (eg: debugging mode or server mode). We do not
1770 * necessarily need to create a session if we are launched from
1771 * inetd because Panther xinetd will create a session for us.
1772 *
1773 * The only case where this logic will fail is if there is an
1774 * inetd running in a non-root session which is not creating
1775 * new sessions for us. Then all the users will end up in the
1776 * same session (bad).
1777 *
1778 * When the client exits, the session will be destroyed for us
1779 * automatically.
1780 *
1781 * We must create the session before any credentials are stored
1782 * (including AFS pags, which happens a few lines below).
1783 */
1784 {
1785 OSStatus err = 0;
1786 SecuritySessionId sid = 0;
1787 SessionAttributeBits sattrs = 0;
1788
1789 err = SessionGetInfo(callerSecuritySession, &sid, &sattrs);
1790 if (err)
1791 error("SessionGetInfo() failed with error %.8X",
1792 (unsigned) err);
1793 else
1794 debug("Current Session ID is %.8X / Session Attributes are %.8X",
1795 (unsigned) sid, (unsigned) sattrs);
1796
1797 if (inetd_flag && !(sattrs & sessionIsRoot))
1798 debug("Running in inetd mode in a non-root session... "
1799 "assuming inetd created the session for us.");
1800 else {
1801 debug("Creating new security session...");
1802 err = SessionCreate(0, sessionHasTTY | sessionIsRemote);
1803 if (err)
1804 error("SessionCreate() failed with error %.8X",
1805 (unsigned) err);
1806
1807 err = SessionGetInfo(callerSecuritySession, &sid,
1808 &sattrs);
1809 if (err)
1810 error("SessionGetInfo() failed with error %.8X",
1811 (unsigned) err);
1812 else
1813 debug("New Session ID is %.8X / Session Attributes are %.8X",
1814 (unsigned) sid, (unsigned) sattrs);
1815 }
1816 }
1817#endif
1818
1758 /* 1819 /*
1759 * We don't want to listen forever unless the other side 1820 * We don't want to listen forever unless the other side
1760 * successfully authenticates itself. So we set up an alarm which is 1821 * successfully authenticates itself. So we set up an alarm which is
@@ -2113,12 +2174,59 @@ do_ssh2_kex(void)
2113 2174
2114 myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS] = list_hostkey_types(); 2175 myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS] = list_hostkey_types();
2115 2176
2177#ifdef GSSAPI
2178 {
2179 char *orig;
2180 char *gss = NULL;
2181 char *newstr = NULL;
2182 orig = myproposal[PROPOSAL_KEX_ALGS];
2183
2184 /*
2185 * If we don't have a host key, then there's no point advertising
2186 * the other key exchange algorithms
2187 */
2188
2189 if (strlen(myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS]) == 0)
2190 orig = NULL;
2191
2192 if (options.gss_keyex)
2193 gss = ssh_gssapi_server_mechanisms();
2194 else
2195 gss = NULL;
2196
2197 if (gss && orig)
2198 xasprintf(&newstr, "%s,%s", gss, orig);
2199 else if (gss)
2200 newstr = gss;
2201 else if (orig)
2202 newstr = orig;
2203
2204 /*
2205 * If we've got GSSAPI mechanisms, then we've got the 'null' host
2206 * key alg, but we can't tell people about it unless its the only
2207 * host key algorithm we support
2208 */
2209 if (gss && (strlen(myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS])) == 0)
2210 myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS] = "null";
2211
2212 if (newstr)
2213 myproposal[PROPOSAL_KEX_ALGS] = newstr;
2214 else
2215 fatal("No supported key exchange algorithms");
2216 }
2217#endif
2218
2116 /* start key exchange */ 2219 /* start key exchange */
2117 kex = kex_setup(myproposal); 2220 kex = kex_setup(myproposal);
2118 kex->kex[KEX_DH_GRP1_SHA1] = kexdh_server; 2221 kex->kex[KEX_DH_GRP1_SHA1] = kexdh_server;
2119 kex->kex[KEX_DH_GRP14_SHA1] = kexdh_server; 2222 kex->kex[KEX_DH_GRP14_SHA1] = kexdh_server;
2120 kex->kex[KEX_DH_GEX_SHA1] = kexgex_server; 2223 kex->kex[KEX_DH_GEX_SHA1] = kexgex_server;
2121 kex->kex[KEX_DH_GEX_SHA256] = kexgex_server; 2224 kex->kex[KEX_DH_GEX_SHA256] = kexgex_server;
2225#ifdef GSSAPI
2226 kex->kex[KEX_GSS_GRP1_SHA1] = kexgss_server;
2227 kex->kex[KEX_GSS_GRP14_SHA1] = kexgss_server;
2228 kex->kex[KEX_GSS_GEX_SHA1] = kexgss_server;
2229#endif
2122 kex->server = 1; 2230 kex->server = 1;
2123 kex->client_version_string=client_version_string; 2231 kex->client_version_string=client_version_string;
2124 kex->server_version_string=server_version_string; 2232 kex->server_version_string=server_version_string;