summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2009-04-01 20:20:44 -0700
committerJeremy Allison <jra@samba.org>2009-04-01 20:20:44 -0700
commit1258ed8b1c52eff93aaa8fe132643e6c2ac31e56 (patch)
tree36734756e93a27d1e17a5d58e67ee87f545d9217
parentaef0bdc6a1ffdf746ce9ce27c45b3ca4f6593ba9 (diff)
parent87fe4d732d18d18ed56c99cba6a395a0bf9e9d95 (diff)
downloadsamba-1258ed8b1c52eff93aaa8fe132643e6c2ac31e56.tar.gz
samba-1258ed8b1c52eff93aaa8fe132643e6c2ac31e56.tar.bz2
samba-1258ed8b1c52eff93aaa8fe132643e6c2ac31e56.zip
Merge branch 'master' of ssh://jra@git.samba.org/data/git/samba
-rw-r--r--source3/modules/onefs_open.c37
-rw-r--r--source3/utils/net_conf.c22
-rw-r--r--source4/torture/raw/oplock.c176
-rw-r--r--source4/torture/raw/streams.c21
4 files changed, 210 insertions, 46 deletions
diff --git a/source3/modules/onefs_open.c b/source3/modules/onefs_open.c
index d628443ef9..f315b34c8b 100644
--- a/source3/modules/onefs_open.c
+++ b/source3/modules/onefs_open.c
@@ -199,23 +199,6 @@ static NTSTATUS onefs_open_file(files_struct *fsp,
if ((conn->fs_capabilities & FILE_NAMED_STREAMS) && stream != NULL) {
SMB_ASSERT(fsp->base_fsp);
- /*
- * We have never seen an oplock taken on a stream, and our
- * current implementation doesn't support it. If a request is
- * seen, log a loud error message and ignore the requested
- * oplock.
- */
- if ((oplock_request & ~SAMBA_PRIVATE_OPLOCK_MASK) !=
- NO_OPLOCK) {
- DEBUG(0, ("Oplock(%d) being requested on a stream! "
- "Ignoring oplock request: base=%s, "
- "stream=%s\n",
- oplock_request & ~SAMBA_PRIVATE_OPLOCK_MASK,
- base, stream));
- /* Recover by requesting NO_OPLOCK instead. */
- oplock_request &= SAMBA_PRIVATE_OPLOCK_MASK;
- }
-
DEBUG(10,("Opening a stream: base=%s(%d), stream=%s\n",
base, fsp->base_fsp->fh->fd, stream));
@@ -522,10 +505,7 @@ NTSTATUS onefs_open_file_ntcreate(connection_struct *conn,
*
* 1. Open the base file of a stream: Always done stat-only
*
- * 2. Open the stream: Oplocks are disallowed on streams, so an
- * oplock will never be contended.
- *
- * 3. open_file_fchmod(), which is called from 3 places:
+ * 2. open_file_fchmod(), which is called from 3 places:
* A. try_chown: Posix acls only. Never called on onefs.
* B. set_ea_dos_attributes: Can't be called from onefs, because
* SMB_VFS_SETXATTR return ENOSYS.
@@ -1773,6 +1753,21 @@ static NTSTATUS onefs_create_file_unixpath(connection_struct *conn,
"failed: %s\n", base, nt_errstr(status)));
goto fail;
}
+
+ /*
+ * Testing against windows xp/2003/vista shows that oplocks
+ * can actually be requested and granted on streams (see the
+ * RAW-OPLOCK-STREAM1 smbtorture test).
+ */
+ if ((oplock_request & ~SAMBA_PRIVATE_OPLOCK_MASK) !=
+ NO_OPLOCK) {
+ DEBUG(5, ("Oplock(%d) being requested on a stream! "
+ "Ignoring oplock request: fname=%s\n",
+ oplock_request & ~SAMBA_PRIVATE_OPLOCK_MASK,
+ fname));
+ /* Request NO_OPLOCK instead. */
+ oplock_request &= SAMBA_PRIVATE_OPLOCK_MASK;
+ }
}
/* Covert generic bits in the security descriptor. */
diff --git a/source3/utils/net_conf.c b/source3/utils/net_conf.c
index 38a2553e53..b65202ee69 100644
--- a/source3/utils/net_conf.c
+++ b/source3/utils/net_conf.c
@@ -300,7 +300,7 @@ static int net_conf_import(struct net_context *c, struct smbconf_ctx *conf_ctx,
net_conf_import_usage(c, argc, argv);
goto done;
case 2:
- servicename = talloc_strdup_lower(mem_ctx, argv[1]);
+ servicename = talloc_strdup(mem_ctx, argv[1]);
if (servicename == NULL) {
d_printf("error: out of memory!\n");
goto done;
@@ -501,7 +501,7 @@ static int net_conf_showshare(struct net_context *c,
goto done;
}
- sharename = talloc_strdup_lower(mem_ctx, argv[0]);
+ sharename = talloc_strdup(mem_ctx, argv[0]);
if (sharename == NULL) {
d_printf("error: out of memory!\n");
goto done;
@@ -514,7 +514,7 @@ static int net_conf_showshare(struct net_context *c,
goto done;
}
- d_printf("[%s]\n", sharename);
+ d_printf("[%s]\n", service->name);
for (count = 0; count < service->num_params; count++) {
d_printf("\t%s = %s\n", service->param_names[count],
@@ -600,7 +600,7 @@ static int net_conf_addshare(struct net_context *c,
}
case 2:
path = argv[1];
- sharename = talloc_strdup_lower(mem_ctx, argv[0]);
+ sharename = talloc_strdup(mem_ctx, argv[0]);
if (sharename == NULL) {
d_printf("error: out of memory!\n");
goto done;
@@ -728,7 +728,7 @@ static int net_conf_delshare(struct net_context *c,
net_conf_delshare_usage(c, argc, argv);
goto done;
}
- sharename = talloc_strdup_lower(mem_ctx, argv[0]);
+ sharename = talloc_strdup(mem_ctx, argv[0]);
if (sharename == NULL) {
d_printf("error: out of memory!\n");
goto done;
@@ -761,7 +761,7 @@ static int net_conf_setparm(struct net_context *c, struct smbconf_ctx *conf_ctx,
net_conf_setparm_usage(c, argc, argv);
goto done;
}
- service = talloc_strdup_lower(mem_ctx, argv[0]);
+ service = talloc_strdup(mem_ctx, argv[0]);
if (service == NULL) {
d_printf("error: out of memory!\n");
goto done;
@@ -813,7 +813,7 @@ static int net_conf_getparm(struct net_context *c, struct smbconf_ctx *conf_ctx,
net_conf_getparm_usage(c, argc, argv);
goto done;
}
- service = talloc_strdup_lower(mem_ctx, argv[0]);
+ service = talloc_strdup(mem_ctx, argv[0]);
if (service == NULL) {
d_printf("error: out of memory!\n");
goto done;
@@ -863,7 +863,7 @@ static int net_conf_delparm(struct net_context *c, struct smbconf_ctx *conf_ctx,
net_conf_delparm_usage(c, argc, argv);
goto done;
}
- service = talloc_strdup_lower(mem_ctx, argv[0]);
+ service = talloc_strdup(mem_ctx, argv[0]);
if (service == NULL) {
d_printf("error: out of memory!\n");
goto done;
@@ -916,7 +916,7 @@ static int net_conf_getincludes(struct net_context *c,
goto done;
}
- service = talloc_strdup_lower(mem_ctx, argv[0]);
+ service = talloc_strdup(mem_ctx, argv[0]);
if (service == NULL) {
d_printf("error: out of memory!\n");
goto done;
@@ -956,7 +956,7 @@ static int net_conf_setincludes(struct net_context *c,
goto done;
}
- service = talloc_strdup_lower(mem_ctx, argv[0]);
+ service = talloc_strdup(mem_ctx, argv[0]);
if (service == NULL) {
d_printf("error: out of memory!\n");
goto done;
@@ -996,7 +996,7 @@ static int net_conf_delincludes(struct net_context *c,
goto done;
}
- service = talloc_strdup_lower(mem_ctx, argv[0]);
+ service = talloc_strdup(mem_ctx, argv[0]);
if (service == NULL) {
d_printf("error: out of memory!\n");
goto done;
diff --git a/source4/torture/raw/oplock.c b/source4/torture/raw/oplock.c
index 0aeded8664..3493a552c3 100644
--- a/source4/torture/raw/oplock.c
+++ b/source4/torture/raw/oplock.c
@@ -2855,6 +2855,181 @@ done:
return ret;
}
+/* Test how oplocks work on streams. */
+static bool test_raw_oplock_stream1(struct torture_context *tctx,
+ struct smbcli_state *cli1,
+ struct smbcli_state *cli2)
+{
+ NTSTATUS status;
+ union smb_open io;
+ const char *fname_base = BASEDIR "\\test_stream1.txt";
+ const char *stream = "Stream One:$DATA";
+ const char *fname_stream, *fname_default_stream;
+ const char *default_stream = "::$DATA";
+ bool ret = true;
+ int fnum = -1;
+ int i;
+ int stream_fnum = -1;
+ uint32_t batch_req = NTCREATEX_FLAGS_REQUEST_OPLOCK |
+ NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK | NTCREATEX_FLAGS_EXTENDED;
+ uint32_t exclusive_req = NTCREATEX_FLAGS_REQUEST_OPLOCK |
+ NTCREATEX_FLAGS_EXTENDED;
+
+ /* Only passes against windows at the moment. */
+ if (torture_setting_bool(tctx, "samba3", false) ||
+ torture_setting_bool(tctx, "samba4", false)) {
+ torture_skip(tctx, "STREAM1 disabled against samba3+4\n");
+ }
+
+ fname_stream = talloc_asprintf(tctx, "%s:%s", fname_base, stream);
+ fname_default_stream = talloc_asprintf(tctx, "%s%s", fname_base,
+ default_stream);
+
+ if (!torture_setup_dir(cli1, BASEDIR)) {
+ return false;
+ }
+ smbcli_unlink(cli1->tree, fname_base);
+
+ smbcli_oplock_handler(cli2->transport, oplock_handler_ack_to_given, cli2->tree);
+ smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree);
+
+ /* Setup generic open parameters. */
+ io.generic.level = RAW_OPEN_NTCREATEX;
+ io.ntcreatex.in.root_fid = 0;
+ io.ntcreatex.in.access_mask = (SEC_FILE_READ_DATA|SEC_FILE_WRITE_DATA|
+ SEC_FILE_APPEND_DATA|SEC_STD_READ_CONTROL);
+ 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;
+ io.ntcreatex.in.alloc_size = 0;
+ io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS;
+ io.ntcreatex.in.security_flags = 0;
+
+ /* Create the file with a stream */
+ io.ntcreatex.in.fname = fname_stream;
+ io.ntcreatex.in.flags = 0;
+ io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE;
+ status = smb_raw_open(cli1->tree, tctx, &io);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
+ smbcli_close(cli1->tree, io.ntcreatex.out.file.fnum);
+
+ /* Change the disposition to open now that the file has been created. */
+ io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN;
+
+ /* Try some permutations of taking oplocks on streams. */
+#define NSTREAM_OPLOCK_RESULTS 8
+ struct {
+ const char *fname;
+ bool open_base_file;
+ uint32_t oplock_req;
+ uint32_t oplock_granted;
+ } stream_oplock_results[NSTREAM_OPLOCK_RESULTS] = {
+ /* Request oplock on stream without the base file open. */
+ {fname_stream, false, batch_req, NO_OPLOCK_RETURN},
+ {fname_default_stream, false, batch_req, NO_OPLOCK_RETURN},
+ {fname_stream, false, exclusive_req, EXCLUSIVE_OPLOCK_RETURN},
+ {fname_default_stream, false, exclusive_req, EXCLUSIVE_OPLOCK_RETURN},
+
+ /* Request oplock on stream with the base file open. */
+ {fname_stream, true, batch_req, NO_OPLOCK_RETURN},
+ {fname_default_stream, true, batch_req, NO_OPLOCK_RETURN},
+ {fname_stream, true, exclusive_req, EXCLUSIVE_OPLOCK_RETURN},
+ {fname_default_stream, true, exclusive_req, LEVEL_II_OPLOCK_RETURN},
+
+ };
+
+ for (i = 0; i < NSTREAM_OPLOCK_RESULTS; i++) {
+ const char *fname = stream_oplock_results[i].fname;
+ bool open_base_file = stream_oplock_results[i].open_base_file;
+ uint32_t oplock_req = stream_oplock_results[i].oplock_req;
+ uint32_t oplock_granted =
+ stream_oplock_results[i].oplock_granted;
+ int base_fnum = -1;
+
+ if (open_base_file) {
+ torture_comment(tctx, "Opening base file: %s with "
+ "%d\n", fname_base, oplock_req);
+ io.ntcreatex.in.fname = fname_base;
+ io.ntcreatex.in.flags = batch_req;
+ status = smb_raw_open(cli2->tree, tctx, &io);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
+ CHECK_VAL(io.ntcreatex.out.oplock_level,
+ BATCH_OPLOCK_RETURN);
+ base_fnum = io.ntcreatex.out.file.fnum;
+ }
+
+ torture_comment(tctx, "%d: Opening stream: %s with %d\n", i,
+ fname, oplock_req);
+ io.ntcreatex.in.fname = fname;
+ io.ntcreatex.in.flags = oplock_req;
+
+ /* Do the open with the desired oplock on the stream. */
+ status = smb_raw_open(cli1->tree, tctx, &io);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
+ CHECK_VAL(io.ntcreatex.out.oplock_level, oplock_granted);
+ smbcli_close(cli1->tree, io.ntcreatex.out.file.fnum);
+
+ /* Cleanup the base file if it was opened. */
+ if (base_fnum != -1) {
+ smbcli_close(cli2->tree, base_fnum);
+ }
+ }
+
+ /* Open the stream with an exclusive oplock. */
+ torture_comment(tctx, "Opening stream: %s with %d\n",
+ fname_stream, exclusive_req);
+ io.ntcreatex.in.fname = fname_stream;
+ io.ntcreatex.in.flags = exclusive_req;
+ status = smb_raw_open(cli1->tree, tctx, &io);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
+ CHECK_VAL(io.ntcreatex.out.oplock_level, EXCLUSIVE_OPLOCK_RETURN);
+ stream_fnum = io.ntcreatex.out.file.fnum;
+
+ /* Open the base file and see if it contends. */
+ ZERO_STRUCT(break_info);
+ torture_comment(tctx, "Opening base file: %s with "
+ "%d\n", fname_base, batch_req);
+ io.ntcreatex.in.fname = fname_base;
+ io.ntcreatex.in.flags = batch_req;
+ status = smb_raw_open(cli2->tree, tctx, &io);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
+ CHECK_VAL(io.ntcreatex.out.oplock_level,
+ BATCH_OPLOCK_RETURN);
+ smbcli_close(cli2->tree, io.ntcreatex.out.file.fnum);
+
+ CHECK_VAL(break_info.count, 0);
+ CHECK_VAL(break_info.failures, 0);
+
+ /* Open the stream again to see if it contends. */
+ ZERO_STRUCT(break_info);
+ torture_comment(tctx, "Opening stream again: %s with "
+ "%d\n", fname_base, batch_req);
+ io.ntcreatex.in.fname = fname_stream;
+ io.ntcreatex.in.flags = exclusive_req;
+ status = smb_raw_open(cli2->tree, tctx, &io);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
+ CHECK_VAL(io.ntcreatex.out.oplock_level,
+ LEVEL_II_OPLOCK_RETURN);
+ smbcli_close(cli2->tree, io.ntcreatex.out.file.fnum);
+
+ CHECK_VAL(break_info.count, 1);
+ CHECK_VAL(break_info.level, OPLOCK_BREAK_TO_LEVEL_II);
+ CHECK_VAL(break_info.failures, 0);
+
+ /* Close the stream. */
+ if (stream_fnum != -1) {
+ smbcli_close(cli1->tree, stream_fnum);
+ }
+
+ done:
+ smbcli_close(cli1->tree, fnum);
+ smb_raw_exit(cli1->session);
+ smb_raw_exit(cli2->session);
+ smbcli_deltree(cli1->tree, BASEDIR);
+ return ret;
+}
+
/*
basic testing of oplocks
*/
@@ -2893,6 +3068,7 @@ struct torture_suite *torture_raw_oplock(TALLOC_CTX *mem_ctx)
torture_suite_add_2smb_test(suite, "BATCH23", test_raw_oplock_batch23);
torture_suite_add_2smb_test(suite, "BATCH24", test_raw_oplock_batch24);
torture_suite_add_2smb_test(suite, "BATCH25", test_raw_oplock_batch25);
+ torture_suite_add_2smb_test(suite, "STREAM1", test_raw_oplock_stream1);
return suite;
}
diff --git a/source4/torture/raw/streams.c b/source4/torture/raw/streams.c
index d0d21ccc06..818eb402dd 100644
--- a/source4/torture/raw/streams.c
+++ b/source4/torture/raw/streams.c
@@ -1309,7 +1309,6 @@ static bool test_stream_rename2(struct torture_context *tctx,
static bool create_file_with_stream(struct torture_context *tctx,
struct smbcli_state *cli,
TALLOC_CTX *mem_ctx,
- const char *base_fname,
const char *stream)
{
NTSTATUS status;
@@ -1359,8 +1358,7 @@ static bool test_stream_create_disposition(struct torture_context *tctx,
stream_list[0] = talloc_asprintf(mem_ctx, ":%s", stream);
stream_list[1] = default_stream_name;
- if (!create_file_with_stream(tctx, cli, mem_ctx, fname,
- fname_stream)) {
+ if (!create_file_with_stream(tctx, cli, mem_ctx, fname_stream)) {
goto done;
}
@@ -1407,8 +1405,7 @@ static bool test_stream_create_disposition(struct torture_context *tctx,
*/
printf("(%s) Checking ntcreatex disp: overwrite_if\n", __location__);
smbcli_unlink(cli->tree, fname);
- if (!create_file_with_stream(tctx, cli, mem_ctx, fname,
- fname_stream)) {
+ if (!create_file_with_stream(tctx, cli, mem_ctx, fname_stream)) {
goto done;
}
@@ -1425,8 +1422,7 @@ static bool test_stream_create_disposition(struct torture_context *tctx,
*/
printf("(%s) Checking ntcreatex disp: supersede\n", __location__);
smbcli_unlink(cli->tree, fname);
- if (!create_file_with_stream(tctx, cli, mem_ctx, fname,
- fname_stream)) {
+ if (!create_file_with_stream(tctx, cli, mem_ctx, fname_stream)) {
goto done;
}
@@ -1444,8 +1440,7 @@ static bool test_stream_create_disposition(struct torture_context *tctx,
printf("(%s) Checking ntcreatex disp: overwrite_if on stream\n",
__location__);
smbcli_unlink(cli->tree, fname);
- if (!create_file_with_stream(tctx, cli, mem_ctx, fname,
- fname_stream)) {
+ if (!create_file_with_stream(tctx, cli, mem_ctx, fname_stream)) {
goto done;
}
@@ -1463,8 +1458,7 @@ static bool test_stream_create_disposition(struct torture_context *tctx,
*/
printf("(%s) Checking openx disp: overwrite_if\n", __location__);
smbcli_unlink(cli->tree, fname);
- if (!create_file_with_stream(tctx, cli, mem_ctx, fname,
- fname_stream)) {
+ if (!create_file_with_stream(tctx, cli, mem_ctx, fname_stream)) {
goto done;
}
@@ -1517,7 +1511,7 @@ static bool test_stream_large_streaminfo(struct torture_context *tctx,
for (i = 0; i < 10000; i++) {
fname_stream = talloc_asprintf(mem_ctx, "%s:%s%d", fname,
lstream_name, i);
- ret = create_file_with_stream(tctx, cli, mem_ctx, fname,
+ ret = create_file_with_stream(tctx, cli, mem_ctx,
fname_stream);
if (!ret) {
goto done;
@@ -1556,8 +1550,7 @@ static bool test_stream_attributes(struct torture_context *tctx,
fname_stream = talloc_asprintf(mem_ctx, "%s:%s", fname, stream);
/* Create a file with a stream with attribute FILE_ATTRIBUTE_ARCHIVE. */
- ret = create_file_with_stream(tctx, cli, mem_ctx, fname,
- fname_stream);
+ ret = create_file_with_stream(tctx, cli, mem_ctx, fname_stream);
if (!ret) {
goto done;
}