diff options
author | Nick Mathewson <nickm@torproject.org> | 2011-07-01 12:56:40 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2011-07-01 12:56:40 -0400 |
commit | 734e860d98e1874dcd92e69051806e53205ee0b0 (patch) | |
tree | 61f31b749be3aabf788a3a8b44d6383ed4e442ac /src/common | |
parent | 0b536469ee8a6d437cd939cbcdaa56039e27cdcb (diff) | |
parent | 06f0c1aa6a4ad0a6dfc93b1637214c307feed566 (diff) | |
download | tor-734e860d98e1874dcd92e69051806e53205ee0b0.tar.gz tor-734e860d98e1874dcd92e69051806e53205ee0b0.zip |
Merge remote-tracking branch 'origin/maint-0.2.2'
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/compat.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/common/compat.c b/src/common/compat.c index 83cf0322d9..330c432284 100644 --- a/src/common/compat.c +++ b/src/common/compat.c @@ -1280,7 +1280,8 @@ log_credential_status(void) /* Read, effective and saved GIDs */ gid_t rgid, egid, sgid; /* Supplementary groups */ - gid_t sup_gids[NGROUPS_MAX + 1]; + gid_t *sup_gids = NULL; + int sup_gids_size; /* Number of supplementary groups */ int ngids; @@ -1326,9 +1327,19 @@ log_credential_status(void) #endif /* log supplementary groups */ - if ((ngids = getgroups(NGROUPS_MAX + 1, sup_gids)) < 0) { + sup_gids_size = 64; + sup_gids = tor_malloc(sizeof(gid_t) * 64); + while ((ngids = getgroups(sup_gids_size, sup_gids)) < 0 && + errno == EINVAL && + sup_gids_size < NGROUPS_MAX) { + sup_gids_size *= 2; + sup_gids = tor_realloc(sup_gids, sizeof(gid_t) * sup_gids_size); + } + + if (ngids < 0) { log_warn(LD_GENERAL, "Error getting supplementary GIDs: %s", strerror(errno)); + tor_free(sup_gids); return -1; } else { int i, retval = 0; @@ -1358,6 +1369,7 @@ log_credential_status(void) tor_free(cp); }); smartlist_free(elts); + tor_free(sup_gids); return retval; } |