summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorNiels Provos <provos@cvs.openbsd.org>2000-08-01 22:10:17 +0000
committerNiels Provos <provos@cvs.openbsd.org>2000-08-01 22:10:17 +0000
commit94da7af015bc3066711d2bdf0513667a7dcb4afe (patch)
tree7a90605a3ffd682cb4c353586eca25b23db79e34 /lib
parent72e3a9f626e20354527aad68a8533df3643a5a17 (diff)
close fd for pw_lck on exec, okay deraadt@
Diffstat (limited to 'lib')
-rw-r--r--lib/libutil/passwd.c8
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);