The branch, master has been updated
       via  c5c67ca s3: Add a test that makes a chained open break an oplock
       via  e916778 s3: More fix for smbd -i
      from  6081fab Fix problem reported by Tom Lee <tlee2...@gmail.com> - when 
calculating the share security mask, take priviliges into account for the 
connecting user.

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit c5c67cacd979c5ea6a9ca9acdac104212556ec62
Author: Volker Lendecke <v...@samba.org>
Date:   Tue Feb 28 20:28:55 2012 +0100

    s3: Add a test that makes a chained open break an oplock
    
    Autobuild-User: Volker Lendecke <v...@samba.org>
    Autobuild-Date: Wed Feb 29 01:13:03 CET 2012 on sn-devel-104

commit e916778e6eb34c956c5e6559bbf3f6dfd17a8ba1
Author: Volker Lendecke <v...@samba.org>
Date:   Tue Feb 28 22:36:06 2012 +0100

    s3: More fix for smbd -i
    
    We need a full re-initialize, otherwise we don't re-init the USR1
    signal handler

-----------------------------------------------------------------------

Summary of changes:
 source3/Makefile.in           |    1 +
 source3/selftest/tests.py     |    1 +
 source3/smbd/server.c         |    2 +-
 source3/torture/proto.h       |    1 +
 source3/torture/test_chain3.c |  294 +++++++++++++++++++++++++++++++++++++++++
 source3/torture/torture.c     |    1 +
 source3/wscript_build         |    1 +
 7 files changed, 300 insertions(+), 1 deletions(-)
 create mode 100644 source3/torture/test_chain3.c


Changeset truncated at 500 lines:

diff --git a/source3/Makefile.in b/source3/Makefile.in
index 0a189b5..71a18d6 100644
--- a/source3/Makefile.in
+++ b/source3/Makefile.in
@@ -1266,6 +1266,7 @@ SMBTORTURE_OBJ1 = torture/torture.o torture/nbio.o 
torture/scanner.o torture/uta
                torture/test_case_insensitive.o \
                torture/test_posix_append.o \
                torture/test_smb2.o \
+               torture/test_chain3.o \
                torture/test_authinfo_structs.o \
                torture/test_cleanup.o \
                torture/t_strappend.o
