예제 #1
0
static void
cockpit_ssh_transport_remove_auth_process (CockpitSshTransport *self)
{
  g_return_if_fail (self->auth_process != NULL);
  if (self->agent)
    cockpit_ssh_agent_close (self->agent);

  if (!self->pipe)
    cockpit_auth_process_terminate (self->auth_process);

  g_clear_object (&self->auth_process);
}
예제 #2
0
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;
}