From 28f750643bac2049eeeaab23d7d2d9a5a6256bcd Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 12 Nov 2014 16:42:59 +0100 Subject: [PATCH] messaging3: Add messaging_send_iov_from In the notifyd code it will be very helpful to fake source server_ids Signed-off-by: Volker Lendecke Reviewed-by: Jeremy Allison --- source3/include/messages.h | 5 +++++ source3/lib/messages.c | 30 ++++++++++++++++++++---------- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/source3/include/messages.h b/source3/include/messages.h index 80b6c19bf1f..3db675611e0 100644 --- a/source3/include/messages.h +++ b/source3/include/messages.h @@ -123,6 +123,11 @@ NTSTATUS messaging_send(struct messaging_context *msg_ctx, NTSTATUS messaging_send_buf(struct messaging_context *msg_ctx, struct server_id server, uint32_t msg_type, const uint8_t *buf, size_t len); +NTSTATUS messaging_send_iov_from(struct messaging_context *msg_ctx, + struct server_id src, struct server_id dst, + uint32_t msg_type, + const struct iovec *iov, int iovlen, + const int *fds, size_t num_fds); NTSTATUS messaging_send_iov(struct messaging_context *msg_ctx, struct server_id server, uint32_t msg_type, const struct iovec *iov, int iovlen, diff --git a/source3/lib/messages.c b/source3/lib/messages.c index 27114687189..0866e7d38c7 100644 --- a/source3/lib/messages.c +++ b/source3/lib/messages.c @@ -489,16 +489,17 @@ NTSTATUS messaging_send_buf(struct messaging_context *msg_ctx, return messaging_send(msg_ctx, server, msg_type, &blob); } -NTSTATUS messaging_send_iov(struct messaging_context *msg_ctx, - struct server_id server, uint32_t msg_type, - const struct iovec *iov, int iovlen, - const int *fds, size_t num_fds) +NTSTATUS messaging_send_iov_from(struct messaging_context *msg_ctx, + struct server_id src, struct server_id dst, + uint32_t msg_type, + const struct iovec *iov, int iovlen, + const int *fds, size_t num_fds) { int ret; struct messaging_hdr hdr; struct iovec iov2[iovlen+1]; - if (server_id_is_disconnected(&server)) { + if (server_id_is_disconnected(&dst)) { return NT_STATUS_INVALID_PARAMETER_MIX; } @@ -506,12 +507,12 @@ NTSTATUS messaging_send_iov(struct messaging_context *msg_ctx, return NT_STATUS_INVALID_PARAMETER_MIX; } - if (!procid_is_local(&server)) { + if (!procid_is_local(&dst)) { if (num_fds > 0) { return NT_STATUS_NOT_SUPPORTED; } - ret = msg_ctx->remote->send_fn(msg_ctx->id, server, + ret = msg_ctx->remote->send_fn(src, dst, msg_type, iov, iovlen, NULL, 0, msg_ctx->remote); @@ -524,14 +525,14 @@ NTSTATUS messaging_send_iov(struct messaging_context *msg_ctx, ZERO_STRUCT(hdr); hdr = (struct messaging_hdr) { .msg_type = msg_type, - .dst = server, - .src = msg_ctx->id + .dst = dst, + .src = src }; iov2[0] = (struct iovec){ .iov_base = &hdr, .iov_len = sizeof(hdr) }; memcpy(&iov2[1], iov, iovlen * sizeof(*iov)); become_root(); - ret = messaging_dgm_send(server.pid, iov2, iovlen+1, fds, num_fds); + ret = messaging_dgm_send(dst.pid, iov2, iovlen+1, fds, num_fds); unbecome_root(); if (ret != 0) { @@ -540,6 +541,15 @@ NTSTATUS messaging_send_iov(struct messaging_context *msg_ctx, return NT_STATUS_OK; } +NTSTATUS messaging_send_iov(struct messaging_context *msg_ctx, + struct server_id dst, uint32_t msg_type, + const struct iovec *iov, int iovlen, + const int *fds, size_t num_fds) +{ + return messaging_send_iov_from(msg_ctx, msg_ctx->id, dst, msg_type, + iov, iovlen, fds, num_fds); +} + static struct messaging_rec *messaging_rec_dup(TALLOC_CTX *mem_ctx, struct messaging_rec *rec) { -- 2.11.4.GIT