Skip to content

Commit

Permalink
Merge tag 'android-4.3_r2.1' into cm-10.2
Browse files Browse the repository at this point in the history
Android 4.3 release 2.1
  • Loading branch information
rmcc committed Jul 24, 2013
2 parents d758e60 + 360f71a commit 2576524
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES:= ping6.c
LOCAL_MODULE := ping6
LOCAL_MODULE_TAGS := eng
LOCAL_MODULE_TAGS := debug
include $(BUILD_EXECUTABLE)
24 changes: 24 additions & 0 deletions ping6.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ __RCSID("$NetBSD: ping6.c,v 1.73 2010/09/20 11:49:48 ahoka Exp $");
#include <unistd.h>
#include <poll.h>

#include <private/android_filesystem_config.h>

#ifdef IPSEC
#include <netinet6/ah.h>
#include <netinet6/ipsec.h>
Expand Down Expand Up @@ -297,6 +299,23 @@ char *nigroup(char *);
#endif
void usage(void);

int
isInSupplementaryGroup(gid_t group)
{
int numgroups, i;
gid_t groups[sysconf(_SC_NGROUPS_MAX) + 1];
numgroups = getgroups(sizeof(groups) / sizeof(groups[0]), groups);
if (numgroups < 0) {
perror("getgroups");
return 0;
}
for (i = 0; i < numgroups; i++) {
if (group == groups[i])
return 1;
}
return 0;
}

int
main(int argc, char *argv[])
{
Expand Down Expand Up @@ -331,6 +350,11 @@ main(int argc, char *argv[])
int mflag = 0;
#endif

if (getuid() != 0 && !isInSupplementaryGroup(AID_INET)) {
fprintf(stderr, "%s: not root or in group AID_INET\n", argv[0]);
exit(3);
}

/* just to be sure */
memset(&smsghdr, 0, sizeof(smsghdr));
memset(&smsgiov, 0, sizeof(smsgiov));
Expand Down

0 comments on commit 2576524

Please sign in to comment.