s3:smbd: inline check_guest_password() into reply_sesssetup_and_X()
authorStefan Metzmacher <metze@samba.org>
Sun, 18 Jun 2017 10:08:58 +0000 (12:08 +0200)
committerStefan Metzmacher <metze@samba.org>
Mon, 26 Jun 2017 06:47:14 +0000 (08:47 +0200)
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source3/smbd/sesssetup.c

index 80dc77aa468ea9c38510fa31a5b7c1cd3a4fd366..8a5041bb695d87d81ead90df3bd7b0d0a2bb39b4 100644 (file)
@@ -74,45 +74,6 @@ static int push_signature(uint8_t **outbuf)
        return result;
 }
 
-/****************************************************************************
- Do a 'guest' logon, getting back the
-****************************************************************************/
-
-static NTSTATUS check_guest_password(const struct tsocket_address *remote_address,
-                                    const struct tsocket_address *local_address,
-                                    TALLOC_CTX *mem_ctx, 
-                                    struct auth_session_info **session_info)
-{
-       struct auth4_context *auth_context;
-       struct auth_usersupplied_info *user_info = NULL;
-       uint8_t chal[8];
-       NTSTATUS nt_status;
-
-       DEBUG(3,("Got anonymous request\n"));
-
-       nt_status = make_auth4_context(talloc_tos(), &auth_context);
-       if (!NT_STATUS_IS_OK(nt_status)) {
-               return nt_status;
-       }
-
-       auth_context->get_ntlm_challenge(auth_context,
-                                        chal);
-
-       if (!make_user_info_guest(talloc_tos(), remote_address, local_address,
-                                 "SMB", &user_info)) {
-               TALLOC_FREE(auth_context);
-               return NT_STATUS_NO_MEMORY;
-       }
-
-       user_info->auth_description = "guest";
-
-       nt_status = auth_check_password_session_info(auth_context, 
-                                                    mem_ctx, user_info, session_info);
-       TALLOC_FREE(user_info);
-       TALLOC_FREE(auth_context);
-       return nt_status;
-}
-
 /****************************************************************************
  Reply to a session setup command.
  conn POINTER CAN BE NULL HERE !
@@ -885,11 +846,33 @@ void reply_sesssetup_and_X(struct smb_request *req)
        reload_services(sconn, conn_snum_used, true);
 
        if (!*user) {
+               struct auth4_context *auth_context = NULL;
 
-               nt_status = check_guest_password(sconn->remote_address,
-                                                sconn->local_address,
-                                                req, &session_info);
+               DEBUG(3,("Got anonymous request\n"));
+
+               nt_status = make_auth4_context(talloc_tos(), &auth_context);
+               if (NT_STATUS_IS_OK(nt_status)) {
+                       uint8_t chal[8];
 
+                       auth_context->get_ntlm_challenge(auth_context,
+                                                        chal);
+
+                       if (!make_user_info_guest(talloc_tos(),
+                                                 sconn->remote_address,
+                                                 sconn->local_address,
+                                                 "SMB", &user_info)) {
+                               nt_status =  NT_STATUS_NO_MEMORY;
+                       }
+
+                       if (NT_STATUS_IS_OK(nt_status)) {
+                               user_info->auth_description = "guest";
+                               nt_status = auth_check_password_session_info(
+                                                               auth_context,
+                                                               req, user_info,
+                                                               &session_info);
+                       }
+                       TALLOC_FREE(auth_context);
+               }
        } else if (doencrypt) {
                struct auth4_context *negprot_auth_context = NULL;
                negprot_auth_context = xconn->smb1.negprot.auth_context;