The branch, master has been updated
       via  5d22bcf s3:torture: in LOCAL-MESSAGING-READ3, print some messages 
to child
       via  db384ef s3:torture: in LOCAL-MESSAGING-READ3, tell child to exit 
and wait
       via  17055cc selftest: run smbtorture3 LOCAL-MESSAGING-FDPASS2 test
       via  5ed8be7 s3:torture: work on LOCAL-MESSAGING-FDPASS2
       via  31e5faa0 selftest: run smbtorture3 LOCAL-MESSAGING-FDPASS1 test
       via  db809c5 s3:torture: add test LOCAL-MESSAGING-FDPASS1
       via  0102636 s3:messaging: add fds-array to messaging_send_iov()
       via  1667839 s3:messaging: add fds-array to message-backend send function
       via  64d1401 s3:messaging: make it possible to receive a fd array from 
another process
       via  1b35d2e s3:unix_msg: add fds-array to unix_msg_send() for fd passing
       via  c689547 s3:unix_msg: pass the fd array to the unix_msg 
recv_callback function
       via  af573af s3:unix_msg: add fds-array to unix_dgram_send() for 
fd-passing
       via  3f519a5 s3:unix_msg: pass the fd array to the unix_dgram 
recv_callback function
       via  5b6f041 s3:unix_msg: read fds from recvmsg in 
unix_dgram_recv_handler()
       via  c9d08be s3:unix_msg: add close_fd_array()
       via  eca6d83 s3:unix_msg: use sendmsg() in unix_dgram_send_job()
       via  fbcd912 s3:messaging: use struct initializers for 'struct 
messaging_rec'
      from  93423cb ctdb-logging: Add forward declaration of debug_level

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 5d22bcf160bc6baf94d0d8de6dddbb15dfefe2ce
Author: Michael Adam <[email protected]>
Date:   Tue Sep 23 09:52:16 2014 +0200

    s3:torture: in LOCAL-MESSAGING-READ3, print some messages to child
    
    Signed-off-by: Michael Adam <[email protected]>
    Reviewed-by: Stefan Metzmacher <[email protected]>
    
    Autobuild-User(master): Michael Adam <[email protected]>
    Autobuild-Date(master): Wed Sep 24 11:09:43 CEST 2014 on sn-devel-104

commit db384efa40a7f688cb9cbedae1b214555b4f9eed
Author: Michael Adam <[email protected]>
Date:   Tue Sep 23 09:51:40 2014 +0200

    s3:torture: in LOCAL-MESSAGING-READ3, tell child to exit and wait
    
    Signed-off-by: Michael Adam <[email protected]>
    Reviewed-by: Stefan Metzmacher <[email protected]>

commit 17055cca7bd130c3a82205e74ee696d97381fa28
Author: Michael Adam <[email protected]>
Date:   Wed Sep 24 07:19:03 2014 +0200

    selftest: run smbtorture3 LOCAL-MESSAGING-FDPASS2 test
    
    Signed-off-by: Michael Adam <[email protected]>
    Reviewed-by: Stefan Metzmacher <[email protected]>

commit 5ed8be7b2ecf13fec5c210680ef95663a63e2ed5
Author: Michael Adam <[email protected]>
Date:   Tue Sep 23 09:53:15 2014 +0200

    s3:torture: work on LOCAL-MESSAGING-FDPASS2
    
    - parent: fork
    - parent: create up and down pipes,
    - parent: pass read end of up pipe and write end of down pipe to child
    - parent: write to up pipe
    - child:  read from up pipe
    - child:  write to down pipe
    - parent: read from down pipe
    
    Signed-off-by: Michael Adam <[email protected]>
    Reviewed-by: Stefan Metzmacher <[email protected]>

commit 31e5faa008c4e1acdf25c12ef03183896596a88b
Author: Michael Adam <[email protected]>
Date:   Mon Sep 22 20:13:39 2014 +0200

    selftest: run smbtorture3 LOCAL-MESSAGING-FDPASS1 test
    
    Signed-off-by: Michael Adam <[email protected]>
    Reviewed-by: Stefan Metzmacher <[email protected]>

