Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 8 Oct 1999 19:40:01 -0700 (PDT)
From:      "Robert Wojciechowski Jr." <robertw@wojo.com>
To:        freebsd-bugs@FreeBSD.org
Subject:   RE: kern/14201: setpassent() in libc does not function properly
Message-ID:  <199910090240.TAA47794@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR kern/14201; it has been noted by GNATS.

From: "Robert Wojciechowski Jr." <robertw@wojo.com>
To: 'Ruslan Ermilov' <ru@ucb.crimea.ua>
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 <stdlib.h>
 #include <stdio.h>
 #include <unistd.h>
 #include <pwd.h>
 
 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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199910090240.TAA47794>