]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: don't call change_to_root_user() before change_to_guest()
authorStefan Metzmacher <metze@samba.org>
Wed, 23 May 2018 12:26:37 +0000 (14:26 +0200)
committerStefan Metzmacher <metze@samba.org>
Thu, 14 Jun 2018 21:38:55 +0000 (23:38 +0200)
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 <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Thu Jun 14 23:38:55 CEST 2018 on sn-devel-144

source3/smbd/process.c

index e0528f3498cc83abb63061b88c6ca079747b92dd..1c54ca491462987e72f44a9164a3cc9b2e4eaa85 100644 (file)
@@ -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.