From owner-freebsd-bugs Fri Oct 8 19:40: 4 1999 Delivered-To: freebsd-bugs@freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by hub.freebsd.org (Postfix) with ESMTP id 1B06E152A5 for ; Fri, 8 Oct 1999 19:40:01 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.9.3/8.9.2) id TAA47794; Fri, 8 Oct 1999 19:40:01 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Date: Fri, 8 Oct 1999 19:40:01 -0700 (PDT) Message-Id: <199910090240.TAA47794@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org Cc: From: "Robert Wojciechowski Jr." Subject: RE: kern/14201: setpassent() in libc does not function properly Reply-To: "Robert Wojciechowski Jr." Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org The following reply was made to PR kern/14201; it has been noted by GNATS. From: "Robert Wojciechowski Jr." To: 'Ruslan Ermilov' Cc: freebsd-gnats-submit@FreeBSD.org Subject: RE: kern/14201: setpassent() in libc does not function properly Date: Fri, 8 Oct 1999 22:31:04 -0400 Ruslan, Looks like the original patch works the best. It works well too. If you look in getgrent.c, it contains the right code to handle the stayopen flag: /* correct, from getgrent.c */ if (!_gr_stayopen) endgrent(); return(rval ? &_gr_group : NULL); instead of /* incorrect */ endgrent(); return(rval ? &_gr_group : NULL); The incorrect code is what getpwent.c contains. A test for this functionality is the following program: --SNIP-- #include #include #include #include int main() { setpassent(1); getpwent(); chroot("/usr"); chdir("/"); if(!getpwuid(0)) { printf("setpassent doesn't appear to work\n"); } else { if(!getpwuid(0)) printf("second getpwuid(0) didn't work\n"); else printf("setpassent works\n"); } return 0; } --SNIP-- It passes with flying colors after the fix. Best regards, Robert S. Wojciechowski Jr. robertw@wojo.com PGP: 0xF2CA68F2 - http://www.wojo.com/pgpkeys/robertw.asc -----Original Message----- From: Ruslan Ermilov [mailto:ru@ucb.crimea.ua] Sent: Friday, October 08, 1999 3:20 AM To: Robert Wojciechowski Jr. Cc: freebsd-gnats-submit@FreeBSD.org Subject: Re: kern/14201: setpassent() in libc does not function properly On Fri, Oct 08, 1999 at 12:00:01AM -0700, Robert Wojciechowski Jr. wrote: > > The patch in this bug report does not work fully. I patched the endpwent() > function, and it works correctly now: > > 244,246d243 > < if (_pw_stayopen) > < return; > < > > It will keep the fd open when setpassent(int stayopen) is passed 1. It's > now behaving the way it should ;) > And endpwent() will never close the file :-( -- Ruslan Ermilov Sysadmin and DBA of the ru@ucb.crimea.ua United Commercial Bank, ru@FreeBSD.org FreeBSD committer, +380.652.247.647 Simferopol, Ukraine http://www.FreeBSD.org The Power To Serve http://www.oracle.com Enabling The Information Age To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message