[SCM] Samba Shared Repository - branch master updated

Jeremy Allison jra at samba.org
Mon Jan 9 22:15:03 UTC 2017


The branch, master has been updated
       via  28cc347 smbd/ioctl: match WS2016 ReFS set compression behaviour
       via  6fde123 torture/ioctl: test set_compression(format_none)
       via  5737624 s3/torture: add a test for "mangled names = invalid"
       via  18591ed s3/smbd: new "mangled names" setting "illegal"
       via  19eae53 s3/smbd: convert "mangled names" option to an enum
       via  e2f3411 s3: vfs: dirsort doesn't handle opendir of "." correctly.
      from  b9e76cc passdb: Remove pdb_wbc_sam

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


- Log -----------------------------------------------------------------
commit 28cc347876b97b7409d6efd377f031fc6df0c5f3
Author: David Disseldorp <ddiss at samba.org>
Date:   Thu Jan 5 17:36:02 2017 +0100

    smbd/ioctl: match WS2016 ReFS set compression behaviour
    
    ReFS doesn't support compression, but responds to set-compression FSCTLs
    with NT_STATUS_OK if (and only if) the requested compression format is
    COMPRESSION_FORMAT_NONE.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=12144
    
    Reported-by: Nick Barrett <nick at barrett.org.nz>
    Signed-off-by: David Disseldorp <ddiss at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Mon Jan  9 23:14:28 CET 2017 on sn-devel-144

commit 6fde123176409e261d955e24b3d28e5124f33bed
Author: David Disseldorp <ddiss at samba.org>
Date:   Thu Jan 5 17:10:42 2017 +0100

    torture/ioctl: test set_compression(format_none)
    
    This test case was overlooked in the previous bso#12144 update -
    set compression requests with format=COMPRESSION_FORMAT_NONE should
    succeed if the server / backing storage doesn't offer compression
    support.
    Confirm that Samba matches Windows Server 2016 ReFS behaviour here.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=12144
    
    Reported-by: Nick Barrett <nick at barrett.org.nz>
    Signed-off-by: David Disseldorp <ddiss at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 573762436ae4fe2663b12be3f5f9c4314348e312
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Dec 15 13:05:50 2016 +0100

    s3/torture: add a test for "mangled names = invalid"
    
    This checks both that illegal NTFS names are still mangled and that long
    names have no shortname.
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 18591edafad17172502cc9b831d58d27f9076bbc
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Nov 17 14:24:07 2016 +0100

    s3/smbd: new "mangled names" setting "illegal"
    
    This does mangling for names with illegal NTFS characters, but not for
    names longer then 8.3:
    
    Name mangling with mangled named = yes
    ======================================
    
    Mangled | Short | Name
    ----------------------------
            |       | foo
            | yes   | 123456789
    yes     |       | foo:bar
    
    Name mangling with mangled named = illegal
    ==========================================
    
    Mangled | Short | Name
    ----------------------------
            |       | foo
            |       | 123456789
    yes     |       | foo:bar
    
    Setting "mangled names = illegal" is the most sensible setting for
    modern clients that don't use the shortname anymore.
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 19eae537739daf95d10b67d9888769e7bf895d76
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Nov 17 14:22:41 2016 +0100

    s3/smbd: convert "mangled names" option to an enum
    
    This is in preparation of adding an additional setting for this
    option. No change in behaviour by this commit, that comes in the next
    one.
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit e2f34116ab6328e2b872999dc7c4bcda69c03ab2
Author: Jeremy Allison <jra at samba.org>
Date:   Thu Jan 5 12:38:07 2017 -0800

    s3: vfs: dirsort doesn't handle opendir of "." correctly.
    
    Needs to store $cwd path for correct sorting.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12499
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Uri Simchoni <uri at samba.org>

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

