summaryrefslogtreecommitdiffstats
path: root/source3/modules
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2014-12-31 14:26:43 +0100
committerJeremy Allison <jra@samba.org>2015-01-06 00:33:10 +0100
commit4b1e6ae5d393c3ac5e837b64f16bfbcf5267a2e0 (patch)
treeee1e2c5eabb4566f1c944a931cda4dc5652e5176 /source3/modules
parent8caa866b08172dd5da5ef2cfadad4210c1dabf08 (diff)
downloadsamba-4b1e6ae5d393c3ac5e837b64f16bfbcf5267a2e0.tar.gz
samba-4b1e6ae5d393c3ac5e837b64f16bfbcf5267a2e0.tar.xz
samba-4b1e6ae5d393c3ac5e837b64f16bfbcf5267a2e0.zip
smbd: Use msghdr.[ch] in vfs_aio_fork
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
Diffstat (limited to 'source3/modules')
-rw-r--r--source3/modules/vfs_aio_fork.c62
1 files changed, 20 insertions, 42 deletions
diff --git a/source3/modules/vfs_aio_fork.c b/source3/modules/vfs_aio_fork.c
index 3b6699bd1f..7d2aff9064 100644
--- a/source3/modules/vfs_aio_fork.c
+++ b/source3/modules/vfs_aio_fork.c
@@ -157,26 +157,10 @@ static ssize_t read_fd(int fd, void *ptr, size_t nbytes, int *recvfd)
struct msghdr msg;
struct iovec iov[1];
ssize_t n;
-#ifndef HAVE_STRUCT_MSGHDR_MSG_CONTROL
- int newfd;
-
- ZERO_STRUCT(msg);
- msg.msg_accrights = (caddr_t) &newfd;
- msg.msg_accrightslen = sizeof(int);
-#else
-
- union {
- struct cmsghdr cm;
- char control[CMSG_SPACE(sizeof(int))];
- } control_un;
- struct cmsghdr *cmptr;
-
- ZERO_STRUCT(msg);
- ZERO_STRUCT(control_un);
+ size_t bufsize = msghdr_prep_recv_fds(NULL, NULL, 0, 1);
+ uint8_t buf[bufsize];
- msg.msg_control = control_un.control;
- msg.msg_controllen = sizeof(control_un.control);
-#endif
+ msghdr_prep_recv_fds(&msg, buf, bufsize, 1);
msg.msg_name = NULL;
msg.msg_namelen = 0;
@@ -190,31 +174,25 @@ static ssize_t read_fd(int fd, void *ptr, size_t nbytes, int *recvfd)
return(n);
}
-#ifdef HAVE_STRUCT_MSGHDR_MSG_CONTROL
- if ((cmptr = CMSG_FIRSTHDR(&msg)) != NULL
- && cmptr->cmsg_len == CMSG_LEN(sizeof(int))) {
- if (cmptr->cmsg_level != SOL_SOCKET) {
- DEBUG(10, ("control level != SOL_SOCKET"));
- errno = EINVAL;
- return -1;
- }
- if (cmptr->cmsg_type != SCM_RIGHTS) {
- DEBUG(10, ("control type != SCM_RIGHTS"));
- errno = EINVAL;
- return -1;
+ {
+ size_t num_fds = msghdr_extract_fds(&msg, NULL, 0);
+ int fds[num_fds];
+
+ msghdr_extract_fds(&msg, fds, num_fds);
+
+ if (num_fds != 1) {
+ size_t i;
+
+ for (i=0; i<num_fds; i++) {
+ close(fds[i]);
+ }
+
+ *recvfd = -1;
+ return n;
}
- memcpy(recvfd, CMSG_DATA(cmptr), sizeof(*recvfd));
- } else {
- *recvfd = -1; /* descriptor was not passed */
- }
-#else
- if (msg.msg_accrightslen == sizeof(int)) {
- *recvfd = newfd;
- }
- else {
- *recvfd = -1; /* descriptor was not passed */
+
+ *recvfd = fds[0];
}
-#endif
return(n);
}