aboutsummaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2011-07-01 12:55:23 -0400
committerNick Mathewson <nickm@torproject.org>2011-07-01 12:55:23 -0400
commit2ba19f9b4a052dcaa5ebd3c6a629e1ec67a595f9 (patch)
tree7f05139b1c751d534b12a43de0c234154bc93925 /src/common
parent2b5ebc70973b1c0dd62201908632733c0953a4ec (diff)
parent021cf3f0521375f1722a7fb82ce286086db79142 (diff)
downloadtor-2ba19f9b4a052dcaa5ebd3c6a629e1ec67a595f9.tar.gz
tor-2ba19f9b4a052dcaa5ebd3c6a629e1ec67a595f9.zip
Merge remote-tracking branch 'origin/maint-0.2.1' into maint-0.2.2
Diffstat (limited to 'src/common')
-rw-r--r--src/common/compat.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/common/compat.c b/src/common/compat.c
index c9839255d4..80b4907b81 100644
--- a/src/common/compat.c
+++ b/src/common/compat.c
@@ -1225,7 +1225,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;
@@ -1271,9 +1272,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;
@@ -1303,6 +1314,7 @@ log_credential_status(void)
tor_free(cp);
});
smartlist_free(elts);
+ tor_free(sup_gids);
return retval;
}