From 5ef6775919e83fdae66385db8d1579fa259602f1 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 23 May 2018 14:26:37 +0200 Subject: [PATCH] smbd: don't call change_to_root_user() before change_to_guest() This is just an optimization and it makes it clearer that calling change_to_root_user() just before change_to_guest() is useless and confusing. We call change_to_guest() before set_current_service() now, but that has no impact as we pass 'do_chdir=false' as AS_GUEST is never mixed with AS_USER or DO_CHDIR. Signed-off-by: Stefan Metzmacher Reviewed-by: Jeremy Allison Autobuild-User(master): Stefan Metzmacher Autobuild-Date(master): Thu Jun 14 23:38:55 CEST 2018 on sn-devel-144 --- source3/smbd/process.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/source3/smbd/process.c b/source3/smbd/process.c index e0528f3498c..1c54ca49146 100644 --- a/source3/smbd/process.c +++ b/source3/smbd/process.c @@ -1624,6 +1624,15 @@ static connection_struct *switch_message(uint8_t type, struct smb_request *req) reply_nterror(req, NT_STATUS_ACCESS_DENIED); return conn; } + } else if (flags & AS_GUEST) { + /* + * Does this protocol need to be run as guest? (Only archane + * messenger service requests have this...) + */ + if (!change_to_guest()) { + reply_nterror(req, NT_STATUS_ACCESS_DENIED); + return conn; + } } else { /* This call needs to be run as root */ change_to_root_user(); @@ -1656,17 +1665,6 @@ static connection_struct *switch_message(uint8_t type, struct smb_request *req) conn->num_smb_operations++; } - /* - * Does this protocol need to be run as guest? (Only archane - * messenger service requests have this...) - */ - if (flags & AS_GUEST) { - if (!change_to_guest()) { - reply_nterror(req, NT_STATUS_ACCESS_DENIED); - return conn; - } - } - /* * Update encryption and signing state tracking flags that are * used by smbstatus to display signing and encryption status. -- 2.34.1