wext: Pull ioctl permission checking out into helper function.
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
d88174e4d2
commit
67dd760807
|
@ -1061,18 +1061,26 @@ static int wireless_process_ioctl(struct net *net, struct ifreq *ifr, unsigned i
|
||||||
return -EOPNOTSUPP;
|
return -EOPNOTSUPP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* If command is `set a parameter', or `get the encoding parameters',
|
||||||
|
* check if the user has the right to do it.
|
||||||
|
*/
|
||||||
|
static int wext_permission_check(unsigned int cmd)
|
||||||
|
{
|
||||||
|
if ((IW_IS_SET(cmd) || cmd == SIOCGIWENCODE || cmd == SIOCGIWENCODEEXT)
|
||||||
|
&& !capable(CAP_NET_ADMIN))
|
||||||
|
return -EPERM;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* entry point from dev ioctl */
|
/* entry point from dev ioctl */
|
||||||
int wext_handle_ioctl(struct net *net, struct ifreq *ifr, unsigned int cmd,
|
int wext_handle_ioctl(struct net *net, struct ifreq *ifr, unsigned int cmd,
|
||||||
void __user *arg)
|
void __user *arg)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret = wext_permission_check(cmd);
|
||||||
|
|
||||||
/* If command is `set a parameter', or
|
if (ret)
|
||||||
* `get the encoding parameters', check if
|
return ret;
|
||||||
* the user has the right to do it */
|
|
||||||
if ((IW_IS_SET(cmd) || cmd == SIOCGIWENCODE || cmd == SIOCGIWENCODEEXT)
|
|
||||||
&& !capable(CAP_NET_ADMIN))
|
|
||||||
return -EPERM;
|
|
||||||
|
|
||||||
dev_load(net, ifr->ifr_name);
|
dev_load(net, ifr->ifr_name);
|
||||||
rtnl_lock();
|
rtnl_lock();
|
||||||
|
|
Loading…
Reference in New Issue