summaryrefslogtreecommitdiff
path: root/clients/cli/polkit-agent.c
diff options
context:
space:
mode:
authorJiří Klimeš <jklimes@redhat.com>2014-10-30 15:45:43 +0100
committerJiří Klimeš <jklimes@redhat.com>2014-11-07 11:21:35 +0100
commit0d9c9208026a8c5c14b657bceb477931fd35375d (patch)
tree084650b6126059806a8a4c76bc2b8ee94cbf2f17 /clients/cli/polkit-agent.c
parent9e6e6344cb114c5d79eae52594547112d6f800e9 (diff)
downloadNetworkManager-jk/nmcli-agent-command.tar.gz
cli: add 'nmcli agent' commandjk/nmcli-agent-command
Synopsis: nmcli agent { secret | polkit | all } The command runs separate NetworkManager secret agent or session polkit agent, or both. It is useful when - no other secret agent is available (such as GUI nm-applet, gnome-shell, KDE applet) - no other polkit agent is available (such as polkit-gnome-authentication-agent-1, polkit-kde-authentication-agent-1 or lxpolkit)
Diffstat (limited to 'clients/cli/polkit-agent.c')
-rw-r--r--clients/cli/polkit-agent.c28
1 files changed, 24 insertions, 4 deletions
diff --git a/clients/cli/polkit-agent.c b/clients/cli/polkit-agent.c
index e8502884e4..a163b824fa 100644
--- a/clients/cli/polkit-agent.c
+++ b/clients/cli/polkit-agent.c
@@ -102,10 +102,6 @@ nmc_polkit_agent_init (NmCli* nmc, gboolean for_session, GError **error)
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
- /* We don't register polkit agent at all when running non-interactively */
- if (!nmc->ask)
- return TRUE;
-
listener = nm_polkit_listener_new (for_session, error);
if (!listener)
return FALSE;
@@ -125,6 +121,24 @@ nmc_polkit_agent_fini (NmCli* nmc)
g_clear_object (&nmc->pk_listener);
}
+gboolean
+nmc_start_polkit_agent_start_try (NmCli *nmc)
+{
+ GError *error = NULL;
+
+ /* We don't register polkit agent at all when running non-interactively */
+ if (!nmc->ask)
+ return TRUE;
+
+ if (!nmc_polkit_agent_init (nmc, FALSE, &error)) {
+ g_printerr (_("Warning: polkit agent initialization failed: %s\n"),
+ error->message);
+ g_error_free (error);
+ return FALSE;
+ }
+ return TRUE;
+}
+
#else
/* polkit agent is not avalable; implement stub functions. */
@@ -143,4 +157,10 @@ nmc_polkit_agent_fini (NmCli* nmc)
{
}
+gboolean
+nmc_start_polkit_agent_start_try (NmCli *nmc)
+{
+ return TRUE;
+}
+
#endif /* #if WITH_POLKIT_AGENT */