Patchwork [meta-gnome/meta-oe/meta-xfce,12/15] networkmanager: add group 'network' allowing members to change settings

login
register
mail settings
Submitter Andreas Müller
Date June 11, 2013, 5:34 a.m.
Message ID <1370928876-14423-13-git-send-email-schnitzeltony@googlemail.com>
Download mbox | patch
Permalink /patch/51511/
State Accepted, archived
Headers show

Comments

Andreas Müller - June 11, 2013, 5:34 a.m.
Signed-off-by: Andreas Müller <schnitzeltony@googlemail.com>
---
 .../50-org.freedesktop.NetworkManager.rules        |    8 ++++++++
 .../networkmanager/networkmanager_0.9.8.0.bb       |   10 +++++++++-
 2 files changed, 17 insertions(+), 1 deletions(-)
 create mode 100644 meta-oe/recipes-connectivity/networkmanager/networkmanager/50-org.freedesktop.NetworkManager.rules

Patch

diff --git a/meta-oe/recipes-connectivity/networkmanager/networkmanager/50-org.freedesktop.NetworkManager.rules b/meta-oe/recipes-connectivity/networkmanager/networkmanager/50-org.freedesktop.NetworkManager.rules
new file mode 100644
index 0000000..d771a17
--- /dev/null
+++ b/meta-oe/recipes-connectivity/networkmanager/networkmanager/50-org.freedesktop.NetworkManager.rules
@@ -0,0 +1,8 @@ 
+# give group 'network' rights to change settings
+# taken from https://wiki.archlinux.org/index.php/NetworkManager#Set_up_PolicyKit_permissions
+
+polkit.addRule(function(action, subject) {
+  if (action.id.indexOf("org.freedesktop.NetworkManager.") == 0 && subject.isInGroup("network")) {
+    return polkit.Result.YES;
+  }
+});
diff --git a/meta-oe/recipes-connectivity/networkmanager/networkmanager_0.9.8.0.bb b/meta-oe/recipes-connectivity/networkmanager/networkmanager_0.9.8.0.bb
index ef686cf..ea91c84 100644
--- a/meta-oe/recipes-connectivity/networkmanager/networkmanager_0.9.8.0.bb
+++ b/meta-oe/recipes-connectivity/networkmanager/networkmanager_0.9.8.0.bb
@@ -6,12 +6,13 @@  LIC_FILES_CHKSUM = "file://COPYING;md5=cbbffd568227ada506640fe950a4823b"
 
 DEPENDS = "libnl dbus dbus-glib udev wireless-tools gnutls util-linux ppp"
 
-inherit gnome gettext systemd
+inherit gnome gettext systemd useradd
 
 SRC_URI = " \
     ${GNOME_MIRROR}/NetworkManager/${@gnome_verdir("${PV}")}/NetworkManager-${PV}.tar.xz \
     file://0001-don-t-try-to-run-sbin-dhclient-to-get-the-version-nu.patch \
     file://0002-NetworkManager.service-remove-reference-to-NetworkMa.patch \
+    file://50-org.freedesktop.NetworkManager.rules \
 "
 SRC_URI[md5sum] = "38d28f6bd9220d85dfff47210706195c"
 SRC_URI[sha256sum] = "c366bcded6354d8186ad93c05d26d6a20bc550aa0391f974704e7a60e9f6096b"
@@ -58,6 +59,10 @@  do_install_append () {
     # Install an empty VPN folder as nm-connection-editor will happily segfault without it :o.
     # With or without VPN support built in ;).
     install -d ${D}/etc/NetworkManager/VPN
+
+    # polkit
+    install -m 700 -d ${D}/etc/polkit-1/rules.d
+    install -m 0755 ${WORKDIR}/50-org.freedesktop.NetworkManager.rules ${D}/etc/polkit-1/rules.d
 }
 
 PACKAGES =+ "libnmutil libnmglib libnmglib-vpn ${PN}-tests ${PN}-bash-completion"
@@ -104,3 +109,6 @@  FILES_${PN}-tests = " \
 FILES_${PN}-bash-completion = "${datadir}/bash-completion"
 
 SYSTEMD_SERVICE_${PN} = "NetworkManager.service"
+
+USERADD_PACKAGES = "${PN}"
+GROUPADD_PARAM_${PN} = "--system network"