commit db809c5eb494fe345b43b0f30cfa4e61004f6f22
Author: Michael Adam <[email protected]>
Date:   Mon Aug 18 18:20:34 2014 +0200

    s3:torture: add test LOCAL-MESSAGING-FDPASS1
    
    Verify that a process can not pass an fd to itself.
    
    Signed-off-by: Michael Adam <[email protected]>
    Reviewed-by: Stefan Metzmacher <[email protected]>

commit 01026363dd0051eac00b555c5e0503a0484134cc
Author: Michael Adam <[email protected]>
Date:   Sat May 17 15:19:18 2014 +0200

    s3:messaging: add fds-array to messaging_send_iov()
    
    Pair-Programmed-With: Stefan Metzmacher <[email protected]>
    Signed-off-by: Stefan Metzmacher <[email protected]>
    Signed-off-by: Michael Adam <[email protected]>

commit 16678391925335d84ac95de11158959cb20280bc
Author: Michael Adam <[email protected]>
Date:   Sat May 17 15:16:02 2014 +0200

    s3:messaging: add fds-array to message-backend send function
    
    Pair-Programmed-With: Stefan Metzmacher <[email protected]>
    Signed-off-by: Stefan Metzmacher <[email protected]>
    Signed-off-by: Michael Adam <[email protected]>

commit 64d140197e7d668a773ac2f85c9cabd8c59e4804
Author: Stefan Metzmacher <[email protected]>
Date:   Tue Jun 24 07:39:05 2014 +0200

    s3:messaging: make it possible to receive a fd array from another process
    
    In order to receive the fd array the caller needs to use
    messaging_filtered_read_send/recv(). For all higher level
    methods we silently close/ignore the fd array.
    
    Signed-off-by: Stefan Metzmacher <[email protected]>
    Reviewed-by: Michael Adam <[email protected]>

commit 1b35d2ed631631f470dc5a7cff54068a832bfafc
Author: Michael Adam <[email protected]>
Date:   Sun May 18 00:22:55 2014 +0200

    s3:unix_msg: add fds-array to unix_msg_send() for fd passing
    
    Pair-Programmed-With: Stefan Metzmacher <[email protected]>
    Signed-off-by: Stefan Metzmacher <[email protected]>
    Signed-off-by: Michael Adam <[email protected]>

commit c689547c9370967b3eecf0ea88252ad86f0234bf
Author: Stefan Metzmacher <[email protected]>
Date:   Mon Jun 23 17:16:32 2014 +0200

    s3:unix_msg: pass the fd array to the unix_msg recv_callback function
    
    Signed-off-by: Stefan Metzmacher <[email protected]>
    Reviewed-by: Michael Adam <[email protected]>

commit af573af0ff2fed6a9ce6f3cbd27e32c62d5884eb
Author: Michael Adam <[email protected]>
Date:   Sun May 18 00:22:19 2014 +0200

    s3:unix_msg: add fds-array to unix_dgram_send() for fd-passing
    
    Pair-Programmed-With: Stefan Metzmacher <[email protected]>
    Signed-off-by: Stefan Metzmacher <[email protected]>
    Signed-off-by: Michael Adam <[email protected]>

commit 3f519a507ad31c17d381af352490bd9cc9270baf
Author: Stefan Metzmacher <[email protected]>
Date:   Mon Jun 23 17:16:32 2014 +0200

    s3:unix_msg: pass the fd array to the unix_dgram recv_callback function
    
    For now unix_msg_recv() will just close the fds, but they will be passed
    to the unix_msg recv_callback in the next commits.
    
    Signed-off-by: Stefan Metzmacher <[email protected]>
    Reviewed-by: Michael Adam <[email protected]>

commit 5b6f0416e089c3db8803a27d6c7e88525fa78528
Author: Michael Adam <[email protected]>
Date:   Mon Jun 23 16:47:24 2014 +0200

    s3:unix_msg: read fds from recvmsg in unix_dgram_recv_handler()
    
    For now we directly close the fds, the next commits will pass them
    to the recv_callback function.
    
    Pair-Programmed-With: Stefan Metzmacher <[email protected]>
    Signed-off-by: Stefan Metzmacher <[email protected]>
    Signed-off-by: Michael Adam <[email protected]>

