about summary refs log tree commit diff
path: root/clients/cli/polkit-agent.c
diff options
context:
space:
mode:
authorSebastien Bacher <seb128@ubuntu.com>2018-08-24 11:00:09 +0200
committerSebastien Bacher <seb128@ubuntu.com>2018-08-24 11:06:47 +0200
commitb7db94545968c37886b7111d8c85f62eb063fbb4 (patch)
tree7c2aedd497b1fdcb26bf9d49f98cc63a530baf2e /clients/cli/polkit-agent.c
parent9d5cdc3adde9e7e57bf5a0e754e563b6a9e8e513 (diff)
parentcaf1db9d6fbc056cc6c76a24574890f6c7895f3d (diff)
Import Debian changes 1.12.2-0ubuntu3
network-manager (1.12.2-0ubuntu3) cosmic; urgency=medium

  * debian/rules:
    - use --with-libnm-glib, the default reversed since that's a legacy
      library but we still need it for unity-control-center

network-manager (1.12.2-0ubuntu2) cosmic; urgency=medium

  * debian/patches/git-newglib-test.patch:
    - backport upstream commit to fix the tests with the new glib 

network-manager (1.12.2-0ubuntu1) cosmic; urgency=medium

  * New upstream version
  * d/p/libnm-register-empty-NMClient-and-NetworkManager-when-loa.patch,
    d/p/e91f1a7d2a6b8400b6b331d5b72287dcb5164a39.patch,
    d/p/git_thunderbolt_connect.patch:
    - removed, those changes are in the new version
  * Backport Debian changes
  * Update symbols file for libnm0
  * Enable iwd support
  * Drop version requirements when oldstable ships a newer version
  * Drop dh_strip override, the dbgsym migration is done
  * Rebase patches
  * Make sure the example server.conf is actually installed
  * Update install path for plugins, it now includes a version number
  * Drop libnl3 build dependency.
    Upstream has copied the code directly from libnl3 for the few functions it
    needs with a few small modifications.
  * Drop libiw build dependency.
    Hasn't been needed for a long time and was simply a left over from older
    releases.
  * Bump Standards-Version to 4.1.5
  * Fix compile error due to NM_AVAILABLE_IN_1_12_2 macro (Closes: #905372)
Diffstat (limited to 'clients/cli/polkit-agent.c')
-rw-r--r--clients/cli/polkit-agent.c73
1 files changed, 33 insertions, 40 deletions
diff --git a/clients/cli/polkit-agent.c b/clients/cli/polkit-agent.c
index ecd58ba5..338f0b15 100644
--- a/clients/cli/polkit-agent.c
+++ b/clients/cli/polkit-agent.c
@@ -19,8 +19,6 @@
 
 #include "nm-default.h"
 
-#if WITH_POLKIT_AGENT
-
 #include "polkit-agent.h"
 
 #include <stdio.h>
@@ -29,17 +27,18 @@
 #include <unistd.h>
 
 #include "nm-polkit-listener.h"
-
 #include "common.h"
 
+#if WITH_POLKIT_AGENT
 static char *
-polkit_request (const char *request,
+polkit_request (NMPolkitListener *listener,
+                const char *request,
                 const char *action_id,
                 const char *message,
                 const char *icon_name,
                 const char *user,
                 gboolean echo_on,
-		gpointer user_data)
+                gpointer user_data)
 {
 	char *response, *tmp, *p;
 
@@ -62,28 +61,42 @@ polkit_request (const char *request,
 }
 
 static void
-polkit_show_info (const char *text)
+polkit_show_info (NMPolkitListener *listener,
+                  const char *text,
+                  gpointer user_data)
 {
 	g_print (_("Authentication message: %s\n"), text);
 }
 
 static void
-polkit_show_error (const char *text)
+polkit_show_error (NMPolkitListener *listener,
+                   const char *text,
+                   gpointer user_data)
 {
 	g_print (_("Authentication error: %s\n"), text);
 }
 
 static void
-polkit_completed (gboolean gained_authorization)
+polkit_completed (NMPolkitListener *listener,
+                  gboolean gained_authorization,
+                  gpointer user_data)
 {
 	/* We don't print anything here. The outcome will be evident from
 	 * the operation result anyway. */
 }
+#endif
 
 gboolean
 nmc_polkit_agent_init (NmCli* nmc, gboolean for_session, GError **error)
 {
-	PolkitAgentListener *listener;
+#if WITH_POLKIT_AGENT
+	static const NMPolkitListenVtable vtable = {
+		.on_request = polkit_request,
+		.on_show_info = polkit_show_info,
+		.on_show_error = polkit_show_error,
+		.on_completed = polkit_completed,
+	};
+	NMPolkitListener *listener;
 
 	g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
 
@@ -91,24 +104,28 @@ nmc_polkit_agent_init (NmCli* nmc, gboolean for_session, GError **error)
 	if (!listener)
 		return FALSE;
 
-	nm_polkit_listener_set_request_callback (NM_POLKIT_LISTENER (listener), polkit_request, nmc);
-	nm_polkit_listener_set_show_info_callback (NM_POLKIT_LISTENER (listener), polkit_show_info);
-	nm_polkit_listener_set_show_error_callback (NM_POLKIT_LISTENER (listener), polkit_show_error);
-	nm_polkit_listener_set_completed_callback (NM_POLKIT_LISTENER (listener), polkit_completed);
+	nm_polkit_listener_set_vtable (listener, &vtable, nmc);
 
-	nmc->pk_listener = NM_POLKIT_LISTENER (listener);
+	nmc->pk_listener = listener;
+#endif
 	return TRUE;
 }
 
 void
 nmc_polkit_agent_fini (NmCli* nmc)
 {
-	g_clear_object (&nmc->pk_listener);
+#if WITH_POLKIT_AGENT
+	if (nmc->pk_listener) {
+		nm_polkit_listener_set_vtable (nmc->pk_listener, NULL, NULL);
+		g_clear_object (&nmc->pk_listener);
+	}
+#endif
 }
 
 gboolean
 nmc_start_polkit_agent_start_try (NmCli *nmc)
 {
+#if WITH_POLKIT_AGENT
 	GError *error = NULL;
 
 	/* We don't register polkit agent at all when running non-interactively */
@@ -121,30 +138,6 @@ nmc_start_polkit_agent_start_try (NmCli *nmc)
 		g_error_free (error);
 		return FALSE;
 	}
+#endif
 	return TRUE;
 }
-
-#else
-/* polkit agent is not avalable; implement stub functions. */
-
-#include "nmcli.h"
-#include "polkit-agent.h"
-
-gboolean
-nmc_polkit_agent_init (NmCli* nmc, gboolean for_session, GError **error)
-{
-	return TRUE;
-}
-
-void
-nmc_polkit_agent_fini (NmCli* nmc)
-{
-}
-
-gboolean
-nmc_start_polkit_agent_start_try (NmCli *nmc)
-{
-	return TRUE;
-}
-
-#endif /* #if WITH_POLKIT_AGENT */