diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1996-06-19 12:36:02 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1996-06-19 12:36:02 +0000 |
commit | d68ff5f046b1d123969c59e31a6366d88ea17e9b (patch) | |
tree | 66c27b86da20979b77adc9fa25893d91fbef3f40 /lib/libutil | |
parent | 98770ff25edc630eb8437635f084a7133a088f89 (diff) |
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')
-rw-r--r-- | lib/libutil/passwd.c | 22 | ||||
-rw-r--r-- | lib/libutil/pw_lock.3 | 5 |
2 files changed, 18 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); } - diff --git a/lib/libutil/pw_lock.3 b/lib/libutil/pw_lock.3 index f768f6970c9..b5791af817c 100644 --- a/lib/libutil/pw_lock.3 +++ b/lib/libutil/pw_lock.3 @@ -79,6 +79,11 @@ You should finish writing to and close the file descriptor returned by .Fn pw_lock before calling .Fn pw_mkdb . +If +.Fn pw_mkdb +fails and you do not wish to retry, you should make sure to call +.Fn pw_abort +to clean up the lock file. .Pp The .Fn pw_abort |