summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source4/torture/raw/context.c71
1 files changed, 65 insertions, 6 deletions
diff --git a/source4/torture/raw/context.c b/source4/torture/raw/context.c
index a610eaa79e..bc8a7b12cf 100644
--- a/source4/torture/raw/context.c
+++ b/source4/torture/raw/context.c
@@ -23,6 +23,7 @@
#include "librpc/gen_ndr/ndr_security.h"
#include "libcli/composite/composite.h"
#include "lib/cmdline/popt_common.h"
+#include "lib/events/events.h"
#define BASEDIR "\\rawcontext"
@@ -61,14 +62,18 @@ static BOOL test_session(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
struct smbcli_session *session;
struct smbcli_session *session2;
struct smbcli_session *session3;
+ struct smbcli_session *sessions[15];
+ struct composite_context *composite_contexts[15];
struct smbcli_tree *tree;
struct smb_composite_sesssetup setup;
+ struct smb_composite_sesssetup setups[15];
union smb_open io;
union smb_write wr;
union smb_close cl;
int fnum;
const char *fname = BASEDIR "\\test.txt";
uint8_t c = 1;
+ int i;
printf("TESTING SESSION HANDLING\n");
@@ -87,7 +92,7 @@ static BOOL test_session(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
status = smb_composite_sesssetup(session, &setup);
CHECK_STATUS(status, NT_STATUS_OK);
-
+
session->vuid = setup.out.vuid;
printf("create a third security context on the same transport, with vuid set\n");
@@ -106,7 +111,12 @@ static BOOL test_session(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
session2->vuid = setup.out.vuid;
printf("vuid1=%d vuid2=%d vuid3=%d\n", cli->session->vuid, session->vuid, session2->vuid);
- CHECK_NOT_VALUE(session->vuid, session2->vuid);
+ if (cli->transport->negotiate.capabilities & CAP_EXTENDED_SECURITY) {
+ /* Samba4 currently fails this - we need to determine if this insane behaviour is important */
+ CHECK_VALUE(session2->vuid, session->vuid);
+ } else {
+ CHECK_NOT_VALUE(session2->vuid, session->vuid);
+ }
talloc_free(session2);
if (cli->transport->negotiate.capabilities & CAP_EXTENDED_SECURITY) {
@@ -168,12 +178,16 @@ 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);
CHECK_STATUS(status, NT_STATUS_INVALID_HANDLE);
+ printf("second logoff for the new vuid should fail\n");
+ status = smb_raw_ulogoff(session);
+ CHECK_STATUS(status, NT_STATUS_INVALID_HANDLE);
+ talloc_free(session);
+
printf("the fnum should have been auto-closed\n");
cl.close.level = RAW_CLOSE_CLOSE;
cl.close.in.fnum = fnum;
@@ -181,6 +195,38 @@ static BOOL test_session(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
status = smb_raw_close(cli->tree, &cl);
CHECK_STATUS(status, NT_STATUS_INVALID_HANDLE);
+ printf("create %d secondary security contexts on the same transport\n",
+ ARRAY_SIZE(sessions));
+ for (i=0; i <ARRAY_SIZE(sessions); i++) {
+ setups[i].in.sesskey = cli->transport->negotiate.sesskey;
+ setups[i].in.capabilities = cli->transport->negotiate.capabilities; /* ignored in secondary session setup, except by our libs, which care about the extended security bit */
+ setups[i].in.workgroup = lp_workgroup();
+
+ setups[i].in.credentials = cmdline_credentials;
+
+ sessions[i] = smbcli_session_init(cli->transport, mem_ctx, False);
+ composite_contexts[i] = smb_composite_sesssetup_send(sessions[i], &setups[i]);
+
+ }
+
+
+ /* flush the queue */
+ for (i=0; i < ARRAY_SIZE(sessions); i++) {
+ event_loop_once(composite_contexts[0]->event_ctx);
+ }
+
+ printf("finishing %d secondary security contexts on the same transport\n",
+ ARRAY_SIZE(sessions));
+ for (i=0; i< ARRAY_SIZE(sessions); i++) {
+ status = smb_composite_sesssetup_recv(composite_contexts[i]);
+ CHECK_STATUS(status, NT_STATUS_OK);
+ sessions[i]->vuid = setups[i].out.vuid;
+ printf("VUID: %d\n", sessions[i]->vuid);
+ status = smb_raw_ulogoff(sessions[i]);
+ CHECK_STATUS(status, NT_STATUS_OK);
+ }
+
+
talloc_free(tree);
done:
@@ -391,14 +437,12 @@ done:
/*
basic testing of session/tree context calls
*/
-BOOL torture_raw_context(void)
+static BOOL torture_raw_context_int(void)
{
struct smbcli_state *cli;
BOOL ret = True;
TALLOC_CTX *mem_ctx;
- lp_set_cmdline("use spnego", "False");
-
if (!torture_open_connection(&cli)) {
return False;
}
@@ -425,3 +469,18 @@ BOOL torture_raw_context(void)
return ret;
}
+/*
+ basic testing of session/tree context calls
+*/
+BOOL torture_raw_context(void)
+{
+ BOOL ret = True;
+ if (lp_use_spnego()) {
+ ret &= torture_raw_context_int();
+ lp_set_cmdline("use spnego", "False");
+ }
+
+ ret &= torture_raw_context_int();
+
+ return ret;
+}