commit c9d08be7d0f5756c19c4c31af8b9034b02ebe33e
Author: Stefan Metzmacher <[email protected]>
Date:   Wed Aug 6 12:42:41 2014 +0200

    s3:unix_msg: add close_fd_array()
    
    Signed-off-by: Stefan Metzmacher <[email protected]>
    Reviewed-by: Michael Adam <[email protected]>

commit eca6d83a5f2fb7f85da7067868fdd6143ae726ff
Author: Stefan Metzmacher <[email protected]>
Date:   Wed Aug 6 09:40:56 2014 +0200

    s3:unix_msg: use sendmsg() in unix_dgram_send_job()
    
    This prepares fd-passing.
    
    Signed-off-by: Stefan Metzmacher <[email protected]>
    Reviewed-by: Michael Adam <[email protected]>

commit fbcd912bb6114d203a8645e9aec1c6134e9ebf3f
Author: Stefan Metzmacher <[email protected]>
Date:   Thu Aug 7 09:51:57 2014 +0200

    s3:messaging: use struct initializers for 'struct messaging_rec'
    
    This makes sure new struct members will always be initialized,
    without explicitly finding all users.
    
    Signed-off-by: Stefan Metzmacher <[email protected]>
    Reviewed-by: Michael Adam <[email protected]>

-----------------------------------------------------------------------

Summary of changes:
 source3/include/messages.h                  |    4 +-
 source3/lib/dbwrap/dbwrap_watch.c           |    3 +
 source3/lib/messages.c                      |  110 +++++++++--
 source3/lib/messages_ctdbd.c                |   19 +-
 source3/lib/messages_dgm.c                  |   15 +-
 source3/lib/messages_dgm.h                  |    6 +-
 source3/lib/unix_msg/test_drain.c           |    2 +
 source3/lib/unix_msg/test_source.c          |    2 +-
 source3/lib/unix_msg/tests.c                |   16 +-
 source3/lib/unix_msg/unix_msg.c             |  300 +++++++++++++++++++++++--
 source3/lib/unix_msg/unix_msg.h             |    6 +-
 source3/librpc/idl/messaging.idl            |    2 +
 source3/selftest/tests.py                   |    2 +
 source3/smbd/notify_internal.c              |    2 +-
 source3/torture/proto.h                     |    2 +
 source3/torture/test_messaging_fd_passing.c |  313 +++++++++++++++++++++++++++
 source3/torture/test_messaging_read.c       |   22 ++
 source3/torture/torture.c                   |    2 +
 source3/wscript_build                       |    1 +
 19 files changed, 770 insertions(+), 59 deletions(-)
 create mode 100644 source3/torture/test_messaging_fd_passing.c


Changeset truncated at 500 lines:

diff --git a/source3/include/messages.h b/source3/include/messages.h
index 7543301..eb0943a 100644
--- a/source3/include/messages.h
+++ b/source3/include/messages.h
@@ -69,6 +69,7 @@ struct messaging_backend {
        int (*send_fn)(struct server_id src,
                       struct server_id pid, int msg_type,
                       const struct iovec *iov, int iovlen,
+                      const int *fds, size_t num_fds,
                       struct messaging_backend *backend);
        void *private_data;
 };
@@ -113,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);
 
