diff options
author | Lorenzo Colitti <lorenzo@google.com> | 2013-07-12 20:58:48 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2013-07-12 20:58:49 +0000 |
commit | 5f7905da854b1042b143c9156c20e6214f2d01fd (patch) | |
tree | 47fff5af0d0a9850cb02875ff797273bdf7576dd | |
parent | b4ef47459422fb32dab979e9488e33e30c4d7626 (diff) | |
parent | 924a10d5d9645d4e82fa4b9781f2d85b41ec74f1 (diff) | |
download | iputils-5f7905da854b1042b143c9156c20e6214f2d01fd.tar.gz |
Merge "Put the Android security check in its own function"
-rw-r--r-- | ping.c | 9 | ||||
-rw-r--r-- | ping_common.c | 8 | ||||
-rw-r--r-- | ping_common.h | 2 |
3 files changed, 11 insertions, 8 deletions
@@ -73,10 +73,6 @@ struct icmp_filter { }; #endif -#ifdef ANDROID -#include <sys/auxv.h> -#endif - #define MAXIPLEN 60 #define MAXICMPLEN 76 #define NROUTES 9 /* number of record route slots */ @@ -135,10 +131,7 @@ main(int argc, char **argv) char rspace[3 + 4 * NROUTES + 1]; /* record route space */ #ifdef ANDROID - if (getauxval(AT_SECURE) != 0) { - fprintf(stderr, "This version of ping should NOT run with privileges. Aborting\n"); - exit(1); - } + android_check_security(); #endif limit_capabilities(); diff --git a/ping_common.c b/ping_common.c index 1710d14..9c0e8f5 100644 --- a/ping_common.c +++ b/ping_common.c @@ -198,6 +198,14 @@ void drop_capabilities(void) #endif } +void android_check_security(void) +{ + if (getauxval(AT_SECURE) != 0) { + fprintf(stderr, "This version of ping should NOT run with privileges. Aborting\n"); + exit(1); + } +} + /* Fills all the outpack, excluding ICMP header, but _including_ * timestamp area with supplied pattern. */ diff --git a/ping_common.h b/ping_common.h index f9330aa..bc59700 100644 --- a/ping_common.h +++ b/ping_common.h @@ -35,6 +35,7 @@ #ifdef ANDROID #include <linux/icmp.h> +#include <sys/auxv.h> #endif #include "SNAPSHOT.h" @@ -273,6 +274,7 @@ static inline int enable_capability_admin(void) { return modify_capability(1); static inline int disable_capability_admin(void) { return modify_capability(0); }; #endif extern void drop_capabilities(void); +extern void android_check_security(void); extern int send_probe(void); extern int receive_error_msg(void); |