Subject: bin/3807: chpass can leave /etc/ptmp around if the process is SIGKILLed
To: None <gnats-bugs@gnats.netbsd.org>
From: Data In~rte~vgri}ity EnginNO CARRIER <greywolf@starwolf.com>
List: netbsd-bugs
Date: 06/28/1997 14:24:18
>Number: 3807
>Category: bin
>Synopsis: chpass can leave /etc/ptmp around if the process is SIGKILLed
>Confidential: no
>Severity: serious
>Priority: high
>Responsible: bin-bug-people (Utility Bug People)
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sat Jun 28 14:50:02 1997
>Last-Modified:
>Originator: Grey Wolf
>Organization:
Star Wolf Innovations
>Release: 1.2
>Environment:
Sun4c/50, NetBSD 1.2-current-970604, sun4c, current
System: NetBSD starwolf.starwolf.com 1.2E NetBSD 1.2E (STARWOLF) #8: Wed Jun 4 01:11:20 PDT 1997 root@starwolf.starwolf.com:/usr/src/sys/arch/sparc/compile/STARWOLF sparc
>Description:
If chpass is run and the chpass process is SIGKILLed, /etc/ptmp
remains, preventing other modifications to the passwd file.
>How-To-Repeat:
% chpass
[enter editor session]
[shell out from the editor]
[kill -KILL {chpass-pid}]
>Fix:
The problem is that ptmp is created before it needs to be.
We should wait until all data is finalized and ready for re-
injection into the final file before attempting a lock. If
someone else has snuck in and locked on us, oh, well...
If root is running vipw, the passwd file is quite locked and
may remain so for some time.
*** chpass.c Sat Jun 28 01:26:52 1997
--- chpass.c.orig Sat Jun 28 01:25:32 1997
***************
*** 227,232 ****
--- 227,235 ----
* reading.
*/
pw_init();
+ tfd = pw_lock(0);
+ if (tfd < 0)
+ errx(1, "the passwd file is busy.");
pfd = open(_PATH_MASTERPASSWD, O_RDONLY, 0);
if (pfd < 0)
pw_error(_PATH_MASTERPASSWD, 1, 1);
***************
*** 253,262 ****
else
#endif /* YP */
- /* moved here from after pw_init */
- tfd = pw_lock(0);
- if (tfd < 0)
- errx(1, "the passwd file is busy.");
/* Copy the passwd file to the lock file, updating pw. */
pw_copy(pfd, tfd, pw);
--- 256,261 ----
>Audit-Trail:
>Unformatted: