Bugzilla – Attachment 847 Details for
Bug 993
adding and removing forwardings via the control connection
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
-O add-rforward -O cancel-rforward
openssh.patch (text/plain), 5.09 KB, created by
Torsten Förtsch
on 2005-03-05 23:04:11 AEDT
(
hide
)
Description:
-O add-rforward -O cancel-rforward
Filename:
MIME Type:
Creator:
Torsten Förtsch
Created:
2005-03-05 23:04:11 AEDT
Size:
5.09 KB
patch
obsolete
>diff -Naur openssh/clientloop.c openssh.new/clientloop.c >--- openssh/clientloop.c 2005-03-01 11:24:33.000000000 +0100 >+++ openssh.new/clientloop.c 2005-03-04 15:45:19.950645565 +0100 >@@ -551,6 +551,21 @@ > xfree(cctx); > } > >+static inline int >+client_process_control_answer( Buffer *m, int allowed, int client_fd ) >+{ >+ buffer_clear(m); >+ buffer_put_int(m, allowed); >+ buffer_put_int(m, getpid()); >+ if (ssh_msg_send(client_fd, /* version */1, m) == -1) { >+ error("%s: client msg_send failed", __func__); >+ close(client_fd); >+ buffer_free(m); >+ return -1; >+ } >+ return 0; >+} >+ > static void > client_process_control(fd_set * readset) > { >@@ -564,6 +579,7 @@ > u_int len, env_len, command, flags; > uid_t euid; > gid_t egid; >+ char *command_arg; > > /* > * Accept connection on control socket >@@ -611,6 +627,7 @@ > allowed = 1; > command = buffer_get_int(&m); > flags = buffer_get_int(&m); >+ command_arg=buffer_get_string(&m, 0); > > buffer_clear(&m); > >@@ -630,14 +647,49 @@ > /* FALLTHROUGH */ > case SSHMUX_COMMAND_ALIVE_CHECK: > /* Reply for SSHMUX_COMMAND_TERMINATE and ALIVE_CHECK */ >- buffer_clear(&m); >- buffer_put_int(&m, allowed); >- buffer_put_int(&m, getpid()); >- if (ssh_msg_send(client_fd, /* version */1, &m) == -1) { >- error("%s: client msg_send failed", __func__); >- close(client_fd); >- buffer_free(&m); >+ if( client_process_control_answer(&m, allowed, client_fd) ) >+ return; >+ buffer_free(&m); >+ close(client_fd); >+ return; >+ case SSHMUX_COMMAND_RFADD: >+ debug2("%s: RFADD: %s", __func__, command_arg); >+ if( client_process_control_answer(&m, allowed, client_fd) ) >+ return; >+ { >+ Forward fwd; >+ if (parse_forward(&fwd, command_arg)) >+ channel_request_remote_forwarding >+ (fwd.listen_host, fwd.listen_port, >+ fwd.connect_host, fwd.connect_port); >+ else >+ logit("Bad forwarding specification."); >+ } >+ buffer_free(&m); >+ close(client_fd); >+ return; >+ case SSHMUX_COMMAND_RFCANCEL: >+ debug2("%s: RFCANCEL: %s", __func__, command_arg); >+ if( client_process_control_answer(&m, allowed, client_fd) ) > return; >+ { >+ int cancel_port = 0; >+ char *cancel_host = hpdelim(&command_arg); >+ if (command_arg != NULL) { >+ cancel_port = a2port(command_arg); >+ cancel_host = cleanhostname(cancel_host); >+ } else { >+ cancel_port = a2port(cancel_host); >+ cancel_host = NULL; >+ } >+ if (cancel_port == 0) { >+ logit("Bad forwarding close port"); >+ buffer_free(&m); >+ close(client_fd); >+ return; >+ } >+ channel_request_rforward_cancel(cancel_host, >+ cancel_port); > } > buffer_free(&m); > close(client_fd); >@@ -650,15 +702,8 @@ > } > > /* Reply for SSHMUX_COMMAND_OPEN */ >- buffer_clear(&m); >- buffer_put_int(&m, allowed); >- buffer_put_int(&m, getpid()); >- if (ssh_msg_send(client_fd, /* version */1, &m) == -1) { >- error("%s: client msg_send failed", __func__); >- close(client_fd); >- buffer_free(&m); >+ if( client_process_control_answer(&m, allowed, client_fd) ) > return; >- } > > if (!allowed) { > error("Refused control connection"); >diff -Naur openssh/clientloop.h openssh.new/clientloop.h >--- openssh/clientloop.h 2004-11-07 10:06:19.000000000 +0100 >+++ openssh.new/clientloop.h 2005-03-04 14:18:24.368906053 +0100 >@@ -45,6 +45,8 @@ > #define SSHMUX_COMMAND_OPEN 1 /* Open new connection */ > #define SSHMUX_COMMAND_ALIVE_CHECK 2 /* Check master is alive */ > #define SSHMUX_COMMAND_TERMINATE 3 /* Ask master to exit */ >+#define SSHMUX_COMMAND_RFADD 4 /* Add remote forward */ >+#define SSHMUX_COMMAND_RFCANCEL 5 /* Cancel remote forward */ > > #define SSHMUX_FLAG_TTY (1) /* Request tty on open */ > #define SSHMUX_FLAG_SUBSYS (1<<1) /* Subsystem request on open */ >diff -Naur openssh/ssh.c openssh.new/ssh.c >--- openssh/ssh.c 2005-03-01 11:24:34.000000000 +0100 >+++ openssh.new/ssh.c 2005-03-04 15:43:08.122712179 +0100 >@@ -146,6 +146,7 @@ > > /* Multiplexing control command */ > static u_int mux_command = SSHMUX_COMMAND_OPEN; >+static char *mux_command_arg=""; > > /* Only used in control client mode */ > volatile sig_atomic_t control_client_terminate = 0; >@@ -279,7 +280,13 @@ > mux_command = SSHMUX_COMMAND_ALIVE_CHECK; > else if (strcmp(optarg, "exit") == 0) > mux_command = SSHMUX_COMMAND_TERMINATE; >- else >+ else if (strcmp(optarg, "add-rforward") == 0) { >+ mux_command = SSHMUX_COMMAND_RFADD; >+ mux_command_arg=av[optind++]; >+ } else if (strcmp(optarg, "cancel-rforward") == 0) { >+ mux_command = SSHMUX_COMMAND_RFCANCEL; >+ mux_command_arg=av[optind++]; >+ } else > fatal("Invalid multiplex command."); > break; > case 'P': /* deprecated */ >@@ -1326,6 +1333,7 @@ > /* Send our command to server */ > buffer_put_int(&m, mux_command); > buffer_put_int(&m, flags); >+ buffer_put_cstring(&m, mux_command_arg); > if (ssh_msg_send(sock, /* version */1, &m) == -1) > fatal("%s: msg_send", __func__); > buffer_clear(&m); >@@ -1349,6 +1357,12 @@ > case SSHMUX_COMMAND_TERMINATE: > fprintf(stderr, "Exit request sent.\r\n"); > exit(0); >+ case SSHMUX_COMMAND_RFADD: >+ fprintf(stderr, "Add request sent.\r\n"); >+ exit(0); >+ case SSHMUX_COMMAND_RFCANCEL: >+ fprintf(stderr, "Cancel request sent.\r\n"); >+ exit(0); > case SSHMUX_COMMAND_OPEN: > /* continue below */ > break;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 993
: 847 |
1372