View | Details | Raw Unified | Return to bug 3116
Collapse All | Expand All

(-)a/clientloop.c (-1 / +4 lines)
Lines 1641-1647 client_request_agent(struct ssh *ssh, const char *request_type, int rchan) Link Here
1641
1641
1642
char *
1642
char *
1643
client_request_tun_fwd(struct ssh *ssh, int tun_mode,
1643
client_request_tun_fwd(struct ssh *ssh, int tun_mode,
1644
    int local_tun, int remote_tun)
1644
    int local_tun, int remote_tun, channel_open_fn *cb, void *cbctx)
1645
{
1645
{
1646
	Channel *c;
1646
	Channel *c;
1647
	int r, fd;
1647
	int r, fd;
Lines 1663-1668 client_request_tun_fwd(struct ssh *ssh, int tun_mode, Link Here
1663
	    CHAN_TCP_WINDOW_DEFAULT, CHAN_TCP_PACKET_DEFAULT, 0, "tun", 1);
1663
	    CHAN_TCP_WINDOW_DEFAULT, CHAN_TCP_PACKET_DEFAULT, 0, "tun", 1);
1664
	c->datagram = 1;
1664
	c->datagram = 1;
1665
1665
1666
	if (cb != NULL)
1667
		channel_register_open_confirm(ssh, c->self, cb, cbctx);
1668
1666
	if ((r = sshpkt_start(ssh, SSH2_MSG_CHANNEL_OPEN)) != 0 ||
1669
	if ((r = sshpkt_start(ssh, SSH2_MSG_CHANNEL_OPEN)) != 0 ||
1667
	    (r = sshpkt_put_cstring(ssh, "tun@openssh.com")) != 0 ||
1670
	    (r = sshpkt_put_cstring(ssh, "tun@openssh.com")) != 0 ||
1668
	    (r = sshpkt_put_u32(ssh, c->self)) != 0 ||
1671
	    (r = sshpkt_put_u32(ssh, c->self)) != 0 ||
(-)a/clientloop.h (-1 / +2 lines)
Lines 46-52 int client_x11_get_proto(struct ssh *, const char *, const char *, Link Here
46
void	 client_global_request_reply_fwd(int, u_int32_t, void *);
46
void	 client_global_request_reply_fwd(int, u_int32_t, void *);
47
void	 client_session2_setup(struct ssh *, int, int, int,
47
void	 client_session2_setup(struct ssh *, int, int, int,
48
	    const char *, struct termios *, int, struct sshbuf *, char **);
48
	    const char *, struct termios *, int, struct sshbuf *, char **);
49
char	 *client_request_tun_fwd(struct ssh *, int, int, int);
49
char	 *client_request_tun_fwd(struct ssh *, int, int, int,
50
    channel_open_fn *, void *);
50
void	 client_stop_mux(void);
51
void	 client_stop_mux(void);
51
52
52
/* Escape filter for protocol 2 sessions */
53
/* Escape filter for protocol 2 sessions */
(-)a/ssh.c (-22 / +38 lines)
Lines 175-181 struct sshbuf *command; Link Here
175
int subsystem_flag = 0;
175
int subsystem_flag = 0;
176
176
177
/* # of replies received for global requests */
177
/* # of replies received for global requests */
178
static int remote_forward_confirms_received = 0;
178
static int forward_confirms_pending = -1;
179
179
180
/* mux.c */
180
/* mux.c */
181
extern int muxserver_sock;
181
extern int muxserver_sock;
Lines 1640-1645 fork_postauth(void) Link Here
1640
		fatal("daemon() failed: %.200s", strerror(errno));
1640
		fatal("daemon() failed: %.200s", strerror(errno));
1641
}
1641
}
1642
1642
1643
static void
1644
forwarding_success(void)
1645
{
1646
	if (forward_confirms_pending > 0 && --forward_confirms_pending == 0) {
1647
		debug("All forwarding requests processed");
1648
		if (fork_after_authentication_flag)
1649
			fork_postauth();
1650
	}
1651
}
1652
1643
/* Callback for remote forward global requests */
1653
/* Callback for remote forward global requests */
1644
static void
1654
static void
1645
ssh_confirm_remote_forward(struct ssh *ssh, int type, u_int32_t seq, void *ctxt)
1655
ssh_confirm_remote_forward(struct ssh *ssh, int type, u_int32_t seq, void *ctxt)
Lines 1699-1709 ssh_confirm_remote_forward(struct ssh *ssh, int type, u_int32_t seq, void *ctxt) Link Here
1699
				    "for listen port %d", rfwd->listen_port);
1709
				    "for listen port %d", rfwd->listen_port);
