static void cockpit_ssh_transport_attach_pipe (CockpitSshTransport *self) { g_return_if_fail (self->pipe == NULL); g_return_if_fail (self->auth_process != NULL); if (self->agent) cockpit_ssh_agent_close (self->agent); self->pipe = cockpit_auth_process_claim_as_pipe (self->auth_process); self->read_sig = g_signal_connect (self->pipe, "read", G_CALLBACK (on_pipe_read), self); self->close_sig = g_signal_connect (self->pipe, "close", G_CALLBACK (on_pipe_close), self); cockpit_ssh_transport_remove_auth_process (self); while (g_queue_peek_head (self->queue)) { GBytes *block = g_queue_pop_head (self->queue); cockpit_pipe_write (self->pipe, block); g_bytes_unref (block); } if (self->closing && !self->closed) cockpit_pipe_close (self->pipe, NULL); }
static CockpitCreds * cockpit_auth_remote_login_finish (CockpitAuth *self, GAsyncResult *result, GHashTable *headers, JsonObject **prompt_data, CockpitTransport **transport, GError **error) { CockpitCreds *creds; CockpitPipe *pipe = NULL; AuthData *ad; g_return_val_if_fail (g_simple_async_result_is_valid (result, G_OBJECT (self), cockpit_auth_remote_login_async), NULL); ad = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (result)); if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (result), error)) return NULL; creds = parse_ssh_spawn_results (self, ad, headers, prompt_data, error); if (creds) { if (transport) { pipe = cockpit_auth_process_claim_as_pipe (ad->auth_process); *transport = cockpit_pipe_transport_new (pipe); g_object_unref (pipe); } } else { if (prompt_data && *prompt_data) cockpit_auth_prepare_login_reply (self, *prompt_data, headers, ad); else cockpit_auth_process_terminate (ad->auth_process); } g_free (ad->response_data); ad->response_data = NULL; return creds; }