status/network: Add user permissions to new wifi connections
When creating a new NM connection they are by default system connections. A user cannot create them if they don't have the correct polkit permissions (org.freedesktop.NetworkManager.settings.modify.system). If a user tried to add a new connection in the drop down menu, then they got no password prompt and NM logged the following: [...] audit: op="connection-add-activate" pid=1872 uid=1000 result="fail" \ reason="Insufficient privileges" This change adds the current user to the user permissions for the new connection, if the user has no permissions to modify the system connections, which copies the behavior of GNOME Settings. Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3462>
This commit is contained in:
parent
2e659472f6
commit
cdf0e5fc6e
@ -949,6 +949,15 @@ const WirelessNetwork = GObject.registerClass({
|
|||||||
this._getDeviceDBusPath(), ap.get_path());
|
this._getDeviceDBusPath(), ap.get_path());
|
||||||
} else {
|
} else {
|
||||||
conn = new NM.SimpleConnection();
|
conn = new NM.SimpleConnection();
|
||||||
|
const permission = Polkit.Permission.new_sync('org.freedesktop.NetworkManager.settings.modify.system', null, null);
|
||||||
|
let allowedToShare = false;
|
||||||
|
if (permission)
|
||||||
|
allowedToShare = permission.get_allowed();
|
||||||
|
if (!allowedToShare) {
|
||||||
|
const setting = new NM.SettingConnection();
|
||||||
|
setting.add_permission('user', GLib.get_user_name(), null);
|
||||||
|
conn.add_setting(setting);
|
||||||
|
}
|
||||||
this._device.client.add_and_activate_connection_async(
|
this._device.client.add_and_activate_connection_async(
|
||||||
conn, this._device, ap.get_path(), null, null);
|
conn, this._device, ap.get_path(), null, null);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user