diff options
author | 1996-06-19 12:36:00 +0000 | |
---|---|---|
committer | 1996-06-19 12:36:00 +0000 | |
commit | 961df418c861ab029a5830d1d1b9b9ba13b780a7 (patch) | |
tree | d0363251a5cd28c46e8d08c50608ffabaf96eb95 /lib/libutil/passwd.c | |
parent | util.h no longer here (diff) | |
download | wireguard-openbsd-961df418c861ab029a5830d1d1b9b9ba13b780a7.tar.xz wireguard-openbsd-961df418c861ab029a5830d1d1b9b9ba13b780a7.zip |
do not unexpectedly unlink the ptmp file; also support SIG*STOP cleanly
with our changes which permit "EDITOR=emacs -nw" to work.
Diffstat (limited to 'lib/libutil/passwd.c')
-rw-r--r-- | lib/libutil/passwd.c | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/lib/libutil/passwd.c b/lib/libutil/passwd.c index 8c7eeb5faac..8df9b382a14 100644 --- a/lib/libutil/passwd.c +++ b/lib/libutil/passwd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: passwd.c,v 1.3 1996/06/17 07:46:04 downsj Exp $ */ +/* $OpenBSD: passwd.c,v 1.4 1996/06/19 12:36:01 deraadt Exp $ */ /* * Copyright (c) 1987, 1993, 1994, 1995 * The Regents of the University of California. All rights reserved. @@ -33,7 +33,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$NetBSD: passwd.c,v 1.1 1996/05/15 21:42:31 jtc Exp $"; +static char rcsid[] = "$NetBSD: passwd.c,v 1.1.4.1 1996/06/02 19:48:31 ghudson Exp $"; #endif /* LIBC_SCCS and not lint */ #include <sys/types.h> @@ -89,10 +89,8 @@ pw_mkdb() exit(1); } pid = waitpid(pid, &pstat, 0); - if (pid == -1 || !WIFEXITED(pstat) || WEXITSTATUS(pstat) != 0) { - unlink(_PATH_MASTERPASSWD_LOCK); + if (pid == -1 || !WIFEXITED(pstat) || WEXITSTATUS(pstat) != 0) return(-1); - } return(0); } @@ -151,6 +149,7 @@ pw_edit(notsetuid, filename) { int pstat; char *p, *editor; + char *argp[] = {"sh", "-c", NULL, NULL}; if (!filename) filename = _PATH_MASTERPASSWD_LOCK; @@ -161,15 +160,21 @@ pw_edit(notsetuid, filename) if (p == NULL) return; sprintf(p, "%s %s", editor, filename); + argp[2] = p; - if (!(editpid = vfork())) { + switch(editpid = vfork()) { + case -1: /* error */ + free(p); + return; + case 0: /* child */ if (notsetuid) { setgid(getgid()); setuid(getuid()); } - system(p); - _exit(1); + execv(_PATH_BSHELL, argp); + _exit(127); } + free(p); for (;;) { editpid = waitpid(editpid, (int *)&pstat, WUNTRACED); @@ -348,4 +353,3 @@ pw_error(name, err, eval) pw_abort(); exit(eval); } - |