static void on_pipe_close (CockpitPipe *pipe, const gchar *problem, gpointer user_data) { CockpitTextStream *self = user_data; CockpitChannel *channel = user_data; gint status; gchar *signal; self->open = FALSE; if (cockpit_pipe_get_pid (pipe, NULL)) { status = cockpit_pipe_exit_status (pipe); if (WIFEXITED (status)) cockpit_channel_close_int_option (channel, "exit-status", WEXITSTATUS (status)); else if (WIFSIGNALED (status)) { signal = cockpit_strsignal (WTERMSIG (status)); cockpit_channel_close_option (channel, "exit-signal", signal); g_free (signal); } else if (status) cockpit_channel_close_int_option (channel, "exit-status", -1); } cockpit_channel_close (channel, problem); }
static void on_pipe_close (CockpitPipe *pipe, const gchar *problem, gpointer user_data) { CockpitPipeTransport *self = COCKPIT_PIPE_TRANSPORT (user_data); gboolean is_cockpit; GError *error = NULL; gint status; self->closed = TRUE; /* This function is called by the base class when it is closed */ if (cockpit_pipe_get_pid (pipe, NULL)) { is_cockpit = g_str_equal (self->name, "cockpit-bridge") || g_str_equal (self->name, "cockpit-session"); if (problem == NULL || g_str_equal (problem, "internal-error")) { status = cockpit_pipe_exit_status (pipe); if (WIFSIGNALED (status) && WTERMSIG (status) == SIGTERM) problem = "terminated"; else if (is_cockpit && WIFEXITED (status) && WEXITSTATUS (status) == 127) problem = "no-cockpit"; // cockpit-bridge not installed else if (WIFEXITED (status) && WEXITSTATUS (status) == 255) problem = "terminated"; // failed or got a signal, etc. else if (!g_spawn_check_exit_status (status, &error)) { problem = "internal-error"; if (is_cockpit) g_warning ("%s: bridge program failed: %s", self->name, error->message); else g_debug ("%s: process failed: %s", self->name, error->message); g_error_free (error); } } else if (g_str_equal (problem, "not-found")) { if (is_cockpit) { g_message ("%s: failed to execute bridge: not found", self->name); problem = "no-cockpit"; } else { g_debug ("%s: failed to run: not found", self->name); } } } g_debug ("%s: closed%s%s", self->name, problem ? ": " : "", problem ? problem : ""); cockpit_transport_emit_closed (COCKPIT_TRANSPORT (self), problem); }
static void on_pipe_close (CockpitPipe *pipe, const gchar *problem, gpointer user_data) { CockpitPipeTransport *self = COCKPIT_PIPE_TRANSPORT (user_data); GError *error = NULL; gint status; /* This function is called by the base class when it is closed */ if (cockpit_pipe_get_pid (pipe, NULL)) { if (problem == NULL) { status = cockpit_pipe_exit_status (pipe); if (WIFSIGNALED (status) && WTERMSIG (status) == SIGTERM) problem = "terminated"; else if (WIFEXITED (status) && WEXITSTATUS (status) == 5) problem = "not-authorized"; // wrong password else if (WIFEXITED (status) && WEXITSTATUS (status) == 6) problem = "unknown-hostkey"; else if (WIFEXITED (status) && WEXITSTATUS (status) == 127) problem = "no-agent"; // cockpit-agent not installed else if (WIFEXITED (status) && WEXITSTATUS (status) == 255) problem = "terminated"; // ssh failed or got a signal, etc. else if (!g_spawn_check_exit_status (status, &error)) { problem = "internal-error"; g_warning ("%s: agent program failed: %s", self->name, error->message); g_error_free (error); } } else if (g_str_equal (problem, "not-found")) { g_message ("%s: failed to execute agent: not found", self->name); problem = "no-agent"; } } g_debug ("%s: closed%s%s", self->name, problem ? ": " : "", problem ? problem : ""); cockpit_transport_emit_closed (COCKPIT_TRANSPORT (self), problem); }
static void on_pipe_close (CockpitPipe *pipe, const gchar *problem, gpointer user_data) { CockpitSshTransport *self = COCKPIT_SSH_TRANSPORT (user_data); GError *error = NULL; gint status; self->closing = TRUE; self->closed = TRUE; /* This function is called by the base class when it is closed */ if (cockpit_pipe_get_pid (pipe, NULL)) { if (problem == NULL || g_str_equal (problem, "internal-error") || g_str_equal (problem, "terminated")) { status = cockpit_pipe_exit_status (pipe); if (WIFSIGNALED (status) && WTERMSIG (status) == SIGTERM) problem = "terminated"; else if (WIFEXITED (status) && WEXITSTATUS (status) == 127) problem = "no-cockpit"; // cockpit-bridge not installed else if (WIFEXITED (status) && WEXITSTATUS (status) == 255) problem = "terminated"; // failed or got a signal, etc. else if (WIFEXITED (status) && WEXITSTATUS (status) == 254) problem = "disconnected"; // got IO_ERR. else if (!g_spawn_check_exit_status (status, &error)) { if (problem == NULL) problem = "internal-error"; g_warning ("%s: ssh session failed: %s", self->logname, error->message); g_error_free (error); } } } g_debug ("%s: closed%s%s", self->logname, problem ? ": " : "", problem ? problem : ""); cockpit_transport_emit_closed (COCKPIT_TRANSPORT (self), problem); }