s3-talloc Change TALLOC_ZERO_P() to talloc_zero()
[garming/samba-autobuild/.git] / source3 / auth / check_samsec.c
index 8460110b06669fc0e9d0f66ae7c4e0abdc004bbf..2d3cb657859965604acf3ad4292bdda0f4c05e3d 100644 (file)
@@ -21,7 +21,9 @@
 */
 
 #include "includes.h"
+#include "auth.h"
 #include "../libcli/auth/libcli_auth.h"
+#include "passdb.h"
 
 #undef DBGC_CLASS
 #define DBGC_CLASS DBGC_AUTH
@@ -373,7 +375,7 @@ NTSTATUS check_sam_security(const DATA_BLOB *challenge,
        NTSTATUS update_login_attempts_status;
        DATA_BLOB user_sess_key = data_blob_null;
        DATA_BLOB lm_sess_key = data_blob_null;
-       bool updated_autolock = False, updated_badpw = False;
+       bool updated_badpw = False;
        const char *username;
        const uint8_t *nt_pw;
        const uint8_t *lm_pw;
@@ -490,7 +492,7 @@ NTSTATUS check_sam_security(const DATA_BLOB *challenge,
                goto done;
        }
 
-       (*server_info)->user_session_key =
+       (*server_info)->session_key =
                data_blob_talloc(*server_info, user_sess_key.data,
                                 user_sess_key.length);
        data_blob_free(&user_sess_key);
@@ -519,29 +521,31 @@ NTSTATUS check_sam_security_info3(const DATA_BLOB *challenge,
        struct auth_serversupplied_info *server_info = NULL;
        struct netr_SamInfo3 *info3;
        NTSTATUS status;
-       TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx);
-       if (!tmp_ctx) {
-               return NT_STATUS_NO_MEMORY;
-       }
-       status = check_sam_security(challenge, tmp_ctx, user_info, &server_info);
+       TALLOC_CTX *frame = talloc_stackframe();
+
+       status = check_sam_security(challenge, talloc_tos(), user_info,
+                                   &server_info);
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(10, ("check_sam_security failed: %s\n",
                           nt_errstr(status)));
-               return status;
+               goto done;
        }
 
-       info3 = TALLOC_ZERO_P(mem_ctx, struct netr_SamInfo3);
+       info3 = talloc_zero(mem_ctx, struct netr_SamInfo3);
        if (info3 == NULL) {
-               talloc_free(tmp_ctx);
-               return NT_STATUS_NO_MEMORY;
+               status = NT_STATUS_NO_MEMORY;
+               goto done;
        }
 
        status = serverinfo_to_SamInfo3(server_info, NULL, 0, info3);
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(10, ("serverinfo_to_SamInfo3 failed: %s\n",
                           nt_errstr(status)));
-               return status;
+               goto done;
        }
        *pinfo3 = info3;
-       return NT_STATUS_OK;
+       status =  NT_STATUS_OK;
+done:
+       TALLOC_FREE(frame);
+       return status;
 }