summaryrefslogtreecommitdiff
path: root/sshd.c
diff options
context:
space:
mode:
authordjm@openbsd.org <djm@openbsd.org>2017-09-12 06:32:07 +0000
committerDamien Miller <djm@mindrot.org>2017-09-12 17:37:02 +1000
commitdbee4119b502e3f8b6cd3282c69c537fd01d8e16 (patch)
treeb8a3263a79e0920e8d08f188654f1ccb7c254406 /sshd.c
parentabd59663df37a42152e37980113ccaa405b9a282 (diff)
upstream commit
refactor channels.c Move static state to a "struct ssh_channels" that is allocated at runtime and tracked as a member of struct ssh. Explicitly pass "struct ssh" to all channels functions. Replace use of the legacy packet APIs in channels.c. Rework sshd_config PermitOpen handling: previously the configuration parser would call directly into the channels layer. After the refactor this is not possible, as the channels structures are allocated at connection time and aren't available when the configuration is parsed. The server config parser now tracks PermitOpen itself and explicitly configures the channels code later. ok markus@ Upstream-ID: 11828f161656b965cc306576422613614bea2d8f
Diffstat (limited to 'sshd.c')
-rw-r--r--sshd.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/sshd.c b/sshd.c
index 1d19ce679..51a1aaf6e 100644
--- a/sshd.c
+++ b/sshd.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: sshd.c,v 1.491 2017/07/01 13:50:45 djm Exp $ */ 1/* $OpenBSD: sshd.c,v 1.492 2017/09/12 06:32:07 djm Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -1621,9 +1621,6 @@ main(int ac, char **av)
1621 "enabled authentication methods"); 1621 "enabled authentication methods");
1622 } 1622 }
1623 1623
1624 /* set default channel AF */
1625 channel_set_af(options.address_family);
1626
1627 /* Check that there are no remaining arguments. */ 1624 /* Check that there are no remaining arguments. */
1628 if (optind < ac) { 1625 if (optind < ac) {
1629 fprintf(stderr, "Extra argument %s.\n", av[optind]); 1626 fprintf(stderr, "Extra argument %s.\n", av[optind]);
@@ -1955,8 +1952,14 @@ main(int ac, char **av)
1955 packet_set_connection(sock_in, sock_out); 1952 packet_set_connection(sock_in, sock_out);
1956 packet_set_server(); 1953 packet_set_server();
1957 ssh = active_state; /* XXX */ 1954 ssh = active_state; /* XXX */
1955
1958 check_ip_options(ssh); 1956 check_ip_options(ssh);
1959 1957
1958 /* Prepare the channels layer */
1959 channel_init_channels(ssh);
1960 channel_set_af(ssh, options.address_family);
1961 process_permitopen(ssh, &options);
1962
1960 /* Set SO_KEEPALIVE if requested. */ 1963 /* Set SO_KEEPALIVE if requested. */
1961 if (options.tcp_keep_alive && packet_connection_is_on_socket() && 1964 if (options.tcp_keep_alive && packet_connection_is_on_socket() &&
1962 setsockopt(sock_in, SOL_SOCKET, SO_KEEPALIVE, &on, sizeof(on)) < 0) 1965 setsockopt(sock_in, SOL_SOCKET, SO_KEEPALIVE, &on, sizeof(on)) < 0)
@@ -2080,10 +2083,10 @@ main(int ac, char **av)
2080 options.client_alive_count_max); 2083 options.client_alive_count_max);
2081 2084
2082 /* Try to send all our hostkeys to the client */ 2085 /* Try to send all our hostkeys to the client */
2083 notify_hostkeys(active_state); 2086 notify_hostkeys(ssh);
2084 2087
2085 /* Start session. */ 2088 /* Start session. */
2086 do_authenticated(authctxt); 2089 do_authenticated(ssh, authctxt);
2087 2090
2088 /* The connection has been terminated. */ 2091 /* The connection has been terminated. */
2089 packet_get_bytes(&ibytes, &obytes); 2092 packet_get_bytes(&ibytes, &obytes);
@@ -2211,8 +2214,10 @@ do_ssh2_kex(void)
2211void 2214void
2212cleanup_exit(int i) 2215cleanup_exit(int i)
2213{ 2216{
2217 struct ssh *ssh = active_state; /* XXX */
2218
2214 if (the_authctxt) { 2219 if (the_authctxt) {
2215 do_cleanup(the_authctxt); 2220 do_cleanup(ssh, the_authctxt);
2216 if (use_privsep && privsep_is_preauth && 2221 if (use_privsep && privsep_is_preauth &&
2217 pmonitor != NULL && pmonitor->m_pid > 1) { 2222 pmonitor != NULL && pmonitor->m_pid > 1) {
2218 debug("Killing privsep child %d", pmonitor->m_pid); 2223 debug("Killing privsep child %d", pmonitor->m_pid);