Re: [PATCH] winbind kills nscd on Solaris
On Fri, 2002-05-10 at 09:13, Mike Gerdts wrote: > Does "" get allocated statically, or on the stack? If it gets allocated > on the stack, then garbage could replace it at some time in the future. > > Mike I just found a copy of K&R and answered the question for myself. For anyone else that cares, K&R A2.6 says that string literals have a storage type of static. According to A4.1, Static objects may be local to a block or external to all blocks, but in either case retain their values across exit from and reentry to functions and blocks. Mike
Re: [PATCH] winbind kills nscd on Solaris
On Thu, 2002-05-09 at 22:58, Tim Potter wrote: > On Fri, May 10, 2002 at 11:10:58AM +1000, Tim Potter wrote: > > > > Solaris has a couple extra fields in struct passwd. Since getpwent(3c) > > > says that pw_age and pw_comment are not used, it seems reasonable not to > > > fill them in. nscd may not use them, but assumes that they at least are > > > pointers to allocated buffers. Since they are are not pointers to > > > allocated buffers, a SEGV occurs. > > OK I've checked in a patch to the HEAD branch. Would you mind seeing if > this correctly fixes the problem? If so I'll merge it into the other > branches. > > > Tim. One question about your implementation... #if HAVE_PASSWD_PW_COMMENT result->pw_comment = ""; #endif #if HAVE_PASSWD_PW_AGE result->pw_age = ""; #endif Does "" get allocated statically, or on the stack? If it gets allocated on the stack, then garbage could replace it at some time in the future. Mike
Re: [PATCH] winbind kills nscd on Solaris
On Thu, 2002-05-09 at 22:58, Tim Potter wrote: > On Fri, May 10, 2002 at 11:10:58AM +1000, Tim Potter wrote: > > > > Solaris has a couple extra fields in struct passwd. Since getpwent(3c) > > > says that pw_age and pw_comment are not used, it seems reasonable not to > > > fill them in. nscd may not use them, but assumes that they at least are > > > pointers to allocated buffers. Since they are are not pointers to > > > allocated buffers, a SEGV occurs. > > OK I've checked in a patch to the HEAD branch. Would you mind seeing if > this correctly fixes the problem? If so I'll merge it into the other > branches. After regenerating configure, it worked fine. Thanks, Mike
Re: [PATCH] winbind kills nscd on Solaris
On Fri, May 10, 2002 at 11:10:58AM +1000, Tim Potter wrote: > > Solaris has a couple extra fields in struct passwd. Since getpwent(3c) > > says that pw_age and pw_comment are not used, it seems reasonable not to > > fill them in. nscd may not use them, but assumes that they at least are > > pointers to allocated buffers. Since they are are not pointers to > > allocated buffers, a SEGV occurs. OK I've checked in a patch to the HEAD branch. Would you mind seeing if this correctly fixes the problem? If so I'll merge it into the other branches. Tim.
Re: [PATCH] winbind kills nscd on Solaris
On Thu, May 09, 2002 at 02:36:51PM -0400, Mike Gerdts wrote: > Solaris has a couple extra fields in struct passwd. Since getpwent(3c) > says that pw_age and pw_comment are not used, it seems reasonable not to > fill them in. nscd may not use them, but assumes that they at least are > pointers to allocated buffers. Since they are are not pointers to > allocated buffers, a SEGV occurs. Hey what a neat bug. (-: I'll have to add some autoconf stuff to do this but I can check this solution in pretty soon. Regards, Tim.
[PATCH] winbind kills nscd on Solaris
The problem: Solaris has a couple extra fields in struct passwd. Since getpwent(3c) says that pw_age and pw_comment are not used, it seems reasonable not to fill them in. nscd may not use them, but assumes that they at least are pointers to allocated buffers. Since they are are not pointers to allocated buffers, a SEGV occurs. Those with Solaris source can see this in osnet_volume/usr/src/cmd/nscd/getpw.c in fixbuffer(). Adding these assertions just before the series of strlen()s confirms the problem, as it fails the check for pw_age. assert(in != NULL); assert(in->nsc_u.pwd.pw_name != NULL); assert(in->nsc_u.pwd.pw_passwd != NULL); assert(in->nsc_u.pwd.pw_age != NULL); assert(in->nsc_u.pwd.pw_comment != NULL); assert(in->nsc_u.pwd.pw_gecos != NULL); assert(in->nsc_u.pwd.pw_dir != NULL); assert(in->nsc_u.pwd.pw_shell != NULL); The Solution The following patch fixes this problem. If it is blessed as the right solution, I will create a patch that includes the appropriate checks in configure.in along with some #ifdefs in the code so it doesn't break other platforms. Mike Index: winbind_nss.c === RCS file: /cvsroot/samba/source/nsswitch/winbind_nss.c,v retrieving revision 1.4.6.4 diff -c -r1.4.6.4 winbind_nss.c *** winbind_nss.c 30 Apr 2002 13:27:23 - 1.4.6.4 --- winbind_nss.c 9 May 2002 18:28:53 - *** *** 594,599 --- 594,600 struct winbindd_pw *pw, char **buffer, int *buflen) { + static const char *static_null_string = ""; /* User name */ if ((result->pw_name = *** *** 656,661 --- 657,665 return NSS_STATUS_TRYAGAIN; } + + result->pw_age = static_null_string; + result->pw_comment = static_null_string; strcpy(result->pw_shell, pw->pw_shell);