diff options
author | Johannes Berg <johannes@sipsolutions.net> | 2009-07-10 21:41:39 +0200 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2009-07-21 12:07:37 -0400 |
commit | f54c142725ad2ba33c3ee627873cb6966bf05447 (patch) | |
tree | 4bd86d879222e94c5ee175355242b8a04990334b /net/rfkill | |
parent | e2e414d92397c366396d13f627a98a20be92e509 (diff) | |
download | linux-stable-f54c142725ad2ba33c3ee627873cb6966bf05447.tar.gz linux-stable-f54c142725ad2ba33c3ee627873cb6966bf05447.tar.bz2 linux-stable-f54c142725ad2ba33c3ee627873cb6966bf05447.zip |
rfkill: allow toggling soft state in sysfs again
Apparently there actually _are_ tools that try to set
this in sysfs even though it wasn't supposed to be used
this way without claiming first. Guess what: now that
I've cleaned it all up it doesn't matter and we can
simply allow setting the soft-block state in sysfs.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Tested-By: Darren Salt <linux@youmustbejoking.demon.co.uk>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net/rfkill')
-rw-r--r-- | net/rfkill/core.c | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/net/rfkill/core.c b/net/rfkill/core.c index 79693fe2001e..6896c0b45b4a 100644 --- a/net/rfkill/core.c +++ b/net/rfkill/core.c @@ -648,15 +648,26 @@ static ssize_t rfkill_state_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { - /* - * The intention was that userspace can only take control over - * a given device when/if rfkill-input doesn't control it due - * to user_claim. Since user_claim is currently unsupported, - * we never support changing the state from userspace -- this - * can be implemented again later. - */ + struct rfkill *rfkill = to_rfkill(dev); + unsigned long state; + int err; + + if (!capable(CAP_NET_ADMIN)) + return -EPERM; + + err = strict_strtoul(buf, 0, &state); + if (err) + return err; + + if (state != RFKILL_USER_STATE_SOFT_BLOCKED && + state != RFKILL_USER_STATE_UNBLOCKED) + return -EINVAL; + + mutex_lock(&rfkill_global_mutex); + rfkill_set_block(rfkill, state == RFKILL_USER_STATE_SOFT_BLOCKED); + mutex_unlock(&rfkill_global_mutex); - return -EPERM; + return err ?: count; } static ssize_t rfkill_claim_show(struct device *dev, |