From a093a76dc14303fd1c42fb2c0b87faf3748815e4 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 28 Jul 2006 22:42:39 +0000 Subject: r17293: After the results from the cluster tests in Germany, fix the messaging code to call the efficient calls : save_re_uid() set_effective_uid(0); messaging_op restore_re_uid(); instead of using heavyweight become_root()/unbecome_root() pairs around all messaging code. Fixup the messaging code to ensure sec_init() is called (only once) so that non-root processes still work when sending messages. This is a lighter weight solution to become_root()/unbecome_root() (which swaps all the supplemental groups) and should be more efficient. I will migrate all server code over to using this (a similar technique should be used in the passdb backend where needed). Jeremy. (This used to be commit 4ace291278d9a44f5c577bdd3b282c1231e543df) --- source3/smbd/blocking.c | 3 --- source3/smbd/close.c | 2 -- source3/smbd/open.c | 2 -- source3/smbd/oplock.c | 11 ----------- 4 files changed, 18 deletions(-) (limited to 'source3/smbd') diff --git a/source3/smbd/blocking.c b/source3/smbd/blocking.c index a0b93f5032..ed57c9f621 100644 --- a/source3/smbd/blocking.c +++ b/source3/smbd/blocking.c @@ -837,9 +837,6 @@ BOOL blocking_lock_cancel(files_struct *fsp, memcpy(msg, &blr, sizeof(blr)); memcpy(&msg[sizeof(blr)], &err, sizeof(NTSTATUS)); - /* Don't need to be root here as we're only ever - sending to ourselves. */ - message_send_pid(pid_to_procid(sys_getpid()), MSG_SMB_BLOCKING_LOCK_CANCEL, &msg, sizeof(msg), True); diff --git a/source3/smbd/close.c b/source3/smbd/close.c index 08e4a24a56..a3ddcae11d 100644 --- a/source3/smbd/close.c +++ b/source3/smbd/close.c @@ -134,10 +134,8 @@ static void notify_deferred_opens(struct share_mode_lock *lck) share_mode_entry_to_message(msg, e); - become_root(); message_send_pid(e->pid, MSG_SMB_OPEN_RETRY, msg, MSG_SMB_SHARE_MODE_ENTRY_SIZE, True); - unbecome_root(); } } } diff --git a/source3/smbd/open.c b/source3/smbd/open.c index ef59da6447..5c10c59054 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -713,10 +713,8 @@ static BOOL delay_for_oplocks(struct share_mode_lock *lck, SSVAL(msg,6,exclusive->op_type | FORCE_OPLOCK_BREAK_TO_NONE); } - become_root(); ret = message_send_pid(exclusive->pid, MSG_SMB_BREAK_REQUEST, msg, MSG_SMB_SHARE_MODE_ENTRY_SIZE, True); - unbecome_root(); if (!ret) { DEBUG(3, ("Could not send oplock break message\n")); } diff --git a/source3/smbd/oplock.c b/source3/smbd/oplock.c index 99ce79296f..d9850ee051 100644 --- a/source3/smbd/oplock.c +++ b/source3/smbd/oplock.c @@ -504,13 +504,10 @@ static void process_oplock_break_message(int msg_type, struct process_id src, * get to process this message, we have closed the file. Reply * with 'ok, oplock broken' */ DEBUG(3, ("Did not find fsp\n")); - become_root(); /* We just send the same message back. */ message_send_pid(src, MSG_SMB_BREAK_RESPONSE, buf, MSG_SMB_SHARE_MODE_ENTRY_SIZE, True); - - unbecome_root(); return; } @@ -529,13 +526,9 @@ static void process_oplock_break_message(int msg_type, struct process_id src, DEBUG(3, ("Already downgraded oplock on 0x%x/%.0f: %s\n", (unsigned int)fsp->dev, (double)fsp->inode, fsp->fsp_name)); - become_root(); - /* We just send the same message back. */ message_send_pid(src, MSG_SMB_BREAK_RESPONSE, buf, MSG_SMB_SHARE_MODE_ENTRY_SIZE, True); - - unbecome_root(); return; } @@ -656,7 +649,6 @@ void reply_to_oplock_break_requests(files_struct *fsp) { int i; - become_root(); for (i=0; inum_pending_break_messages; i++) { struct share_mode_entry *e = &fsp->pending_break_messages[i]; char msg[MSG_SMB_SHARE_MODE_ENTRY_SIZE]; @@ -666,7 +658,6 @@ void reply_to_oplock_break_requests(files_struct *fsp) message_send_pid(e->pid, MSG_SMB_BREAK_RESPONSE, msg, MSG_SMB_SHARE_MODE_ENTRY_SIZE, True); } - unbecome_root(); SAFE_FREE(fsp->pending_break_messages); fsp->num_pending_break_messages = 0; @@ -801,10 +792,8 @@ void release_level_2_oplocks_on_change(files_struct *fsp) share_mode_entry_to_message(msg, share_entry); - become_root(); message_send_pid(share_entry->pid, MSG_SMB_ASYNC_LEVEL2_BREAK, msg, MSG_SMB_SHARE_MODE_ENTRY_SIZE, True); - unbecome_root(); } /* We let the message receivers handle removing the oplock state -- cgit