On 2009/07/23 00:49, Ted Unangst wrote: > doesn't work. at all. > > run cherokee as any user and get: > ERROR: Group '_cherokee' not found in the system > > the group does exist. the problem is the cherokee_getgrnam function calls > getgrnam_r which returns 34, ERANGE. > > i propose the following patch, which makes it work as expected. > > --- cherokee/util.c.orig Thu Jul 23 00:36:34 2009 > +++ cherokee/util.c Thu Jul 23 00:36:36 2009 > @@ -1178,14 +1178,14 @@ > } > > > -#if defined(HAVE_PTHREAD) && !defined(HAVE_GETGRNAM_R) > +#if defined(HAVE_PTHREAD) && !defined(HAVE_GETGRNAM_RCRAP) > static pthread_mutex_t __global_getgrnam_mutex = PTHREAD_MUTEX_INITIALIZER; > #endif > > ret_t > cherokee_getgrnam (const char *name, struct group *grbuf, char *buf, size_t > buflen) > { > -#ifndef HAVE_GETGRNAM_R > +#ifndef HAVE_GETGRNAM_RCRAP > size_t gr_name_len = 0; > size_t gr_passwd_len = 0; > char *ptr; >
the buffer cherokee passes to getgrnam_r isn't large enough, getgrent.c: #define GETGR_R_SIZE_MAX (1024+200*sizeof(char*)) ... if (bufsize < GETGR_R_SIZE_MAX) return ERANGE; both places in cherokee that call cherokee_getgrnam (cherokee/server.c and cherokee/source_interpreter.c) use a 1KB buffer so they trigger the problem struct group grp; char tmp[1024]; ret = cherokee_getgrnam (conf->val.buf, &grp, tmp, sizeof(tmp)); Apache 2 which also uses getgrnam_r() uses a different method and just uses a static 8K buffer. #define GRBUF_SIZE 8192 ... char grbuf[GRBUF_SIZE]; from what I can tell it would be most correct, but perhaps not totally portable, to use sysconf(_SC_GETGR_R_SIZE_MAX) and dynamically allocate the buffer. thoughts?? Fernando, I think you were in contact with cherokee upstream about this weren't you? perhaps it would be helpful if you could pass this mail along.