Created
May 5, 2016 10:32
-
-
Save infirit/edb76e72be50164ebd3367982efa9a5f to your computer and use it in GitHub Desktop.
blueman polkit auth changes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/blueman/plugins/mechanism/Network.py b/blueman/plugins/mechanism/Network.py | |
| index ab7465f..317a3f6 100644 | |
| --- a/blueman/plugins/mechanism/Network.py | |
| +++ b/blueman/plugins/mechanism/Network.py | |
| @@ -53,6 +53,7 @@ class Network(MechanismPlugin): | |
| @dbus.service.method('org.blueman.Mechanism', in_signature="ayays", out_signature="", sender_keyword="caller", | |
| byte_arrays=True) | |
| def EnableNetwork(self, ip_address, netmask, dhcp_handler, caller): | |
| + self.confirm_authorization(caller, "org.blueman.network.setup") | |
| nc = NetConf.get_default() | |
| nc.set_ipv4(ip_address, netmask) | |
| nc.set_dhcp_handler(DHCPDHANDLERS[dhcp_handler]) | |
| @@ -60,11 +61,13 @@ class Network(MechanismPlugin): | |
| @dbus.service.method('org.blueman.Mechanism', in_signature="", out_signature="", sender_keyword="caller") | |
| def ReloadNetwork(self, caller): | |
| + self.confirm_authorization(caller, "org.blueman.network.setup") | |
| nc = NetConf.get_default() | |
| nc.apply_settings() | |
| @dbus.service.method('org.blueman.Mechanism', in_signature="", out_signature="", sender_keyword="caller") | |
| def DisableNetwork(self, caller): | |
| + self.confirm_authorization(caller, "org.blueman.network.setup") | |
| nc = NetConf.get_default() | |
| nc.remove_settings() | |
| nc.set_ipv4(None, None) | |
| diff --git a/blueman/plugins/mechanism/Ppp.py b/blueman/plugins/mechanism/Ppp.py | |
| index 873e7c9..c601c31 100644 | |
| --- a/blueman/plugins/mechanism/Ppp.py | |
| +++ b/blueman/plugins/mechanism/Ppp.py | |
| @@ -21,6 +21,7 @@ class Ppp(MechanismPlugin): | |
| @dbus.service.method('org.blueman.Mechanism', in_signature="sss", out_signature="s", sender_keyword="caller", | |
| async_callbacks=("ok", "err")) | |
| def PPPConnect(self, port, number, apn, caller, ok, err): | |
| + self.confirm_authorization(caller, "org.blueman.pppd.pppconnect") | |
| self.timer.stop() | |
| from blueman.main.PPPConnection import PPPConnection | |
| diff --git a/blueman/plugins/mechanism/RfKill.py b/blueman/plugins/mechanism/RfKill.py | |
| index 2a2b456..3b091a0 100644 | |
| --- a/blueman/plugins/mechanism/RfKill.py | |
| +++ b/blueman/plugins/mechanism/RfKill.py | |
| @@ -13,8 +13,9 @@ if not os.path.exists('/dev/rfkill'): | |
| raise ImportError("Hardware kill switch not found") | |
| class RfKill(MechanismPlugin): | |
| - @dbus.service.method('org.blueman.Mechanism', in_signature="b", out_signature="") | |
| - def SetRfkillState(self, state): | |
| + @dbus.service.method('org.blueman.Mechanism', in_signature="b", out_signature="", sender_keyword="caller") | |
| + def SetRfkillState(self, state, caller): | |
| + self.confirm_authorization(caller, "org.blueman.rfkill.setstate") | |
| f = open('/dev/rfkill', 'r+b', buffering=0) | |
| f.write(struct.pack("IBBBB", 0, RFKILL_TYPE_BLUETOOTH, RFKILL_OP_CHANGE_ALL, (0 if state else 1), 0)) | |
| f.close() | |
| diff --git a/data/configs/org.blueman.Mechanism.conf b/data/configs/org.blueman.Mechanism.conf | |
| index f2e9ccc..a187c0c 100644 | |
| --- a/data/configs/org.blueman.Mechanism.conf | |
| +++ b/data/configs/org.blueman.Mechanism.conf | |
| @@ -6,8 +6,11 @@ | |
| <busconfig> | |
| <policy user="root"> | |
| <allow own="org.blueman.Mechanism"/> | |
| + <allow send_destination="org.blueman.Mechanism"/> | |
| + <allow receive_sender="org.blueman.Mechanism"/> | |
| </policy> | |
| <policy context="default"> | |
| <allow send_destination="org.blueman.Mechanism"/> | |
| + <allow receive_sender="org.blueman.Mechanism"/> | |
| </policy> | |
| </busconfig> | |
| diff --git a/data/configs/org.blueman.policy.in b/data/configs/org.blueman.policy.in | |
| index c48ea12..75a377d 100644 | |
| --- a/data/configs/org.blueman.policy.in | |
| +++ b/data/configs/org.blueman.policy.in | |
| @@ -23,17 +23,26 @@ | |
| <_message>Launching DHCP client requires privileges</_message> | |
| <defaults> | |
| <allow_inactive>no</allow_inactive> | |
| - <allow_active>yes</allow_active> | |
| + <allow_active>auth_admin_keep</allow_active> | |
| </defaults> | |
| </action> | |
| - | |
| - <action id="org.blueman.bluez.config"> | |
| - <_description>Bluetooth Configuration</_description> | |
| - <_message>Changing Bluetooth system settings requires privileges</_message> | |
| + | |
| + <action id="org.blueman.pppd.pppconnect"> | |
| + <_description>Launch PPP daemon</_description> | |
| + <_message>Launching PPP daemon requires privileges</_message> | |
| <defaults> | |
| <allow_inactive>no</allow_inactive> | |
| <allow_active>auth_admin_keep</allow_active> | |
| </defaults> | |
| </action> | |
| - | |
| + | |
| + <action id="org.blueman.rfkill.setstate"> | |
| + <_description>Set RfKill State</_description> | |
| + <_message>Setting RfKill State requires privileges</_message> | |
| + <defaults> | |
| + <allow_inactive>no</allow_inactive> | |
| + <allow_active>auth_admin_keep</allow_active> | |
| + </defaults> | |
| + </action> | |
| + | |
| </policyconfig> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment