net: Replace AID_NET_RAW checks with capable(CAP_NET_RAW).
authorChia-chi Yeh <chiachi@android.com>
Tue, 30 Jun 2009 03:23:04 +0000 (11:23 +0800)
committerArve Hjønnevåg <arve@android.com>
Mon, 8 Feb 2010 23:35:52 +0000 (15:35 -0800)
Signed-off-by: Chia-chi Yeh <chiachi@android.com>
net/ipv4/af_inet.c
net/ipv6/af_inet6.c

index 941d9752a3c1523f59d7df88eb82f9972d60e754..58525bd72506e95277fa63c93bd03b4be7d83237 100644 (file)
 
 #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.
@@ -354,7 +342,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;
index 0a883bf68ceb0d0ed3916c9ea7890a375e8c77b4..2f7c3bf90e83a9842747e70372feca8a63a8e3e3 100644 (file)
 
 #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)
 {
        struct inet_sock *inet;
@@ -188,7 +175,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;
 
        sock->ops = answer->ops;