Article View: comp.bugs.4bsd
Article #177getpwent(3) does not rewind in some cases (+FIX)
From: Steven M. Schultz
Date: Wed, 25 Jul 1990 02:20
Date: Wed, 25 Jul 1990 02:20
49 lines
1953 bytes
1953 bytes
Subject: getpwent(3) does not rewind in some cases (+FIX)
Index: lib/libc/gen/getpwent.c 4.3BSD
Description:
This only applies to the shadow/aging version of getpwent(3).
The fetch_pw() function in getpwent.c in the
/usr/src/lib/libc/gen/getpwent.c code checks the
_pw_rewind flag. If dbm_open is called
in start_pw after having previously processed the
entire database and then getpwent() is called, fetch_pw still
thinks its processing the original dbm stream.
Setting _pw_rewind to 1 after the dbm_open fixes the
problem, start_pw() then knows it is dealing with a
newly dbm_opened passwd file.
Repeat-By:
The 'filec' code in csh(1) exposed this bug.
If you do a ~^D for login names listing, you
can only do it once without an intervening ~username
action.
Fix:
*** getpwent.c.old Sat May 13 00:44:24 1989
--- getpwent.c Tue Jul 24 21:36:32 1990
***************
*** 121,128 ****
rewind(_pw_fp);
return(1);
}
! if (_pw_db = dbm_open(_pw_file, O_RDONLY, 0))
return(1);
/*
* special case; if it's the official password file, look in
* the master password file, otherwise, look in the file itself.
--- 121,130 ----
rewind(_pw_fp);
return(1);
}
! if (_pw_db = dbm_open(_pw_file, O_RDONLY, 0)) {
! _pw_rewind = 1;
return(1);
+ }
/*
* special case; if it's the official password file, look in
* the master password file, otherwise, look in the file itself.
Technical Details
Message-ID:
<56131@wlbr.IMSD.CONTEL.COM>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!decwrl!apple!voder!wlbr!wlv.imsd.contel.com!smsShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!decwrl!apple!voder!wlbr!wlv.imsd.contel.com!sms From: sms@wlv.imsd.contel.com (Steven M. Schultz) Newsgroups: comp.bugs.4bsd Subject: getpwent(3) does not rewind in some cases (+FIX) Message-ID: <56131@wlbr.IMSD.CONTEL.COM> Date: 25 Jul 90 02:20:42 GMT Sender: news@wlbr.IMSD.CONTEL.COM Reply-To: sms@wlv.imsd.contel.com (Steven M. Schultz) Organization: Contel Federal Systems Lines: 49