[SCM] Samba Shared Repository - branch master updated
Günther Deschner
gd at samba.org
Wed Mar 24 05:48:38 MDT 2010
The branch, master has been updated
via 9fd24eb... s4-smbtorture: cleanup some of the RPC-SAMBA3 tests.
via 5e87e85... s4-smbtorture: add rap_get_servername to RPC-SAMBA3 family of tests.
from 7d89c7c... idl: fix comment and convert whitespaces to tabs
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 9fd24eb9c5fdd0e4a801af83cf9ec7f6de6c4504
Author: Günther Deschner <gd at samba.org>
Date: Mon Mar 22 15:58:09 2010 +0100
s4-smbtorture: cleanup some of the RPC-SAMBA3 tests.
This avoids printf, uses simplication functions where appropriate, etc.
Guenther
commit 5e87e8576caddfb6e46b6c7d42428b79d2056569
Author: Günther Deschner <gd at samba.org>
Date: Mon Mar 22 17:24:38 2010 +0100
s4-smbtorture: add rap_get_servername to RPC-SAMBA3 family of tests.
Guenther
-----------------------------------------------------------------------
Summary of changes:
source4/torture/rpc/samba3rpc.c | 1706 +++++++++++++++------------------------
1 files changed, 630 insertions(+), 1076 deletions(-)
Changeset truncated at 500 lines:
diff --git a/source4/torture/rpc/samba3rpc.c b/source4/torture/rpc/samba3rpc.c
index 7b94de9..4de8f67 100644
--- a/source4/torture/rpc/samba3rpc.c
+++ b/source4/torture/rpc/samba3rpc.c
@@ -69,7 +69,7 @@ bool torture_bind_authcontext(struct torture_context *torture)
mem_ctx = talloc_init("torture_bind_authcontext");
if (mem_ctx == NULL) {
- d_printf("talloc_init failed\n");
+ torture_comment(torture, "talloc_init failed\n");
return false;
}
@@ -87,7 +87,7 @@ bool torture_bind_authcontext(struct torture_context *torture)
lp_iconv_convenience(torture->lp_ctx),
lp_gensec_settings(torture, torture->lp_ctx));
if (!NT_STATUS_IS_OK(status)) {
- d_printf("smbcli_full_connection failed: %s\n",
+ torture_comment(torture, "smbcli_full_connection failed: %s\n",
nt_errstr(status));
goto done;
}
@@ -95,21 +95,21 @@ bool torture_bind_authcontext(struct torture_context *torture)
lsa_pipe = dcerpc_pipe_init(mem_ctx, cli->transport->socket->event.ctx,
lp_iconv_convenience(torture->lp_ctx));
if (lsa_pipe == NULL) {
- d_printf("dcerpc_pipe_init failed\n");
+ torture_comment(torture, "dcerpc_pipe_init failed\n");
goto done;
}
lsa_handle = lsa_pipe->binding_handle;
status = dcerpc_pipe_open_smb(lsa_pipe, cli->tree, "\\lsarpc");
if (!NT_STATUS_IS_OK(status)) {
- d_printf("dcerpc_pipe_open_smb failed: %s\n",
+ torture_comment(torture, "dcerpc_pipe_open_smb failed: %s\n",
nt_errstr(status));
goto done;
}
status = dcerpc_bind_auth_none(lsa_pipe, &ndr_table_lsarpc);
if (!NT_STATUS_IS_OK(status)) {
- d_printf("dcerpc_bind_auth_none failed: %s\n",
+ torture_comment(torture, "dcerpc_bind_auth_none failed: %s\n",
nt_errstr(status));
goto done;
}
@@ -124,7 +124,7 @@ bool torture_bind_authcontext(struct torture_context *torture)
status = dcerpc_lsa_OpenPolicy2_r(lsa_handle, mem_ctx, &openpolicy);
if (!NT_STATUS_IS_OK(status)) {
- d_printf("dcerpc_lsa_OpenPolicy2 failed: %s\n",
+ torture_comment(torture, "dcerpc_lsa_OpenPolicy2 failed: %s\n",
nt_errstr(status));
goto done;
}
@@ -134,19 +134,19 @@ bool torture_bind_authcontext(struct torture_context *torture)
status = dcerpc_lsa_Close_r(lsa_handle, mem_ctx, &close_handle);
if (!NT_STATUS_IS_OK(status)) {
- d_printf("dcerpc_lsa_Close failed: %s\n",
+ torture_comment(torture, "dcerpc_lsa_Close failed: %s\n",
nt_errstr(status));
goto done;
}
session2 = smbcli_session_init(cli->transport, mem_ctx, false, session_options);
if (session2 == NULL) {
- d_printf("smbcli_session_init failed\n");
+ torture_comment(torture, "smbcli_session_init failed\n");
goto done;
}
if (!(anon_creds = cli_credentials_init_anon(mem_ctx))) {
- d_printf("create_anon_creds failed\n");
+ torture_comment(torture, "create_anon_creds failed\n");
goto done;
}
@@ -158,7 +158,7 @@ bool torture_bind_authcontext(struct torture_context *torture)
status = smb_composite_sesssetup(session2, &setup);
if (!NT_STATUS_IS_OK(status)) {
- d_printf("anon session setup failed: %s\n",
+ torture_comment(torture, "anon session setup failed: %s\n",
nt_errstr(status));
goto done;
}
@@ -174,7 +174,7 @@ bool torture_bind_authcontext(struct torture_context *torture)
lsa_pipe = NULL;
if (!NT_STATUS_EQUAL(status, NT_STATUS_INVALID_HANDLE)) {
- d_printf("dcerpc_lsa_OpenPolicy2 with wrong vuid gave %s, "
+ torture_comment(torture, "dcerpc_lsa_OpenPolicy2 with wrong vuid gave %s, "
"expected NT_STATUS_INVALID_HANDLE\n",
nt_errstr(status));
goto done;
@@ -190,9 +190,9 @@ bool torture_bind_authcontext(struct torture_context *torture)
* Bind to lsa using a specific auth method
*/
-static bool bindtest(struct smbcli_state *cli,
+static bool bindtest(struct torture_context *tctx,
+ struct smbcli_state *cli,
struct cli_credentials *credentials,
- struct loadparm_context *lp_ctx,
uint8_t auth_type, uint8_t auth_level)
{
TALLOC_CTX *mem_ctx;
@@ -209,31 +209,31 @@ static bool bindtest(struct smbcli_state *cli,
struct lsa_Close close_handle;
if ((mem_ctx = talloc_init("bindtest")) == NULL) {
- d_printf("talloc_init failed\n");
+ torture_comment(tctx, "talloc_init failed\n");
return false;
}
lsa_pipe = dcerpc_pipe_init(mem_ctx,
cli->transport->socket->event.ctx,
- lp_iconv_convenience(lp_ctx));
+ lp_iconv_convenience(tctx->lp_ctx));
if (lsa_pipe == NULL) {
- d_printf("dcerpc_pipe_init failed\n");
+ torture_comment(tctx, "dcerpc_pipe_init failed\n");
goto done;
}
lsa_handle = lsa_pipe->binding_handle;
status = dcerpc_pipe_open_smb(lsa_pipe, cli->tree, "\\lsarpc");
if (!NT_STATUS_IS_OK(status)) {
- d_printf("dcerpc_pipe_open_smb failed: %s\n",
+ torture_comment(tctx, "dcerpc_pipe_open_smb failed: %s\n",
nt_errstr(status));
goto done;
}
status = dcerpc_bind_auth(lsa_pipe, &ndr_table_lsarpc,
- credentials, lp_gensec_settings(lp_ctx, lp_ctx), auth_type, auth_level,
+ credentials, lp_gensec_settings(tctx->lp_ctx, tctx->lp_ctx), auth_type, auth_level,
NULL);
if (!NT_STATUS_IS_OK(status)) {
- d_printf("dcerpc_bind_auth failed: %s\n", nt_errstr(status));
+ torture_comment(tctx, "dcerpc_bind_auth failed: %s\n", nt_errstr(status));
goto done;
}
@@ -247,7 +247,7 @@ static bool bindtest(struct smbcli_state *cli,
status = dcerpc_lsa_OpenPolicy2_r(lsa_handle, mem_ctx, &openpolicy);
if (!NT_STATUS_IS_OK(status)) {
- d_printf("dcerpc_lsa_OpenPolicy2 failed: %s\n",
+ torture_comment(tctx, "dcerpc_lsa_OpenPolicy2 failed: %s\n",
nt_errstr(status));
goto done;
}
@@ -258,7 +258,7 @@ static bool bindtest(struct smbcli_state *cli,
status = dcerpc_lsa_QueryInfoPolicy_r(lsa_handle, mem_ctx, &query);
if (!NT_STATUS_IS_OK(status)) {
- d_printf("dcerpc_lsa_QueryInfoPolicy failed: %s\n",
+ torture_comment(tctx, "dcerpc_lsa_QueryInfoPolicy failed: %s\n",
nt_errstr(status));
goto done;
}
@@ -268,7 +268,7 @@ static bool bindtest(struct smbcli_state *cli,
status = dcerpc_lsa_Close_r(lsa_handle, mem_ctx, &close_handle);
if (!NT_STATUS_IS_OK(status)) {
- d_printf("dcerpc_lsa_Close failed: %s\n",
+ torture_comment(tctx, "dcerpc_lsa_Close failed: %s\n",
nt_errstr(status));
goto done;
}
@@ -295,7 +295,7 @@ static bool torture_bind_samba3(struct torture_context *torture)
mem_ctx = talloc_init("torture_bind_authcontext");
if (mem_ctx == NULL) {
- d_printf("talloc_init failed\n");
+ torture_comment(torture, "talloc_init failed\n");
return false;
}
@@ -313,20 +313,20 @@ static bool torture_bind_samba3(struct torture_context *torture)
lp_iconv_convenience(torture->lp_ctx),
lp_gensec_settings(torture, torture->lp_ctx));
if (!NT_STATUS_IS_OK(status)) {
- d_printf("smbcli_full_connection failed: %s\n",
+ torture_comment(torture, "smbcli_full_connection failed: %s\n",
nt_errstr(status));
goto done;
}
ret = true;
- ret &= bindtest(cli, cmdline_credentials, torture->lp_ctx, DCERPC_AUTH_TYPE_NTLMSSP,
+ ret &= bindtest(torture, cli, cmdline_credentials, DCERPC_AUTH_TYPE_NTLMSSP,
DCERPC_AUTH_LEVEL_INTEGRITY);
- ret &= bindtest(cli, cmdline_credentials, torture->lp_ctx, DCERPC_AUTH_TYPE_NTLMSSP,
+ ret &= bindtest(torture, cli, cmdline_credentials, DCERPC_AUTH_TYPE_NTLMSSP,
DCERPC_AUTH_LEVEL_PRIVACY);
- ret &= bindtest(cli, cmdline_credentials, torture->lp_ctx, DCERPC_AUTH_TYPE_SPNEGO,
+ ret &= bindtest(torture, cli, cmdline_credentials, DCERPC_AUTH_TYPE_SPNEGO,
DCERPC_AUTH_LEVEL_INTEGRITY);
- ret &= bindtest(cli, cmdline_credentials, torture->lp_ctx, DCERPC_AUTH_TYPE_SPNEGO,
+ ret &= bindtest(torture, cli, cmdline_credentials, DCERPC_AUTH_TYPE_SPNEGO,
DCERPC_AUTH_LEVEL_PRIVACY);
done:
@@ -338,17 +338,17 @@ static bool torture_bind_samba3(struct torture_context *torture)
* Lookup or create a user and return all necessary info
*/
-static NTSTATUS get_usr_handle(struct smbcli_state *cli,
- TALLOC_CTX *mem_ctx,
- struct loadparm_context *lp_ctx,
- struct cli_credentials *admin_creds,
- uint8_t auth_type,
- uint8_t auth_level,
- const char *username,
- char **domain,
- struct dcerpc_pipe **result_pipe,
- struct policy_handle **result_handle,
- struct dom_sid **sid_p)
+static bool get_usr_handle(struct torture_context *tctx,
+ struct smbcli_state *cli,
+ TALLOC_CTX *mem_ctx,
+ struct cli_credentials *admin_creds,
+ uint8_t auth_type,
+ uint8_t auth_level,
+ const char *username,
+ char **domain,
+ struct dcerpc_pipe **result_pipe,
+ struct policy_handle **result_handle,
+ struct dom_sid **sid_p)
{
struct dcerpc_pipe *samr_pipe;
struct dcerpc_binding_handle *samr_handle;
@@ -372,38 +372,26 @@ static NTSTATUS get_usr_handle(struct smbcli_state *cli,
samr_pipe = dcerpc_pipe_init(mem_ctx,
cli->transport->socket->event.ctx,
- lp_iconv_convenience(lp_ctx));
- if (samr_pipe == NULL) {
- d_printf("dcerpc_pipe_init failed\n");
- status = NT_STATUS_NO_MEMORY;
- goto fail;
- }
+ lp_iconv_convenience(tctx->lp_ctx));
+ torture_assert(tctx, samr_pipe, "dcerpc_pipe_init failed");
+
samr_handle = samr_pipe->binding_handle;
- status = dcerpc_pipe_open_smb(samr_pipe, cli->tree, "\\samr");
- if (!NT_STATUS_IS_OK(status)) {
- d_printf("dcerpc_pipe_open_smb failed: %s\n",
- nt_errstr(status));
- goto fail;
- }
+ torture_assert_ntstatus_ok(tctx,
+ dcerpc_pipe_open_smb(samr_pipe, cli->tree, "\\samr"),
+ "dcerpc_pipe_open_smb failed");
if (admin_creds != NULL) {
- status = dcerpc_bind_auth(samr_pipe, &ndr_table_samr,
- admin_creds, lp_gensec_settings(lp_ctx, lp_ctx), auth_type, auth_level,
- NULL);
- if (!NT_STATUS_IS_OK(status)) {
- d_printf("dcerpc_bind_auth failed: %s\n",
- nt_errstr(status));
- goto fail;
- }
+ torture_assert_ntstatus_ok(tctx,
+ dcerpc_bind_auth(samr_pipe, &ndr_table_samr,
+ admin_creds, lp_gensec_settings(tctx->lp_ctx, tctx->lp_ctx), auth_type, auth_level,
+ NULL),
+ "dcerpc_bind_auth failed");
} else {
/* We must have an authenticated SMB connection */
- status = dcerpc_bind_auth_none(samr_pipe, &ndr_table_samr);
- if (!NT_STATUS_IS_OK(status)) {
- d_printf("dcerpc_bind_auth_none failed: %s\n",
- nt_errstr(status));
- goto fail;
- }
+ torture_assert_ntstatus_ok(tctx,
+ dcerpc_bind_auth_none(samr_pipe, &ndr_table_samr),
+ "dcerpc_bind_auth_none failed");
}
conn.in.system_name = talloc_asprintf(
@@ -411,11 +399,9 @@ static NTSTATUS get_usr_handle(struct smbcli_state *cli,
conn.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
conn.out.connect_handle = &conn_handle;
- status = dcerpc_samr_Connect2_r(samr_handle, mem_ctx, &conn);
- if (!NT_STATUS_IS_OK(status)) {
- d_printf("samr_Connect2 failed: %s\n", nt_errstr(status));
- goto fail;
- }
+ torture_assert_ntstatus_ok(tctx,
+ dcerpc_samr_Connect2_r(samr_handle, mem_ctx, &conn),
+ "samr_Connect2 failed");
enumdom.in.connect_handle = &conn_handle;
enumdom.in.resume_handle = &resume_handle;
@@ -424,18 +410,12 @@ static NTSTATUS get_usr_handle(struct smbcli_state *cli,
enumdom.out.num_entries = &num_entries;
enumdom.out.sam = &sam;
- status = dcerpc_samr_EnumDomains_r(samr_handle, mem_ctx, &enumdom);
- if (!NT_STATUS_IS_OK(status)) {
- d_printf("samr_EnumDomains failed: %s\n", nt_errstr(status));
- goto fail;
- }
+ torture_assert_ntstatus_ok(tctx,
+ dcerpc_samr_EnumDomains_r(samr_handle, mem_ctx, &enumdom),
+ "samr_EnumDomains failed");
- if (*enumdom.out.num_entries != 2) {
- d_printf("samr_EnumDomains returned %d entries, expected 2\n",
- *enumdom.out.num_entries);
- status = NT_STATUS_UNSUCCESSFUL;
- goto fail;
- }
+ torture_assert_int_equal(tctx, *enumdom.out.num_entries, 2,
+ "samr_EnumDomains returned unexpected num_entries");
dom_idx = strequal(sam->entries[0].name.string,
"builtin") ? 1:0;
@@ -446,22 +426,18 @@ static NTSTATUS get_usr_handle(struct smbcli_state *cli,
l.in.domain_name = &domain_name;
l.out.sid = &sid;
- status = dcerpc_samr_LookupDomain_r(samr_handle, mem_ctx, &l);
- if (!NT_STATUS_IS_OK(status)) {
- d_printf("samr_LookupDomain failed: %s\n", nt_errstr(status));
- goto fail;
- }
+ torture_assert_ntstatus_ok(tctx,
+ dcerpc_samr_LookupDomain_r(samr_handle, mem_ctx, &l),
+ "samr_LookupDomain failed");
o.in.connect_handle = &conn_handle;
o.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
o.in.sid = *l.out.sid;
o.out.domain_handle = &domain_handle;
- status = dcerpc_samr_OpenDomain_r(samr_handle, mem_ctx, &o);
- if (!NT_STATUS_IS_OK(status)) {
- d_printf("samr_OpenDomain failed: %s\n", nt_errstr(status));
- goto fail;
- }
+ torture_assert_ntstatus_ok(tctx,
+ dcerpc_samr_OpenDomain_r(samr_handle, mem_ctx, &o),
+ "samr_OpenDomain failed");
c.in.domain_handle = &domain_handle;
user_name.string = username;
@@ -486,48 +462,39 @@ static NTSTATUS get_usr_handle(struct smbcli_state *cli,
ln.out.rids = &rids;
ln.out.types = &types;
- status = dcerpc_samr_LookupNames_r(samr_handle, mem_ctx, &ln);
- if (!NT_STATUS_IS_OK(status)) {
- d_printf("samr_LookupNames failed: %s\n",
- nt_errstr(status));
- goto fail;
- }
+ torture_assert_ntstatus_ok(tctx,
+ dcerpc_samr_LookupNames_r(samr_handle, mem_ctx, &ln),
+ "samr_LookupNames failed");
ou.in.domain_handle = &domain_handle;
ou.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
user_rid = ou.in.rid = ln.out.rids->ids[0];
ou.out.user_handle = user_handle;
- status = dcerpc_samr_OpenUser_r(samr_handle, mem_ctx, &ou);
- if (!NT_STATUS_IS_OK(status)) {
- d_printf("samr_OpenUser failed: %s\n",
- nt_errstr(status));
- goto fail;
- }
+ torture_assert_ntstatus_ok(tctx,
+ dcerpc_samr_OpenUser_r(samr_handle, mem_ctx, &ou),
+ "samr_OpenUser failed");
+ status = ou.out.result;
}
- if (!NT_STATUS_IS_OK(status)) {
- d_printf("samr_CreateUser failed: %s\n", nt_errstr(status));
- goto fail;
- }
+ torture_assert_ntstatus_ok(tctx, status,
+ "samr_CreateUser failed");
*result_pipe = samr_pipe;
*result_handle = user_handle;
if (sid_p != NULL) {
*sid_p = dom_sid_add_rid(mem_ctx, *l.out.sid, user_rid);
}
- return NT_STATUS_OK;
+ return true;
- fail:
- return status;
}
/*
* Create a test user
*/
-static bool create_user(TALLOC_CTX *mem_ctx, struct smbcli_state *cli,
- struct loadparm_context *lp_ctx,
+static bool create_user(struct torture_context *tctx,
+ TALLOC_CTX *mem_ctx, struct smbcli_state *cli,
struct cli_credentials *admin_creds,
const char *username, const char *password,
char **domain_name,
@@ -541,17 +508,17 @@ static bool create_user(TALLOC_CTX *mem_ctx, struct smbcli_state *cli,
bool ret = false;
if (!(tmp_ctx = talloc_new(mem_ctx))) {
- d_printf("talloc_init failed\n");
+ torture_comment(tctx, "talloc_init failed\n");
return false;
}
- status = get_usr_handle(cli, tmp_ctx, lp_ctx, admin_creds,
- DCERPC_AUTH_TYPE_NTLMSSP,
- DCERPC_AUTH_LEVEL_INTEGRITY,
- username, domain_name, &samr_pipe, &wks_handle,
- user_sid);
- if (!NT_STATUS_IS_OK(status)) {
- d_printf("get_usr_handle failed: %s\n", nt_errstr(status));
+ ret = get_usr_handle(tctx, cli, tmp_ctx, admin_creds,
+ DCERPC_AUTH_TYPE_NTLMSSP,
+ DCERPC_AUTH_LEVEL_INTEGRITY,
+ username, domain_name, &samr_pipe, &wks_handle,
+ user_sid);
+ if (ret == false) {
+ torture_comment(tctx, "get_usr_handle failed\n");
goto done;
}
samr_handle = samr_pipe->binding_handle;
@@ -571,7 +538,7 @@ static bool create_user(TALLOC_CTX *mem_ctx, struct smbcli_state *cli,
status = dcerpc_fetch_session_key(samr_pipe, &session_key);
if (!NT_STATUS_IS_OK(status)) {
- d_printf("dcerpc_fetch_session_key failed\n");
+ torture_comment(tctx, "dcerpc_fetch_session_key failed\n");
goto done;
}
arcfour_crypt_blob(u_info.info23.password.data, 516,
@@ -586,7 +553,7 @@ static bool create_user(TALLOC_CTX *mem_ctx, struct smbcli_state *cli,
status = dcerpc_samr_SetUserInfo2_r(samr_handle, tmp_ctx, &sui2);
if (!NT_STATUS_IS_OK(status)) {
- d_printf("samr_SetUserInfo(23) failed: %s\n",
+ torture_comment(tctx, "samr_SetUserInfo(23) failed: %s\n",
nt_errstr(status));
goto done;
}
@@ -598,7 +565,7 @@ static bool create_user(TALLOC_CTX *mem_ctx, struct smbcli_state *cli,
status = dcerpc_samr_SetUserInfo_r(samr_handle, tmp_ctx, &sui);
if (!NT_STATUS_IS_OK(status)) {
- d_printf("samr_SetUserInfo(16) failed\n");
+ torture_comment(tctx, "samr_SetUserInfo(16) failed\n");
goto done;
}
@@ -608,7 +575,7 @@ static bool create_user(TALLOC_CTX *mem_ctx, struct smbcli_state *cli,
status = dcerpc_samr_QueryUserInfo_r(samr_handle, tmp_ctx, &qui);
if (!NT_STATUS_IS_OK(status)) {
- d_printf("samr_QueryUserInfo(21) failed\n");
+ torture_comment(tctx, "samr_QueryUserInfo(21) failed\n");
goto done;
}
@@ -626,7 +593,7 @@ static bool create_user(TALLOC_CTX *mem_ctx, struct smbcli_state *cli,
status = dcerpc_samr_SetUserInfo_r(samr_handle, tmp_ctx, &sui);
if (!NT_STATUS_IS_OK(status)) {
- d_printf("samr_SetUserInfo(21) failed\n");
+ torture_comment(tctx, "samr_SetUserInfo(21) failed\n");
goto done;
}
}
@@ -643,8 +610,8 @@ static bool create_user(TALLOC_CTX *mem_ctx, struct smbcli_state *cli,
* Delete a test user
*/
-static bool delete_user(struct smbcli_state *cli,
- struct loadparm_context *lp_ctx,
+static bool delete_user(struct torture_context *tctx,
+ struct smbcli_state *cli,
struct cli_credentials *admin_creds,
--
Samba Shared Repository
More information about the samba-cvs
mailing list