Re: Blocking a user from activating Airplane mode



On Sun, 2013-09-15 at 19:36 +0100, Phil Reynolds wrote:
My partner sometimes uses my laptop, and on two occasions has somehow
activated Airplane mode - this of course drops the WLAN and WWAN
connections. I can't even get the WWAN to work again after this happens
without rebooting.

I am wondering if there is a way I can stop him activating Airplane
mode - it's not something he would ever need to activate anyway.

NetworkManager uses PolicyKit to protect various operations like this.
What you want to do is to ensure that the user cannot obtain these
permissions:

org.freedesktop.NetworkManager.enable-disable-wifi
org.freedesktop.NetworkManager.enable-disable-wwan

which you'd do by writing some PolicyKit rules to deny that user these
two permissons.  Rules are just files that get dropped
into /etc/polkit-1/rules.d and look like this:

polkit.addRule(function(action, subject) {
    if (action.id == "org.freedesktop.NetworkManager.enable-disable-wifi" ||
        action.id == "org.freedesktop.NetworkManager.enable-disable-wwan") {
        if (subject.isInGroup("wheel")) {
            return polkit.Result.YES;
        } else {
            return polkit.Result.NO;
        }
    }
});

(or something along those lines) which will deny this permission
completely to any user who is not in the Unix 'wheel' group.  There
should be a good bit of info out there on writing policykit rules.

Hope this helps,
Dan



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]