This is an automated email from the git hooks/post-receive script. x2go pushed a change to branch master in repository libx2goclient. from b74bd64 src/x2goclient-openssh-version.c: rework std{out,err} size checking. new bb23e7a src/x2goclient-network-ssh.c: add debug log line for portspec. new 1099f59 src/x2goclient-network-ssh.c: add private wrapper function x2goclient_network_ssh_log_std_str (). new 0efb0ef src/x2goclient-network-ssh.c: rework master connection spawn code to ignore stderr if the bug shim is set. new afb65da src/x2goclient-network-ssh.c: stop using g_printf (), use g_log () instead. The 4 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Summary of changes: src/x2goclient-network-ssh.c | 124 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 112 insertions(+), 12 deletions(-) -- Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/libx2goclient.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch master in repository libx2goclient. commit 1099f5951685b5abb3c7937011dc0217f4d21a21 Author: Mihai Moldovan <ionic@ionic.de> Date: Mon Jun 29 14:31:36 2020 +0200 src/x2goclient-network-ssh.c: add private wrapper function x2goclient_network_ssh_log_std_str (). Prints out an stdout or stderr string in a potentially multi-stage process if the size is bigger than INT_MAX. --- src/x2goclient-network-ssh.c | 53 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/src/x2goclient-network-ssh.c b/src/x2goclient-network-ssh.c index a515f85..96ec797 100644 --- a/src/x2goclient-network-ssh.c +++ b/src/x2goclient-network-ssh.c @@ -31,6 +31,7 @@ #include <stdlib.h> #include <errno.h> #include <limits.h> +#include <stdbool.h> #include <glib.h> #include <glib/gi18n.h> @@ -131,6 +132,7 @@ static GSocketAddress* x2goclient_network_ssh_parse_sockspec (X2GoClientNetwork static gboolean x2goclient_network_ssh_kill_subprocesses (X2GoClientNetworkSSH *self); static gboolean x2goclient_network_ssh_parent_connect (X2GoClientNetwork *parent, GError **gerr); static gboolean x2goclient_network_ssh_fetch_openssh_version (X2GoClientNetworkSSH *self, GError **gerr); +static void x2goclient_network_ssh_log_std_str (const gchar * const str, const gsize str_size, const _Bool stderr); static void x2goclient_network_ssh_class_init (X2GoClientNetworkSSHClass *klass) { @@ -1021,3 +1023,54 @@ static gboolean x2goclient_network_ssh_fetch_openssh_version (X2GoClientNetworkS return (ret); } + +static void x2goclient_network_ssh_log_std_str (const gchar * const str, const gsize str_size, const _Bool stderr) { + /* + * For a size bigger than zero, the bytes object must be non-NULL, + * otherwise any value is legit according to the documentation. + */ + g_return_if_fail (((str_size) && (str)) || (!(str_size))); + + const gchar *stream = "out"; + + if (stderr) { + stream = "err"; + } + + if ((str) && (str_size)) { + gsize str_size_work = str_size; + + g_log (NULL, G_LOG_LEVEL_DEBUG, "Std%s:", stream); + + _Bool cont = FALSE; + const gchar *str_work = str; + while (str_size_work) { + int cur_len = str_size_work; + + if (INT_MAX < str_size_work) { + cur_len = INT_MAX; + str_size_work -= INT_MAX; + } + + const char *fmt = ">>>%.*s<<<"; + if (cont) { + fmt = "(continuation) >>>%.*s<<<"; + } + + g_log (NULL, G_LOG_LEVEL_DEBUG, fmt, cur_len, str_work); + + /* + * Setting this out of bounds is fine as long as we don't actually access + * out-of-bounds data. + * + * Be extra careful here. + */ + str_work += cur_len; + + cont = TRUE; + } + } + else { + g_log (NULL, G_LOG_LEVEL_DEBUG, "Std%s: no data", stream); + } +} -- Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/libx2goclient.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch master in repository libx2goclient. commit afb65da70f7f7adcd06fbfbbe21d7882f7bf4230 Author: Mihai Moldovan <ionic@ionic.de> Date: Mon Jun 29 14:49:07 2020 +0200 src/x2goclient-network-ssh.c: stop using g_printf (), use g_log () instead. --- src/x2goclient-network-ssh.c | 37 +++++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/src/x2goclient-network-ssh.c b/src/x2goclient-network-ssh.c index e873c7e..010810d 100644 --- a/src/x2goclient-network-ssh.c +++ b/src/x2goclient-network-ssh.c @@ -945,13 +945,34 @@ static gboolean x2goclient_network_ssh_parent_connect (X2GoClientNetwork *parent } 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)); + { + /* + * Yeah, this is potentially slow, but there is no better way to use + * g_log (). + */ + const gchar *tmp_start = "Would try to connect via:"; + gchar *tmp = NULL; + for (gsize i = 0; i < ssh_cmd->len; ++i) { + gchar *tmp_new = NULL; + + if (0 == i) { + tmp_new = g_strdup_printf ("%s [%s]", tmp_start, (gchar *)g_ptr_array_index (ssh_cmd, i)); + } + else { + tmp_new = g_strdup_printf ("%s [%s]", tmp, (gchar *)g_ptr_array_index (ssh_cmd, i)); + + g_free (tmp); + } + + tmp = tmp_new; + } + g_log (NULL, G_LOG_LEVEL_DEBUG, "%s", tmp); + + g_free (tmp); + tmp = NULL; } - g_printf ("\n"); - g_printf ("Launching!\n"); + g_log (NULL, G_LOG_LEVEL_DEBUG, "Launching!"); GError *ssh_err = NULL; GSubprocessFlags flags = G_SUBPROCESS_FLAGS_STDOUT_PIPE; @@ -967,10 +988,10 @@ static gboolean x2goclient_network_ssh_parent_connect (X2GoClientNetwork *parent ret = (self->master_conn != NULL); if (ret) { - g_printf ("Process started/executed successfully!\n"); + g_log (NULL, G_LOG_LEVEL_DEBUG, "Process started/executed successfully!"); if (ssh_err) { - g_printf ("Successful execution, but ssh_err set? Weird, here's the message: %s", ssh_err->message); + g_log (NULL, G_LOG_LEVEL_WARNING, "Successful execution, but ssh_err set? Weird, here's the message: %s", ssh_err->message); } GCancellable *master_conn_comm_cancel = g_cancellable_new (); @@ -1007,7 +1028,7 @@ static gboolean x2goclient_network_ssh_parent_connect (X2GoClientNetwork *parent g_clear_error (&ssh_err); } else { - g_printf ("Process didn't execute/start successfully!\nError:\n>>>%s<<<\n", ssh_err->message); + g_log (NULL, G_LOG_LEVEL_CRITICAL, "Process didn't execute/start successfully!\nError:\n>>>%s<<<", ssh_err->message); } g_clear_error (&ssh_err); -- Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/libx2goclient.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch master in repository libx2goclient. commit 0efb0ef318856cd10e59843d4d0610573f80afa9 Author: Mihai Moldovan <ionic@ionic.de> Date: Mon Jun 29 14:33:26 2020 +0200 src/x2goclient-network-ssh.c: rework master connection spawn code to ignore stderr if the bug shim is set. --- src/x2goclient-network-ssh.c | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/src/x2goclient-network-ssh.c b/src/x2goclient-network-ssh.c index 96ec797..e873c7e 100644 --- a/src/x2goclient-network-ssh.c +++ b/src/x2goclient-network-ssh.c @@ -953,7 +953,16 @@ static gboolean x2goclient_network_ssh_parent_connect (X2GoClientNetwork *parent g_printf ("Launching!\n"); GError *ssh_err = NULL; - self->master_conn = g_subprocess_newv ((const gchar* const*)(ssh_cmd->pdata), (G_SUBPROCESS_FLAGS_STDOUT_PIPE | G_SUBPROCESS_FLAGS_STDERR_PIPE), &ssh_err); + GSubprocessFlags flags = G_SUBPROCESS_FLAGS_STDOUT_PIPE; + + if (self->openssh_bugs->backgrounding_keeps_stderr) { + flags |= G_SUBPROCESS_FLAGS_STDERR_SILENCE; + } + else { + flags |= G_SUBPROCESS_FLAGS_STDERR_PIPE; + } + + self->master_conn = g_subprocess_newv ((const gchar* const*)(ssh_cmd->pdata), flags, &ssh_err); ret = (self->master_conn != NULL); @@ -972,9 +981,24 @@ static gboolean x2goclient_network_ssh_parent_connect (X2GoClientNetwork *parent } else { gsize ssh_stdout_size = 0, ssh_stderr_size = 0; - const gchar *ssh_stdout_str = g_bytes_get_data (ssh_stdout, &ssh_stdout_size), - *ssh_stderr_str = g_bytes_get_data (ssh_stderr, &ssh_stderr_size); - g_printf ("Stdout:\n>>>%.*s<<<\nStderr:\n>>>%.*s<<<\n", ssh_stdout_size, ssh_stdout_str, ssh_stderr_size, ssh_stderr_str); + + const gchar *ssh_stdout_str = NULL, *ssh_stderr_str = NULL; + if (ssh_stdout) { + ssh_stdout_str = g_bytes_get_data (ssh_stdout, &ssh_stdout_size); + } + else { + g_log (NULL, G_LOG_LEVEL_WARNING, "Master connection does not have stdout pipe attached, but we expect it to be available. Ignoring output on stdout."); + } + + if (ssh_stderr) { + ssh_stderr_str = g_bytes_get_data (ssh_stderr, &ssh_stderr_size); + } + else if (!(self->openssh_bugs->backgrounding_keeps_stderr)) { + g_log (NULL, G_LOG_LEVEL_WARNING, "Master connection does not have stderr pipe attached, but we expect it to be available. Ignoring output on stderr."); + } + + x2goclient_network_ssh_log_std_str (ssh_stdout_str, ssh_stdout_size, 0); + x2goclient_network_ssh_log_std_str (ssh_stderr_str, ssh_stderr_size, 1); g_bytes_unref (ssh_stdout); g_bytes_unref (ssh_stderr); -- Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/libx2goclient.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch master in repository libx2goclient. commit bb23e7a5a1e07a3e38fc5c67d9415a08a37bb101 Author: Mihai Moldovan <ionic@ionic.de> Date: Mon Jun 29 14:26:50 2020 +0200 src/x2goclient-network-ssh.c: add debug log line for portspec. --- src/x2goclient-network-ssh.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/x2goclient-network-ssh.c b/src/x2goclient-network-ssh.c index 5405ddc..a515f85 100644 --- a/src/x2goclient-network-ssh.c +++ b/src/x2goclient-network-ssh.c @@ -320,6 +320,8 @@ static guint16 x2goclient_network_ssh_parse_sockspec_port (const GString * const g_return_val_if_fail (((NULL == gerr) || (NULL == *gerr)), ret); if (':' == portspec->str[0]) { + g_log (NULL, G_LOG_LEVEL_DEBUG, "portspec: %s", portspec->str); + /* * In the worst case, portspec->str[1] will point to a terminating NULL * character, but that's non-critical. -- Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/libx2goclient.git