From: Todd C. Miller Date: Wed, 24 Apr 2013 19:24:24 +0000 (-0400) Subject: Solaris maps negative gids to GID_NOBODY. X-Git-Tag: SUDO_1_8_7~1^2~33 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c5971524f150bfe79c9a763ef462151f6bcc0127;p=sudo Solaris maps negative gids to GID_NOBODY. --- diff --git a/compat/getgrouplist.c b/compat/getgrouplist.c index a3eb87179..c37ddb6e7 100644 --- a/compat/getgrouplist.c +++ b/compat/getgrouplist.c @@ -153,9 +153,18 @@ str2grp(const char *instr, int inlen, void *ent, char *buf, int buflen) gid = strtoul(cp, &ep, 10); if (*cp == '\0' || *ep != '\0') return yp ? NSS_STR_PARSE_SUCCESS : NSS_STR_PARSE_PARSE; - if (gid > GID_MAX || (gid == ULONG_MAX && errno == ERANGE)) +#ifdef GID_NOBODY + if (*cp == '-' && gid != 0) { + /* Negative gids get mapped to nobody on Solaris. */ + grp->gr_gid = GID_NOBODY; + } else +#endif + if ((errno == ERANGE && gid == ULONG_MAX) || + gid > GID_MAX || gid != (gid_t)gid) { return NSS_STR_PARSE_ERANGE; - grp->gr_gid = (gid_t)gid; + } else { + grp->gr_gid = (gid_t)gid; + } /* Store group members, taking care to use proper alignment. */ grp->gr_mem = NULL;