diff options
author | Chia-chi Yeh <chiachi@android.com> | 2009-06-30 11:23:04 +0800 |
---|---|---|
committer | Chia-chi Yeh <chiachi@android.com> | 2009-06-30 12:05:36 +0800 |
commit | eebb2700cba487bcda8da153c2e0813ce4b5a11d (patch) | |
tree | 5e0e3aaa6f753564d01996f42b4fb875ccbc6d5b /net/ipv4 | |
parent | 964fc4881b3f3c90ec3a59350464d39158b88d52 (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 ee76b0bd4be9..9749b1ec43d4 100644 --- a/net/ipv4/af_inet.c +++ b/net/ipv4/af_inet.c @@ -118,6 +118,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 extern void ip_mc_drop_socket(struct sock *sk); @@ -262,28 +272,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 (answer->capability > 0 && !current_has_cap(answer->capability)) + if (answer->capability > 0 && !capable(answer->capability)) goto out_rcu_unlock; err = -EAFNOSUPPORT; |