1700
		}
1710
		}
1701
	}
1711
	}
1702
	if (++remote_forward_confirms_received == options.num_remote_forwards) {
1712
	forwarding_success();
1703
		debug("All remote forwarding requests processed");
1704
		if (fork_after_authentication_flag)
1705
			fork_postauth();
1706
	}
1707
}
1713
}
1708
1714
1709
static void
1715
static void
Lines 1720-1725 ssh_stdio_confirm(struct ssh *ssh, int id, int success, void *arg) Link Here
1720
		fatal("stdio forwarding failed");
1726
		fatal("stdio forwarding failed");
1721
}
1727
}
1722
1728
1729
static void
1730
ssh_tun_confirm(struct ssh *ssh, int id, int success, void *arg)
1731
{
1732
	if (!success) {
1733
		error("Tunnel forwarding failed");
1734
		if (options.exit_on_forward_failure)
1735
			cleanup_exit(255);
1736
	}
1737
1738
	debug("%s: tunnel forward established, id=%d", __func__, id);
1739
	forwarding_success();
1740
}
1741
1723
static void
1742
static void
1724
ssh_init_stdio_forwarding(struct ssh *ssh)
1743
ssh_init_stdio_forwarding(struct ssh *ssh)
1725
{
1744
{
Lines 1783-1814 ssh_init_forwarding(struct ssh *ssh, char **ifname) Link Here
1783
		    options.remote_forwards[i].connect_path :
1802
		    options.remote_forwards[i].connect_path :
1784
		    options.remote_forwards[i].connect_host,
1803
		    options.remote_forwards[i].connect_host,
1785
		    options.remote_forwards[i].connect_port);
1804
		    options.remote_forwards[i].connect_port);
1786
		options.remote_forwards[i].handle =
1805
		if ((options.remote_forwards[i].handle =
1787
		    channel_request_remote_forwarding(ssh,
1806
		    channel_request_remote_forwarding(ssh,
1788
		    &options.remote_forwards[i]);
1807
		    &options.remote_forwards[i])) >= 0) {
1789
		if (options.remote_forwards[i].handle < 0) {
1790
			if (options.exit_on_forward_failure)
1791
				fatal("Could not request remote forwarding.");
1792
			else
1793
				logit("Warning: Could not request remote "
1794
				    "forwarding.");
1795
		} else {
1796
			client_register_global_confirm(
1808
			client_register_global_confirm(
1797
			    ssh_confirm_remote_forward,
1809
			    ssh_confirm_remote_forward,
1798
			    &options.remote_forwards[i]);
1810
			    &options.remote_forwards[i]);
1799
		}
1811
			forward_confirms_pending++;
1812
		} else if (options.exit_on_forward_failure)
1813
			fatal("Could not request remote forwarding.");
1814
		else
1815
			logit("Warning: Could not request remote forwarding.");
1800
	}
1816
	}
1801
1817
1802
	/* Initiate tunnel forwarding. */
1818
	/* Initiate tunnel forwarding. */
1803
	if (options.tun_open != SSH_TUNMODE_NO) {
1819
	if (options.tun_open != SSH_TUNMODE_NO) {
1804
		if ((*ifname = client_request_tun_fwd(ssh,
1820
		if ((*ifname = client_request_tun_fwd(ssh,
1805
		    options.tun_open, options.tun_local,
1821
		    options.tun_open, options.tun_local,
1806
		    options.tun_remote)) == NULL) {
1822
		    options.tun_remote, ssh_tun_confirm, NULL)) != NULL)
1807
			if (options.exit_on_forward_failure)
1823
			forward_confirms_pending++;
1808
				fatal("Could not request tunnel forwarding.");
1824
		else if (options.exit_on_forward_failure)
1809
			else
1825
			fatal("Could not request tunnel forwarding.");
1810
				error("Could not request tunnel forwarding.");
1826
		else
1811
		}
1827
			error("Could not request tunnel forwarding.");
1812
	}
1828
	}
1813
}
1829
}
1814
1830

Return to bug 3116