vipw(8) in shadow passwords does not always update files

Sean McLinden sean at cadre.dsl.PITTSBURGH.EDU
Wed Aug 23 00:10:44 AEST 1989


Subject: Vipw(8) does not always update files in shadow passwords
Index: /usr/src/etc/vipw.c in 4.3BSD with shadow password extensions

Description:
	In order to determine if the password file was actually edited
	vipw(8) fstats the file descriptor for the temporary file /etc/ptmp.
	Certain editors back-up the original /etc/ptmp using a link and
	unlink which causes the fstat to be unchanged and results in
	the system assuming that the file was unedited (in particular,
	GNU emacs).

Repeat-By:
	Install the shadow password package. Use vipw(8) with the EDITOR
	defined as GNU Emacs.

Fix:
	The simplest, and least elegant, way is to stat the temp file
	name rather than fstat the descriptor after the edit. The
	following appears to work:


*** vipw.c	Tue Aug 22 09:38:38 1989
--- vipw.c.old	Sat Jul 22 10:37:28 1989
***************
*** 95,101 ****
  			(void)fprintf(stderr, "vipw: edit failed; ");
  			stop(1);
  		}
! 		(void)stat(temp, &s2);
  		if (s1.st_mtime == s2.st_mtime) {
  			(void)fprintf(stderr, "vipw: no changes made; ");
  			stop(0);
--- 95,101 ----
  			(void)fprintf(stderr, "vipw: edit failed; ");
  			stop(1);
  		}
! 		(void)fstat(fd, &s2);
  		if (s1.st_mtime == s2.st_mtime) {
  			(void)fprintf(stderr, "vipw: no changes made; ");
  			stop(0);



More information about the Comp.bugs.4bsd.ucb-fixes mailing list