The Samba-Bugzilla – Attachment 11476 Details for
Bug 11053
source3/lib/msghdr.c compiling error on Solaris
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch for 4.3
11053-4.3.patch (text/plain), 7.75 KB, created by
Volker Lendecke
on 2015-10-05 09:08:47 UTC
(
hide
)
Description:
Patch for 4.3
Filename:
MIME Type:
Creator:
Volker Lendecke
Created:
2015-10-05 09:08:47 UTC
Size:
7.75 KB
patch
obsolete
>From a3890ff83aacd7aa5ee4c518de72d09f6c233b18 Mon Sep 17 00:00:00 2001 >From: Volker Lendecke <vl@samba.org> >Date: Sun, 27 Sep 2015 00:35:45 +0200 >Subject: [PATCH 1/4] lib: We only need the fd-passing check once > >unix_dgram_send will tell us as well > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=11053 > >Signed-off-by: Volker Lendecke <vl@samba.org> >Reviewed-by: Michael Adam <obnox@samba.org> >(cherry picked from commit 2c675aad40e3e0bb412f9fb8558de349ad62860a) >--- > source3/lib/unix_msg/unix_msg.c | 6 ------ > 1 file changed, 6 deletions(-) > >diff --git a/source3/lib/unix_msg/unix_msg.c b/source3/lib/unix_msg/unix_msg.c >index 0baaa9d..782748b 100644 >--- a/source3/lib/unix_msg/unix_msg.c >+++ b/source3/lib/unix_msg/unix_msg.c >@@ -798,12 +798,6 @@ int unix_msg_send(struct unix_msg_ctx *ctx, const struct sockaddr_un *dst, > return EINVAL; > } > >-#ifndef HAVE_STRUCT_MSGHDR_MSG_CONTROL >- if (num_fds > 0) { >- return ENOSYS; >- } >-#endif /* ! HAVE_STRUCT_MSGHDR_MSG_CONTROL */ >- > if (num_fds > INT8_MAX) { > return EINVAL; > } >-- >1.9.1 > > >From 3ee35278cf85e3f360f71543dd60c2f5ff8b8c3c Mon Sep 17 00:00:00 2001 >From: Volker Lendecke <vl@samba.org> >Date: Sun, 27 Sep 2015 00:46:33 +0200 >Subject: [PATCH 2/4] lib: Move some routines around in msghdr.c > >This way we only need one #ifdef for ACCRIGHTS > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=11053 > >Signed-off-by: Volker Lendecke <vl@samba.org> >Reviewed-by: Michael Adam <obnox@samba.org> >(cherry picked from commit f4e06a9bce42d60f6c96a21307266a99d2785ae9) >--- > source3/lib/msghdr.c | 96 ++++++++++++++++++++++++++-------------------------- > 1 file changed, 48 insertions(+), 48 deletions(-) > >diff --git a/source3/lib/msghdr.c b/source3/lib/msghdr.c >index de0eed4..d89b7c1 100644 >--- a/source3/lib/msghdr.c >+++ b/source3/lib/msghdr.c >@@ -58,6 +58,54 @@ ssize_t msghdr_prep_fds(struct msghdr *msg, uint8_t *buf, size_t bufsize, > return cmsg_space; > } > >+size_t msghdr_prep_recv_fds(struct msghdr *msg, uint8_t *buf, size_t bufsize, >+ size_t num_fds) >+{ >+ size_t ret = CMSG_SPACE(sizeof(int) * num_fds); >+ >+ if (bufsize < ret) { >+ return ret; >+ } >+ if (msg != NULL) { >+ if (num_fds != 0) { >+ msg->msg_control = buf; >+ msg->msg_controllen = ret; >+ } else { >+ msg->msg_control = NULL; >+ msg->msg_controllen = 0; >+ } >+ } >+ return ret; >+} >+ >+size_t msghdr_extract_fds(struct msghdr *msg, int *fds, size_t fds_size) >+{ >+ struct cmsghdr *cmsg; >+ size_t num_fds; >+ >+ for(cmsg = CMSG_FIRSTHDR(msg); >+ cmsg != NULL; >+ cmsg = CMSG_NXTHDR(msg, cmsg)) >+ { >+ if ((cmsg->cmsg_type == SCM_RIGHTS) && >+ (cmsg->cmsg_level == SOL_SOCKET)) { >+ break; >+ } >+ } >+ >+ if (cmsg == NULL) { >+ return 0; >+ } >+ >+ num_fds = (cmsg->cmsg_len - CMSG_LEN(0)) / sizeof(int); >+ >+ if ((num_fds != 0) && (fds != NULL) && (fds_size >= num_fds)) { >+ memcpy(fds, CMSG_DATA(cmsg), num_fds * sizeof(int)); >+ } >+ >+ return num_fds; >+} >+ > struct msghdr_buf { > struct msghdr msg; > struct sockaddr_storage addr; >@@ -130,51 +178,3 @@ struct msghdr *msghdr_buf_msghdr(struct msghdr_buf *msg) > { > return &msg->msg; > } >- >-size_t msghdr_prep_recv_fds(struct msghdr *msg, uint8_t *buf, size_t bufsize, >- size_t num_fds) >-{ >- size_t ret = CMSG_SPACE(sizeof(int) * num_fds); >- >- if (bufsize < ret) { >- return ret; >- } >- if (msg != NULL) { >- if (num_fds != 0) { >- msg->msg_control = buf; >- msg->msg_controllen = ret; >- } else { >- msg->msg_control = NULL; >- msg->msg_controllen = 0; >- } >- } >- return ret; >-} >- >-size_t msghdr_extract_fds(struct msghdr *msg, int *fds, size_t fds_size) >-{ >- struct cmsghdr *cmsg; >- size_t num_fds; >- >- for(cmsg = CMSG_FIRSTHDR(msg); >- cmsg != NULL; >- cmsg = CMSG_NXTHDR(msg, cmsg)) >- { >- if ((cmsg->cmsg_type == SCM_RIGHTS) && >- (cmsg->cmsg_level == SOL_SOCKET)) { >- break; >- } >- } >- >- if (cmsg == NULL) { >- return 0; >- } >- >- num_fds = (cmsg->cmsg_len - CMSG_LEN(0)) / sizeof(int); >- >- if ((num_fds != 0) && (fds != NULL) && (fds_size >= num_fds)) { >- memcpy(fds, CMSG_DATA(cmsg), num_fds * sizeof(int)); >- } >- >- return num_fds; >-} >-- >1.9.1 > > >From 3be2c85a08d79b4454cbd021a0dbac63e6383849 Mon Sep 17 00:00:00 2001 >From: Volker Lendecke <vl@samba.org> >Date: Sun, 27 Sep 2015 00:54:42 +0200 >Subject: [PATCH 3/4] lib: Support fd passing using the 4.3BSD way > >This is required on Solaris > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=11053 > >Signed-off-by: Volker Lendecke <vl@samba.org> >Reviewed-by: Michael Adam <obnox@samba.org> >(cherry picked from commit 0499cee90307d9644271869c86fac2b5401df0e0) >--- > source3/lib/msghdr.c | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 80 insertions(+) > >diff --git a/source3/lib/msghdr.c b/source3/lib/msghdr.c >index d89b7c1..2aa2f2e 100644 >--- a/source3/lib/msghdr.c >+++ b/source3/lib/msghdr.c >@@ -21,6 +21,8 @@ > #include "lib/util/iov_buf.h" > #include <sys/socket.h> > >+#if defined(HAVE_STRUCT_MSGHDR_MSG_CONTROL) >+ > ssize_t msghdr_prep_fds(struct msghdr *msg, uint8_t *buf, size_t bufsize, > const int *fds, size_t num_fds) > { >@@ -106,6 +108,84 @@ size_t msghdr_extract_fds(struct msghdr *msg, int *fds, size_t fds_size) > return num_fds; > } > >+#elif defined(HAVE_STRUCT_MSGHDR_MSG_ACCRIGHTS) >+ >+ssize_t msghdr_prep_fds(struct msghdr *msg, uint8_t *buf, size_t bufsize, >+ const int *fds, size_t num_fds) >+{ >+ size_t needed; >+ >+ if (num_fds > INT8_MAX) { >+ return -1; >+ } >+ >+ needed = sizeof(int) * num_fds; >+ >+ if ((msg == NULL) || (needed > bufsize)) { >+ return needed; >+ } >+ >+ memcpy(buf, fds, needed); >+ >+ msg->msg_accrights = (caddr_t) buf; >+ msg->msg_accrightslen = needed; >+ >+ return needed; >+} >+ >+size_t msghdr_prep_recv_fds(struct msghdr *msg, uint8_t *buf, size_t bufsize, >+ size_t num_fds) >+{ >+ size_t ret = num_fds * sizeof(int); >+ >+ if (bufsize < ret) { >+ return ret; >+ } >+ >+ if (msg != NULL) { >+ if (num_fds != 0) { >+ msg->msg_accrights = (caddr_t) buf; >+ msg->msg_accrightslen = ret; >+ } else { >+ msg->msg_accrights = NULL; >+ msg->msg_accrightslen = 0; >+ } >+ } >+ return ret; >+} >+ >+size_t msghdr_extract_fds(struct msghdr *msg, int *fds, size_t fds_size) >+{ >+ size_t num_fds = msg->msg_accrightslen / sizeof(int); >+ >+ if ((fds != 0) && (num_fds <= fds_size)) { >+ memcpy(fds, msg->msg_accrights, msg->msg_accrightslen); >+ } >+ >+ return num_fds; >+} >+ >+#else >+ >+ssize_t msghdr_prep_fds(struct msghdr *msg, uint8_t *buf, size_t bufsize, >+ const int *fds, size_t num_fds) >+{ >+ return -1; >+} >+ >+size_t msghdr_prep_recv_fds(struct msghdr *msg, uint8_t *buf, size_t bufsize, >+ size_t num_fds) >+{ >+ return 0; >+} >+ >+size_t msghdr_extract_fds(struct msghdr *msg, int *fds, size_t fds_size) >+{ >+ return 0; >+} >+ >+#endif >+ > struct msghdr_buf { > struct msghdr msg; > struct sockaddr_storage addr; >-- >1.9.1 > > >From be5f51f358c62353d0ffd6ec48bfc7129e59d2c2 Mon Sep 17 00:00:00 2001 >From: Volker Lendecke <vl@samba.org> >Date: Sun, 27 Sep 2015 00:36:23 +0200 >Subject: [PATCH 4/4] lib: We can do ACCRIGHTS style fdpassing > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=11053 > >Signed-off-by: Volker Lendecke <vl@samba.org> >Reviewed-by: Michael Adam <obnox@samba.org> > >Autobuild-User(master): Michael Adam <obnox@samba.org> >Autobuild-Date(master): Thu Oct 1 05:55:42 CEST 2015 on sn-devel-104 > >(cherry picked from commit 00954a975b45cdb0dcf08c25850d2be26efabe48) >--- > source3/lib/unix_msg/unix_msg.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > >diff --git a/source3/lib/unix_msg/unix_msg.c b/source3/lib/unix_msg/unix_msg.c >index 782748b..3221133 100644 >--- a/source3/lib/unix_msg/unix_msg.c >+++ b/source3/lib/unix_msg/unix_msg.c >@@ -572,11 +572,11 @@ static int unix_dgram_send(struct unix_dgram_ctx *ctx, > return EINVAL; > } > >-#ifndef HAVE_STRUCT_MSGHDR_MSG_CONTROL >+#if !defined(HAVE_STRUCT_MSGHDR_MSG_CONTROL) && !defined(HAVE_STRUCT_MSGHDR_MSG_ACCRIGHTS) > if (num_fds > 0) { > return ENOSYS; > } >-#endif /* ! HAVE_STRUCT_MSGHDR_MSG_CONTROL */ >+#endif > > for (i = 0; i < num_fds; i++) { > /* >-- >1.9.1 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Flags:
obnox
:
review+
Actions:
View
Attachments on
bug 11053
:
10623
|
11457
| 11476