[X2Go-Commits] [libx2goclient] 98/132: src/x2goclient-network-ssh.c: reference X2GoClientNetwork:options property in x2goclient_network_ssh_connect () documentation, since no X2GoClientNetworkSSH:options property exists, but also make clear that this class/function expects an X2GoClientNetworkOptionsSSH instance being bound to the property.
git-admin at x2go.org
git-admin at x2go.org
Fri Dec 3 15:26:33 CET 2021
This is an automated email from the git hooks/post-receive script.
x2go pushed a commit to branch master
in repository libx2goclient.
commit 8e661a22516685a399512dd975a88df4bafed331
Author: Mihai Moldovan <ionic at ionic.de>
Date: Thu Sep 30 03:54:17 2021 +0200
src/x2goclient-network-ssh.c: reference X2GoClientNetwork:options property in x2goclient_network_ssh_connect () documentation, since no X2GoClientNetworkSSH:options property exists, but also make clear that this class/function expects an X2GoClientNetworkOptionsSSH instance being bound to the property.
Make sure to check for that in x2goclient_network_ssh_parent_connect ().
---
src/x2goclient-network-ssh.c | 36 ++++++++++++++++++++++++------------
src/x2goclient-network-ssh.h | 2 ++
2 files changed, 26 insertions(+), 12 deletions(-)
diff --git a/src/x2goclient-network-ssh.c b/src/x2goclient-network-ssh.c
index 2c34dba..24ebd26 100644
--- a/src/x2goclient-network-ssh.c
+++ b/src/x2goclient-network-ssh.c
@@ -1080,8 +1080,10 @@ static gboolean x2goclient_network_ssh_kill_subprocesses (X2GoClientNetworkSSH *
* #X2GoClientNetwork:connected property.
*
* The connection parameters are looked up from the
- * #X2GoClientNetwork:socket, #X2GoClientNetworkSSH:options and
- * #X2GoClientNetwork:session-path properties.
+ * #X2GoClientNetwork:socket, #X2GoClientNetwork:options and
+ * #X2GoClientNetwork:session-path properties. It is expected (and checked)
+ * that a #X2GoClientNetworkOptionsSSH instance is bound to the
+ * #X2GoClientNetwork:options property.
*
* Currently, the control socket path is hardcoded to
* <filename><varname>session-path</varname>/ssh/control</filename>.
@@ -1245,21 +1247,31 @@ static gboolean x2goclient_network_ssh_parent_connect (const gpointer ptr, GErro
g_object_get (G_OBJECT (self), "options", &options, NULL);
if (options) {
- /* Get string-array representation. */
- GPtrArray *options_arr = x2goclient_network_options_ssh_to_array (options);
-
- if (!(options_arr)) {
- g_set_error_literal (gerr, X2GOCLIENT_NETWORK_SSH_ERROR, X2GOCLIENT_NETWORK_SSH_ERROR_CONNECT_OPTIONS_INVALID, "Unable to convert options structure to an array, can't connect.");
+ /*
+ * Check if it's actually an X2GoClientOptionsSSH instance - it might not
+ * be.
+ */
+ if (!(X2GOCLIENT_IS_NETWORK_OPTIONS_SSH (options))) {
+ g_set_error_literal (gerr, X2GOCLIENT_NETWORK_SSH_ERROR, X2GOCLIENT_NETWORK_SSH_ERROR_CONNECT_OPTIONS_INVALID, "Options structure is not of expected type X2GoClientNetworkOptionsSSH.");
ret = FALSE;
}
else {
- /* Add each element to command. */
- for (size_t i = 0; i < options_arr->len; ++i) {
- g_ptr_array_add (ssh_cmd, g_strdup ("-o"));
- g_ptr_array_add (ssh_cmd, g_strdup ((gchar *)g_ptr_array_index (options_arr, i)));
+ /* Get string-array representation. */
+ GPtrArray *options_arr = x2goclient_network_options_ssh_to_array (options);
+
+ if (!(options_arr)) {
+ g_set_error_literal (gerr, X2GOCLIENT_NETWORK_SSH_ERROR, X2GOCLIENT_NETWORK_SSH_ERROR_CONNECT_OPTIONS_INVALID, "Unable to convert options structure to an array, can't connect.");
+ ret = FALSE;
}
+ else {
+ /* Add each element to command. */
+ for (size_t i = 0; i < options_arr->len; ++i) {
+ g_ptr_array_add (ssh_cmd, g_strdup ("-o"));
+ g_ptr_array_add (ssh_cmd, g_strdup ((gchar *)g_ptr_array_index (options_arr, i)));
+ }
- g_ptr_array_unref (options_arr);
+ g_ptr_array_unref (options_arr);
+ }
}
}
diff --git a/src/x2goclient-network-ssh.h b/src/x2goclient-network-ssh.h
index 05150ca..2650a95 100644
--- a/src/x2goclient-network-ssh.h
+++ b/src/x2goclient-network-ssh.h
@@ -91,6 +91,8 @@ X2GoClientNetworkSSH* x2goclient_network_ssh_new (const gchar * const session_pa
* address type in
* connect function.
* @X2GOCLIENT_NETWORK_SSH_ERROR_CONNECT_OPTIONS_INVALID: options structure
+ * was not of the
+ * expected type or
* could not be parsed
* into string array in
* connect function.
--
Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/libx2goclient.git
More information about the x2go-commits
mailing list