static void secrets_requested (NMSecretAgentSimple *agent, const char *request_id, const char *title, const char *msg, GPtrArray *secrets, gpointer user_data) { NmCli *nmc = (NmCli *) user_data; gboolean success = FALSE; if (nmc->print_output == NMC_PRINT_PRETTY) nmc_terminal_erase_line (); success = get_secrets_from_user (request_id, title, msg, secrets); if (success) nm_secret_agent_simple_response (agent, request_id, secrets); else nm_secret_agent_simple_response (agent, request_id, NULL); }
/** * nmc_secrets_requested: * @agent: the #NMSecretAgentSimple * @request_id: request ID, to eventually pass to * nm_secret_agent_simple_response() * @title: a title for the password request * @msg: a prompt message for the password request * @secrets: (element-type #NMSecretAgentSimpleSecret): array of secrets * being requested. * @user_data: user data passed to the function * * This function is used as a callback for "request-secrets" signal of * NMSecretAgentSimpleSecret. */ void nmc_secrets_requested (NMSecretAgentSimple *agent, const char *request_id, const char *title, const char *msg, GPtrArray *secrets, gpointer user_data) { NmCli *nmc = (NmCli *) user_data; NMConnection *connection = NULL; char *path, *p; gboolean success = FALSE; if (nmc->print_output == NMC_PRINT_PRETTY) nmc_terminal_erase_line (); /* Find the connection for the request */ path = g_strdup (request_id); if (path) { p = strrchr (path, '/'); if (p) *p = '\0'; connection = nmc_find_connection (nmc->connections, "path", path, NULL); g_free (path); } success = get_secrets_from_user (request_id, title, msg, connection, nmc->in_editor || nmc->ask, nmc->show_secrets, nmc->pwds_hash, secrets); if (success) nm_secret_agent_simple_response (agent, request_id, secrets); else { /* Unregister our secret agent on failure, so that another agent * may be tried */ if (nmc->secret_agent) { nm_secret_agent_old_unregister (nmc->secret_agent, NULL, NULL); g_clear_object (&nmc->secret_agent); } } }