This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch master in repository libx2goclient. commit d674d5b6c43f5ef24fa04c6666c9b35e06fc56e5 Author: Mihai Moldovan <ionic@ionic.de> Date: Mon Nov 11 17:38:26 2019 +0100 src/x2goclient-network-ssh.c: actually spawn an SSH process. Weirdly, g_spawn_sync () seems to not notice processes detaching (like ssh -f) and will just hang forever. That's weird, because the process itself is exiting correctly (after spawning a new child, naturally). We'll probably want to use something like GSubProcess later on anyway, so that's probably not a huge issue, but I wasn't able to find out why it's behaving like that for now. --- src/x2goclient-network-ssh.c | 58 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/src/x2goclient-network-ssh.c b/src/x2goclient-network-ssh.c index 41abff7..3b26cfd 100644 --- a/src/x2goclient-network-ssh.c +++ b/src/x2goclient-network-ssh.c @@ -680,12 +680,70 @@ static gboolean x2goclient_network_ssh_parent_connect (X2GoClientNetwork *parent sock_addr = NULL; } + if (ret) { + /* Add control path options. */ + g_ptr_array_add (ssh_cmd, g_strdup ("-o")); + g_ptr_array_add (ssh_cmd, g_strdup ("ControlMaster=\"yes\"")); + g_ptr_array_add (ssh_cmd, g_strdup ("-o")); + g_ptr_array_add (ssh_cmd, g_strdup ("ControlPersist=\"yes\"")); + g_ptr_array_add (ssh_cmd, g_strdup ("-o")); + g_ptr_array_add (ssh_cmd, g_strdup_printf ("ControlPath=\"%s\"", self->control_path)); + + /* Force ssh process to background. */ + g_ptr_array_add (ssh_cmd, g_strdup ("-f")); + + /* Do not execute commands, we just want to have a master connection. */ + g_ptr_array_add (ssh_cmd, g_strdup ("-N")); + + /* We do not need a pseudo terminal. */ + g_ptr_array_add (ssh_cmd, g_strdup ("-T")); + + /* Let process terminate if it wasn't able to connect or set up sockets. */ + g_ptr_array_add (ssh_cmd, g_strdup ("-o")); + g_ptr_array_add (ssh_cmd, g_strdup ("ExitOnForwardFailure=\"yes\"")); + + /* Try to call uptime. */ + g_ptr_array_add (ssh_cmd, g_strdup ("uptime")); + + /* + * Quite importantly, zero-terminate the array, as it will be used as + * argv! + */ + g_ptr_array_add (ssh_cmd, NULL); + } + if (ret) { g_printf ("Would try to connect via:"); for (gsize i = 0; i < ssh_cmd->len; ++i) { g_printf (" [%s]", (gchar *)g_ptr_array_index (ssh_cmd, i)); } g_printf ("\n"); + + g_printf ("Launching!\n"); + gint ssh_exit = -1; + gchar *ssh_stdout = NULL, *ssh_stderr = NULL; + GError *ssh_err = NULL; + ret = g_spawn_sync (NULL, (gchar**)(ssh_cmd->pdata), NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, &ssh_stdout, &ssh_stderr, &ssh_exit, &ssh_err); + + if (ret) { + g_printf ("Process executed successfully!\nReturn value: %d\nStdout:\n>>>%s<<<\nStderr:\n>>>%s<<<\n", ssh_exit, ssh_stdout, ssh_stderr); + + if (ssh_err) { + g_printf ("Successful execution, but ssh_err set? Weird, here's the message: %s", ssh_err->message); + } + } + else { + g_printf ("Process didn't execute successfully!\nError:\n>>>%s<<<\n", ssh_err->message); + } + + g_free (ssh_stdout); + ssh_stdout = NULL; + + g_free (ssh_stderr); + ssh_stderr = NULL; + + g_free (ssh_err); + ssh_err = NULL; } g_free (session_path); -- Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/libx2goclient.git