summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.bin/chpass/chpass.c18
-rw-r--r--usr.bin/chpass/edit.c9
2 files changed, 16 insertions, 11 deletions
diff --git a/usr.bin/chpass/chpass.c b/usr.bin/chpass/chpass.c
index b5ed2d382e1..6b1b2b2b301 100644
--- a/usr.bin/chpass/chpass.c
+++ b/usr.bin/chpass/chpass.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: chpass.c,v 1.13 1998/08/03 17:09:46 millert Exp $ */
+/* $OpenBSD: chpass.c,v 1.14 1999/12/05 20:18:35 millert Exp $ */
/* $NetBSD: chpass.c,v 1.8 1996/05/15 21:50:43 jtc Exp $ */
/*-
@@ -44,7 +44,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)chpass.c 8.4 (Berkeley) 4/2/94";
#else
-static char rcsid[] = "$OpenBSD: chpass.c,v 1.13 1998/08/03 17:09:46 millert Exp $";
+static char rcsid[] = "$OpenBSD: chpass.c,v 1.14 1999/12/05 20:18:35 millert Exp $";
#endif
#endif /* not lint */
@@ -67,7 +67,7 @@ static char rcsid[] = "$OpenBSD: chpass.c,v 1.13 1998/08/03 17:09:46 millert Exp
#include "chpass.h"
#include "pathnames.h"
-char *tempname;
+char tempname[] = __CONCAT(_PATH_VARTMP,"pw.XXXXXXXX");
uid_t uid;
extern char *__progname;
@@ -81,6 +81,7 @@ int pw_yp __P((struct passwd *, uid_t));
#endif
void baduser __P((void));
+void tempcleanup __P((void));
void usage __P((void));
int
@@ -91,7 +92,7 @@ main(argc, argv)
enum { NEWSH, LOADENTRY, EDITENTRY } op;
struct passwd *pw, lpw;
int ch, pfd, tfd, dfd;
- char *arg, tempname[] = __CONCAT(_PATH_VARTMP,"pw.XXXXXXXX");
+ char *arg;
#ifdef YP
use_yp = _yp_check(NULL);
@@ -197,9 +198,9 @@ main(argc, argv)
dfd = mkstemp(tempname);
if (dfd == -1 || fcntl(dfd, F_SETFD, 1) == -1)
pw_error(tempname, 1, 1);
+ atexit(tempcleanup);
display(tempname, dfd, pw);
edit(tempname, pw);
- (void)unlink(tempname);
}
#ifdef YP
@@ -233,6 +234,13 @@ baduser()
}
void
+tempcleanup()
+{
+
+ unlink(tempname);
+}
+
+void
usage()
{
diff --git a/usr.bin/chpass/edit.c b/usr.bin/chpass/edit.c
index 43ee7ab6deb..6cc40675879 100644
--- a/usr.bin/chpass/edit.c
+++ b/usr.bin/chpass/edit.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: edit.c,v 1.17 1999/11/28 13:08:17 ho Exp $ */
+/* $OpenBSD: edit.c,v 1.18 1999/12/05 20:18:35 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.17 1999/11/28 13:08:17 ho Exp $";
+static char rcsid[] = "$OpenBSD: edit.c,v 1.18 1999/12/05 20:18:35 millert Exp $";
#endif
#endif /* not lint */
@@ -74,13 +74,10 @@ edit(tempname, pw)
if (begin.st_mtime == end.st_mtime &&
begin.st_size == end.st_size) {
warnx("no changes made");
- unlink(tempname);
pw_error(NULL, 0, 0);
}
- if (verify(tempname, pw)) {
- unlink(tempname);
+ if (verify(tempname, pw))
break;
- }
pw_prompt();
}
}