summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiří Klimeš <jklimes@redhat.com>2015-04-27 16:53:43 +0200
committerJiří Klimeš <jklimes@redhat.com>2015-04-27 17:05:12 +0200
commitf9a6531ddb9c6324604dd04aa911a7a22953f2b2 (patch)
treec6f025a2f6eef2f0014f2b7acb6e0122a05dc94f
parent6c50f00b60b5c887410c89fd82d2681fb0bd56aa (diff)
downloadnetwork-manager-applet-f9a6531ddb9c6324604dd04aa911a7a22953f2b2.tar.gz
applet: make new auto connections only available for current user (rh #1176042)jk/applet-add-and-activate-rh1176042
When a user clicks a new Wi-Fi network in nm-applet, AddAndActivateConnection() D-Bus method is called to create a new connection and activate it. The connection is available to all users by default (no connection.permissions). However, this causes troubles when polkit action for modifying system connections [1] is set to require admin access. Then a normal user cannot connect to a new network, because it would require admin password to save the new connection and finish AddAndActivateConnection(). We solve that by creating new connections as private to current user only. [1] org.freedesktop.NetworkManager.settings.modify.system set to auth (i.e. auth_admin, auth_admin_keep) https://bugzilla.redhat.com/show_bug.cgi?id=1176042
-rw-r--r--src/applet-device-wifi.c7
-rw-r--r--src/mobile-helpers.c3
2 files changed, 8 insertions, 2 deletions
diff --git a/src/applet-device-wifi.c b/src/applet-device-wifi.c
index 91d0ea8f..ab16c094 100644
--- a/src/applet-device-wifi.c
+++ b/src/applet-device-wifi.c
@@ -393,6 +393,11 @@ _do_new_auto_connection (NMApplet *applet,
connection = nm_simple_connection_new ();
+ /* Make the new connection available only for the current user */
+ s_con = (NMSettingConnection *) nm_setting_connection_new ();
+ nm_setting_connection_add_permission (s_con, "user", g_get_user_name (), NULL);
+ nm_connection_add_setting (connection, NM_SETTING (s_con));
+
ssid = nm_access_point_get_ssid (ap);
if ( (nm_access_point_get_mode (ap) == NM_802_11_MODE_INFRA)
&& (is_manufacturer_default_ssid (ssid) == TRUE)) {
@@ -414,11 +419,9 @@ _do_new_auto_connection (NMApplet *applet,
|| (wpa_flags & NM_802_11_AP_SEC_KEY_MGMT_802_1X)) {
/* Need a UUID for the "always ask" stuff in the Dialog of Doom */
- s_con = (NMSettingConnection *) nm_setting_connection_new ();
uuid = nm_utils_uuid_generate ();
g_object_set (s_con, NM_SETTING_CONNECTION_UUID, uuid, NULL);
g_free (uuid);
- nm_connection_add_setting (connection, NM_SETTING (s_con));
if (!s_wifi) {
s_wifi = (NMSettingWireless *) nm_setting_wireless_new ();
diff --git a/src/mobile-helpers.c b/src/mobile-helpers.c
index f957d731..d867b355 100644
--- a/src/mobile-helpers.c
+++ b/src/mobile-helpers.c
@@ -214,6 +214,9 @@ mobile_wizard_done (NMAMobileWizard *wizard,
NM_SETTING_CONNECTION_AUTOCONNECT, FALSE,
NM_SETTING_CONNECTION_UUID, uuid,
NULL);
+ /* Make the new connection available only for the current user */
+ nm_setting_connection_add_permission ((NMSettingConnection *) setting,
+ "user", g_get_user_name (), NULL);
g_free (uuid);
g_free (id);
nm_connection_add_setting (connection, setting);