diff --git a/source3/selftest/tests.py b/source3/selftest/tests.py
index 163cfb4..eab1356 100755
--- a/source3/selftest/tests.py
+++ b/source3/selftest/tests.py
@@ -69,6 +69,7 @@ tests=[ "FDPASS", "LOCK1", "LOCK2", "LOCK3", "LOCK4", 
"LOCK5", "LOCK6", "LOCK7",
         "DIR", "DIR1", "DIR-CREATETIME", "TCON", "TCONDEV", "RW1", "RW2", 
"RW3", "RW-SIGNING",
         "OPEN", "XCOPY", "RENAME", "DELETE", "DELETE-LN", "PROPERTIES", "W2K",
         "TCON2", "IOCTL", "CHKPATH", "FDSESS", "CHAIN1", "CHAIN2",
+        "CHAIN3",
         "GETADDRINFO", "POSIX", "UID-REGRESSION-TEST", "SHORTNAME-TEST",
         "POSIX-APPEND",
         "CASE-INSENSITIVE-CREATE", "SMB2-BASIC", "NTTRANS-FSCTL", 
"SMB2-NEGPROT",
diff --git a/source3/smbd/server.c b/source3/smbd/server.c
index 986eb21..0fb7d16 100644
--- a/source3/smbd/server.c
+++ b/source3/smbd/server.c
@@ -466,7 +466,7 @@ static void smbd_accept_connection(struct tevent_context 
*ev,
        }
 
        if (s->parent->interactive) {
-               tevent_re_initialise(ev);
+               reinit_after_fork(msg_ctx, sconn->ev_ctx, true);
                smbd_process(ev, sconn);
                exit_server_cleanly("end of interactive mode");
                return;
diff --git a/source3/torture/proto.h b/source3/torture/proto.h
index 8d661aa..e65b272 100644
--- a/source3/torture/proto.h
+++ b/source3/torture/proto.h
@@ -99,6 +99,7 @@ bool run_smb2_session_reconnect(int dummy);
 bool run_smb2_tcon_dependence(int dummy);
 bool run_smb2_multi_channel(int dummy);
 bool run_smb2_session_reauth(int dummy);
+bool run_chain3(int dummy);
 bool run_local_conv_auth_info(int dummy);
 bool run_local_sprintf_append(int dummy);
 bool run_cleanup1(int dummy);
diff --git a/source3/torture/test_chain3.c b/source3/torture/test_chain3.c
new file mode 100644
index 0000000..7b9eeb0
--- /dev/null
+++ b/source3/torture/test_chain3.c
@@ -0,0 +1,294 @@
+/*
+   Unix SMB/CIFS implementation.
+   Test smbd chain routines
+
+   Copyright (C) Volker Lendecke 2012
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "includes.h"
+#include "torture/proto.h"
+#include "libsmb/libsmb.h"
+#include "system/filesys.h"
+#include "async_smb.h"
+#include "lib/util/tevent_ntstatus.h"
+#include "libcli/security/security.h"
+
+struct chain3_andx_state {
+       uint16_t fnum;
+       size_t written;
+       char str[6];
+};
+
+static void chain3_andx_open_done(struct tevent_req *subreq);
+static void chain3_andx_write_done(struct tevent_req *subreq);
+static void chain3_andx_close_done(struct tevent_req *subreq);
+
+static struct tevent_req *chain3_andx_send(TALLOC_CTX *mem_ctx,
+                                          struct tevent_context *ev,
+                                          struct cli_state *cli,
+                                          const char *fname)
+{
+       struct tevent_req *req, *subreq;
+       struct tevent_req *smbreqs[3];
+       struct chain3_andx_state *state;
+       NTSTATUS status;
+
+       req = tevent_req_create(mem_ctx, &state, struct chain3_andx_state);
+       if (req == NULL) {
+               return NULL;
+       }
+
+       strlcpy(state->str, "hello", sizeof(state->str));
+
+       subreq = cli_openx_create(state, ev, cli, fname,
+                                 O_CREAT|O_RDWR, 0, &smbreqs[0]);
+       if (tevent_req_nomem(subreq, req)) {
+               return tevent_req_post(req, ev);
+       }
+       tevent_req_set_callback(subreq, chain3_andx_open_done, req);
+
+       subreq = cli_write_andx_create(state, ev, cli, 0, 0,
+                                      (const uint8_t *)state->str, 0,
+                                      strlen(state->str)+1,
+                                      smbreqs, 1, &smbreqs[1]);
+       if (tevent_req_nomem(subreq, req)) {
+               return tevent_req_post(req, ev);
+       }
+       tevent_req_set_callback(subreq, chain3_andx_write_done, req);
+
+       subreq = cli_close_create(state, ev, cli, 0, &smbreqs[2]);
+       if (tevent_req_nomem(subreq, req)) {
+               return tevent_req_post(req, ev);
+       }
+       tevent_req_set_callback(subreq, chain3_andx_close_done, req);
+
+       status = cli_smb_chain_send(smbreqs, ARRAY_SIZE(smbreqs));
+       if (tevent_req_nterror(req, status)) {
+               return tevent_req_post(req, ev);
+       }
+       return req;
+}
+
+static void chain3_andx_open_done(struct tevent_req *subreq)
+{
+       struct tevent_req *req = tevent_req_callback_data(
+               subreq, struct tevent_req);
+       struct chain3_andx_state *state = tevent_req_data(
+               req, struct chain3_andx_state);
+       NTSTATUS status;
+
+       status = cli_openx_recv(subreq, &state->fnum);
+       printf("cli_openx returned %s, fnum=%u\n", nt_errstr(status),
+              (unsigned)state->fnum);
+       TALLOC_FREE(subreq);
+       if (tevent_req_nterror(req, status)) {
+               return;
+       }
+}
+
+static void chain3_andx_write_done(struct tevent_req *subreq)
+{
+       struct tevent_req *req = tevent_req_callback_data(
+               subreq, struct tevent_req);
+       struct chain3_andx_state *state = tevent_req_data(
+               req, struct chain3_andx_state);
+       NTSTATUS status;
+
+       status = cli_write_andx_recv(subreq, &state->written);
+       printf("cli_write_andx returned %s, written=%u\n", nt_errstr(status),
+              (unsigned)state->written);
+       TALLOC_FREE(subreq);
+       if (tevent_req_nterror(req, status)) {
+               return;
+       }
+}
+
+static void chain3_andx_close_done(struct tevent_req *subreq)
+{
+       struct tevent_req *req = tevent_req_callback_data(
+               subreq, struct tevent_req);
+       NTSTATUS status;
+
+       status = cli_close_recv(subreq);
+       printf("cli_close returned %s\n", nt_errstr(status));
+       TALLOC_FREE(subreq);
+       if (tevent_req_nterror(req, status)) {
+               return;
+       }
+       tevent_req_done(req);
+}
+
+static NTSTATUS chain3_andx_recv(struct tevent_req *req)
+{
+       return tevent_req_simple_recv_ntstatus(req);
+}
+
+struct chain3_state {
+       struct tevent_context *ev;
+       struct cli_state *cli;
+       const char *fname;
+       uint16_t fnum;
+};
+
+static void chain3_got_break(struct tevent_req *subreq);
+static void chain3_ntcreate_done(struct tevent_req *subreq);
+static void chain3_break_close_done(struct tevent_req *subreq);
+static void chain3_andx_done(struct tevent_req *subreq);
+
+static struct tevent_req *chain3_send(TALLOC_CTX *mem_ctx,
+                                     struct tevent_context *ev)
+{
+       struct tevent_req *req, *subreq;
+       struct chain3_state *state;
+
+       req = tevent_req_create(mem_ctx, &state, struct chain3_state);
+       if (req == NULL) {
+               return NULL;
+       }
+       state->ev = ev;
+       state->fname = "chain3.txt";
+
+       if (!torture_open_connection(&state->cli, 0)) {
+               tevent_req_nterror(req, NT_STATUS_UNSUCCESSFUL);
+               return tevent_req_post(req, ev);
+       }
+
+       subreq = cli_smb_oplock_break_waiter_send(
+               state, state->ev, state->cli);
+       if (tevent_req_nomem(subreq, req)) {
+               return tevent_req_post(req, ev);
+       }
+       tevent_req_set_callback(subreq, chain3_got_break, req);
+
+       subreq = cli_ntcreate_send(
+               state, state->ev, state->cli, state->fname,
+               REQUEST_OPLOCK|REQUEST_BATCH_OPLOCK,
+               GENERIC_READ_ACCESS|GENERIC_WRITE_ACCESS,
+               FILE_ATTRIBUTE_NORMAL,
+               FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
+               FILE_OVERWRITE_IF, 0, 0);
+       if (tevent_req_nomem(subreq, req)) {
+               return tevent_req_post(req, ev);
+       }
+       tevent_req_set_callback(subreq, chain3_ntcreate_done, req);
+       return req;
+}
+
+static void chain3_got_break(struct tevent_req *subreq)
+{
+       struct tevent_req *req = tevent_req_callback_data(
+               subreq, struct tevent_req);
+       struct chain3_state *state = tevent_req_data(
+               req, struct chain3_state);
+       uint16_t fnum;
+       uint8_t level;
+       NTSTATUS status;
+
+       status = cli_smb_oplock_break_waiter_recv(subreq, &fnum, &level);
+       TALLOC_FREE(subreq);
+       printf("cli_smb_oplock_break_waiter_recv returned %s\n",
+              nt_errstr(status));
+       if (tevent_req_nterror(req, status)) {
+               return;
+       }
+       subreq = cli_close_send(state, state->ev, state->cli, fnum);
+       if (tevent_req_nomem(subreq, req)) {
+               return;
+       }
+       tevent_req_set_callback(subreq, chain3_break_close_done, req);
+}
+
+static void chain3_break_close_done(struct tevent_req *subreq)
+{
+       struct tevent_req *req = tevent_req_callback_data(
+               subreq, struct tevent_req);
+       NTSTATUS status;
+
+       status = cli_close_recv(subreq);
+       TALLOC_FREE(subreq);
+       printf("cli_close_recv returned %s\n", nt_errstr(status));
+       if (tevent_req_nterror(req, status)) {
+               return;
+       }
+}
+
+static void chain3_ntcreate_done(struct tevent_req *subreq)
+{
+       struct tevent_req *req = tevent_req_callback_data(
+               subreq, struct tevent_req);
+       struct chain3_state *state = tevent_req_data(
+               req, struct chain3_state);
+       NTSTATUS status;
+
+       status = cli_ntcreate_recv(subreq, &state->fnum);
+       TALLOC_FREE(subreq);
+       printf("cli_ntcreate returned %s, fnum=%u\n", nt_errstr(status),
+              (unsigned)state->fnum);
+       if (tevent_req_nterror(req, status)) {
+               return;
+       }
+
+       subreq = chain3_andx_send(state, state->ev, state->cli, state->fname);
+       if (tevent_req_nomem(subreq, req)) {
+               return;
+       }
+       tevent_req_set_callback(subreq, chain3_andx_done, req);
+}
+
+static void chain3_andx_done(struct tevent_req *subreq)
+{
+       struct tevent_req *req = tevent_req_callback_data(
+               subreq, struct tevent_req);
+       NTSTATUS status;
+
+       status = chain3_andx_recv(subreq);
+       TALLOC_FREE(subreq);
+       printf("chain3_andx_recv returned %s\n", nt_errstr(status));
+       if (tevent_req_nterror(req, status)) {
+               return;
+       }
+       tevent_req_done(req);
+}
+
+static NTSTATUS chain3_recv(struct tevent_req *req)
+{
+       return tevent_req_simple_recv_ntstatus(req);
+}
+
+bool run_chain3(int dummy)
+{
+       TALLOC_CTX *frame = talloc_stackframe();
+       struct tevent_context *ev;
+       struct tevent_req *req;
+       NTSTATUS status = NT_STATUS_NO_MEMORY;
+
+       ev = tevent_context_init(frame);
+       if (ev == NULL) {
+               goto fail;
+       }
+       req = chain3_send(frame, ev);
+       if (req == NULL) {
+               goto fail;
+       }
+       if (!tevent_req_poll_ntstatus(req, ev, &status)) {
+               goto fail;
+       }
+       status = chain3_recv(req);
+fail:
+       TALLOC_FREE(frame);
+       printf("run_chain3 returns %s\n", nt_errstr(status));
+       return NT_STATUS_IS_OK(status);
+}
diff --git a/source3/torture/torture.c b/source3/torture/torture.c
index 0b2727c..99896ec 100644
--- a/source3/torture/torture.c
+++ b/source3/torture/torture.c
@@ -8881,6 +8881,7 @@ static struct {
        { "SESSSETUP_BENCH", run_sesssetup_bench, 0},
        { "CHAIN1", run_chain1, 0},
        { "CHAIN2", run_chain2, 0},
+       { "CHAIN3", run_chain3, 0},
        { "WINDOWS-WRITE", run_windows_write, 0},
        { "NTTRANS-CREATE", run_nttrans_create, 0},
        { "NTTRANS-FSCTL", run_nttrans_fsctl, 0},
diff --git a/source3/wscript_build b/source3/wscript_build
index b24090e..8e17c37 100755
--- a/source3/wscript_build
+++ b/source3/wscript_build
@@ -566,6 +566,7 @@ SMBTORTURE_SRC1 = '''torture/torture.c torture/nbio.c 
torture/scanner.c torture/
                torture/test_nttrans_fsctl.c
                torture/test_case_insensitive.c
                torture/test_notify_online.c
+               torture/test_chain3.c
                torture/test_smb2.c
                torture/test_authinfo_structs.c
                 torture/test_smbsock_any_connect.c


-- 
Samba Shared Repository

Reply via email to