Seems to me like the problem is "simply" that there is a missing
parameter to vpn_connection_import(). It should in effect have about
the same signature as vpn_connection_new().

The attached updated patch seems to fix the issue. (Taken from Ubuntu,
against n-m-applet 0.9.8.8)


Mathieu Trudel-Lapierre <mathieu...@gmail.com>
Freenode: cyphermox, Jabber: mathieu...@gmail.com
4096R/EE018C93 1967 8F7D 03A1 8F38 732E  FF82 C126 33E1 EE01 8C93
From: Josselin Mouette <j...@debian.org>
Subject: Set passwords as agent-owned when they need to, to allow users
    without modify.system permissions to easily configure their connections.
Last-Update: 2014-03-18

---
 src/applet-device-wifi.c                |   25 +++++++++++++++++++++++++
 src/connection-editor/ce-page.h         |    1 +
 src/connection-editor/new-connection.c  |    2 ++
 src/connection-editor/page-bond.c       |    1 +
 src/connection-editor/page-bond.h       |    1 +
 src/connection-editor/page-bridge.c     |    1 +
 src/connection-editor/page-bridge.h     |    1 +
 src/connection-editor/page-dsl.c        |    1 +
 src/connection-editor/page-dsl.h        |    1 +
 src/connection-editor/page-ethernet.c   |    1 +
 src/connection-editor/page-ethernet.h   |    1 +
 src/connection-editor/page-infiniband.c |    1 +
 src/connection-editor/page-infiniband.h |    1 +
 src/connection-editor/page-mobile.c     |   11 +++++++++++
 src/connection-editor/page-mobile.h     |    1 +
 src/connection-editor/page-vlan.c       |    1 +
 src/connection-editor/page-vlan.h       |    1 +
 src/connection-editor/page-vpn.c        |   11 +++++++++++
 src/connection-editor/page-vpn.h        |    2 ++
 src/connection-editor/page-wifi.c       |   14 ++++++++++++++
 src/connection-editor/page-wifi.h       |    1 +
 src/connection-editor/page-wimax.c      |    1 +
 src/connection-editor/page-wimax.h      |    1 +
 src/gnome-bluetooth/nma-bt-device.c     |    5 +++++
 src/libnm-gtk/nm-wifi-dialog.c          |    4 ++++
 src/mobile-helpers.c                    |    3 +++
 src/utils/utils.c                       |    7 +++++++
 src/utils/utils.h                       |    3 +++
 src/wireless-security/ws-wep-key.c      |    7 +++++++
 src/wireless-security/ws-wpa-psk.c      |    5 +++++
 30 files changed, 116 insertions(+)

