🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Steven M. Schultz Wed, 25 Jul 1990 02:18
getpwent(3) does not rewind in some cases (+FIX)
#70
Author: Steven M. Schultz
Date: Wed, 25 Jul 1990 02:18
49 lines
1941 bytes
Subject: getpwent(3) does not rewind in some cases (+FIX)
Index:	lib/libc/gen/getpwent.c 2.10BSD

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.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads