r4777: added a smb_composite_sesssetup() async composite function. This
[gd/samba-autobuild/.git] / source4 / torture / raw / context.c
index 446ada80a6f79369f6f6a866c4f2cec7e258d56e..4f1c6337eb9fa44ffc1135e50acb5f3e596bf3f5 100644 (file)
@@ -20,6 +20,8 @@
 
 #include "includes.h"
 #include "libcli/raw/libcliraw.h"
+#include "librpc/gen_ndr/ndr_security.h"
+#include "libcli/composite/composite.h"
 
 #define BASEDIR "\\rawcontext"
 
@@ -60,13 +62,13 @@ static BOOL test_session(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
        struct smbcli_session *session2;
        struct smbcli_session *session3;
        struct smbcli_tree *tree;
-       union smb_sesssetup setup;
+       struct smb_composite_sesssetup setup;
        union smb_open io;
        union smb_write wr;
        union smb_close cl;
        int fnum;
        const char *fname = BASEDIR "\\test.txt";
-       char c = 1;
+       uint8_t c = 1;
 
        printf("TESTING SESSION HANDLING\n");
 
@@ -81,33 +83,31 @@ 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);
 
-       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 */
-       setup.generic.in.password = password;
-       setup.generic.in.user = username;
-       setup.generic.in.domain = domain;
+       setup.in.sesskey = cli->transport->negotiate.sesskey;
+       setup.in.capabilities = cli->transport->negotiate.capabilities; /* ignored in secondary session setup, except by our libs, which care about the extended security bit */
+       setup.in.password = password;
+       setup.in.user = username;
+       setup.in.domain = domain;
 
-       status = smb_raw_session_setup(session, mem_ctx, &setup);
+       status = smb_composite_sesssetup(session, &setup);
        CHECK_STATUS(status, NT_STATUS_OK);
 
-       session->vuid = setup.generic.out.vuid;
+       session->vuid = setup.out.vuid;
 
        printf("create a third security context on the same transport, with vuid set\n");
        session2 = smbcli_session_init(cli->transport);
 
        session2->vuid = session->vuid;
-       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 */
-       setup.generic.in.password = password;
-       setup.generic.in.user = username;
-       setup.generic.in.domain = domain;
-
-       status = smb_raw_session_setup(session2, mem_ctx, &setup);
+       setup.in.sesskey = cli->transport->negotiate.sesskey;
+       setup.in.capabilities = cli->transport->negotiate.capabilities; /* ignored in secondary session setup, except by our libs, which care about the extended security bit */
+       setup.in.password = password;
+       setup.in.user = username;
+       setup.in.domain = domain;
+
+       status = smb_composite_sesssetup(session2, &setup);
        CHECK_STATUS(status, NT_STATUS_OK);
 
-       session2->vuid = setup.generic.out.vuid;
+       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);
@@ -118,14 +118,13 @@ static BOOL test_session(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
                session3 = smbcli_session_init(cli->transport);
 
                session3->vuid = session->vuid;
-               setup.generic.level = RAW_SESSSETUP_GENERIC;
-               setup.generic.in.sesskey = cli->transport->negotiate.sesskey;
-               setup.generic.in.capabilities = 0; /* force a non extended security login (should fail) */
-               setup.generic.in.password = password;
-               setup.generic.in.user = username;
-               setup.generic.in.domain = domain;
-
-               status = smb_raw_session_setup(session3, mem_ctx, &setup);
+               setup.in.sesskey = cli->transport->negotiate.sesskey;
+               setup.in.capabilities = 0; /* force a non extended security login (should fail) */
+               setup.in.password = password;
+               setup.in.user = username;
+               setup.in.domain = domain;
+
+               status = smb_composite_sesssetup(session3, &setup);
                CHECK_STATUS(status, NT_STATUS_ACCESS_DENIED);
 
                talloc_free(session3);
@@ -139,7 +138,7 @@ static BOOL test_session(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
        io.generic.level = RAW_OPEN_NTCREATEX;
        io.ntcreatex.in.root_fid = 0;
        io.ntcreatex.in.flags = 0;
-       io.ntcreatex.in.access_mask = SEC_RIGHT_MAXIMUM_ALLOWED;
+       io.ntcreatex.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
        io.ntcreatex.in.create_options = 0;
        io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL;
        io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_READ | NTCREATEX_SHARE_ACCESS_WRITE;
@@ -207,7 +206,7 @@ static BOOL test_tree(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
        union smb_close cl;
        int fnum;
        const char *fname = BASEDIR "\\test.txt";
-       char c = 1;
+       uint8_t c = 1;
 
        printf("TESTING TREE HANDLING\n");
 
@@ -228,7 +227,7 @@ static BOOL test_tree(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
        status = smb_tree_connect(tree, mem_ctx, &tcon);
        CHECK_STATUS(status, NT_STATUS_OK);
 
-       tree->tid = tcon.tconx.out.cnum;
+       tree->tid = tcon.tconx.out.tid;
        printf("tid1=%d tid2=%d\n", cli->tree->tid, tree->tid);
 
        printf("try a tconx with a bad device type\n");
@@ -241,7 +240,7 @@ static BOOL test_tree(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
        io.generic.level = RAW_OPEN_NTCREATEX;
        io.ntcreatex.in.root_fid = 0;
        io.ntcreatex.in.flags = 0;
-       io.ntcreatex.in.access_mask = SEC_RIGHT_MAXIMUM_ALLOWED;
+       io.ntcreatex.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
        io.ntcreatex.in.create_options = 0;
        io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL;
        io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_READ | NTCREATEX_SHARE_ACCESS_WRITE;
@@ -306,7 +305,7 @@ static BOOL test_pid(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
        union smb_close cl;
        int fnum;
        const char *fname = BASEDIR "\\test.txt";
-       char c = 1;
+       uint8_t c = 1;
        uint16_t pid1, pid2;
 
        printf("TESTING PID HANDLING\n");
@@ -326,7 +325,7 @@ static BOOL test_pid(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
        io.generic.level = RAW_OPEN_NTCREATEX;
        io.ntcreatex.in.root_fid = 0;
        io.ntcreatex.in.flags = 0;
-       io.ntcreatex.in.access_mask = SEC_RIGHT_MAXIMUM_ALLOWED;
+       io.ntcreatex.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
        io.ntcreatex.in.create_options = 0;
        io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL;
        io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_READ | NTCREATEX_SHARE_ACCESS_WRITE;