summaryrefslogtreecommitdiffstats
path: root/sys/compat/linux/linux_socket.c
diff options
context:
space:
mode:
authormarcel <marcel@FreeBSD.org>2000-02-28 18:58:59 +0000
committermarcel <marcel@FreeBSD.org>2000-02-28 18:58:59 +0000
commit39a8b7149f0ab399cdd6a6d5f254c70ba2cf6fa6 (patch)
tree81ed557c084a12e62127a245f4b232eb0d0b4033 /sys/compat/linux/linux_socket.c
parent499e159c089579eb4a3572e76d1b8171cb9c34aa (diff)
downloadFreeBSD-src-39a8b7149f0ab399cdd6a6d5f254c70ba2cf6fa6.zip
FreeBSD-src-39a8b7149f0ab399cdd6a6d5f254c70ba2cf6fa6.tar.gz
Fix accept(2) behavior in that accepted sockets don't inherit the
parents flags. Note on the PR: The PR contains another patch that's not being committed without further background information. The PR stays open for now. PR: 16946 (Victor A. Salaman <salaman@teknos.com>) Prompted by: msmith Indirect/implicit approval: jkh (shoot me if I'm wrong :-)
Diffstat (limited to 'sys/compat/linux/linux_socket.c')
-rw-r--r--sys/compat/linux/linux_socket.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/sys/compat/linux/linux_socket.c b/sys/compat/linux/linux_socket.c
index d29efb63d8..d2be9b9 100644
--- a/sys/compat/linux/linux_socket.c
+++ b/sys/compat/linux/linux_socket.c
@@ -441,6 +441,11 @@ linux_accept(struct proc *p, struct linux_accept_args *args)
caddr_t name;
int *anamelen;
} */ bsd_args;
+ struct fcntl_args /* {
+ int fd;
+ int cmd;
+ long arg;
+ } */ f_args;
int error;
if ((error=copyin((caddr_t)args, (caddr_t)&linux_args, sizeof(linux_args))))
@@ -448,7 +453,21 @@ linux_accept(struct proc *p, struct linux_accept_args *args)
bsd_args.s = linux_args.s;
bsd_args.name = (caddr_t)linux_args.addr;
bsd_args.anamelen = linux_args.namelen;
- return oaccept(p, &bsd_args);
+ error = oaccept(p, &bsd_args);
+ 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.
+ */
+ f_args.fd = p->p_retval[0];
+ f_args.cmd = F_SETFL;
+ f_args.arg = 0;
+ (void)fcntl(p, &f_args);
+ p->p_retval[0] = f_args.fd;
+ return (0);
}
struct linux_getsockname_args {
OpenPOWER on IntegriCloud