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
diff --git a/clientloop.h b/clientloop.h
index ae83aa8..a1975cc 100644
--- a/clientloop.h
+++ b/clientloop.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: clientloop.h,v 1.33 2016/09/30 09:19:13 markus Exp $ */
+/* $OpenBSD: clientloop.h,v 1.34 2017/09/12 06:32:07 djm Exp $ */
 
 /*
  * Author: Tatu Ylonen <ylo@cs.hut.fi>
@@ -37,28 +37,31 @@
 
 #include <termios.h>
 
+struct ssh;
+
 /* Client side main loop for the interactive session. */
-int	 client_loop(int, int, int);
-int	 client_x11_get_proto(const char *, const char *, u_int, u_int,
-	    char **, char **);
+int	 client_loop(struct ssh *, int, int, int);
+int	 client_x11_get_proto(struct ssh *, const char *, const char *,
+	    u_int, u_int, char **, char **);
 void	 client_global_request_reply_fwd(int, u_int32_t, void *);
-void	 client_session2_setup(int, int, int, const char *, struct termios *,
-	    int, Buffer *, char **);
-int	 client_request_tun_fwd(int, int, int);
+void	 client_session2_setup(struct ssh *, int, int, int,
+	    const char *, struct termios *, int, Buffer *, char **);
+int	 client_request_tun_fwd(struct ssh *, int, int, int);
 void	 client_stop_mux(void);
 
 /* Escape filter for protocol 2 sessions */
 void	*client_new_escape_filter_ctx(int);
-void	 client_filter_cleanup(int, void *);
-int	 client_simple_escape_filter(Channel *, char *, int);
+void	 client_filter_cleanup(struct ssh *, int, void *);
+int	 client_simple_escape_filter(struct ssh *, Channel *, char *, int);
 
 /* Global request confirmation callbacks */
-typedef void global_confirm_cb(int, u_int32_t seq, void *);
+typedef void global_confirm_cb(struct ssh *, int, u_int32_t, void *);
 void	 client_register_global_confirm(global_confirm_cb *, void *);
 
 /* Channel request confirmation callbacks */
 enum confirm_action { CONFIRM_WARN = 0, CONFIRM_CLOSE, CONFIRM_TTY };
-void client_expect_confirm(int, const char *, enum confirm_action);
+void client_expect_confirm(struct ssh *, int, const char *,
+    enum confirm_action);
 
 /* Multiplexing protocol version */
 #define SSHMUX_VER			4
@@ -73,8 +76,8 @@
 #define SSHMUX_COMMAND_CANCEL_FWD	7	/* Cancel forwarding(s) */
 #define SSHMUX_COMMAND_PROXY		8	/* Open new connection */
 
-void	muxserver_listen(void);
+void	muxserver_listen(struct ssh *);
 int	muxclient(const char *);
-void	mux_exit_message(Channel *, int);
-void	mux_tty_alloc_failed(Channel *);
+void	mux_exit_message(struct ssh *, Channel *, int);
+void	mux_tty_alloc_failed(struct ssh *ssh, Channel *);