From fc424b28cd54f4ff5737417db1e1f8059cad80db Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 7 Feb 2018 11:36:51 +0100 Subject: [PATCH] smbd: Pass "file_id" explicitly into share_mode_entry_to_message() Signed-off-by: Volker Lendecke Reviewed-by: Jeremy Allison --- source3/rpc_server/srvsvc/srv_srvsvc_nt.c | 2 +- source3/smbd/open.c | 2 +- source3/smbd/oplock.c | 11 ++++++++--- source3/smbd/proto.h | 3 ++- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/source3/rpc_server/srvsvc/srv_srvsvc_nt.c b/source3/rpc_server/srvsvc/srv_srvsvc_nt.c index e0561b6e7e0..8a738b396cd 100644 --- a/source3/rpc_server/srvsvc/srv_srvsvc_nt.c +++ b/source3/rpc_server/srvsvc/srv_srvsvc_nt.c @@ -2725,7 +2725,7 @@ static int enum_file_close_fn(const struct share_mode_entry *e, DBG_DEBUG("request to close file %s, %s\n", sharepath, share_mode_str(talloc_tos(), 0, id, e)); - share_mode_entry_to_message(msg, e); + share_mode_entry_to_message(msg, &e->id, e); state->r->out.result = ntstatus_to_werror( messaging_send_buf(state->msg_ctx, diff --git a/source3/smbd/open.c b/source3/smbd/open.c index 9f96d581212..995417bc764 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -1701,7 +1701,7 @@ NTSTATUS send_break_message(struct messaging_context *msg_ctx, server_id_str_buf(exclusive->pid, &tmp))); /* Create the message. */ - share_mode_entry_to_message(msg, exclusive); + share_mode_entry_to_message(msg, &exclusive->id, exclusive); /* Overload entry->op_type */ /* diff --git a/source3/smbd/oplock.c b/source3/smbd/oplock.c index e848b5e0d86..419296eb060 100644 --- a/source3/smbd/oplock.c +++ b/source3/smbd/oplock.c @@ -1134,7 +1134,7 @@ static void send_break_to_none(struct messaging_context *msg_ctx, { char msg[MSG_SMB_SHARE_MODE_ENTRY_SIZE]; - share_mode_entry_to_message(msg, e); + share_mode_entry_to_message(msg, &e->id, e); /* Overload entry->op_type */ SSVAL(msg, OP_BREAK_MSG_OP_TYPE_OFFSET, NO_OPLOCK); @@ -1291,7 +1291,8 @@ void smbd_contend_level2_oplocks_end(files_struct *fsp, Linearize a share mode entry struct to an internal oplock break message. ****************************************************************************/ -void share_mode_entry_to_message(char *msg, const struct share_mode_entry *e) +void share_mode_entry_to_message(char *msg, const struct file_id *id, + const struct share_mode_entry *e) { SIVAL(msg,OP_BREAK_MSG_PID_OFFSET,(uint32_t)e->pid.pid); SBVAL(msg,OP_BREAK_MSG_MID_OFFSET,e->op_mid); @@ -1301,7 +1302,11 @@ void share_mode_entry_to_message(char *msg, const struct share_mode_entry *e) SIVAL(msg,OP_BREAK_MSG_PRIV_OFFSET,e->private_options); SIVAL(msg,OP_BREAK_MSG_TIME_SEC_OFFSET,(uint32_t)e->time.tv_sec); SIVAL(msg,OP_BREAK_MSG_TIME_USEC_OFFSET,(uint32_t)e->time.tv_usec); - push_file_id_24(msg+OP_BREAK_MSG_DEV_OFFSET, &e->id); + /* + * "id" used to be part of share_mode_entry, thus the strange + * place to put this. Feel free to move somewhere else :-) + */ + push_file_id_24(msg+OP_BREAK_MSG_DEV_OFFSET, id); SIVAL(msg,OP_BREAK_MSG_FILE_ID_OFFSET,e->share_file_id); SIVAL(msg,OP_BREAK_MSG_UID_OFFSET,e->uid); SSVAL(msg,OP_BREAK_MSG_FLAGS_OFFSET,e->flags); diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h index fe376404709..175b92bc1cd 100644 --- a/source3/smbd/proto.h +++ b/source3/smbd/proto.h @@ -722,7 +722,8 @@ void smbd_contend_level2_oplocks_begin(files_struct *fsp, enum level2_contention_type type); void smbd_contend_level2_oplocks_end(files_struct *fsp, enum level2_contention_type type); -void share_mode_entry_to_message(char *msg, const struct share_mode_entry *e); +void share_mode_entry_to_message(char *msg, const struct file_id *id, + const struct share_mode_entry *e); void message_to_share_mode_entry(struct share_mode_entry *e, const char *msg); bool init_oplocks(struct smbd_server_connection *sconn); void init_kernel_oplocks(struct smbd_server_connection *sconn); -- 2.11.4.GIT