summaryrefslogtreecommitdiff
path: root/net/ipv6
diff options
context:
space:
mode:
authorChia-chi Yeh <chiachi@android.com>2009-06-30 11:23:04 +0800
committerColin Cross <ccross@android.com>2012-04-09 13:57:47 -0700
commitc543f112f11bd08d5efdf8815ff419bd20a7a392 (patch)
tree141ab0657cbec45454b435988db0e7d8b4d5d29b /net/ipv6
parent0432013eb1fbddf51f43d3dfb7553db011c81707 (diff)
net: Replace AID_NET_RAW checks with capable(CAP_NET_RAW).
Signed-off-by: Chia-chi Yeh <chiachi@android.com>
Diffstat (limited to 'net/ipv6')
-rw-r--r--net/ipv6/af_inet6.c35
1 files changed, 11 insertions, 24 deletions
diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c
index a5e8f1b1b83..29625e9a51a 100644
--- a/net/ipv6/af_inet6.c
+++ b/net/ipv6/af_inet6.c
@@ -64,6 +64,16 @@
#ifdef CONFIG_ANDROID_PARANOID_NETWORK
#include <linux/android_aid.h>
+
+static inline int current_has_network(void)
+{
+ return in_egroup_p(AID_INET) || capable(CAP_NET_RAW);
+}
+#else
+static inline int current_has_network(void)
+{
+ return 1;
+}
#endif
MODULE_AUTHOR("Cast of dozens");
@@ -99,29 +109,6 @@ static __inline__ struct ipv6_pinfo *inet6_sk_generic(struct sock *sk)
return (struct ipv6_pinfo *)(((u8 *)sk) + offset);
}
-#ifdef CONFIG_ANDROID_PARANOID_NETWORK
-static inline int current_has_network(void)
-{
- return (!current_euid() || in_egroup_p(AID_INET) ||
- in_egroup_p(AID_NET_RAW));
-}
-static inline int current_has_cap(int cap)
-{
- if (cap == CAP_NET_RAW && in_egroup_p(AID_NET_RAW))
- return 1;
- return capable(cap);
-}
-# else
-static inline int current_has_network(void)
-{
- return 1;
-}
-static inline int current_has_cap(int cap)
-{
- return capable(cap);
-}
-#endif
-
static int inet6_create(struct net *net, struct socket *sock, int protocol,
int kern)
{
@@ -189,7 +176,7 @@ lookup_protocol:
}
err = -EPERM;
- if (sock->type == SOCK_RAW && !kern && !current_has_cap(CAP_NET_RAW))
+ if (sock->type == SOCK_RAW && !kern && !capable(CAP_NET_RAW))
goto out_rcu_unlock;
sock->ops = answer->ops;