diff options
author | djm@openbsd.org <djm@openbsd.org> | 2017-10-23 05:08:00 +0000 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2017-10-23 16:14:30 +1100 |
commit | b7548b12a6b2b4abf4d057192c353147e0abba08 (patch) | |
tree | dc76477cd371b6197ba840c3a178bfbcf6d7baba /clientloop.c | |
parent | 887669ef032d63cf07f53cada216fa8a0c9a7d72 (diff) |
upstream commit
Expose devices allocated for tun/tap forwarding.
At the client, the device may be obtained from a new %T expansion
for LocalCommand.
At the server, the allocated devices will be listed in a
SSH_TUNNEL variable exposed to the environment of any user sessions
started after the tunnel forwarding was established.
ok markus
Upstream-ID: e61e53f8ae80566e9ddc0d67a5df5bdf2f3c9f9e
Diffstat (limited to 'clientloop.c')
-rw-r--r-- | clientloop.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/clientloop.c b/clientloop.c index 791d336e3..46ede4f0e 100644 --- a/clientloop.c +++ b/clientloop.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: clientloop.c,v 1.305 2017/09/19 04:24:22 djm Exp $ */ | 1 | /* $OpenBSD: clientloop.c,v 1.306 2017/10/23 05:08:00 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 |
@@ -1601,12 +1601,13 @@ client_request_agent(struct ssh *ssh, const char *request_type, int rchan) | |||
1601 | return c; | 1601 | return c; |
1602 | } | 1602 | } |
1603 | 1603 | ||
1604 | int | 1604 | char * |
1605 | client_request_tun_fwd(struct ssh *ssh, int tun_mode, | 1605 | client_request_tun_fwd(struct ssh *ssh, int tun_mode, |
1606 | int local_tun, int remote_tun) | 1606 | int local_tun, int remote_tun) |
1607 | { | 1607 | { |
1608 | Channel *c; | 1608 | Channel *c; |
1609 | int fd; | 1609 | int fd; |
1610 | char *ifname = NULL; | ||
1610 | 1611 | ||
1611 | if (tun_mode == SSH_TUNMODE_NO) | 1612 | if (tun_mode == SSH_TUNMODE_NO) |
1612 | return 0; | 1613 | return 0; |
@@ -1614,10 +1615,11 @@ client_request_tun_fwd(struct ssh *ssh, int tun_mode, | |||
1614 | debug("Requesting tun unit %d in mode %d", local_tun, tun_mode); | 1615 | debug("Requesting tun unit %d in mode %d", local_tun, tun_mode); |
1615 | 1616 | ||
1616 | /* Open local tunnel device */ | 1617 | /* Open local tunnel device */ |
1617 | if ((fd = tun_open(local_tun, tun_mode)) == -1) { | 1618 | if ((fd = tun_open(local_tun, tun_mode, &ifname)) == -1) { |
1618 | error("Tunnel device open failed."); | 1619 | error("Tunnel device open failed."); |
1619 | return -1; | 1620 | return NULL; |
1620 | } | 1621 | } |
1622 | debug("Tunnel forwarding using interface %s", ifname); | ||
1621 | 1623 | ||
1622 | c = channel_new(ssh, "tun", SSH_CHANNEL_OPENING, fd, fd, -1, | 1624 | c = channel_new(ssh, "tun", SSH_CHANNEL_OPENING, fd, fd, -1, |
1623 | CHAN_TCP_WINDOW_DEFAULT, CHAN_TCP_PACKET_DEFAULT, 0, "tun", 1); | 1625 | CHAN_TCP_WINDOW_DEFAULT, CHAN_TCP_PACKET_DEFAULT, 0, "tun", 1); |
@@ -1638,7 +1640,7 @@ client_request_tun_fwd(struct ssh *ssh, int tun_mode, | |||
1638 | packet_put_int(remote_tun); | 1640 | packet_put_int(remote_tun); |
1639 | packet_send(); | 1641 | packet_send(); |
1640 | 1642 | ||
1641 | return 0; | 1643 | return ifname; |
1642 | } | 1644 | } |
1643 | 1645 | ||
1644 | /* XXXX move to generic input handler */ | 1646 | /* XXXX move to generic input handler */ |