diff options
author | 2000-08-01 22:10:16 +0000 | |
---|---|---|
committer | 2000-08-01 22:10:16 +0000 | |
commit | ce4f90690b6fc9258e6bd132231909d28b88ffd6 (patch) | |
tree | 9c6fcb13238569467cbd00477b1e1c15ce6d8302 /lib/libutil | |
parent | Traditional NDBM supports dbm_open(foo, O_WRONLY) but dbopen() does (diff) | |
download | wireguard-openbsd-ce4f90690b6fc9258e6bd132231909d28b88ffd6.tar.xz wireguard-openbsd-ce4f90690b6fc9258e6bd132231909d28b88ffd6.zip |
close fd for pw_lck on exec, okay deraadt@
Diffstat (limited to 'lib/libutil')
-rw-r--r-- | lib/libutil/passwd.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/libutil/passwd.c b/lib/libutil/passwd.c index 5de35e97e5d..7d43a4eed98 100644 --- a/lib/libutil/passwd.c +++ b/lib/libutil/passwd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: passwd.c,v 1.21 2000/06/30 16:00:07 millert Exp $ */ +/* $OpenBSD: passwd.c,v 1.22 2000/08/01 22:10:16 provos Exp $ */ /* * Copyright (c) 1987, 1993, 1994, 1995 @@ -34,7 +34,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: passwd.c,v 1.21 2000/06/30 16:00:07 millert Exp $"; +static char rcsid[] = "$OpenBSD: passwd.c,v 1.22 2000/08/01 22:10:16 provos Exp $"; #endif /* LIBC_SCCS and not lint */ #include <sys/types.h> @@ -263,6 +263,10 @@ pw_lock(retries) fd = open(pw_lck, O_WRONLY|O_CREAT|O_EXCL, 0600); } save_errno = errno; + if (fd != -1 && fcntl(fd, F_SETFD, 1) == -1) { + close(fd); + fd = -1; + } (void) umask(old_mode); errno = save_errno; return (fd); |