r14208: removed use of req->flags2 inside the ntvfs layer. This should help
authorAndrew Tridgell <tridge@samba.org>
Sat, 11 Mar 2006 12:58:36 +0000 (12:58 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:57:03 +0000 (13:57 -0500)
metze on his quest to unify the ntvfs strucures for the smb and smb2
servers. The only place we needed flags2 inside ntvfs was for the
FLAGS2_READ_PERMIT_EXECUTE bit, which only affects readx, so I added a
readx.in.read_for_execute flag instead.
(This used to be commit b78abbbce60ab0009da19a72dd769800c44298a2)

12 files changed:
source4/libcli/clireadwrite.c
source4/libcli/raw/interfaces.h
source4/libcli/raw/rawreadwrite.c
source4/libcli/smb_composite/loadfile.c
source4/librpc/rpc/dcerpc_smb.c
source4/ntvfs/ntvfs_generic.c
source4/ntvfs/posix/pvfs_read.c
source4/smb_server/smb/reply.c
source4/torture/basic/denytest.c
source4/torture/gentest.c
source4/torture/nbench/nbio.c
source4/torture/raw/read.c

index afffba968a74e07243c69bfa686fb515a0c9d2e0..03d1864a5d25483f756ab5623462f399fc1bf2d2 100644 (file)
@@ -56,6 +56,7 @@ ssize_t smbcli_read(struct smbcli_tree *tree, int fnum, void *_buf, off_t offset
                parms.readx.in.mincnt    = readsize;
                parms.readx.in.maxcnt    = readsize;
                parms.readx.in.remaining = size - total;
+               parms.readx.in.read_for_execute = False;
                parms.readx.out.data     = buf + total;
                
                status = smb_raw_read(tree, &parms);
index e476a00b68698fbf45015e9f1adf53442a27fd42..086686b9e964517027a4b5427e91e15ea7eacda5 100644 (file)
@@ -1352,6 +1352,7 @@ union smb_read {
                        uint16_t mincnt;
                        uint32_t maxcnt;
                        uint16_t remaining;
+                       BOOL read_for_execute;
                } in;
                struct {
                        uint8_t *data;
index 00dc71971ef759595b2fbd7a12a8395e6a58753d..c4e2ab24982bcbcb0d4170c1989f49be997564e0 100644 (file)
@@ -84,6 +84,9 @@ struct smbcli_request *smb_raw_read_send(struct smbcli_tree *tree, union smb_rea
                if (bigoffset) {
                        SIVAL(req->out.vwv, VWV(10),parms->readx.in.offset>>32);
                }
+               if (parms->readx.in.read_for_execute) {
+                       req->flags2 |= FLAGS2_READ_PERMIT_EXECUTE;
+               }
                break;
        }
 
index 9a593c07266a4331e9b25f651040c8a6607889c8..db074bfd2b526fdff0a4356d2c15ec7ce983a901 100644 (file)
@@ -106,6 +106,7 @@ static NTSTATUS loadfile_open(struct composite_context *c,
        state->io_read->readx.in.mincnt    = MIN(32768, io->out.size);
        state->io_read->readx.in.maxcnt    = state->io_read->readx.in.mincnt;
        state->io_read->readx.in.remaining = 0;
+       state->io_read->readx.in.read_for_execute = False;
        state->io_read->readx.out.data     = io->out.data;
 
        state->req = smb_raw_read_send(tree, state->io_read);
index cf82f1daed21b74f43d67f59b92f4c67808e0fbd..bac91ef134c0f7d31d0ce785c8cbc5a81cebebd6 100644 (file)
@@ -157,6 +157,7 @@ static NTSTATUS send_read_request_continue(struct dcerpc_connection *c, DATA_BLO
        io->readx.in.maxcnt = io->readx.in.mincnt;
        io->readx.in.offset = 0;
        io->readx.in.remaining = 0;
+       io->readx.in.read_for_execute = False;
        io->readx.out.data = state->data.data + state->received;
        req = smb_raw_read_send(smb->tree, io);
        if (req == NULL) {
index e373c7a28ec41a9342c9fcf78d95a93d96877ad4..e4bc963882f4b52eeeb9f35a7f7762d89a57a46a 100644 (file)
@@ -1158,6 +1158,7 @@ _PUBLIC_ NTSTATUS ntvfs_map_read(struct ntvfs_module_context *ntvfs,
        }
 
        rd2->readx.level = RAW_READ_READX;
+       rd2->readx.in.read_for_execute = False;
 
        switch (rd->generic.level) {
        case RAW_READ_READX:
index 15c9111d6172a5d59aae779c04514937d08d193d..a6b7cf6dd09c2afc3bd30a20f6c15fd2a929b65b 100644 (file)
@@ -51,7 +51,7 @@ NTSTATUS pvfs_read(struct ntvfs_module_context *ntvfs,
        }
 
        mask = SEC_FILE_READ_DATA;
-       if (req->flags2 & FLAGS2_READ_PERMIT_EXECUTE) {
+       if (rd->readx.in.read_for_execute) {
                mask |= SEC_FILE_EXECUTE;
        }
        if (!(f->access_mask & mask)) {
index d4c98ab416355069e13368856a88e6eb339f606e..8b6dedb81a2a3ce52ed0d59e76ea07ac964fa5e3 100644 (file)
@@ -900,6 +900,11 @@ void smbsrv_reply_read_and_X(struct smbsrv_request *req)
        io->readx.in.maxcnt        = SVAL(req->in.vwv, VWV(5));
        io->readx.in.mincnt        = SVAL(req->in.vwv, VWV(6));
        io->readx.in.remaining     = SVAL(req->in.vwv, VWV(9));
+       if (req->flags2 & FLAGS2_READ_PERMIT_EXECUTE) {
+               io->readx.in.read_for_execute = True;
+       } else {
+               io->readx.in.read_for_execute = False;
+       }
 
        if (req->smb_conn->negotiate.client_caps & CAP_LARGE_READX) {
                uint32_t high_part = IVAL(req->in.vwv, VWV(7));
index 646714a4e9175c11ba33b59483876eb9f83ecdd2..5715238fca37ef33ab87cbac0543871eec51f94a 100644 (file)
@@ -1693,7 +1693,7 @@ static const char *bit_string(TALLOC_CTX *mem_ctx, const struct bit_value *bv, i
   determine if two opens conflict
 */
 static NTSTATUS predict_share_conflict(uint32_t sa1, uint32_t am1, uint32_t sa2, uint32_t am2,
-                                      uint16_t flags2, enum deny_result *res)
+                                      BOOL read_for_execute, enum deny_result *res)
 {
 #define CHECK_MASK(am, sa, right, share) do { \
        if (((am) & (right)) && !((sa) & (share))) { \
@@ -1707,8 +1707,7 @@ static NTSTATUS predict_share_conflict(uint32_t sa1, uint32_t am1, uint32_t sa2,
        }
        if (am2 & SEC_FILE_READ_DATA) {
                *res += A_R;
-       } else if ((am2 & SEC_FILE_EXECUTE) && 
-                  (flags2 & FLAGS2_READ_PERMIT_EXECUTE)) {
+       } else if ((am2 & SEC_FILE_EXECUTE) && read_for_execute) {
                *res += A_R;
        }
 
@@ -1822,6 +1821,7 @@ static BOOL torture_ntdenytest(struct smbcli_state *cli1, struct smbcli_state *c
                int b_am1 = random() & ((1<<nbits2)-1);
                int b_sa2 = random() & ((1<<nbits1)-1);
                int b_am2 = random() & ((1<<nbits2)-1);
+               BOOL read_for_execute;
 
                progress_bar(i, torture_numops);
                
@@ -1835,9 +1835,9 @@ static BOOL torture_ntdenytest(struct smbcli_state *cli1, struct smbcli_state *c
                status2 = smb_raw_open(cli2->tree, mem_ctx, &io2);
 
                if (random() % 2 == 0) {
-                       cli2->tree->session->flags2 |= FLAGS2_READ_PERMIT_EXECUTE;
+                       read_for_execute = True;
                } else {
-                       cli2->tree->session->flags2 &= ~FLAGS2_READ_PERMIT_EXECUTE;
+                       read_for_execute = False;
                }
                
                if (!NT_STATUS_IS_OK(status1)) {
@@ -1845,9 +1845,23 @@ static BOOL torture_ntdenytest(struct smbcli_state *cli1, struct smbcli_state *c
                } else if (!NT_STATUS_IS_OK(status2)) {
                        res = A_0;
                } else {
+                       union smb_read r;
+                       NTSTATUS status;
+
+                       /* we can't use smbcli_read() as we need to
+                          set read_for_execute */
+                       r.readx.level = RAW_READ_READX;
+                       r.readx.file.fnum = io2.ntcreatex.file.fnum;
+                       r.readx.in.offset = 0;
+                       r.readx.in.mincnt = sizeof(buf);
+                       r.readx.in.maxcnt = sizeof(buf);
+                       r.readx.in.remaining = 0;
+                       r.readx.in.read_for_execute = read_for_execute;
+                       r.readx.out.data = buf;
+
                        res = A_0;
-                       if (smbcli_read(cli2->tree, 
-                                       io2.ntcreatex.file.fnum, buf, 0, sizeof(buf)) >= 1) {
+                       status = smb_raw_read(cli2->tree, &r);
+                       if (NT_STATUS_IS_OK(status)) {
                                res += A_R;
                        }
                        if (smbcli_write(cli2->tree, 
@@ -1867,7 +1881,7 @@ static BOOL torture_ntdenytest(struct smbcli_state *cli1, struct smbcli_state *c
                                                   io1.ntcreatex.in.access_mask,
                                                   io2.ntcreatex.in.share_access,
                                                   io2.ntcreatex.in.access_mask, 
-                                                  cli2->tree->session->flags2,
+                                                  read_for_execute,
                                                   &res2);
                
                GetTimeOfDay(&tv);
index 9a268c57b52e93dda0fc1772d6f6a864ff7470d2..79ce27e2df3711aff7e2202ae326d951cc7b3c64 100644 (file)
@@ -1351,6 +1351,7 @@ static BOOL handler_readx(int instance)
        parm[0].readx.in.mincnt = gen_io_count();
        parm[0].readx.in.maxcnt = gen_io_count();
        parm[0].readx.in.remaining = gen_io_count();
+       parm[0].readx.in.read_for_execute = gen_bool();
        parm[0].readx.out.data = talloc_size(current_op.mem_ctx,
                                             MAX(parm[0].readx.in.mincnt, parm[0].readx.in.maxcnt));
 
index c5cebdc8d26f3065ac479bc6e80ed0b163d42e7c..76728eb7b5cf10e97b4e8937e9de3657d9567612 100644 (file)
@@ -437,6 +437,7 @@ void nb_readx(int handle, int offset, int size, int ret_size, NTSTATUS status)
        io.readx.in.mincnt    = size;
        io.readx.in.maxcnt    = size;
        io.readx.in.remaining = 0;
+       io.readx.in.read_for_execute = False;
        io.readx.out.data     = buf;
                
        ret = smb_raw_read(c->tree, &io);
index 2e5a06df63830755ef0ec5f0a59331a11fc4f182..d41f0a025d7f7727a284662e13ccf57ef9c03be8 100644 (file)
@@ -382,6 +382,7 @@ static BOOL test_readx(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
        io.readx.in.maxcnt = 1;
        io.readx.in.offset = 0;
        io.readx.in.remaining = 0;
+       io.readx.in.read_for_execute = False;
        io.readx.out.data = buf;
        status = smb_raw_read(cli->tree, &io);
 
@@ -411,6 +412,7 @@ static BOOL test_readx(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
        io.readx.file.fnum = fnum;
        io.readx.in.offset = 0;
        io.readx.in.remaining = 0;
+       io.readx.in.read_for_execute = False;
        io.readx.in.mincnt = strlen(test_data);
        io.readx.in.maxcnt = strlen(test_data);
        status = smb_raw_read(cli->tree, &io);