This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch master in repository libx2goclient. commit b871c1b39fcb71b7198bcb0094bc19bcd60527b9 Author: Mihai Moldovan <ionic@ionic.de> Date: Thu Jul 30 15:05:01 2020 +0200 src/x2goclient-network-ssh.c: rewrite x2goclient_network_ssh_kill_subprocesses () to not kill an actual process but spawn an OpenSSH client process executing an exit command for the master connection. --- src/x2goclient-network-ssh.c | 45 +++++++++++++++++++------------------------- 1 file changed, 19 insertions(+), 26 deletions(-) diff --git a/src/x2goclient-network-ssh.c b/src/x2goclient-network-ssh.c index 48a75a4..fded0cb 100644 --- a/src/x2goclient-network-ssh.c +++ b/src/x2goclient-network-ssh.c @@ -699,40 +699,33 @@ static gboolean x2goclient_network_ssh_kill_subprocesses (X2GoClientNetworkSSH * g_return_val_if_fail (X2GOCLIENT_IS_NETWORK_SSH (self), ret); if (self->active_master_conn) { - /* FIXME: rework this code! */ - /* Cleanup, if necessary. */ g_log (NULL, G_LOG_LEVEL_DEBUG, "Master connection cleanup required."); - g_subprocess_force_exit (self->master_conn); + GPtrArray *ssh_cmd = g_ptr_array_new_with_free_func (&x2goclient_clear_strings); + g_ptr_array_add (ssh_cmd, g_strdup ("ssh")); - GCancellable *wait_cancel = g_cancellable_new (); - GError *wait_error = NULL; - while (!(g_subprocess_wait (self->master_conn, wait_cancel, &wait_error))) { - /* - * Try to wait for subprocess termination really hard. - * The wait call should only fail if the operation was cancelled, but - * given that we don't do that (explicitly), it should not occur in the - * first place. - */ - g_log (NULL, G_LOG_LEVEL_CRITICAL, "Waiting on master connection subprocess termination was cancelled!\nError: %s\nThis should not have happened. Retrying.", wait_error->message); + /* Add control path options. */ + g_ptr_array_add (ssh_cmd, g_strdup ("-o")); + g_ptr_array_add (ssh_cmd, g_strdup_printf ("ControlPath=\"%s\"", self->control_path)); - g_clear_error (&wait_error); - } + /* Add master socket command. */ + g_ptr_array_add (ssh_cmd, g_strdup ("-O")); + g_ptr_array_add (ssh_cmd, g_strdup ("exit")); - if (0 == g_subprocess_get_if_exited (self->master_conn)) { - gint exit_status = g_subprocess_get_exit_status (self->master_conn); - g_log (NULL, G_LOG_LEVEL_WARNING, "Master connection subprocess exited with an error; return code: %d", exit_status); - } - else { - g_log (NULL, G_LOG_LEVEL_MESSAGE, "Master connection subprocess exited successfully."); - } + ret = x2goclient_network_ssh_sshcmd_add_host_port (self, ssh_cmd, NULL); - g_object_unref (self->master_conn); - self->master_conn = NULL; - self->active_master_conn = FALSE; + if (ret) { + /* Zero-terminate. */ + g_ptr_array_add (ssh_cmd, NULL); - ret = TRUE; + /* Okay, execute. */ + x2goclient_network_ssh_gptrarray_print_debug (ssh_cmd, "Terminating master connection via:", "OpenSSH client command"); + + g_log (NULL, G_LOG_LEVEL_DEBUG, "Launching!"); + ret = x2goclient_network_ssh_start_sshcmd (self, ssh_cmd, NULL, FALSE); + self->active_master_conn = (!(ret)); + } } return (ret); -- Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/libx2goclient.git