Index: b/src/applet-device-wifi.c
===================================================================
--- a/src/applet-device-wifi.c
+++ b/src/applet-device-wifi.c
@@ -577,6 +577,7 @@ _do_new_auto_connection (NMApplet *apple
 	NMSettingWirelessSecurity *s_wsec = NULL;
 	NMSetting8021x *s_8021x = NULL;
 	const GByteArray *ssid;
+	NM80211ApFlags flags;
 	NM80211ApSecurityFlags wpa_flags, rsn_flags;
 	GtkWidget *dialog;
 	MoreInfo *more_info;
@@ -603,6 +604,7 @@ _do_new_auto_connection (NMApplet *apple
 	/* If the AP is WPA[2]-Enterprise then we need to set up a minimal 802.1x
 	 * setting and ask the user for more information.
 	 */
+	flags = nm_access_point_get_flags (ap);
 	rsn_flags = nm_access_point_get_rsn_flags (ap);
 	wpa_flags = nm_access_point_get_wpa_flags (ap);
 	if (   (rsn_flags & NM_802_11_AP_SEC_KEY_MGMT_802_1X)
@@ -634,6 +636,29 @@ _do_new_auto_connection (NMApplet *apple
 		nm_connection_add_setting (connection, NM_SETTING (s_8021x));
 	}
 
+	if (utils_default_to_private_connection (applet->nm_client)) {
+		if (!s_con) {
+			s_con = (NMSettingConnection *) nm_setting_connection_new ();
+			nm_connection_add_setting (connection, NM_SETTING (s_con));
+		}
+		nm_setting_connection_add_permission (s_con, "user", g_get_user_name (), NULL);
+
+		if ((rsn_flags & NM_802_11_AP_SEC_KEY_MGMT_PSK) ||
+		    (wpa_flags & NM_802_11_AP_SEC_KEY_MGMT_PSK)) {
+			if (!s_wsec) {
+				s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new ();
+				nm_connection_add_setting (connection, NM_SETTING (s_wsec));
+			}
+			g_object_set (s_wsec, NM_SETTING_WIRELESS_SECURITY_PSK_FLAGS, NM_SETTING_SECRET_FLAG_AGENT_OWNED, NULL);
+		} else if (flags & NM_802_11_AP_FLAGS_PRIVACY) {
+			if (!s_wsec) {
+				s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new ();
+				nm_connection_add_setting (connection, NM_SETTING (s_wsec));
+			}
+			g_object_set (s_wsec, NM_SETTING_WIRELESS_SECURITY_WEP_KEY_FLAGS, NM_SETTING_SECRET_FLAG_AGENT_OWNED, NULL);
+		}
+	}
+
 	/* If it's an 802.1x connection, we need more information, so pop up the
 	 * Dialog Of Doom.
 	 */
Index: b/src/connection-editor/ce-page.h
===================================================================
--- a/src/connection-editor/ce-page.h
+++ b/src/connection-editor/ce-page.h
@@ -48,6 +48,7 @@ typedef void (*PageNewConnectionFunc) (G
                                        const char *detail,
                                        NMRemoteSettings *settings,
                                        PageNewConnectionResultFunc result_func,
+                                       NMClient *client,
                                        gpointer user_data);
 
 #define CE_TYPE_PAGE            (ce_page_get_type ())
Index: b/src/connection-editor/new-connection.c
===================================================================
--- a/src/connection-editor/new-connection.c
+++ b/src/connection-editor/new-connection.c
@@ -394,6 +394,7 @@ new_connection_of_type (GtkWindow *paren
                         gpointer user_data)
 {
 	NewConnectionData *ncd;
+	NMConnectionList *list = user_data;
 
 	ncd = g_slice_new (NewConnectionData);
 	ncd->parent_window = parent_window;
@@ -405,6 +406,7 @@ new_connection_of_type (GtkWindow *paren
 	          detail,
 	          settings,
 	          new_connection_result,
+	          list->nm_client,
 	          ncd);
 }
 
Index: b/src/connection-editor/page-bond.c
===================================================================
--- a/src/connection-editor/page-bond.c
+++ b/src/connection-editor/page-bond.c
@@ -571,6 +571,7 @@ bond_connection_new (GtkWindow *parent,
                      const char *detail,
                      NMRemoteSettings *settings,
                      PageNewConnectionResultFunc result_func,
+                     NMClient *client,
                      gpointer user_data)
 {
 	NMConnection *connection;
Index: b/src/connection-editor/page-bond.h
===================================================================
--- a/src/connection-editor/page-bond.h
+++ b/src/connection-editor/page-bond.h
@@ -56,6 +56,7 @@ void bond_connection_new (GtkWindow *par
                           const char *detail,
                           NMRemoteSettings *settings,
                           PageNewConnectionResultFunc result_func,
+                          NMClient *client,
                           gpointer user_data);
 
 #endif  /* __PAGE_BOND_H__ */
Index: b/src/connection-editor/page-bridge.c
===================================================================
--- a/src/connection-editor/page-bridge.c
+++ b/src/connection-editor/page-bridge.c
@@ -297,6 +297,7 @@ bridge_connection_new (GtkWindow *parent
                      const char *detail,
                      NMRemoteSettings *settings,
                      PageNewConnectionResultFunc result_func,
+                     NMClient *client,
                      gpointer user_data)
 {
 	NMConnection *connection;
Index: b/src/connection-editor/page-bridge.h
===================================================================
--- a/src/connection-editor/page-bridge.h
+++ b/src/connection-editor/page-bridge.h
@@ -56,6 +56,7 @@ void bridge_connection_new (GtkWindow *p
                             const char *detail,
                             NMRemoteSettings *settings,
                             PageNewConnectionResultFunc result_func,
+                            NMClient *client,
                             gpointer user_data);
 
 #endif  /* __PAGE_BRIDGE_H__ */
Index: b/src/connection-editor/page-dsl.c
===================================================================
--- a/src/connection-editor/page-dsl.c
+++ b/src/connection-editor/page-dsl.c
@@ -227,6 +227,7 @@ dsl_connection_new (GtkWindow *parent,
                     const char *detail,
                     NMRemoteSettings *settings,
                     PageNewConnectionResultFunc result_func,
+                    NMClient *client,
                     gpointer user_data)
 {
 	NMConnection *connection;
Index: b/src/connection-editor/page-dsl.h
===================================================================
--- a/src/connection-editor/page-dsl.h
+++ b/src/connection-editor/page-dsl.h
@@ -58,6 +58,7 @@ void dsl_connection_new (GtkWindow *pare
                          const char *detail,
                          NMRemoteSettings *settings,
                          PageNewConnectionResultFunc callback,
+                         NMClient *client,
                          gpointer user_data);
 
 #endif  /* __PAGE_DSL_H__ */
Index: b/src/connection-editor/page-ethernet.c
===================================================================
--- a/src/connection-editor/page-ethernet.c
+++ b/src/connection-editor/page-ethernet.c
@@ -389,6 +389,7 @@ ethernet_connection_new (GtkWindow *pare
                          const char *detail,
                          NMRemoteSettings *settings,
                          PageNewConnectionResultFunc result_func,
+                         NMClient *client,
                          gpointer user_data)
 {
 	NMConnection *connection;
Index: b/src/connection-editor/page-ethernet.h
===================================================================
--- a/src/connection-editor/page-ethernet.h
+++ b/src/connection-editor/page-ethernet.h
@@ -58,6 +58,7 @@ void ethernet_connection_new (GtkWindow
                               const char *detail,
                               NMRemoteSettings *settings,
                               PageNewConnectionResultFunc result_func,
+                              NMClient *client,
                               gpointer user_data);
 
 #endif  /* __PAGE_ETHERNET_H__ */
Index: b/src/connection-editor/page-infiniband.c
===================================================================
--- a/src/connection-editor/page-infiniband.c
+++ b/src/connection-editor/page-infiniband.c
@@ -256,6 +256,7 @@ infiniband_connection_new (GtkWindow *pa
                            const char *detail,
                            NMRemoteSettings *settings,
                            PageNewConnectionResultFunc result_func,
+                           NMClient *client,
                            gpointer user_data)
 {
 	NMConnection *connection;
Index: b/src/connection-editor/page-infiniband.h
===================================================================
--- a/src/connection-editor/page-infiniband.h
+++ b/src/connection-editor/page-infiniband.h
@@ -56,6 +56,7 @@ void infiniband_connection_new (GtkWindo
                                 const char *detail,
                                 NMRemoteSettings *settings,
                                 PageNewConnectionResultFunc result_func,
+                                NMClient *client,
                                 gpointer user_data);
 
 #endif  /* __PAGE_INFINIBAND_H__ */
Index: b/src/connection-editor/page-mobile.c
===================================================================
--- a/src/connection-editor/page-mobile.c
+++ b/src/connection-editor/page-mobile.c
@@ -570,6 +570,7 @@ new_connection_mobile_wizard_done (NMAMo
 	NMConnection *connection = NULL;
 
 	if (!canceled && method) {
+		NMSettingConnection *s_con;
 		NMSetting *type_setting;
 		const char *ctype = NULL;
 		char *detail = NULL;
@@ -583,6 +584,7 @@ new_connection_mobile_wizard_done (NMAMo
 			              NM_SETTING_GSM_NUMBER, "*99#",
 			              NM_SETTING_GSM_USERNAME, method->username,
 			              NM_SETTING_GSM_PASSWORD, method->password,
+			              NM_SETTING_GSM_PASSWORD_FLAGS, NM_SETTING_SECRET_FLAG_AGENT_OWNED,
 			              NM_SETTING_GSM_APN, method->gsm_apn,
 			              NULL);
 			break;
@@ -594,6 +596,7 @@ new_connection_mobile_wizard_done (NMAMo
 			              NM_SETTING_CDMA_NUMBER, "#777",
 			              NM_SETTING_GSM_USERNAME, method->username,
 			              NM_SETTING_GSM_PASSWORD, method->password,
+			              NM_SETTING_GSM_PASSWORD_FLAGS, NM_SETTING_SECRET_FLAG_AGENT_OWNED,
 			              NULL);
 			break;
 		default:
@@ -608,6 +611,13 @@ new_connection_mobile_wizard_done (NMAMo
 		connection = ce_page_new_connection (detail, ctype, FALSE, info->settings, info->user_data);
 		g_free (detail);
 
+		s_con = nm_connection_get_setting_connection (connection);
+		if (!s_con) {
+			s_con = (NMSettingConnection *) nm_setting_connection_new ();
+			nm_connection_add_setting (connection, NM_SETTING (s_con));
+		}
+		nm_setting_connection_add_permission (s_con, "user", g_get_user_name (), NULL);
+
 		nm_connection_add_setting (connection, type_setting);
 		add_default_serial_setting (connection);
 		nm_connection_add_setting (connection, nm_setting_ppp_new ());
@@ -633,6 +643,7 @@ mobile_connection_new (GtkWindow *parent
                        const char *detail,
                        NMRemoteSettings *settings,
                        PageNewConnectionResultFunc result_func,
+                       NMClient *client,
                        gpointer user_data)
 {
 	NMAMobileWizard *wizard;
Index: b/src/connection-editor/page-mobile.h
===================================================================
--- a/src/connection-editor/page-mobile.h
+++ b/src/connection-editor/page-mobile.h
@@ -58,6 +58,7 @@ void mobile_connection_new (GtkWindow *p
                             const char *detail,
                             NMRemoteSettings *settings,
                             PageNewConnectionResultFunc result_func,
+                            NMClient *client,
                             gpointer user_data);
 
 #endif  /* __PAGE_MOBILE_H__ */
Index: b/src/connection-editor/page-vlan.c
===================================================================
--- a/src/connection-editor/page-vlan.c
+++ b/src/connection-editor/page-vlan.c
@@ -675,6 +675,7 @@ vlan_connection_new (GtkWindow *parent,
                      const char *detail,
                      NMRemoteSettings *settings,
                      PageNewConnectionResultFunc result_func,
+                     NMClient *client,
                      gpointer user_data)
 {
 	NMConnection *connection;
Index: b/src/connection-editor/page-vlan.h
===================================================================
--- a/src/connection-editor/page-vlan.h
+++ b/src/connection-editor/page-vlan.h
@@ -56,6 +56,7 @@ void vlan_connection_new (GtkWindow *par
                           const char *detail,
                           NMRemoteSettings *settings,
                           PageNewConnectionResultFunc result_func,
+                          NMClient *client,
                           gpointer user_data);
 
 #endif  /* __PAGE_VLAN_H__ */
Index: b/src/connection-editor/page-vpn.c
===================================================================
--- a/src/connection-editor/page-vpn.c
+++ b/src/connection-editor/page-vpn.c
@@ -261,6 +261,7 @@ vpn_connection_import (GtkWindow *parent
                        const char *detail,
                        NMRemoteSettings *settings,
                        PageNewConnectionResultFunc result_func,
+                       NMClient *client,
                        gpointer user_data)
 {
 	NewVpnInfo *info;
@@ -295,9 +296,11 @@ vpn_connection_new (GtkWindow *parent,
                     const char *detail,
                     NMRemoteSettings *settings,
                     PageNewConnectionResultFunc result_func,
+                    NMClient *client,
                     gpointer user_data)
 {
 	NMConnection *connection;
+	NMSettingConnection *s_con;
 	NMSetting *s_vpn;
 
 	if (!detail) {
@@ -323,6 +326,14 @@ vpn_connection_new (GtkWindow *parent,
 	                                     FALSE,
 	                                     settings,
 	                                     user_data);
+
+	s_con = nm_connection_get_setting_connection (connection);
+	if (!s_con) {
+		s_con = (NMSettingConnection *) nm_setting_connection_new ();
+		nm_connection_add_setting (connection, NM_SETTING (s_con));
+	}
+	nm_setting_connection_add_permission (s_con, "user", g_get_user_name (), NULL);
+
 	s_vpn = nm_setting_vpn_new ();
 	g_object_set (s_vpn, NM_SETTING_VPN_SERVICE_TYPE, detail, NULL);
 	nm_connection_add_setting (connection, s_vpn);
Index: b/src/connection-editor/page-vpn.h
===================================================================
--- a/src/connection-editor/page-vpn.h
+++ b/src/connection-editor/page-vpn.h
@@ -60,12 +60,14 @@ void vpn_connection_new (GtkWindow *pare
                          const char *detail,
                          NMRemoteSettings *settings,
                          PageNewConnectionResultFunc result_func,
+                         NMClient *client,
                          gpointer user_data);
 
 void vpn_connection_import (GtkWindow *parent,
                             const char *detail,
                             NMRemoteSettings *settings,
                             PageNewConnectionResultFunc result_func,
+                            NMClient *client,
                             gpointer user_data);
 
 #endif  /* __PAGE_VPN_H__ */
Index: b/src/connection-editor/page-wifi.c
===================================================================
--- a/src/connection-editor/page-wifi.c
+++ b/src/connection-editor/page-wifi.c
@@ -33,6 +33,8 @@
 #include <nm-device-wifi.h>
 #include <nm-utils.h>
 
+#include "utils.h"
+
 #include "page-wifi.h"
 
 G_DEFINE_TYPE (CEPageWifi, ce_page_wifi, CE_TYPE_PAGE)
@@ -655,6 +657,7 @@ wifi_connection_new (GtkWindow *parent,
                      const char *detail,
                      NMRemoteSettings *settings,
                      PageNewConnectionResultFunc result_func,
+                     NMClient *client,
                      gpointer user_data)
 {
 	NMConnection *connection;
@@ -665,6 +668,17 @@ wifi_connection_new (GtkWindow *parent,
 	                                     TRUE,
 	                                     settings,
 	                                     user_data);
+
+	if (utils_default_to_private_connection (client)) {
+		NMSettingConnection *s_con;
+		s_con = nm_connection_get_setting_connection (connection);
+		if (!s_con) {
+			s_con = (NMSettingConnection *) nm_setting_connection_new ();
+			nm_connection_add_setting (connection, NM_SETTING (s_con));
+		}
+		nm_setting_connection_add_permission (s_con, "user", g_get_user_name (), NULL);
+	}
+
 	s_wifi = nm_setting_wireless_new ();
 	g_object_set (s_wifi, NM_SETTING_WIRELESS_MODE, "infrastructure", NULL);
 	nm_connection_add_setting (connection, s_wifi);
Index: b/src/connection-editor/page-wifi.h
===================================================================
--- a/src/connection-editor/page-wifi.h
+++ b/src/connection-editor/page-wifi.h
@@ -62,6 +62,7 @@ void wifi_connection_new (GtkWindow *par
                           const char *detail,
                           NMRemoteSettings *settings,
                           PageNewConnectionResultFunc result_func,
+                          NMClient *client,
                           gpointer user_data);
 
 #endif  /* __PAGE_WIFI_H__ */
Index: b/src/connection-editor/page-wimax.c
===================================================================
--- a/src/connection-editor/page-wimax.c
+++ b/src/connection-editor/page-wimax.c
@@ -225,6 +225,7 @@ wimax_connection_new (GtkWindow *parent,
                       const char *detail,
                       NMRemoteSettings *settings,
                       PageNewConnectionResultFunc result_func,
+                      NMClient *client,
                       gpointer user_data)
 {
 	NMConnection *connection;
Index: b/src/connection-editor/page-wimax.h
===================================================================
--- a/src/connection-editor/page-wimax.h
+++ b/src/connection-editor/page-wimax.h
@@ -56,6 +56,7 @@ void wimax_connection_new (GtkWindow *pa
                            const char *detail,
                            NMRemoteSettings *settings,
                            PageNewConnectionResultFunc result_func,
+                           NMClient *client,
                            gpointer user_data);
 
 #endif  /* __PAGE_WIMAX_H__ */
Index: b/src/gnome-bluetooth/nma-bt-device.c
===================================================================
--- a/src/gnome-bluetooth/nma-bt-device.c
+++ b/src/gnome-bluetooth/nma-bt-device.c
@@ -354,6 +354,7 @@ dun_new_cdma (NMAMobileWizardAccessMetho
 	              NM_SETTING_CDMA_NUMBER, "#777",
 	              NM_SETTING_CDMA_USERNAME, method->username,
 	              NM_SETTING_CDMA_PASSWORD, method->password,
+	              NM_SETTING_CDMA_PASSWORD_FLAGS, NM_SETTING_SECRET_FLAG_AGENT_OWNED,
 	              NULL);
 	nm_connection_add_setting (connection, setting);
 
@@ -380,6 +381,7 @@ dun_new_cdma (NMAMobileWizardAccessMetho
 	              NULL);
 	g_free (uuid);
 	g_free (id);
+	nm_setting_connection_add_permission ((NMSettingConnection *) setting, "user", g_get_user_name (), NULL);
 	nm_connection_add_setting (connection, setting);
 
 	return connection;
@@ -399,6 +401,7 @@ dun_new_gsm (NMAMobileWizardAccessMethod
 	              NM_SETTING_GSM_NUMBER, "*99#",
 	              NM_SETTING_GSM_USERNAME, method->username,
 	              NM_SETTING_GSM_PASSWORD, method->password,
+	              NM_SETTING_GSM_PASSWORD_FLAGS, NM_SETTING_SECRET_FLAG_AGENT_OWNED,
 	              NM_SETTING_GSM_APN, method->gsm_apn,
 	              NULL);
 	nm_connection_add_setting (connection, setting);
@@ -426,6 +429,7 @@ dun_new_gsm (NMAMobileWizardAccessMethod
 	              NULL);
 	g_free (uuid);
 	g_free (id);
+	nm_setting_connection_add_permission ((NMSettingConnection *) setting, "user", g_get_user_name (), NULL);
 	nm_connection_add_setting (connection, setting);
 
 	return connection;
@@ -1011,6 +1015,7 @@ add_pan_connection (NmaBtDevice *self)
 	              NULL);
 	g_free (id);
 	g_free (uuid);
+	nm_setting_connection_add_permission ((NMSettingConnection *) setting, "user", g_get_user_name (), NULL);
 	nm_connection_add_setting (connection, setting);
 
 	/* The Bluetooth settings */
Index: b/src/libnm-gtk/nm-wifi-dialog.c
===================================================================
--- a/src/libnm-gtk/nm-wifi-dialog.c
+++ b/src/libnm-gtk/nm-wifi-dialog.c
@@ -38,6 +38,7 @@
 #include "nm-wifi-dialog.h"
 #include "wireless-security.h"
 #include "nm-ui-utils.h"
+#include "utils.h"
 
 G_DEFINE_TYPE (NMAWifiDialog, nma_wifi_dialog, GTK_TYPE_DIALOG)
 
@@ -1220,6 +1221,9 @@ nma_wifi_dialog_get_connection (NMAWifiD
 			      NM_SETTING_CONNECTION_UUID, uuid,
 			      NULL);
 		g_free (uuid);
+		if (utils_default_to_private_connection (priv->client)) {
+			nm_setting_connection_add_permission (s_con, "user", g_get_user_name (), NULL);
+		}
 		nm_connection_add_setting (connection, (NMSetting *) s_con);
 
 		s_wireless = (NMSettingWireless *) nm_setting_wireless_new ();
Index: b/src/mobile-helpers.c
===================================================================
--- a/src/mobile-helpers.c
+++ b/src/mobile-helpers.c
@@ -309,6 +309,7 @@ mobile_wizard_done (NMAMobileWizard *wiz
 			              NM_SETTING_CDMA_NUMBER, "#777",
 			              NM_SETTING_CDMA_USERNAME, method->username,
 			              NM_SETTING_CDMA_PASSWORD, method->password,
+			              NM_SETTING_CDMA_PASSWORD_FLAGS, NM_SETTING_SECRET_FLAG_AGENT_OWNED,
 			              NULL);
 			nm_connection_add_setting (connection, setting);
 		} else if (method->devtype == NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS) {
@@ -319,6 +320,7 @@ mobile_wizard_done (NMAMobileWizard *wiz
 			              NM_SETTING_GSM_USERNAME, method->username,
 			              NM_SETTING_GSM_PASSWORD, method->password,
 			              NM_SETTING_GSM_APN, method->gsm_apn,
+			              NM_SETTING_GSM_PASSWORD_FLAGS, NM_SETTING_SECRET_FLAG_AGENT_OWNED,
 			              NULL);
 			nm_connection_add_setting (connection, setting);
 		} else
@@ -347,6 +349,7 @@ mobile_wizard_done (NMAMobileWizard *wiz
 		              NULL);
 		g_free (uuid);
 		g_free (id);
+		nm_setting_connection_add_permission ((NMSettingConnection *) setting, "user", g_get_user_name (), NULL);
 		nm_connection_add_setting (connection, setting);
 	}
 
Index: b/src/utils/utils.c
===================================================================
--- a/src/utils/utils.c
+++ b/src/utils/utils.c
@@ -211,3 +211,10 @@ utils_show_error_dialog (const char *tit
 	}
 }
 
+gboolean
+utils_default_to_private_connection (NMClient *client)
+{
+	NMClientPermissionResult perms;
+	perms = nm_client_get_permission_result (client, NM_CLIENT_PERMISSION_SETTINGS_MODIFY_SYSTEM);
+	return (perms != NM_CLIENT_PERMISSION_RESULT_YES);
+}
Index: b/src/utils/utils.h
===================================================================
--- a/src/utils/utils.h
+++ b/src/utils/utils.h
@@ -27,6 +27,7 @@
 #include <gtk/gtk.h>
 #include <nm-connection.h>
 #include <nm-device.h>
+#include <nm-client.h>
 #include <net/ethernet.h>
 #include <nm-access-point.h>
 
@@ -53,6 +54,8 @@ void utils_show_error_dialog (const char
                               gboolean modal,
                               GtkWindow *parent);
 
+gboolean utils_default_to_private_connection (NMClient *client);
+
 #define NMA_ERROR (g_quark_from_static_string ("nma-error-quark"))
 
 typedef enum  {
Index: b/src/wireless-security/ws-wep-key.c
===================================================================
--- a/src/wireless-security/ws-wep-key.c
+++ b/src/wireless-security/ws-wep-key.c
@@ -142,6 +142,7 @@ static void
 fill_connection (WirelessSecurity *parent, NMConnection *connection)
 {
 	WirelessSecurityWEPKey *sec = (WirelessSecurityWEPKey *) parent;
+	NMSettingConnection *s_con;
 	NMSettingWireless *s_wireless;
 	NMSettingWirelessSecurity *s_wsec;
 	GtkWidget *widget;
@@ -156,6 +157,8 @@ fill_connection (WirelessSecurity *paren
 	key = gtk_entry_get_text (GTK_ENTRY (widget));
 	strcpy (sec->keys[sec->cur_index], key);
 
+	s_con = nm_connection_get_setting_connection (connection);
+
 	s_wireless = nm_connection_get_setting_wireless (connection);
 	g_assert (s_wireless);
 
@@ -172,6 +175,10 @@ fill_connection (WirelessSecurity *paren
 	              NM_SETTING_WIRELESS_SECURITY_WEP_KEY_TYPE, sec->type,
 	              NULL);
 
+	/* If the connection is user-owned, mark the secrets as agent-owned */
+	if (s_con && nm_setting_connection_get_num_permissions (s_con))
+		g_object_set (s_wsec, NM_SETTING_WIRELESS_SECURITY_WEP_KEY_FLAGS, NM_SETTING_SECRET_FLAG_AGENT_OWNED, NULL);
+
 	for (i = 0; i < 4; i++) {
 		if (strlen (sec->keys[i]))
 			nm_setting_wireless_security_set_wep_key (s_wsec, i, sec->keys[i]);
Index: b/src/wireless-security/ws-wpa-psk.c
===================================================================
--- a/src/wireless-security/ws-wpa-psk.c
+++ b/src/wireless-security/ws-wpa-psk.c
@@ -92,11 +92,13 @@ fill_connection (WirelessSecurity *paren
 {
 	GtkWidget *widget;
 	const char *key;
+	NMSettingConnection *s_con;
 	NMSettingWireless *s_wireless;
 	NMSettingWirelessSecurity *s_wireless_sec;
 	const char *mode;
 	gboolean is_adhoc = FALSE;
 
+	s_con = nm_connection_get_setting_connection (connection);
 	s_wireless = nm_connection_get_setting_wireless (connection);
 	g_assert (s_wireless);
 
@@ -113,6 +115,9 @@ fill_connection (WirelessSecurity *paren
 	widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "wpa_psk_entry"));
 	key = gtk_entry_get_text (GTK_ENTRY (widget));
 	g_object_set (s_wireless_sec, NM_SETTING_WIRELESS_SECURITY_PSK, key, NULL);
+	/* If the connection is user-owned, mark the secrets as agent-owned */
+	if (s_con && nm_setting_connection_get_num_permissions (s_con))
+		g_object_set (s_wireless_sec, NM_SETTING_WIRELESS_SECURITY_PSK_FLAGS, NM_SETTING_SECRET_FLAG_AGENT_OWNED, NULL);
 
 	wireless_security_clear_ciphers (connection);
 	if (is_adhoc) {

Reply via email to