summaryrefslogtreecommitdiffstats
path: root/src/remmina_protocol_widget.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 17:19:07 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 17:19:07 +0000
commitc1fda57df57ab94139fff24a92c5a796318e2828 (patch)
treebb3dc6013c7a310a3b95f4758517b4539043c0e7 /src/remmina_protocol_widget.c
parentAdding upstream version 1.4.34+dfsg. (diff)
downloadremmina-c1fda57df57ab94139fff24a92c5a796318e2828.tar.xz
remmina-c1fda57df57ab94139fff24a92c5a796318e2828.zip
Adding upstream version 1.4.35+dfsg.upstream/1.4.35+dfsgupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/remmina_protocol_widget.c')
-rw-r--r--src/remmina_protocol_widget.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/remmina_protocol_widget.c b/src/remmina_protocol_widget.c
index 7becda0..c8362a9 100644
--- a/src/remmina_protocol_widget.c
+++ b/src/remmina_protocol_widget.c
@@ -1168,6 +1168,44 @@ gchar *remmina_protocol_widget_start_direct_tunnel(RemminaProtocolWidget *gp, gi
g_ptr_array_add(gp->priv->ssh_tunnels, tunnel);
+
+ //try startup command
+ ssh_channel channel;
+ int rc;
+ const gchar* tunnel_command = remmina_file_get_string(gp->priv->remmina_file, "ssh_tunnel_command");
+ if (tunnel_command != NULL){
+ channel = ssh_channel_new(REMMINA_SSH(tunnel)->session);
+ if (channel == NULL) return g_strdup_printf("127.0.0.1:%i", remmina_pref.sshtunnel_port);
+
+ rc = ssh_channel_open_session(channel);
+ if (rc != SSH_OK)
+ {
+ ssh_channel_free(channel);
+ return g_strdup_printf("127.0.0.1:%i", remmina_pref.sshtunnel_port);
+ }
+ rc = ssh_channel_request_exec(channel, tunnel_command);
+ if (rc != SSH_OK)
+ {
+ ssh_channel_close(channel);
+ ssh_channel_free(channel);
+ return g_strdup_printf("127.0.0.1:%i", remmina_pref.sshtunnel_port);
+ }
+ struct timeval timeout = {10, 0};
+ ssh_channel channels[2];
+ channels[0] = channel;
+ channels[1] = NULL;
+ rc = ssh_channel_select(channels, NULL, NULL, &timeout);
+ if (rc == SSH_OK){
+ char buffer[256];
+ ssh_channel_read(channel, buffer, sizeof(buffer), 0);
+ }
+
+ REMMINA_DEBUG("Ran startup command");
+ ssh_channel_close(channel);
+ ssh_channel_free(channel);
+ }
+
+
return g_strdup_printf("127.0.0.1:%i", remmina_pref.sshtunnel_port);
#else