Summary of changes:
 docs-xml/smbdotconf/filename/manglednames.xml |  20 +++-
 lib/param/loadparm.h                          |   3 +
 lib/param/param_table.c                       |  11 ++
 selftest/target/Samba3.pm                     |   4 +
 source3/modules/vfs_dirsort.c                 |   4 +
 source3/param/loadparm.c                      |   2 +-
 source3/selftest/tests.py                     |   5 +
 source3/smbd/mangle.c                         |   4 +-
 source3/smbd/smb2_ioctl_filesys.c             |  26 ++---
 source3/smbd/trans2.c                         |  12 ++-
 source3/torture/torture.c                     | 147 ++++++++++++++++++++++++++
 source4/torture/smb2/ioctl.c                  |  11 +-
 12 files changed, 230 insertions(+), 19 deletions(-)


Changeset truncated at 500 lines:

diff --git a/docs-xml/smbdotconf/filename/manglednames.xml b/docs-xml/smbdotconf/filename/manglednames.xml
index bd5d97f..972834e 100644
--- a/docs-xml/smbdotconf/filename/manglednames.xml
+++ b/docs-xml/smbdotconf/filename/manglednames.xml
@@ -1,5 +1,6 @@
 <samba:parameter name="mangled names"
-                 type="boolean"
+                 type="enum"
+                 enumlist="enum_mangled_names"
                  context="S"
                  parm="1"
                  xmlns:samba="http://www.samba.org/samba/DTD/samba-doc">
@@ -11,6 +12,22 @@
 	<para>See the section on <smbconfoption name="name mangling"/> for 
 	details on how to control the mangling process.</para>
 
+	<para>Possible option settings are</para>
+
+	<itemizedlist>
+		<listitem><para><emphasis>yes (default)</emphasis> -
+		enables name mangling for all not DOS 8.3 conforming
+		names.</para></listitem>
+
+		<listitem><para><emphasis>no</emphasis> - disables any
+		name mangling.</para></listitem>
+
+		<listitem><para><emphasis>illegal</emphasis> - does
+		mangling for names with illegal NTFS characters. This
+		is the most sensible setting for modern clients that
+		don't use the shortname anymore.</para></listitem>
+	</itemizedlist>
+
 	<para>If mangling is used then the mangling method is as follows:</para>
 
 	<itemizedlist>
@@ -56,4 +73,5 @@
 	do not change between sessions.</para>
 </description>
 <value type="default">yes</value>
+<value type="example">illegal</value>
 </samba:parameter>
diff --git a/lib/param/loadparm.h b/lib/param/loadparm.h
index f9fb7d8..6d01b37 100644
--- a/lib/param/loadparm.h
+++ b/lib/param/loadparm.h
@@ -236,6 +236,9 @@ enum inheritowner_options {
 	INHERIT_OWNER_UNIX_ONLY
 };
 
+/* mangled names options */
+enum mangled_names_options {MANGLED_NAMES_NO, MANGLED_NAMES_YES, MANGLED_NAMES_ILLEGAL};
+
 /*
  * Default passwd chat script.
  */
diff --git a/lib/param/param_table.c b/lib/param/param_table.c
index 4b5234a..95c3b8c 100644
--- a/lib/param/param_table.c
+++ b/lib/param/param_table.c
@@ -315,6 +315,17 @@ static const struct enum_list enum_inherit_owner_vals[] = {
     {INHERIT_OWNER_UNIX_ONLY, "unix only"},
     {-1, NULL}};
 
