mirror of
https://github.com/freebsd/freebsd-src.git
synced 2024-12-03 19:08:58 +00:00
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 :-)
This commit is contained in:
parent
ccd16b43ed
commit
dba5ab6662
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=57564
@ -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 {
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user