Browse Source

do not unexpectedly unlink the ptmp file; also support SIG*STOP cleanly

with our changes which permit "EDITOR=emacs -nw" to work.
OPENBSD_2_0
deraadt 28 years ago
parent
commit
a34e8e5c6d
2 changed files with 18 additions and 9 deletions
  1. +13
    -9
      src/lib/libutil/passwd.c
  2. +5
    -0
      src/lib/libutil/pw_lock.3

+ 13
- 9
src/lib/libutil/passwd.c View File

@ -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 * Copyright (c) 1987, 1993, 1994, 1995
* The Regents of the University of California. All rights reserved. * The Regents of the University of California. All rights reserved.
@ -33,7 +33,7 @@
*/ */
#if defined(LIBC_SCCS) && !defined(lint) #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 */ #endif /* LIBC_SCCS and not lint */
#include <sys/types.h> #include <sys/types.h>
@ -89,10 +89,8 @@ pw_mkdb()
exit(1); exit(1);
} }
pid = waitpid(pid, &pstat, 0); 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(-1);
}
return(0); return(0);
} }
@ -151,6 +149,7 @@ pw_edit(notsetuid, filename)
{ {
int pstat; int pstat;
char *p, *editor; char *p, *editor;
char *argp[] = {"sh", "-c", NULL, NULL};
if (!filename) if (!filename)
filename = _PATH_MASTERPASSWD_LOCK; filename = _PATH_MASTERPASSWD_LOCK;
@ -161,15 +160,21 @@ pw_edit(notsetuid, filename)
if (p == NULL) if (p == NULL)
return; return;
sprintf(p, "%s %s", editor, filename); 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) { if (notsetuid) {
setgid(getgid()); setgid(getgid());
setuid(getuid()); setuid(getuid());
} }
system(p);
_exit(1);
execv(_PATH_BSHELL, argp);
_exit(127);
} }
free(p); free(p);
for (;;) { for (;;) {
editpid = waitpid(editpid, (int *)&pstat, WUNTRACED); editpid = waitpid(editpid, (int *)&pstat, WUNTRACED);
@ -348,4 +353,3 @@ pw_error(name, err, eval)
pw_abort(); pw_abort();
exit(eval); exit(eval);
} }

+ 5
- 0
src/lib/libutil/pw_lock.3 View File

@ -79,6 +79,11 @@ You should finish writing to and close the file descriptor returned by
.Fn pw_lock .Fn pw_lock
before calling before calling
.Fn pw_mkdb . .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 .Pp
The The
.Fn pw_abort .Fn pw_abort


Loading…
Cancel
Save