Merge "Make sure ping doesn't ever run with privileges."
diff --git a/ping.c b/ping.c
index 14bd52a..2b41f44 100644
--- a/ping.c
+++ b/ping.c
@@ -64,6 +64,7 @@
 #include <netinet/ip_icmp.h>
 
 #ifdef ANDROID
+#include <sys/auxv.h>
 #define bcmp(a, b, c) memcmp(a, b, c)
 #endif
 
@@ -118,6 +119,13 @@
 	char *target, hnamebuf[MAXHOSTNAMELEN];
 	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);
+	}
+#endif
+
 	icmp_sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_ICMP);
 	if (icmp_sock != -1)
 		using_ping_socket = 1;
@@ -126,7 +134,9 @@
 	socket_errno = errno;
 
 	uid = getuid();
+#ifndef ANDROID
 	setuid(uid);
+#endif
 
 	source.sin_family = AF_INET;