Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Unix socket forwarding with -W #254

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 8 additions & 2 deletions channels.c
Original file line number Diff line number Diff line change
Expand Up @@ -1517,13 +1517,19 @@ channel_decode_socks5(Channel *c, struct sshbuf *input, struct sshbuf *output)

Channel *
channel_connect_stdio_fwd(struct ssh *ssh,
const char *host_to_connect, u_short port_to_connect,
const char *host_to_connect, int port_to_connect,
int in, int out, int nonblock)
{
Channel *c;
char* rtype;

debug_f("%s:%d", host_to_connect, port_to_connect);

if (port_to_connect == PORT_STREAMLOCAL)
rtype = "direct-streamlocal@openssh.com";
else
rtype = "direct-tcpip";

c = channel_new(ssh, "stdio-forward", SSH_CHANNEL_OPENING, in, out,
-1, CHAN_TCP_WINDOW_DEFAULT, CHAN_TCP_PACKET_DEFAULT,
0, "stdio-forward", nonblock);
Expand All @@ -1534,7 +1540,7 @@ channel_connect_stdio_fwd(struct ssh *ssh,
c->force_drain = 1;

channel_register_fds(ssh, c, in, out, -1, 0, 1, 0);
port_open_helper(ssh, c, "direct-tcpip");
port_open_helper(ssh, c, rtype);

return c;
}
Expand Down
2 changes: 1 addition & 1 deletion channels.h
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ Channel *channel_connect_to_port(struct ssh *, const char *, u_short,
char *, char *, int *, const char **);
Channel *channel_connect_to_path(struct ssh *, const char *, char *, char *);
Channel *channel_connect_stdio_fwd(struct ssh *, const char*,
u_short, int, int, int);
int, int, int, int);
Channel *channel_connect_by_listen_address(struct ssh *, const char *,
u_short, char *, char *);
Channel *channel_connect_by_listen_path(struct ssh *, const char *,
Expand Down
5 changes: 4 additions & 1 deletion ssh.c
Original file line number Diff line number Diff line change
Expand Up @@ -909,7 +909,10 @@ main(int ac, char **av)
if (muxclient_command != 0)
fatal("Cannot specify stdio forward with -O");
if (parse_forward(&fwd, optarg, 1, 0)) {
options.stdio_forward_host = fwd.listen_host;
if (fwd.listen_port == PORT_STREAMLOCAL)
options.stdio_forward_host = fwd.listen_path;
else
options.stdio_forward_host = fwd.listen_host;
options.stdio_forward_port = fwd.listen_port;
free(fwd.connect_host);
} else {
Expand Down