diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2002-07-31 22:08:43 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2002-07-31 22:08:43 +0000 |
commit | a307fd5af8a64e548d9c1607e22f1849dd79a745 (patch) | |
tree | a050683deae2ff2aab7ee452990347a929371e78 /usr.bin/chpass/edit.c | |
parent | 245837def3aec0ed575c4e9fc1522d98ca2142fc (diff) |
When I got removed the use of atexit() I missed the fact that edit()
calls pw_error() which in turn calls exit(). Now edit() returns
its status so the temp file gets cleaned up nicely if the user makes
no changes or if an error occurred. Problem noticed by deraadt@
Diffstat (limited to 'usr.bin/chpass/edit.c')
-rw-r--r-- | usr.bin/chpass/edit.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/usr.bin/chpass/edit.c b/usr.bin/chpass/edit.c index d62dcd1fb12..28dcf1074bf 100644 --- a/usr.bin/chpass/edit.c +++ b/usr.bin/chpass/edit.c @@ -1,4 +1,4 @@ -/* $OpenBSD: edit.c,v 1.22 2002/06/27 19:02:40 deraadt Exp $ */ +/* $OpenBSD: edit.c,v 1.23 2002/07/31 22:08:42 millert Exp $ */ /* $NetBSD: edit.c,v 1.6 1996/05/15 21:50:45 jtc Exp $ */ /*- @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)edit.c 8.3 (Berkeley) 4/2/94"; #else -static char rcsid[] = "$OpenBSD: edit.c,v 1.22 2002/06/27 19:02:40 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: edit.c,v 1.23 2002/07/31 22:08:42 millert Exp $"; #endif #endif /* not lint */ @@ -58,7 +58,7 @@ static char rcsid[] = "$OpenBSD: edit.c,v 1.22 2002/06/27 19:02:40 deraadt Exp $ #include "chpass.h" -void +int edit(tempname, pw) char *tempname; struct passwd *pw; @@ -67,19 +67,20 @@ edit(tempname, pw) for (;;) { if (lstat(tempname, &begin) == -1 || S_ISLNK(begin.st_mode)) - pw_error(tempname, 1, 1); + return (EDIT_ERROR); pw_edit(1, tempname); if (lstat(tempname, &end) == -1 || S_ISLNK(end.st_mode)) - pw_error(tempname, 1, 1); + return (EDIT_ERROR); if (begin.st_mtime == end.st_mtime && begin.st_size == end.st_size) { warnx("no changes made"); - pw_error(NULL, 0, 0); + return (EDIT_NOCHANGE); } if (verify(tempname, pw)) break; pw_prompt(); } + return(EDIT_OK); } /* |