sms@wlv.imsd.contel.com (Steven M. Schultz) (07/25/90)
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.