summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZac Medico <zmedico@gmail.com>2011-01-27 01:19:32 -0800
committerXavier Claessens <xclaesse@gmail.com>2011-01-27 11:45:25 +0100
commitc79de623d62e302964d3a5423bd4d8b12fe4e872 (patch)
treee3c694a780d959e601aa9ec81d511851020592bb
parent2a2fd40902a2e18fd8d43ba1ab0d46204f8aa11b (diff)
Allow the user to pass options to the ssh client
-rw-r--r--src/client-helpers.c12
-rw-r--r--src/client-helpers.h2
-rw-r--r--src/client.c10
-rw-r--r--src/vinagre/tab.c2
4 files changed, 21 insertions, 5 deletions
diff --git a/src/client-helpers.c b/src/client-helpers.c
index 444f30a..2442b0a 100644
--- a/src/client-helpers.c
+++ b/src/client-helpers.c
@@ -260,7 +260,8 @@ _client_create_local_socket (GError **error)
GStrv
_client_create_exec_args (GSocket *socket,
const gchar *contact_id,
- const gchar *username)
+ const gchar *username,
+ gchar **ssh_opts)
{
GPtrArray *args;
GSocketAddress *socket_address;
@@ -268,6 +269,7 @@ _client_create_exec_args (GSocket *socket,
guint16 port;
gchar *host;
gchar *str;
+ gchar **opt;
/* Get the local host and port on which sshd is running */
socket_address = g_socket_get_local_address (socket, NULL);
@@ -298,6 +300,14 @@ _client_create_exec_args (GSocket *socket,
g_ptr_array_add (args, g_strdup (username));
}
+ if (ssh_opts != NULL)
+ {
+ for (opt = ssh_opts; *opt != NULL; opt++)
+ {
+ g_ptr_array_add (args, g_strdup (*opt));
+ }
+ }
+
g_ptr_array_add (args, NULL);
return (gchar **) g_ptr_array_free (args, FALSE);
diff --git a/src/client-helpers.h b/src/client-helpers.h
index 61b26ea..ecfc5cf 100644
--- a/src/client-helpers.h
+++ b/src/client-helpers.h
@@ -35,7 +35,7 @@ GSocketConnection *_client_create_tube_finish (GAsyncResult *res,
GSocket *_client_create_local_socket (GError **error);
GStrv _client_create_exec_args (GSocket *socket, const gchar *contact_id,
- const gchar *username);
+ const gchar *username, gchar **ssh_opts);
gboolean _capabilities_has_stream_tube (TpCapabilities *caps);
diff --git a/src/client.c b/src/client.c
index 5478547..8627c28 100644
--- a/src/client.c
+++ b/src/client.c
@@ -38,6 +38,7 @@ typedef struct
gchar *account_path;
gchar *contact_id;
gchar *login;
+ gchar **ssh_opts;
GList *accounts;
guint n_readying_connections;
@@ -176,7 +177,7 @@ create_tube_cb (GObject *source_object,
ssh_socket_connected_cb, context);
args = _client_create_exec_args (socket, context->contact_id,
- context->login);
+ context->login, context->ssh_opts);
/* spawn ssh client */
if (g_spawn_async (NULL, args, NULL,
@@ -539,6 +540,7 @@ client_context_clear (ClientContext *context)
g_free (context->account_path);
g_free (context->contact_id);
g_free (context->login);
+ g_strfreev (context->ssh_opts);
g_list_foreach (context->accounts, (GFunc) g_object_unref, NULL);
g_list_free (context->accounts);
@@ -569,12 +571,16 @@ main (gint argc, gchar *argv[])
0, G_OPTION_ARG_STRING, &context.login,
"Specifies the user to log in as on the remote machine",
NULL },
+ { G_OPTION_REMAINING, 0,
+ 0, G_OPTION_ARG_STRING_ARRAY, &context.ssh_opts,
+ NULL,
+ NULL },
{ NULL }
};
g_type_init ();
- optcontext = g_option_context_new ("- ssh-contact");
+ optcontext = g_option_context_new ("-- [OPTIONS FOR SSH CLIENT]");
g_option_context_add_main_entries (optcontext, options, NULL);
if (!g_option_context_parse (optcontext, &argc, &argv, &error))
{
diff --git a/src/vinagre/tab.c b/src/vinagre/tab.c
index bcccb56..0d9470b 100644
--- a/src/vinagre/tab.c
+++ b/src/vinagre/tab.c
@@ -217,7 +217,7 @@ create_tube_cb (GObject *source_object,
ssh_socket_connected_cb, self);
get_connection_info (self, NULL, &contact_id, &username);
- args = _client_create_exec_args (socket, contact_id, username);
+ args = _client_create_exec_args (socket, contact_id, username, NULL);
vte_terminal_fork_command (VTE_TERMINAL (self->priv->vte), "ssh", args,
NULL, NULL, FALSE, FALSE, FALSE);