diff options
author | Alec Warner <antarus@google.com> | 2012-02-16 18:25:38 -0800 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2012-06-06 10:14:34 +0200 |
commit | d6874305fff15ce2d9862ef000d81fd2ea56ae23 (patch) | |
tree | 5ee7e5d193c61d8531521e4afb603a1efc519073 /runtime/cfsysline.c | |
parent | 55659b96a38d926445c9ae4123df4b1d29e18c32 (diff) | |
download | rsyslog-d6874305fff15ce2d9862ef000d81fd2ea56ae23.tar.gz rsyslog-d6874305fff15ce2d9862ef000d81fd2ea56ae23.tar.bz2 rsyslog-d6874305fff15ce2d9862ef000d81fd2ea56ae23.zip |
call getgrnam_r repeatedly to get all group members.
Diffstat (limited to 'runtime/cfsysline.c')
-rw-r--r-- | runtime/cfsysline.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/runtime/cfsysline.c b/runtime/cfsysline.c index 4997e0fb..a33810ed 100644 --- a/runtime/cfsysline.c +++ b/runtime/cfsysline.c @@ -338,11 +338,12 @@ static int doParseOnOffOption(uchar **pp) */ static rsRetVal doGetGID(uchar **pp, rsRetVal (*pSetHdlr)(void*, uid_t), void *pVal) { - struct group *pgBuf; + struct group *pgBuf = NULL; struct group gBuf; DEFiRet; uchar szName[256]; - char stringBuf[2048]; /* I hope this is large enough... */ + long bufSize = 2048; + char * stringBuf = malloc(bufSize); assert(pp != NULL); assert(*pp != NULL); @@ -352,7 +353,15 @@ static rsRetVal doGetGID(uchar **pp, rsRetVal (*pSetHdlr)(void*, uid_t), void *p ABORT_FINALIZE(RS_RET_NOT_FOUND); } - getgrnam_r((char*)szName, &gBuf, stringBuf, sizeof(stringBuf), &pgBuf); + while(pgBuf == NULL) { + errno = 0; + getgrnam_r((char*)szName, &gBuf, stringBuf, bufSize, &pgBuf); + if((pgBuf == NULL) && (errno == ERANGE)) { + /* Increase bufsize and try again.*/ + bufSize *= 2; + stringBuf = realloc(stringBuf, bufSize); + } + } if(pgBuf == NULL) { errmsg.LogError(0, RS_RET_NOT_FOUND, "ID for group '%s' could not be found or error", (char*)szName); |