+static const struct enum_list enum_mangled_names[] = {
+	{MANGLED_NAMES_NO, "no"},
+	{MANGLED_NAMES_NO, "false"},
+	{MANGLED_NAMES_NO, "0"},
+	{MANGLED_NAMES_ILLEGAL, "illegal"},
+	{MANGLED_NAMES_YES, "yes"},
+	{MANGLED_NAMES_YES, "true"},
+	{MANGLED_NAMES_YES, "1"},
+	{-1, NULL}
+};
+
 /* Note: We do not initialise the defaults union - it is not allowed in ANSI C
  *
  * NOTE: Handling of duplicated (synonym) parameters:
diff --git a/selftest/target/Samba3.pm b/selftest/target/Samba3.pm
index 9013652..1d77c97 100755
--- a/selftest/target/Samba3.pm
+++ b/selftest/target/Samba3.pm
@@ -1830,6 +1830,10 @@ sub provision($$$$$$$$)
 	copy = tmp
 	acl_xattr:ignore system acls = yes
 	acl_xattr:default acl style = windows
+
+[mangle_illegal]
+	copy = tmp
+        mangled names = illegal
 	";
 	close(CONF);
 
diff --git a/source3/modules/vfs_dirsort.c b/source3/modules/vfs_dirsort.c
index f856835..4a3e152 100644
--- a/source3/modules/vfs_dirsort.c
+++ b/source3/modules/vfs_dirsort.c
@@ -138,6 +138,10 @@ static DIR *dirsort_opendir(vfs_handle_struct *handle,
 		return NULL;
 	}
 
+	if (ISDOT(data->smb_fname->base_name)) {
+		data->smb_fname->base_name = vfs_GetWd(data, handle->conn);
+	}
+
 	/* Open the underlying directory and count the number of entries */
 	data->source_directory = SMB_VFS_NEXT_OPENDIR(handle, smb_fname, mask,
 						      attr);
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
index d8da749..ac9ba49 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -201,7 +201,7 @@ static struct loadparm_service sDefault =
 	.oplocks = true,
 	.kernel_oplocks = false,
 	.level2_oplocks = true,
-	.mangled_names = true,
+	.mangled_names = MANGLED_NAMES_YES,
 	.wide_links = false,
 	.follow_symlinks = true,
 	.sync_always = false,
diff --git a/source3/selftest/tests.py b/source3/selftest/tests.py
index 3aecc9c..37cf1a4 100755
--- a/source3/selftest/tests.py
+++ b/source3/selftest/tests.py
@@ -79,6 +79,11 @@ tests = ["OPLOCK-CANCEL"]
 for t in tests:
     plantestsuite("samba3.smbtorture_s3.plain(nt4_dc).%s" % t, "nt4_dc", [os.path.join(samba3srcdir, "script/tests/test_smbtorture_s3.sh"), t, '//$SERVER_IP/tmp', '$USERNAME', '$PASSWORD', smbtorture3, "", "-l $LOCAL_PATH"])
 
+env = "nt4_dc"
+tests = ["MANGLE-ILLEGAL"]
+for t in tests:
+    plantestsuite("samba3.smbtorture_s3.plain(%s).%s" % (env, t), env, [os.path.join(samba3srcdir, "script/tests/test_smbtorture_s3.sh"), t, '//$SERVER_IP/mangle_illegal', '$USERNAME', '$PASSWORD', smbtorture3, "", "-l $LOCAL_PATH"])
+
 tests = ["RW1", "RW2", "RW3"]
 for t in tests:
     plantestsuite("samba3.smbtorture_s3.vfs_aio_fork(simpleserver).%s" % t, "simpleserver", [os.path.join(samba3srcdir, "script/tests/test_smbtorture_s3.sh"), t, '//$SERVER_IP/vfs_aio_fork', '$USERNAME', '$PASSWORD', smbtorture3, "", "-l $LOCAL_PATH"])
