From 4ccd2dd8a2f78bcd53c047889b8043e8d95a6d55 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 14 Sep 2024 14:31:58 +0200 Subject: [PATCH] s4:torture/rpc: make use of dcerpc_binding_handle_transport_session_key() Signed-off-by: Stefan Metzmacher Reviewed-by: Ralph Boehme --- source4/torture/rpc/backupkey.c | 5 +++-- source4/torture/rpc/forest_trust.c | 5 +++-- source4/torture/rpc/lsa.c | 9 +++++---- source4/torture/rpc/samba3rpc.c | 18 ++++++++++++------ source4/torture/rpc/samr.c | 22 +++++++++++----------- source4/torture/rpc/samsync.c | 6 ++++-- source4/torture/rpc/session_key.c | 4 ++-- source4/torture/rpc/testjoin.c | 2 +- source4/torture/rpc/wkssvc.c | 4 ++-- 9 files changed, 43 insertions(+), 32 deletions(-) diff --git a/source4/torture/rpc/backupkey.c b/source4/torture/rpc/backupkey.c index 71cdf0f6e20..a38e034feac 100644 --- a/source4/torture/rpc/backupkey.c +++ b/source4/torture/rpc/backupkey.c @@ -1842,8 +1842,9 @@ static bool test_ServerWrap_encrypt_decrypt_manual(struct torture_context *tctx, preferred_key.data = r_query_secret.out.new_val->buf->data; preferred_key.length = r_query_secret.out.new_val->buf->size; - torture_assert_ntstatus_ok(tctx, dcerpc_fetch_session_key(lsa_p, &session_key), - "dcerpc_fetch_session_key failed"); + torture_assert_ntstatus_ok(tctx, + dcerpc_binding_handle_transport_session_key(lsa_b, tctx, &session_key), + "transport_session_key failed"); torture_assert_ntstatus_ok(tctx, sess_decrypt_blob(tctx, diff --git a/source4/torture/rpc/forest_trust.c b/source4/torture/rpc/forest_trust.c index 284d5e4441c..279dd4d92dc 100644 --- a/source4/torture/rpc/forest_trust.c +++ b/source4/torture/rpc/forest_trust.c @@ -813,6 +813,7 @@ static bool test_setup_trust(struct torture_context *tctx, DATA_BLOB *auth_blob) { + struct dcerpc_binding_handle *b = p->binding_handle; DATA_BLOB session_key; struct lsa_TrustDomainInfoAuthInfoInternal authinfo; NTSTATUS status; @@ -826,9 +827,9 @@ static bool test_setup_trust(struct torture_context *tctx, return false; } - status = dcerpc_fetch_session_key(p, &session_key); + status = dcerpc_binding_handle_transport_session_key(b, p, &session_key); if (!NT_STATUS_IS_OK(status)) { - torture_comment(tctx, "dcerpc_fetch_session_key failed - %s\n", + torture_comment(tctx, "transport_session_key failed - %s\n", nt_errstr(status)); return false; } diff --git a/source4/torture/rpc/lsa.c b/source4/torture/rpc/lsa.c index d91a5414de1..44ea8cc4bf5 100644 --- a/source4/torture/rpc/lsa.c +++ b/source4/torture/rpc/lsa.c @@ -1730,8 +1730,9 @@ static bool test_CreateSecret(struct dcerpc_pipe *p, torture_assert_ntstatus_ok(tctx, r2.out.result, "OpenSecret failed"); - torture_assert_ntstatus_ok(tctx, dcerpc_fetch_session_key(p, &session_key), - "dcerpc_fetch_session_key failed"); + torture_assert_ntstatus_ok(tctx, + dcerpc_binding_handle_transport_session_key(b, tctx, &session_key), + "transport_session_key failed"); enc_key = sess_encrypt_string(secret1, &session_key); @@ -4655,9 +4656,9 @@ static bool test_CreateTrustedDomainEx_common(struct dcerpc_pipe *p, domsid = talloc_array(tctx, struct dom_sid *, num_trusts); trustdom_handle = talloc_array(tctx, struct policy_handle, num_trusts); - status = dcerpc_fetch_session_key(p, &session_key); + status = dcerpc_binding_handle_transport_session_key(b, tctx, &session_key); if (!NT_STATUS_IS_OK(status)) { - torture_comment(tctx, "dcerpc_fetch_session_key failed - %s\n", nt_errstr(status)); + torture_comment(tctx, "transport_session_key failed - %s\n", nt_errstr(status)); return false; } diff --git a/source4/torture/rpc/samba3rpc.c b/source4/torture/rpc/samba3rpc.c index c6c1944cf8d..8b9cc2cb871 100644 --- a/source4/torture/rpc/samba3rpc.c +++ b/source4/torture/rpc/samba3rpc.c @@ -668,9 +668,11 @@ static bool create_user(struct torture_context *tctx, encode_pw_buffer(u_info.info23.password.data, password, STR_UNICODE); - status = dcerpc_fetch_session_key(samr_pipe, &session_key); + status = dcerpc_binding_handle_transport_session_key(samr_handle, + tctx, + &session_key); if (!NT_STATUS_IS_OK(status)) { - torture_comment(tctx, "dcerpc_fetch_session_key failed\n"); + torture_comment(tctx, "transport_session_key failed\n"); goto done; } @@ -890,9 +892,11 @@ static bool join3(struct torture_context *tctx, i21->password_expired = 1; */ - status = dcerpc_fetch_session_key(samr_pipe, &session_key); + status = dcerpc_binding_handle_transport_session_key(samr_handle, + tctx, + &session_key); if (!NT_STATUS_IS_OK(status)) { - torture_comment(tctx, "dcerpc_fetch_session_key failed: %s\n", + torture_comment(tctx, "transport_session_key failed: %s\n", nt_errstr(status)); goto done; } @@ -928,9 +932,11 @@ static bool join3(struct torture_context *tctx, /* just to make this test pass */ u_info.info24.password_expired = 1; - status = dcerpc_fetch_session_key(samr_pipe, &session_key); + status = dcerpc_binding_handle_transport_session_key(samr_handle, + tctx, + &session_key); if (!NT_STATUS_IS_OK(status)) { - torture_comment(tctx, "dcerpc_fetch_session_key failed\n"); + torture_comment(tctx, "transport_session_key failed\n"); goto done; } diff --git a/source4/torture/rpc/samr.c b/source4/torture/rpc/samr.c index 36dd86f6770..50a779db8df 100644 --- a/source4/torture/rpc/samr.c +++ b/source4/torture/rpc/samr.c @@ -645,7 +645,7 @@ static bool test_SetUserPass(struct dcerpc_pipe *p, struct torture_context *tctx u.info24.password_expired = 0; - status = dcerpc_fetch_session_key(p, &session_key); + status = dcerpc_binding_handle_transport_session_key(b, tctx, &session_key); if (!NT_STATUS_IS_OK(status)) { torture_result(tctx, TORTURE_FAIL, "SetUserInfo level %u - no session key - %s\n", s.in.level, nt_errstr(status)); @@ -710,7 +710,7 @@ static bool test_SetUserPass_23(struct dcerpc_pipe *p, struct torture_context *t u.info23.info.fields_present = fields_present; - status = dcerpc_fetch_session_key(p, &session_key); + status = dcerpc_binding_handle_transport_session_key(b, tctx, &session_key); if (!NT_STATUS_IS_OK(status)) { torture_result(tctx, TORTURE_FAIL, "SetUserInfo level %u - no session key - %s\n", s.in.level, nt_errstr(status)); @@ -739,7 +739,7 @@ static bool test_SetUserPass_23(struct dcerpc_pipe *p, struct torture_context *t *password = newpass; } - status = dcerpc_fetch_session_key(p, &session_key); + status = dcerpc_binding_handle_transport_session_key(b, tctx, &session_key); if (!NT_STATUS_IS_OK(status)) { torture_result(tctx, TORTURE_FAIL, "SetUserInfo level %u - no session key - %s\n", s.in.level, nt_errstr(status)); @@ -813,7 +813,7 @@ static bool test_SetUserPass_32(struct dcerpc_pipe *p, struct torture_context *t u.info32.info.fields_present = fields_present; - status = dcerpc_fetch_session_key(p, &session_key); + status = dcerpc_binding_handle_transport_session_key(b, tctx, &session_key); if (!NT_STATUS_IS_OK(status)) { torture_result(tctx, TORTURE_FAIL, @@ -938,7 +938,7 @@ static bool test_SetUserPass_31(struct dcerpc_pipe *p, struct torture_context *t u.info31.password_expired = 0; - status = dcerpc_fetch_session_key(p, &session_key); + status = dcerpc_binding_handle_transport_session_key(b, tctx, &session_key); if (!NT_STATUS_IS_OK(status)) { torture_result(tctx, TORTURE_FAIL, "SetUserInfo level %u - no session key - %s\n", s.in.level, nt_errstr(status)); @@ -1040,7 +1040,7 @@ static bool test_SetUserPassEx(struct dcerpc_pipe *p, struct torture_context *tc u.info26.password_expired = 0; - status = dcerpc_fetch_session_key(p, &session_key); + status = dcerpc_binding_handle_transport_session_key(b, tctx, &session_key); if (!NT_STATUS_IS_OK(status)) { torture_result(tctx, TORTURE_FAIL, "SetUserInfo level %u - no session key - %s\n", s.in.level, nt_errstr(status)); @@ -1133,7 +1133,7 @@ static bool test_SetUserPass_25(struct dcerpc_pipe *p, struct torture_context *t u.info25.info.fields_present = fields_present; - status = dcerpc_fetch_session_key(p, &session_key); + status = dcerpc_binding_handle_transport_session_key(b, tctx, &session_key); if (!NT_STATUS_IS_OK(status)) { torture_result(tctx, TORTURE_FAIL, "SetUserInfo level %u - no session key - %s\n", s.in.level, nt_errstr(status)); @@ -1228,7 +1228,7 @@ static bool test_SetUserPass_18(struct dcerpc_pipe *p, struct torture_context *t E_md4hash(newpass, nt_hash); E_deshash(newpass, lm_hash); - status = dcerpc_fetch_session_key(p, &session_key); + status = dcerpc_binding_handle_transport_session_key(b, tctx, &session_key); if (!NT_STATUS_IS_OK(status)) { torture_result(tctx, TORTURE_FAIL, "SetUserInfo level %u - no session key - %s\n", s.in.level, nt_errstr(status)); @@ -1316,7 +1316,7 @@ static bool test_SetUserPass_21(struct dcerpc_pipe *p, struct torture_context *t u.info21.nt_password_set = true; } - status = dcerpc_fetch_session_key(p, &session_key); + status = dcerpc_binding_handle_transport_session_key(b, tctx, &session_key); if (!NT_STATUS_IS_OK(status)) { torture_result(tctx, TORTURE_FAIL, "SetUserInfo level %u - no session key - %s\n", s.in.level, nt_errstr(status)); @@ -1506,7 +1506,7 @@ static bool test_SetUserPass_level_ex(struct dcerpc_pipe *p, break; } - status = dcerpc_fetch_session_key(p, &session_key); + status = dcerpc_binding_handle_transport_session_key(b, tctx, &session_key); if (!NT_STATUS_IS_OK(status)) { torture_result(tctx, TORTURE_FAIL, "SetUserInfo level %u - no session key - %s\n", s.in.level, nt_errstr(status)); @@ -3218,7 +3218,7 @@ bool test_ChangePasswordRandomBytes(struct dcerpc_pipe *p, struct torture_contex pw_data = data_blob_const(u.info25.password.data, 516); - status = dcerpc_fetch_session_key(p, &session_key); + status = dcerpc_binding_handle_transport_session_key(b, tctx, &session_key); if (!NT_STATUS_IS_OK(status)) { torture_result(tctx, TORTURE_FAIL, "SetUserInfo level %u - no session key - %s\n", s.in.level, nt_errstr(status)); diff --git a/source4/torture/rpc/samsync.c b/source4/torture/rpc/samsync.c index 9111df9feed..40bea6e8e2d 100644 --- a/source4/torture/rpc/samsync.c +++ b/source4/torture/rpc/samsync.c @@ -933,9 +933,11 @@ static bool samsync_handle_secret(struct torture_context *tctx, We would like to do this, but it is NOT_SUPPORTED on win2k3 TEST_SEC_DESC_EQUAL(secret->sdbuf, lsa, &sec_handle); */ - status = dcerpc_fetch_session_key(samsync_state->p_lsa, &session_key); + status = dcerpc_binding_handle_transport_session_key(samsync_state->b_lsa, + mem_ctx, + &session_key); if (!NT_STATUS_IS_OK(status)) { - torture_comment(tctx, "dcerpc_fetch_session_key failed - %s\n", nt_errstr(status)); + torture_comment(tctx, "transport_session_key failed - %s\n", nt_errstr(status)); return false; } diff --git a/source4/torture/rpc/session_key.c b/source4/torture/rpc/session_key.c index 96f9965a0bd..26acb0ccfff 100644 --- a/source4/torture/rpc/session_key.c +++ b/source4/torture/rpc/session_key.c @@ -66,8 +66,8 @@ static bool test_CreateSecret_basic(struct dcerpc_pipe *p, "CreateSecret failed"); torture_assert_ntstatus_ok(tctx, r.out.result, "CreateSecret failed"); - status = dcerpc_fetch_session_key(p, &session_key); - torture_assert_ntstatus_ok(tctx, status, "dcerpc_fetch_session_key failed"); + status = dcerpc_binding_handle_transport_session_key(b, tctx, &session_key); + torture_assert_ntstatus_ok(tctx, status, "transport_session_key failed"); enc_key = sess_encrypt_string(secret1, &session_key); diff --git a/source4/torture/rpc/testjoin.c b/source4/torture/rpc/testjoin.c index 6cf0232d82e..133b9f09c43 100644 --- a/source4/torture/rpc/testjoin.c +++ b/source4/torture/rpc/testjoin.c @@ -332,7 +332,7 @@ again: u.info24.password_expired = 0; - status = dcerpc_fetch_session_key(join->p, &session_key); + status = dcerpc_binding_handle_transport_session_key(b, tctx, &session_key); if (!NT_STATUS_IS_OK(status)) { torture_comment(tctx, "SetUserInfo level %u - no session key - %s\n", s.in.level, nt_errstr(status)); diff --git a/source4/torture/rpc/wkssvc.c b/source4/torture/rpc/wkssvc.c index c43e16f2e2d..a77ece44b2b 100644 --- a/source4/torture/rpc/wkssvc.c +++ b/source4/torture/rpc/wkssvc.c @@ -1236,7 +1236,7 @@ static bool test_NetrJoinDomain2(struct torture_context *tctx, return false; } - status = dcerpc_fetch_session_key(p, &session_key); + status = dcerpc_binding_handle_transport_session_key(b, tctx, &session_key); if (!NT_STATUS_IS_OK(status)) { return false; } @@ -1324,7 +1324,7 @@ static bool test_NetrUnjoinDomain2(struct torture_context *tctx, return false; } - status = dcerpc_fetch_session_key(p, &session_key); + status = dcerpc_binding_handle_transport_session_key(b, tctx, &session_key); if (!NT_STATUS_IS_OK(status)) { return false; }