diff --git a/source3/lib/dbwrap/dbwrap_watch.c 
b/source3/lib/dbwrap/dbwrap_watch.c
index a5f1ebd..9ff8fc2 100644
--- a/source3/lib/dbwrap/dbwrap_watch.c
+++ b/source3/lib/dbwrap/dbwrap_watch.c
@@ -299,6 +299,9 @@ static bool dbwrap_record_watch_filter(struct messaging_rec 
*rec,
        if (rec->msg_type != MSG_DBWRAP_MODIFIED) {
                return false;
        }
+       if (rec->num_fds != 0) {
+               return false;
+       }
        if (rec->buf.length != state->w_key.dsize) {
                return false;
        }
diff --git a/source3/lib/messages.c b/source3/lib/messages.c
index 52d6538..84147de 100644
--- a/source3/lib/messages.c
+++ b/source3/lib/messages.c
@@ -204,6 +204,7 @@ bool message_send_all(struct messaging_context *msg_ctx,
 }
 
 static void messaging_recv_cb(const uint8_t *msg, size_t msg_len,
+                             const int *fds, size_t num_fds,
                              void *private_data)
 {
        struct messaging_context *msg_ctx = talloc_get_type_abort(
@@ -211,19 +212,38 @@ static void messaging_recv_cb(const uint8_t *msg, size_t 
msg_len,
        const struct messaging_hdr *hdr;
        struct server_id_buf idbuf;
        struct messaging_rec rec;
+       int64_t fds64[MIN(num_fds, INT8_MAX)];
+       size_t i;
 
        if (msg_len < sizeof(*hdr)) {
+               for (i=0; i < num_fds; i++) {
+                       close(fds[i]);
+               }
                DEBUG(1, ("message too short: %u\n", (unsigned)msg_len));
                return;
        }
 
+       if (num_fds > INT8_MAX) {
+               for (i=0; i < num_fds; i++) {
+                       close(fds[i]);
+               }
+               DEBUG(1, ("too many fds: %u\n", (unsigned)num_fds));
+               return;
+       }
+
+       for (i=0; i < num_fds; i++) {
+               fds64[i] = fds[i];
+       }
+
        /*
         * messages_dgm guarantees alignment, so we can cast here
         */
        hdr = (const struct messaging_hdr *)msg;
 
-       DEBUG(10, ("%s: Received message 0x%x len %u from %s\n", __func__,
-                  (unsigned)hdr->msg_type, (unsigned)(msg_len - sizeof(*hdr)),
+       DEBUG(10, ("%s: Received message 0x%x len %u (num_fds:%u) from %s\n",
+                  __func__, (unsigned)hdr->msg_type,
+                  (unsigned)(msg_len - sizeof(*hdr)),
+                  (unsigned)num_fds,
                   server_id_str_buf(hdr->src, &idbuf)));
 
        rec = (struct messaging_rec) {
@@ -232,7 +252,9 @@ static void messaging_recv_cb(const uint8_t *msg, size_t 
msg_len,
                .src = hdr->src,
                .dest = hdr->dst,
                .buf.data = discard_const_p(uint8, msg) + sizeof(*hdr),
-               .buf.length = msg_len - sizeof(*hdr)
+               .buf.length = msg_len - sizeof(*hdr),
+               .num_fds = num_fds,
+               .fds = fds64,
        };
 
        messaging_dispatch_rec(msg_ctx, &rec);
@@ -420,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,
@@ -433,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;
@@ -443,9 +466,18 @@ 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,
                                               msg_ctx->remote);
                if (ret != 0) {
                        return map_nt_error_from_unix(ret);
@@ -461,16 +493,23 @@ 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;
                }
 
-               rec.msg_version = MESSAGE_VERSION;
-               rec.msg_type = msg_type & MSG_TYPE_MASK;
-               rec.dest = server;
-               rec.src = msg_ctx->id;
-               rec.buf = data_blob_const(buf, talloc_get_size(buf));
+               rec = (struct messaging_rec) {
+                       .msg_version = MESSAGE_VERSION,
+                       .msg_type = msg_type & MSG_TYPE_MASK,
+                       .dest = server,
+                       .src = msg_ctx->id,
+                       .buf = data_blob_const(buf, talloc_get_size(buf)),
+               };
+
                messaging_dispatch_rec(msg_ctx, &rec);
                TALLOC_FREE(buf);
                return NT_STATUS_OK;
@@ -485,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);
+       ret = messaging_dgm_send(server.pid, iov2, iovlen+1, fds, num_fds);
        unbecome_root();
 
        if (ret != 0) {
@@ -498,9 +537,10 @@ static struct messaging_rec *messaging_rec_dup(TALLOC_CTX 
*mem_ctx,
                                               struct messaging_rec *rec)
 {
        struct messaging_rec *result;
+       size_t fds_size = sizeof(int64_t) * rec->num_fds;
 
-       result = talloc_pooled_object(mem_ctx, struct messaging_rec,
-                                     1, rec->buf.length);
+       result = talloc_pooled_object(mem_ctx, struct messaging_rec, 2,
+                                     rec->buf.length + fds_size);
        if (result == NULL) {
                return NULL;
        }
@@ -510,6 +550,13 @@ static struct messaging_rec *messaging_rec_dup(TALLOC_CTX 
*mem_ctx,
 
        result->buf.data = talloc_memdup(result, rec->buf.data,
                                         rec->buf.length);
+
+       result->fds = NULL;
+       if (result->num_fds > 0) {
+               result->fds = talloc_array(result, int64_t, result->num_fds);
+               memcpy(result->fds, rec->fds, fds_size);
+       }
+
        return result;
 }
 
@@ -689,6 +736,10 @@ static bool messaging_read_filter(struct messaging_rec 
*rec,
        struct messaging_read_state *state = talloc_get_type_abort(
                private_data, struct messaging_read_state);
 
+       if (rec->num_fds != 0) {
+               return false;
+       }
+
        return rec->msg_type == state->msg_type;
 }
 
@@ -822,6 +873,7 @@ void messaging_dispatch_rec(struct messaging_context 
*msg_ctx,
 {
        struct messaging_callback *cb, *next;
        unsigned i;
+       size_t j;
 
        for (cb = msg_ctx->callbacks; cb != NULL; cb = next) {
                next = cb->next;
@@ -829,6 +881,16 @@ void messaging_dispatch_rec(struct messaging_context 
*msg_ctx,
                        continue;
                }
 
+               /*
+                * the old style callbacks don't support fd passing
+                */
+               for (j=0; j < rec->num_fds; j++) {
+                       int fd = rec->fds[j];
+                       close(fd);
+               }
+               rec->num_fds = 0;
+               rec->fds = NULL;
+
                if (server_id_same_process(&rec->src, &rec->dest)) {
                        /*
                         * This is a self-send. We are called here from
@@ -856,6 +918,12 @@ void messaging_dispatch_rec(struct messaging_context 
*msg_ctx,
        }
 
        if (!messaging_append_new_waiters(msg_ctx)) {
+               for (j=0; j < rec->num_fds; j++) {
+                       int fd = rec->fds[j];
+                       close(fd);
+               }
+               rec->num_fds = 0;
+               rec->fds = NULL;
                return;
        }
 
@@ -886,10 +954,26 @@ void messaging_dispatch_rec(struct messaging_context 
*msg_ctx,
                        req, struct messaging_filtered_read_state);
                if (state->filter(rec, state->private_data)) {
                        messaging_filtered_read_done(req, rec);
+
+                       /*
+                        * Only the first one gets the fd-array
+                        */
+                       rec->num_fds = 0;
+                       rec->fds = NULL;
                }
 
                i += 1;
        }
+
+       /*
+        * If the fd-array isn't used, just close it.
+        */
+       for (j=0; j < rec->num_fds; j++) {
+               int fd = rec->fds[j];
+               close(fd);
+       }
+       rec->num_fds = 0;
+       rec->fds = NULL;
 }
 
 static int mess_parent_dgm_cleanup(void *private_data);
diff --git a/source3/lib/messages_ctdbd.c b/source3/lib/messages_ctdbd.c
index add089d..3d600bf 100644
--- a/source3/lib/messages_ctdbd.c
+++ b/source3/lib/messages_ctdbd.c
@@ -91,26 +91,31 @@ struct ctdbd_connection *messaging_ctdbd_connection(void)
 static int messaging_ctdb_send(struct server_id src,
                               struct server_id pid, int msg_type,
                               const struct iovec *iov, int iovlen,
+                              const int *fds, size_t num_fds,
                               struct messaging_backend *backend)
 {
        struct messaging_ctdbd_context *ctx = talloc_get_type_abort(
                backend->private_data, struct messaging_ctdbd_context);
-
        struct messaging_rec msg;
        uint8_t *buf;
        NTSTATUS status;
 
+       if (num_fds > 0) {
+               return ENOSYS;
+       }
+
        buf = iov_buf(talloc_tos(), iov, iovlen);
        if (buf == NULL) {
                return ENOMEM;
        }
 
-
-       msg.msg_version = MESSAGE_VERSION;
-       msg.msg_type    = msg_type;
-       msg.dest        = pid;
-       msg.src         = src;
-       msg.buf         = data_blob_const(buf, talloc_get_size(buf));
+       msg = (struct messaging_rec) {
+               .msg_version    = MESSAGE_VERSION,
+               .msg_type       = msg_type,
+               .dest           = pid,
+               .src            = src,
+               .buf            = data_blob_const(buf, talloc_get_size(buf)),
+       };
 
        status = ctdbd_messaging_send(ctx->conn, pid.vnn, pid.pid, &msg);
 
diff --git a/source3/lib/messages_dgm.c b/source3/lib/messages_dgm.c
index 471aed4..30ab743 100644
--- a/source3/lib/messages_dgm.c
+++ b/source3/lib/messages_dgm.c
@@ -44,6 +44,8 @@ struct messaging_dgm_context {
 
        void (*recv_cb)(const uint8_t *msg,
                        size_t msg_len,
+                       const int *fds,
+                       size_t num_fds,
                        void *private_data);
        void *recv_cb_private_data;
 
@@ -54,6 +56,7 @@ static struct messaging_dgm_context *global_dgm_context;
 
 static void messaging_dgm_recv(struct unix_msg_ctx *ctx,
                               uint8_t *msg, size_t msg_len,
+                              int *fds, size_t num_fds,
                               void *private_data);
 
 static int messaging_dgm_lockfile_name(struct sun_path_buf *buf,
@@ -178,6 +181,8 @@ int messaging_dgm_init(struct tevent_context *ev,
                       uid_t dir_owner,
                       void (*recv_cb)(const uint8_t *msg,
                                       size_t msg_len,
+                                      const int *fds,
+                                      size_t num_fds,
                                       void *private_data),
                       void *recv_cb_private_data)
 {
@@ -296,7 +301,9 @@ void messaging_dgm_destroy(void)
        TALLOC_FREE(global_dgm_context);
 }
 
-int messaging_dgm_send(pid_t pid, const struct iovec *iov, int iovlen)
+int messaging_dgm_send(pid_t pid,
+                      const struct iovec *iov, int iovlen,
+                      const int *fds, size_t num_fds)
 {
        struct messaging_dgm_context *ctx = global_dgm_context;
        struct sockaddr_un dst;
@@ -317,19 +324,21 @@ int messaging_dgm_send(pid_t pid, const struct iovec 
*iov, int iovlen)
 
        DEBUG(10, ("%s: Sending message to %u\n", __func__, (unsigned)pid));
 
-       ret = unix_msg_send(ctx->dgm_ctx, &dst, iov, iovlen);
+       ret = unix_msg_send(ctx->dgm_ctx, &dst, iov, iovlen, fds, num_fds);
 
        return ret;
 }
 
 static void messaging_dgm_recv(struct unix_msg_ctx *ctx,
                               uint8_t *msg, size_t msg_len,
+                              int *fds, size_t num_fds,
                               void *private_data)
 {
        struct messaging_dgm_context *dgm_ctx = talloc_get_type_abort(
                private_data, struct messaging_dgm_context);
 
-       dgm_ctx->recv_cb(msg, msg_len, dgm_ctx->recv_cb_private_data);
+       dgm_ctx->recv_cb(msg, msg_len, fds, num_fds,
+                        dgm_ctx->recv_cb_private_data);
 }
 
 int messaging_dgm_cleanup(pid_t pid)
diff --git a/source3/lib/messages_dgm.h b/source3/lib/messages_dgm.h
index 169d863..be4b1e5 100644
--- a/source3/lib/messages_dgm.h
+++ b/source3/lib/messages_dgm.h
@@ -26,10 +26,14 @@ int messaging_dgm_init(struct tevent_context *ev,
                       uid_t dir_owner,
                       void (*recv_cb)(const uint8_t *msg,
                                       size_t msg_len,
+                                      const int *fds,
+                                      size_t num_fds,
                                       void *private_data),
                       void *recv_cb_private_data);
 void messaging_dgm_destroy(void);
-int messaging_dgm_send(pid_t pid, const struct iovec *iov, int iovlen);
+int messaging_dgm_send(pid_t pid,
+                      const struct iovec *iov, int iovlen,
+                      const int *fds, size_t num_fds);
 int messaging_dgm_cleanup(pid_t pid);
 int messaging_dgm_wipe(void);
 void *messaging_dgm_register_tevent_context(TALLOC_CTX *mem_ctx,
diff --git a/source3/lib/unix_msg/test_drain.c 
b/source3/lib/unix_msg/test_drain.c
index abaf5ef..5b6a930 100644
--- a/source3/lib/unix_msg/test_drain.c
+++ b/source3/lib/unix_msg/test_drain.c
@@ -12,6 +12,7 @@ struct cb_state {
 
 static void recv_cb(struct unix_msg_ctx *ctx,
                    uint8_t *msg, size_t msg_len,
+                   int *fds, size_t num_fds,
                    void *private_data);
 
 int main(int argc, const char *argv[])
@@ -64,6 +65,7 @@ int main(int argc, const char *argv[])
 
 static void recv_cb(struct unix_msg_ctx *ctx,
                    uint8_t *msg, size_t msg_len,
+                   int *fds, size_t num_fds,
                    void *private_data)
 {
        unsigned num;
diff --git a/source3/lib/unix_msg/test_source.c 
b/source3/lib/unix_msg/test_source.c
index 7f6a7a5..5224ebf 100644
--- a/source3/lib/unix_msg/test_source.c
+++ b/source3/lib/unix_msg/test_source.c
@@ -65,7 +65,7 @@ int main(int argc, const char *argv[])
                unsigned j;
 
                for (j=0; j<100000; j++) {
-                       ret = unix_msg_send(ctxs[i], &dst, &iov, 1);
+                       ret = unix_msg_send(ctxs[i], &dst, &iov, 1, NULL, 0);
                        if (ret != 0) {
                                fprintf(stderr, "unix_msg_send failed: %s\n",
                                        strerror(ret));
diff --git a/source3/lib/unix_msg/tests.c b/source3/lib/unix_msg/tests.c
index 37ff304..df094af 100644
--- a/source3/lib/unix_msg/tests.c
+++ b/source3/lib/unix_msg/tests.c
@@ -11,6 +11,7 @@ struct cb_state {
 
 static void recv_cb(struct unix_msg_ctx *ctx,
                    uint8_t *msg, size_t msg_len,
+                   int *fds, size_t num_fds,
                    void *private_data);
 
 static void expect_messages(struct tevent_context *ev, struct cb_state *state,
@@ -102,7 +103,7 @@ int main(void)
        state.buf = NULL;
        state.buflen = 0;
 
-       ret = unix_msg_send(ctx1, &addr2, NULL, 0);
+       ret = unix_msg_send(ctx1, &addr2, NULL, 0, NULL, 0);
        if (ret != 0) {
                fprintf(stderr, "unix_msg_send failed: %s\n",
                        strerror(ret));
@@ -119,7 +120,7 @@ int main(void)
        state.buf = &msg;
        state.buflen = sizeof(msg);
 
-       ret = unix_msg_send(ctx1, &addr2, &iov, 1);
+       ret = unix_msg_send(ctx1, &addr2, &iov, 1, NULL, 0);
        if (ret != 0) {
                fprintf(stderr, "unix_msg_send failed: %s\n",
                        strerror(ret));
@@ -140,13 +141,13 @@ int main(void)
        state.buflen = sizeof(buf);
 
        for (i=0; i<3; i++) {
-               ret = unix_msg_send(ctx1, &addr2, &iov, 1);
+               ret = unix_msg_send(ctx1, &addr2, &iov, 1, NULL, 0);
                if (ret != 0) {
                        fprintf(stderr, "unix_msg_send failed: %s\n",
                                strerror(ret));
                        return 1;
                }
-               ret = unix_msg_send(ctx2, &addr2, &iov, 1);
+               ret = unix_msg_send(ctx2, &addr2, &iov, 1, NULL, 0);
                if (ret != 0) {
                        fprintf(stderr, "unix_msg_send failed: %s\n",
                                strerror(ret));
@@ -185,7 +186,7 @@ int main(void)
                        j++;
                }
 
-               ret = unix_msg_send(ctx1, &addr1, iovs, j);
+               ret = unix_msg_send(ctx1, &addr1, iovs, j, NULL, 0);
                if (ret != 0) {
                        fprintf(stderr, "unix_msg_send failed: %s\n",
                                strerror(ret));
@@ -198,13 +199,13 @@ int main(void)
        printf("Filling send queues before freeing\n");
 
        for (i=0; i<5; i++) {
-               ret = unix_msg_send(ctx1, &addr2, &iov, 1);


-- 
Samba Shared Repository

Reply via email to