[Pkg-utopia-maintainers] Bug#983641: network-manager-gnome: Wireguard connections cannot be enabled or disabled
Baptiste Jonglez
debian at bitsofnetworks.org
Sat Feb 27 18:18:03 GMT 2021
Package: network-manager-gnome
Version: 1.20.0-2
Severity: important
Tags: patch
Dear Maintainer(s),
The network-manager-applet version in Debian bullseye has support to edit
Wireguard connections, which is a good thing (it was introduced upstream
in version 1.18.0).
However, it is not possible to enable or disable a Wireguard connection in
the applet. This is currently only possible through nmcli (a command-line
tool), which defeats the purpose of using a graphical tool like nm-applet.
This has been fixed upstream but didn't make it in time for the recent
1.20.0 release that Debian is currently using.
Since the fix involves only minor code changes on top of 1.20.0, I suggest
backporting the upstream patch in Debian. This will ensure that Wireguard
support is complete and that it can be used fully graphically in Debian
bullseye.
I am attaching the upstream patch, here are the upstream references:
https://gitlab.gnome.org/GNOME/network-manager-applet/-/commit/514d033b8d0b9e411ba7e878ddbfa338c6720e6f
https://gitlab.gnome.org/GNOME/network-manager-applet/-/merge_requests/95
Thank you,
Baptiste
-- System Information:
Debian Release: bullseye/sid
APT prefers testing
APT policy: (500, 'testing')
Architecture: amd64 (x86_64)
Kernel: Linux 5.9.0-2-amd64 (SMP w/4 CPU threads)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE=en_US:en
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled
Versions of packages network-manager-gnome depends on:
ii dbus-user-session [default-dbus-session-bus] 1.12.20-1
ii dbus-x11 [dbus-session-bus] 1.12.20-1
ii gnome-shell [polkit-1-auth-agent] 3.38.3-2
ii libatk1.0-0 2.36.0-2
ii libayatana-appindicator3-1 0.5.5-2
ii libc6 2.31-9
ii libcairo2 1.16.0-5
ii libgdk-pixbuf-2.0-0 2.42.2+dfsg-1
ii libglib2.0-0 2.66.7-1
ii libgtk-3-0 3.24.24-1
ii libjansson4 2.13.1-1.1
ii libmm-glib0 1.14.10-0.1
ii libnm0 1.28.0-2+b1
ii libnma0 1.8.30-1
ii libnotify4 0.7.9-3
ii libpango-1.0-0 1.46.2-3
ii libpangocairo-1.0-0 1.46.2-3
ii libsecret-1-0 0.20.4-2
ii libselinux1 3.1-3
ii network-manager 1.28.0-2+b1
Versions of packages network-manager-gnome recommends:
ii gnome-keyring 3.36.0-1
ii gnome-shell [notification-daemon] 3.38.3-2
ii iso-codes 4.5.0-1
ii mobile-broadband-provider-info 20201225-1
ii notification-daemon 3.20.0-4
Versions of packages network-manager-gnome suggests:
pn network-manager-openconnect-gnome <none>
ii network-manager-openvpn-gnome 1.8.12-2
pn network-manager-pptp-gnome <none>
pn network-manager-vpnc-gnome <none>
-- no debconf information
-------------- next part --------------
>From 514d033b8d0b9e411ba7e878ddbfa338c6720e6f Mon Sep 17 00:00:00 2001
From: Beniamino Galvani <bgalvani at redhat.com>
Date: Thu, 11 Feb 2021 09:45:00 +0100
Subject: [PATCH] applet: support activating WireGuard connections as VPNs
Display WireGuard connections in the VPN submenu and allow
[de]activating them.
https://gitlab.gnome.org/GNOME/network-manager-applet/-/issues/77
---
src/applet.c | 65 ++++++++++++++++++++++++++++++++++++----------------
1 file changed, 45 insertions(+), 20 deletions(-)
diff --git a/src/applet.c b/src/applet.c
index 8ebac755..8cf6dc43 100644
--- a/src/applet.c
+++ b/src/applet.c
@@ -875,6 +875,13 @@ applet_is_any_device_activating (NMApplet *applet)
return FALSE;
}
+static gboolean
+connection_is_vpn (NMConnection *connection)
+{
+ return nm_connection_is_type (connection, NM_SETTING_VPN_SETTING_NAME)
+ || nm_connection_is_type (connection, NM_SETTING_WIREGUARD_SETTING_NAME);
+}
+
static gboolean
applet_is_any_vpn_activating (NMApplet *applet)
{
@@ -1062,10 +1069,13 @@ nma_menu_vpn_item_clicked (GtkMenuItem *item, gpointer user_data)
return;
}
- active = applet_get_default_active_connection (applet, &device, FALSE);
- if (!active || !device) {
- g_warning ("%s: no active connection or device.", __func__);
- return;
+ if (nm_connection_is_type (connection, NM_SETTING_VPN_SETTING_NAME)) {
+ active = applet_get_default_active_connection (applet, &device, FALSE);
+ if (!active || !device) {
+ /* FIXME: show a UI notification ? */
+ g_warning ("%s: no active connection or device.", __func__);
+ return;
+ }
}
info = g_malloc0 (sizeof (VPNActivateInfo));
@@ -1076,7 +1086,7 @@ nma_menu_vpn_item_clicked (GtkMenuItem *item, gpointer user_data)
nm_client_activate_connection_async (applet->nm_client,
connection,
device,
- nm_object_get_path (NM_OBJECT (active)),
+ active ? nm_object_get_path (NM_OBJECT (active)) : NULL,
NULL,
activate_vpn_cb,
info);
@@ -1112,6 +1122,25 @@ nma_menu_add_vpn_item_activate (GtkMenuItem *item, gpointer user_data)
g_spawn_async (NULL, (gchar **) argv, NULL, 0, NULL, NULL, NULL, NULL);
}
+static NMVpnConnectionState
+ac_state_to_vpn_state (NMActiveConnectionState ac_state)
+{
+ switch (ac_state) {
+ case NM_ACTIVE_CONNECTION_STATE_UNKNOWN:
+ return NM_VPN_CONNECTION_STATE_UNKNOWN;
+ case NM_ACTIVE_CONNECTION_STATE_ACTIVATING:
+ return NM_VPN_CONNECTION_STATE_PREPARE;
+ case NM_ACTIVE_CONNECTION_STATE_ACTIVATED:
+ case NM_ACTIVE_CONNECTION_STATE_DEACTIVATING:
+ return NM_VPN_CONNECTION_STATE_ACTIVATED;
+ case NM_ACTIVE_CONNECTION_STATE_DEACTIVATED:
+ return NM_VPN_CONNECTION_STATE_DISCONNECTED;
+ }
+
+ nm_assert_not_reached ();
+ return NM_VPN_CONNECTION_STATE_UNKNOWN;
+}
+
/*
* applet_get_active_vpn_connection:
*
@@ -1121,7 +1150,7 @@ nma_menu_add_vpn_item_activate (GtkMenuItem *item, gpointer user_data)
*/
static NMActiveConnection *
applet_get_active_vpn_connection (NMApplet *applet,
- NMVpnConnectionState *out_state)
+ NMVpnConnectionState *out_state)
{
const GPtrArray *active_list;
NMActiveConnection *ret = NULL;
@@ -1132,7 +1161,6 @@ applet_get_active_vpn_connection (NMApplet *applet,
for (i = 0; active_list && (i < active_list->len); i++) {
NMActiveConnection *candidate;
NMConnection *connection;
- NMSettingConnection *s_con;
candidate = g_ptr_array_index (active_list, i);
@@ -1140,17 +1168,20 @@ applet_get_active_vpn_connection (NMApplet *applet,
if (!connection)
continue;
- s_con = nm_connection_get_setting_connection (connection);
- if (!s_con)
+ if (!connection_is_vpn (connection))
continue;
- if (!strcmp (nm_setting_connection_get_connection_type (s_con), NM_SETTING_VPN_SETTING_NAME)) {
- ret = candidate;
+ ret = candidate;
+ if (nm_connection_is_type (connection, NM_SETTING_VPN_SETTING_NAME)) {
state = nm_vpn_connection_get_vpn_state (NM_VPN_CONNECTION (candidate));
+ } else {
+ NMActiveConnectionState ac_state;
- if (state != NM_VPN_CONNECTION_STATE_ACTIVATED)
- break;
+ ac_state = nm_active_connection_get_state (candidate);
+ state = ac_state_to_vpn_state (ac_state);
}
+ if (state != NM_VPN_CONNECTION_STATE_ACTIVATED)
+ break;
}
if (ret && out_state)
@@ -1453,15 +1484,9 @@ get_vpn_connections (NMApplet *applet)
for (i = 0; i < all_connections->len; i++) {
NMConnection *connection = NM_CONNECTION (all_connections->pdata[i]);
- if (!nm_connection_is_type (connection, NM_SETTING_VPN_SETTING_NAME))
+ if (!connection_is_vpn (connection))
continue;
- if (!nm_connection_get_setting_vpn (connection)) {
- g_warning ("%s: VPN connection '%s' didn't have required vpn setting.", __func__,
- nm_connection_get_id (connection));
- continue;
- }
-
g_ptr_array_add (vpn_connections, g_object_ref (connection));
}
--
GitLab
More information about the Pkg-utopia-maintainers
mailing list