Browse Source

Support port numbers on host definition

Héctor García 7 years ago
parent
commit
5adcc5bf54
3 changed files with 34 additions and 13 deletions
  1. 6 0
      AUTHORS
  2. 2 0
      ChangeLog
  3. 26 13
      src/mssh-terminal.c

+ 6 - 0
AUTHORS

@@ -5,3 +5,9 @@ Current Developer:
 Founder and Lead Developer:
 ----------------------------------------------------------------------------
     Bradley Smith  <brad@brad-smith.co.uk> (United Kingdom)
+
+Contributors
+----------------------------------------------------------------------------
+    Francisco Licerán <francisco@intelligenia.com>
+    Mario J. Barchéin <mario@intelligenia.com>
+    Oscar Fernandez <oscaretu@gmail.com>

+ 2 - 0
ChangeLog

@@ -2,6 +2,8 @@
 
     Added patch from Oscar Fernandez to support comments on configuration archive
 
+    Added patch from Mario J. Barchéin and Francisco Licerán to support port numbers on host
+
 2014-01-15  Héctor García  <hector@debian.org>
 
     Bumped version to 1.3 gtk2 deprecated symbols free

+ 26 - 13
src/mssh-terminal.c

@@ -40,23 +40,36 @@ void mssh_terminal_init_session(MSSHTerminal *terminal, char *hostname)
 
 void mssh_terminal_start_session(MSSHTerminal *terminal, char **env)
 {
-    char *args[3];
+    char *args[5];
+    char *fullhost;
+    char *host = NULL;
+    char *port = NULL;
+
+    fullhost = strdup(terminal->hostname);
+    host = strtok(fullhost, ":");
+    port = strtok(NULL, "");
 
     args[0] = strdup("ssh");
     args[1] = terminal->hostname;
-    args[2] = NULL;
-
-    vte_terminal_fork_command_full(  VTE_TERMINAL(terminal), 
-                                     VTE_PTY_DEFAULT,
-                                     NULL,  /* working dir */
-                                     args,
-                                     env, 
-                                     G_SPAWN_SEARCH_PATH,
-                                     NULL,  /* child_setup */
-                                     NULL,  /* child_setup_data */
-                                     NULL,  /* *child_pid */
-                                     NULL); /* Error handling */
 
+    if (!port)
+        args[2] = NULL;
+    else {
+         args[2] = "-p";
+         args[3] = port;
+         args[4] = NULL;
+    }
+
+    vte_terminal_fork_command_full(VTE_TERMINAL(terminal),
+                                   VTE_PTY_NO_LASTLOG|VTE_PTY_NO_UTMP|VTE_PTY_NO_WTMP,
+                                   NULL,  /* working dir */
+                                   args,
+                                   env,
+                                   G_SPAWN_SEARCH_PATH,
+                                   NULL,  /* child_setup */
+                                   NULL,  /* child_setup_data */
+                                   NULL,  /* *child_pid */
+                                   NULL); /* Error handling */
 
     free(args[0]);
 }