s3:messaging: add fds-array to messaging_send_iov()
authorMichael Adam <obnox@samba.org>
Sat, 17 May 2014 13:19:18 +0000 (15:19 +0200)
committerMichael Adam <obnox@samba.org>
Wed, 24 Sep 2014 06:44:12 +0000 (08:44 +0200)
Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Michael Adam <obnox@samba.org>
source3/include/messages.h
source3/lib/messages.c
source3/smbd/notify_internal.c

index b7193d5a85f1137df7a020fafd4d50c1c15ed11c..eb0943a95f160051852ab9ee7160283507473ee1 100644 (file)
@@ -114,7 +114,8 @@ NTSTATUS messaging_send_buf(struct messaging_context *msg_ctx,
                            const uint8_t *buf, size_t len);
 NTSTATUS messaging_send_iov(struct messaging_context *msg_ctx,
                            struct server_id server, uint32_t msg_type,
-                           const struct iovec *iov, int iovlen);
+                           const struct iovec *iov, int iovlen,
+                           const int *fds, size_t num_fds);
 void messaging_dispatch_rec(struct messaging_context *msg_ctx,
                            struct messaging_rec *rec);
 
index 0579dbf359944736b80f9d2845db3464c0c02e17..84147de0f6e6fa70545837faa1a84f8241d8a62e 100644 (file)
@@ -442,7 +442,7 @@ NTSTATUS messaging_send(struct messaging_context *msg_ctx,
        iov.iov_base = data->data;
        iov.iov_len = data->length;
 
-       return messaging_send_iov(msg_ctx, server, msg_type, &iov, 1);
+       return messaging_send_iov(msg_ctx, server, msg_type, &iov, 1, NULL, 0);
 }
 
 NTSTATUS messaging_send_buf(struct messaging_context *msg_ctx,
@@ -455,7 +455,8 @@ NTSTATUS messaging_send_buf(struct messaging_context *msg_ctx,
 
 NTSTATUS messaging_send_iov(struct messaging_context *msg_ctx,
                            struct server_id server, uint32_t msg_type,
-                           const struct iovec *iov, int iovlen)
+                           const struct iovec *iov, int iovlen,
+                           const int *fds, size_t num_fds)
 {
        int ret;
        struct messaging_hdr hdr;
@@ -465,7 +466,15 @@ NTSTATUS messaging_send_iov(struct messaging_context *msg_ctx,
                return NT_STATUS_INVALID_PARAMETER_MIX;
        }
 
+       if (num_fds > INT8_MAX) {
+               return NT_STATUS_INVALID_PARAMETER_MIX;
+       }
+
        if (!procid_is_local(&server)) {
+               if (num_fds > 0) {
+                       return NT_STATUS_NOT_SUPPORTED;
+               }
+
                ret = msg_ctx->remote->send_fn(msg_ctx->id, server,
                                               msg_type, iov, iovlen,
                                               NULL, 0,
@@ -484,6 +493,10 @@ NTSTATUS messaging_send_iov(struct messaging_context *msg_ctx,
                 * Self-send, directly dispatch
                 */
 
+               if (num_fds > 0) {
+                       return NT_STATUS_NOT_SUPPORTED;
+               }
+
                buf = iov_buf(talloc_tos(), iov, iovlen);
                if (buf == NULL) {
                        return NT_STATUS_NO_MEMORY;
@@ -511,7 +524,7 @@ NTSTATUS messaging_send_iov(struct messaging_context *msg_ctx,
        memcpy(&iov2[1], iov, iovlen * sizeof(*iov));
 
        become_root();
-       ret = messaging_dgm_send(server.pid, iov2, iovlen+1, NULL, 0);
+       ret = messaging_dgm_send(server.pid, iov2, iovlen+1, fds, num_fds);
        unbecome_root();
 
        if (ret != 0) {
index e902bf4f3e85663ce11fcdaa1fa8492ee28fb261..2ba68d74bca30034d82452def0956e527b218cc2 100644 (file)
@@ -792,7 +792,7 @@ static NTSTATUS notify_send(struct notify_context *notify,
        iov[1].iov_len = strlen(path)+1;
 
        return messaging_send_iov(notify->msg, *pid, MSG_PVFS_NOTIFY,
-                                 iov, ARRAY_SIZE(iov));
+                                 iov, ARRAY_SIZE(iov), NULL, 0);
 }
 
 static void notify_handler(struct messaging_context *msg_ctx,