From e3880fa759cfa03222262327854fe7bbe585fe01 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 26 Sep 2004 11:30:20 +0000 Subject: r2660: - converted the libcli/raw/ library to use talloc_increase_ref_count() rather than manual reference counts - properly support SMBexit in the cifs and posix backends - added a logoff method to all backends With these changes the RAW-CONTEXT test now passes against the posix backend (This used to be commit c315d6ac1cc40546fde1474702a6d66d07ee13c8) --- source4/torture/basic/secleak.c | 2 +- source4/torture/raw/context.c | 20 ++++++++++++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) (limited to 'source4/torture') diff --git a/source4/torture/basic/secleak.c b/source4/torture/basic/secleak.c index 80bc799df0..54fa3ecee6 100644 --- a/source4/torture/basic/secleak.c +++ b/source4/torture/basic/secleak.c @@ -43,7 +43,7 @@ static BOOL try_failed_login(struct smbcli_state *cli) return False; } - smbcli_session_close(session); + talloc_free(session); talloc_free(mem_ctx); return True; diff --git a/source4/torture/raw/context.c b/source4/torture/raw/context.c index 7bc75a6627..194d2de93b 100644 --- a/source4/torture/raw/context.c +++ b/source4/torture/raw/context.c @@ -81,6 +81,8 @@ static BOOL test_session(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) printf("create a second security context on the same transport\n"); session = smbcli_session_init(cli->transport); + talloc_increase_ref_count(cli->transport); + setup.generic.level = RAW_SESSSETUP_GENERIC; setup.generic.in.sesskey = cli->transport->negotiate.sesskey; setup.generic.in.capabilities = cli->transport->negotiate.capabilities; /* ignored in secondary session setup, except by our libs, which care about the extended security bit */ @@ -95,6 +97,8 @@ static BOOL test_session(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) printf("create a third security context on the same transport, with vuid set\n"); session2 = smbcli_session_init(cli->transport); + talloc_increase_ref_count(cli->transport); + session2->vuid = session->vuid; setup.generic.level = RAW_SESSSETUP_GENERIC; setup.generic.in.sesskey = cli->transport->negotiate.sesskey; @@ -110,10 +114,13 @@ static BOOL test_session(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) printf("vuid1=%d vuid2=%d vuid3=%d\n", cli->session->vuid, session->vuid, session2->vuid); CHECK_NOT_VALUE(session->vuid, session2->vuid); + talloc_free(session2); if (cli->transport->negotiate.capabilities & CAP_EXTENDED_SECURITY) { printf("create a fourth security context on the same transport, without extended security\n"); session3 = smbcli_session_init(cli->transport); + talloc_increase_ref_count(cli->transport); + session3->vuid = session->vuid; setup.generic.level = RAW_SESSSETUP_GENERIC; setup.generic.in.sesskey = cli->transport->negotiate.sesskey; @@ -124,12 +131,14 @@ static BOOL test_session(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) status = smb_raw_session_setup(session3, mem_ctx, &setup); CHECK_STATUS(status, NT_STATUS_ACCESS_DENIED); + + talloc_free(session3); } printf("use the same tree as the existing connection\n"); tree = smbcli_tree_init(session); + talloc_increase_ref_count(session); tree->tid = cli->tree->tid; - cli->tree->reference_count++; printf("create a file using the new vuid\n"); io.generic.level = RAW_OPEN_NTCREATEX; @@ -168,6 +177,7 @@ static BOOL test_session(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) printf("logoff the new vuid\n"); status = smb_raw_ulogoff(session); CHECK_STATUS(status, NT_STATUS_OK); + talloc_free(session); printf("the new vuid should not now be accessible\n"); status = smb_raw_write(tree, &wr); @@ -182,7 +192,7 @@ static BOOL test_session(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) /* close down the new tree, which will also close the session as the reference count will be 0 */ - smbcli_tree_close(tree); + talloc_free(tree); done: return ret; @@ -215,9 +225,10 @@ static BOOL test_tree(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) } share = lp_parm_string(-1, "torture", "share"); - + printf("create a second tree context on the same session\n"); tree = smbcli_tree_init(cli->session); + talloc_increase_ref_count(cli->session); tcon.generic.level = RAW_TCON_TCONX; tcon.tconx.in.flags = 0; @@ -286,7 +297,7 @@ static BOOL test_tree(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) CHECK_STATUS(status, NT_STATUS_INVALID_HANDLE); /* close down the new tree */ - smbcli_tree_close(tree); + talloc_free(tree); done: return ret; @@ -425,5 +436,6 @@ BOOL torture_raw_context(int dummy) torture_close_connection(cli); talloc_destroy(mem_ctx); + return ret; } -- cgit