* [WEXT 5/12]: Pull ioctl permission checking out into helper function.
@ 2007-12-22 4:54 David Miller
0 siblings, 0 replies; only message in thread
From: David Miller @ 2007-12-22 4:54 UTC (permalink / raw)
To: linux-wireless-u79uwXL29TY76Z2rM5mHXA; +Cc: netdev-u79uwXL29TY76Z2rM5mHXA
[WEXT]: Pull ioctl permission checking out into helper function.
Signed-off-by: David S. Miller <davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
---
net/wireless/wext.c | 22 +++++++++++++++-------
1 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/net/wireless/wext.c b/net/wireless/wext.c
index 9c3d83f..f183c1d 100644
--- a/net/wireless/wext.c
+++ b/net/wireless/wext.c
@@ -1093,18 +1093,26 @@ static int wireless_process_ioctl(struct net *net, struct ifreq *ifr, unsigned i
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 */
int wext_handle_ioctl(struct net *net, struct ifreq *ifr, unsigned int cmd,
void __user *arg)
{
- int ret;
+ int ret = wext_permission_check(cmd);
- /* If command is `set a parameter', or
- * `get the encoding parameters', check if
- * the user has the right to do it */
- if ((IW_IS_SET(cmd) || cmd == SIOCGIWENCODE || cmd == SIOCGIWENCODEEXT)
- && !capable(CAP_NET_ADMIN))
- return -EPERM;
+ if (ret)
+ return ret;
dev_load(net, ifr->ifr_name);
rtnl_lock();
--
1.5.4.rc1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2007-12-22 4:54 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-12-22 4:54 [WEXT 5/12]: Pull ioctl permission checking out into helper function David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox