Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!uflorida!gatech!udel!rochester!pt.cs.cmu.edu!cadre!sean From: sean@cadre.dsl.PITTSBURGH.EDU (Sean McLinden) Newsgroups: comp.bugs.4bsd Subject: vipw(8) in shadow passwords does not always update files Keywords: vipw shadow passwd Message-ID: <3283@cadre.dsl.PITTSBURGH.EDU> Date: 22 Aug 89 14:10:44 GMT Organization: Decision Systems Lab., Univ. of Pittsburgh, PA. Lines: 40 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);