diff options
author | Federico G. Schwindt <fgsch@cvs.openbsd.org> | 2002-08-09 01:03:26 +0000 |
---|---|---|
committer | Federico G. Schwindt <fgsch@cvs.openbsd.org> | 2002-08-09 01:03:26 +0000 |
commit | a10440cfdc60ff57b5bb923a26acdedd9f990df7 (patch) | |
tree | a159b8f9a99430118dbff27f49ce0fdf78909665 /sys/compat/linux/linux_socket.c | |
parent | 88551637b64881d1ed937ce43e9358a2e0cff16e (diff) |
socket flags are not inherited via accept() on linux; found and tested
by gustavo, several ppl ok@
Diffstat (limited to 'sys/compat/linux/linux_socket.c')
-rw-r--r-- | sys/compat/linux/linux_socket.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/sys/compat/linux/linux_socket.c b/sys/compat/linux/linux_socket.c index db2c4eec904..c4ef4208b6c 100644 --- a/sys/compat/linux/linux_socket.c +++ b/sys/compat/linux/linux_socket.c @@ -1,4 +1,4 @@ -/* $OpenBSD: linux_socket.c,v 1.23 2002/03/14 01:26:50 millert Exp $ */ +/* $OpenBSD: linux_socket.c,v 1.24 2002/08/09 01:03:25 fgsch Exp $ */ /* $NetBSD: linux_socket.c,v 1.14 1996/04/05 00:01:50 christos Exp $ */ /* @@ -284,6 +284,7 @@ linux_accept(p, v, retval) } */ *uap = v; struct linux_accept_args laa; struct compat_43_sys_accept_args baa; + struct sys_fcntl_args fca; int error; if ((error = copyin((caddr_t) uap, (caddr_t) &laa, sizeof laa))) @@ -293,7 +294,21 @@ linux_accept(p, v, retval) SCARG(&baa, name) = (caddr_t) laa.addr; SCARG(&baa, anamelen) = laa.namelen; - return compat_43_sys_accept(p, &baa, retval); + error = compat_43_sys_accept(p, &baa, retval); + if (error) + return (error); + + /* + * linux appears not to copy flags from the parent socket to the + * accepted one, so we must clear the flags in the new descriptor. + * Ignore any errors, because we already have an open fd. + */ + SCARG(&fca, fd) = *retval; + SCARG(&fca, cmd) = F_SETFL; + SCARG(&fca, arg) = 0; + (void)sys_fcntl(p, &fca, retval); + *retval = SCARG(&fca, fd); + return (0); } int |