diff --git a/source3/smbd/mangle.c b/source3/smbd/mangle.c
index a8988f0..3649bf7 100644
--- a/source3/smbd/mangle.c
+++ b/source3/smbd/mangle.c
@@ -104,7 +104,7 @@ bool mangle_is_8_3_wildcards(const char *fname, bool check_case,
 bool mangle_must_mangle(const char *fname,
 		   const struct share_params *p)
 {
-	if (!lp_mangled_names(p)) {
+	if (lp_mangled_names(p) == MANGLED_NAMES_NO) {
 		return False;
 	}
 	return mangle_fns->must_mangle(fname, p);
@@ -140,7 +140,7 @@ bool name_to_8_3(const char *in,
 
 	/* name mangling can be disabled for speed, in which case
 	   we just truncate the string */
-	if (!lp_mangled_names(p)) {
+	if (lp_mangled_names(p) == MANGLED_NAMES_NO) {
 		strlcpy(out, in, 13);
 		return True;
 	}
diff --git a/source3/smbd/smb2_ioctl_filesys.c b/source3/smbd/smb2_ioctl_filesys.c
index f2a0554..64b5454 100644
--- a/source3/smbd/smb2_ioctl_filesys.c
+++ b/source3/smbd/smb2_ioctl_filesys.c
@@ -104,11 +104,6 @@ static NTSTATUS fsctl_set_cmprn(TALLOC_CTX *mem_ctx,
 		return status;
 	}
 
-	if ((fsp->conn->fs_capabilities & FILE_FILE_COMPRESSION) == 0) {
-		DEBUG(4, ("FS does not advertise compression support\n"));
-		return NT_STATUS_NOT_SUPPORTED;
-	}
-
 	ndr_ret = ndr_pull_struct_blob(in_input, mem_ctx, &cmpr_state,
 			(ndr_pull_flags_fn_t)ndr_pull_compression_state);
 	if (ndr_ret != NDR_ERR_SUCCESS) {
@@ -116,15 +111,22 @@ static NTSTATUS fsctl_set_cmprn(TALLOC_CTX *mem_ctx,
 		return NT_STATUS_INVALID_PARAMETER;
 	}
 
-	status = SMB_VFS_SET_COMPRESSION(fsp->conn,
-					 mem_ctx,
-					 fsp,
-					 cmpr_state.format);
-	if (!NT_STATUS_IS_OK(status)) {
-		return status;
+	status = NT_STATUS_NOT_SUPPORTED;
+	if (fsp->conn->fs_capabilities & FILE_FILE_COMPRESSION) {
+		status = SMB_VFS_SET_COMPRESSION(fsp->conn,
+						 mem_ctx,
+						 fsp,
+						 cmpr_state.format);
+	} else if (cmpr_state.format == COMPRESSION_FORMAT_NONE) {
+		/*
+		 * bso#12144: The underlying filesystem doesn't support
+		 * compression. We should still accept set(FORMAT_NONE) requests
+		 * (like WS2016 ReFS).
+		 */
+		status = NT_STATUS_OK;
 	}
 
-	return NT_STATUS_OK;
+	return status;
 }
 
 static NTSTATUS fsctl_zero_data(TALLOC_CTX *mem_ctx,
diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c
index 6999b2d..6fe3f92 100644
--- a/source3/smbd/trans2.c
+++ b/source3/smbd/trans2.c
@@ -2440,11 +2440,17 @@ NTSTATUS smbd_dirptr_lanman2_entry(TALLOC_CTX *ctx,
 	bool ok;
 	uint64_t last_entry_off = 0;
 	NTSTATUS status;
+	enum mangled_names_options mangled_names;
+	bool marshall_with_83_names;
+
+	mangled_names = lp_mangled_names(conn->params);
 
 	ZERO_STRUCT(state);
 	state.conn = conn;
 	state.info_level = info_level;
-	state.check_mangled_names = lp_mangled_names(conn->params);
+	if (mangled_names != MANGLED_NAMES_NO) {
+		state.check_mangled_names = true;
+	}
 	state.has_wild = dptr_has_wild(dirptr);
 	state.got_exact_match = false;
 
@@ -2480,12 +2486,14 @@ NTSTATUS smbd_dirptr_lanman2_entry(TALLOC_CTX *ctx,
 
 	*got_exact_match = state.got_exact_match;
 
+	marshall_with_83_names = (mangled_names == MANGLED_NAMES_YES);
+
 	status = smbd_marshall_dir_entry(ctx,
 				     conn,
 				     flags2,
 				     info_level,
 				     name_list,
-				     state.check_mangled_names,
+				     marshall_with_83_names,
 				     requires_resume_key,
 				     mode,
 				     fname,
diff --git a/source3/torture/torture.c b/source3/torture/torture.c
index ff3d68e..073931e 100644
--- a/source3/torture/torture.c
+++ b/source3/torture/torture.c
@@ -8440,6 +8440,152 @@ static bool run_mangle1(int dummy)
 	return true;
 }
 
+static NTSTATUS mangle_illegal_list_shortname_fn(const char *mntpoint,
+						 struct file_info *f,
+						 const char *mask,
+						 void *state)
+{
+	if (f->short_name == NULL) {
+		return NT_STATUS_OK;
+	}
+
+	if (strlen(f->short_name) == 0) {
+		return NT_STATUS_OK;
+	}
+
+	printf("unexpected shortname: %s\n", f->short_name);
+
+	return NT_STATUS_OBJECT_NAME_INVALID;
+}
+
+static NTSTATUS mangle_illegal_list_name_fn(const char *mntpoint,
+					    struct file_info *f,
+					    const char *mask,
+					    void *state)
+{
+	char *name = state;
+
+	printf("name: %s\n", f->name);
+	fstrcpy(name, f->name);
+	return NT_STATUS_OK;
+}
+
+static bool run_mangle_illegal(int dummy)
+{
+	struct cli_state *cli = NULL;
+	struct cli_state *cli_posix = NULL;
+	const char *fname = "\\MANGLE_ILLEGAL\\this_is_a_long_fname_to_be_mangled.txt";
+	const char *illegal_fname = "MANGLE_ILLEGAL/foo:bar";
+	char *mangled_path = NULL;
+	uint16_t fnum;
+	fstring name;
+	fstring alt_name;
+	NTSTATUS status;
+
+	printf("starting mangle-illegal test\n");
+
+	if (!torture_open_connection(&cli, 0)) {
+		return False;
+	}
+
+	smbXcli_conn_set_sockopt(cli->conn, sockops);
+
+	if (!torture_open_connection(&cli_posix, 0)) {
+		return false;
+	}
+
+	smbXcli_conn_set_sockopt(cli_posix->conn, sockops);
+
+	status = torture_setup_unix_extensions(cli_posix);
+	if (!NT_STATUS_IS_OK(status)) {
+		return false;
+	}
+
+	cli_rmdir(cli, "\\MANGLE_ILLEGAL");
+	status = cli_mkdir(cli, "\\MANGLE_ILLEGAL");
+	if (!NT_STATUS_IS_OK(status)) {
+		printf("mkdir1 failed : %s\n", nt_errstr(status));
+		return False;
+	}
+
+	/*
+	 * Create a file with illegal NTFS characters and test that we
+	 * get a usable mangled name
+	 */
+
+	cli_setatr(cli_posix, illegal_fname, 0, 0);
+	cli_posix_unlink(cli_posix, illegal_fname);
+
+	status = cli_posix_open(cli_posix, illegal_fname, O_RDWR|O_CREAT|O_EXCL,
+				0600, &fnum);
+	if (!NT_STATUS_IS_OK(status)) {
+		printf("POSIX create of %s failed (%s)\n",
+		       illegal_fname, nt_errstr(status));
+		return false;
+	}
+
+	status = cli_close(cli_posix, fnum);
+	if (!NT_STATUS_IS_OK(status)) {
+		printf("close failed (%s)\n", nt_errstr(status));
+		return false;
+	}
+
+	status = cli_list(cli, "\\MANGLE_ILLEGAL\\*", 0, mangle_illegal_list_name_fn, &name);
+	if (!NT_STATUS_IS_OK(status)) {
+		d_printf("cli_list failed: %s\n", nt_errstr(status));
+		return false;
+	}
+
+	mangled_path = talloc_asprintf(talloc_tos(), "\\MANGLE_ILLEGAL\\%s", name);
+	if (mangled_path == NULL) {
+		return false;
+	}
+
+	status = cli_openx(cli, mangled_path, O_RDONLY, DENY_NONE, &fnum);
+	if (!NT_STATUS_IS_OK(status)) {
+		d_printf("cli_openx(%s) failed: %s\n", mangled_path, nt_errstr(status));
+		TALLOC_FREE(mangled_path);
+		return false;
+	}
+	TALLOC_FREE(mangled_path);
+	cli_close(cli, fnum);
+
+	cli_setatr(cli_posix, illegal_fname, 0, 0);
+	cli_posix_unlink(cli_posix, illegal_fname);
+
+	/*
+	 * Create a file with a long name and check that we got *no* short name.
+	 */
+
+	status = cli_ntcreate(cli, fname, 0, GENERIC_ALL_ACCESS|DELETE_ACCESS,
+			      FILE_ATTRIBUTE_NORMAL, 0, FILE_OVERWRITE_IF,
+			      0, 0, &fnum, NULL);
+	if (!NT_STATUS_IS_OK(status)) {
+		d_printf("open %s failed: %s\n", fname, nt_errstr(status));
+		return false;
+	}
+	cli_close(cli, fnum);
+
+	status = cli_list(cli, fname, 0, mangle_illegal_list_shortname_fn, &alt_name);
+	if (!NT_STATUS_IS_OK(status)) {
+		d_printf("cli_list failed\n");
+		return false;
+	}
+
+	cli_unlink(cli, fname, 0);
+	cli_rmdir(cli, "\\MANGLE_ILLEGAL");
+
+	if (!torture_close_connection(cli_posix)) {
+		return false;
+	}
+
+	if (!torture_close_connection(cli)) {
+		return false;
+	}
+
+	return true;
+}
+
 static size_t null_source(uint8_t *buf, size_t n, void *priv)
 {
 	size_t *to_pull = (size_t *)priv;
@@ -11034,6 +11180,7 @@ static struct {
 	{"PROPERTIES", run_properties, 0},
 	{"MANGLE", torture_mangle, 0},
 	{"MANGLE1", run_mangle1, 0},
+	{"MANGLE-ILLEGAL", run_mangle_illegal, 0},
 	{"W2K", run_w2ktest, 0},
 	{"TRANS2SCAN", torture_trans2_scan, 0},
 	{"NTTRANSSCAN", torture_nttrans_scan, 0},
diff --git a/source4/torture/smb2/ioctl.c b/source4/torture/smb2/ioctl.c
index 01cc150..54a36a8 100644
--- a/source4/torture/smb2/ioctl.c
+++ b/source4/torture/smb2/ioctl.c
@@ -2608,7 +2608,16 @@ static bool test_ioctl_compress_notsup_set(struct torture_context *torture,
 					 COMPRESSION_FORMAT_DEFAULT);
 	torture_assert_ntstatus_equal(torture, status,
 				      NT_STATUS_NOT_SUPPORTED,
-				      "FSCTL_GET_COMPRESSION");
+				      "FSCTL_SET_COMPRESSION default");
+
+	/*
+	 * Despite not supporting compression, we should get a successful
+	 * response for set(COMPRESSION_FORMAT_NONE) - like WS2016 ReFS.
+	 */
+	status = test_ioctl_compress_set(torture, tmp_ctx, tree, fh,
+					 COMPRESSION_FORMAT_NONE);
+	torture_assert_ntstatus_ok(torture, status,
+				   "FSCTL_SET_COMPRESSION none");
 
 	smb2_util_close(tree, fh);
 	talloc_free(tmp_ctx);


-- 
Samba Shared Repository



More information about the samba-cvs mailing list