summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_descrip.c
diff options
context:
space:
mode:
authormatthew <matthew@openbsd.org>2012-05-21 16:41:03 +0000
committermatthew <matthew@openbsd.org>2012-05-21 16:41:03 +0000
commit21dc217da274bcd12a6675a745adf90c2942a145 (patch)
tree7835f1cbd02eed43cc7cd79cb96eb6c45916edc5 /sys/kern/kern_descrip.c
parentFix binutils-2.17 configure script to build on amd64. (diff)
downloadwireguard-openbsd-21dc217da274bcd12a6675a745adf90c2942a145.tar.xz
wireguard-openbsd-21dc217da274bcd12a6675a745adf90c2942a145.zip
Cleanup O_CLOEXEC handling and make sure UF_EXCLOSE is set correctly
when opening /dev/fd/* (i.e., UF_EXCLOSE is now set iff O_CLOEXEC is set, rather than copying UF_EXCLOSE from the file descriptor being dup'd). Also, add support for O_CLOEXEC and O_DIRECTORY to fhopen(). ok krw, guenther; feedback from millert; testing and bug finding by krw
Diffstat (limited to 'sys/kern/kern_descrip.c')
-rw-r--r--sys/kern/kern_descrip.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c
index 9aa2f55b225..4e46b056e04 100644
--- a/sys/kern/kern_descrip.c
+++ b/sys/kern/kern_descrip.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_descrip.c,v 1.95 2012/05/14 02:41:13 guenther Exp $ */
+/* $OpenBSD: kern_descrip.c,v 1.96 2012/05/21 16:41:03 matthew Exp $ */
/* $NetBSD: kern_descrip.c,v 1.42 1996/03/30 22:24:38 christos Exp $ */
/*
@@ -1233,7 +1233,8 @@ dupfdopen(struct filedesc *fdp, int indx, int dfd, int mode)
return (EDEADLK);
fdp->fd_ofiles[indx] = wfp;
- fdp->fd_ofileflags[indx] = fdp->fd_ofileflags[dfd];
+ fdp->fd_ofileflags[indx] = (fdp->fd_ofileflags[indx] & UF_EXCLOSE) |
+ (fdp->fd_ofileflags[dfd] & ~UF_EXCLOSE);
wfp->f_count++;
fd_used(fdp, indx);
return (0);