diff options
author | Chia-chi Yeh <chiachi@android.com> | 2009-06-30 11:23:04 +0800 |
---|---|---|
committer | Colin Cross <ccross@android.com> | 2012-02-14 11:26:33 -0800 |
commit | 10647800b773ca2539a2dce4c25b8779e9f2bf5f (patch) | |
tree | 4800b40726940b18dd3401141d5d0a5bf6605862 /net/ipv4 | |
parent | b64107245dbade3bd0a341fb7bd1b9cd4698ff6d (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/ipv4')
-rw-r--r-- | net/ipv4/af_inet.c | 34 |
1 files changed, 11 insertions, 23 deletions
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c index e31dbb0a5b4..5d7272ce0bf 100644 --- a/net/ipv4/af_inet.c +++ b/net/ipv4/af_inet.c @@ -120,6 +120,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 /* The inetsw table contains everything that inet_create needs to @@ -261,28 +271,6 @@ static inline int inet_netns_ok(struct net *net, int protocol) return ipprot->netns_ok; } -#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 /* * Create an inet socket. @@ -355,7 +343,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; err = -EAFNOSUPPORT; |