The Samba-Bugzilla – Attachment 11451 Details for
Bug 11522
smbd can't create or open a stream name on the root directory of a share (e.g. filename of :flibble)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
git-am back-port for 4.2.next.
bug-11522-4.2 (text/plain), 12.99 KB, created by
Jeremy Allison
on 2015-09-18 18:08:04 UTC
(
hide
)
Description:
git-am back-port for 4.2.next.
Filename:
MIME Type:
Creator:
Jeremy Allison
Created:
2015-09-18 18:08:04 UTC
Size:
12.99 KB
patch
obsolete
>From 4430fb455253b8e294473271779a11db7e03402b Mon Sep 17 00:00:00 2001 >From: Jeremy Allison <jra@samba.org> >Date: Fri, 18 Sep 2015 11:01:14 -0700 >Subject: [PATCH 1/4] s3: smbclient: Move cmd_setmode out of clitar.c and back > into client.c > >setmode <file> attribute is a valid smbclient command even if libarchive >isn't on the system and tarmode isn't compiled in. > >Back-ported from master a47012d5429044c9a3616718bac21360f281aa81. > >Signed-off-by: Jeremy Allison <jra@samba.org> >Reviewed-by: Ralph Boehme <slow@samba.org> >--- > source3/client/client.c | 118 ++++++++++++++++++++++++++++++++++++++ > source3/client/client_proto.h | 6 ++ > source3/client/clitar.c | 130 ------------------------------------------ > 3 files changed, 124 insertions(+), 130 deletions(-) > >diff --git a/source3/client/client.c b/source3/client/client.c >index 1458cf2..67cc359 100644 >--- a/source3/client/client.c >+++ b/source3/client/client.c >@@ -4523,6 +4523,124 @@ static int cmd_show_connect( void ) > return 0; > } > >+/** >+ * set_remote_attr - set DOS attributes of a remote file >+ * @filename: path to the file name >+ * @new_attr: attribute bit mask to use >+ * @mode: one of ATTR_SET or ATTR_UNSET >+ * >+ * Update the file attributes with the one provided. >+ */ >+int set_remote_attr(const char *filename, uint16 new_attr, int mode) >+{ >+ extern struct cli_state *cli; >+ uint16 old_attr; >+ NTSTATUS status; >+ >+ status = cli_getatr(cli, filename, &old_attr, NULL, NULL); >+ if (!NT_STATUS_IS_OK(status)) { >+ d_printf("cli_getatr failed: %s\n", nt_errstr(status)); >+ return 1; >+ } >+ >+ if (mode == ATTR_SET) { >+ new_attr |= old_attr; >+ } else { >+ new_attr = old_attr & ~new_attr; >+ } >+ >+ status = cli_setatr(cli, filename, new_attr, 0); >+ if (!NT_STATUS_IS_OK(status)) { >+ d_printf("cli_setatr failed: %s\n", nt_errstr(status)); >+ return 1; >+ } >+ >+ return 0; >+} >+ >+/** >+ * cmd_setmode - interactive command to set DOS attributes >+ * >+ * Read a filename and mode from the client command line and update >+ * the file DOS attributes. >+ */ >+int cmd_setmode(void) >+{ >+ const extern char *cmd_ptr; >+ char *buf; >+ char *fname = NULL; >+ uint16 attr[2] = {0}; >+ int mode = ATTR_SET; >+ int err = 0; >+ bool ok; >+ TALLOC_CTX *ctx = talloc_new(NULL); >+ if (ctx == NULL) { >+ return 1; >+ } >+ >+ ok = next_token_talloc(ctx, &cmd_ptr, &buf, NULL); >+ if (!ok) { >+ d_printf("setmode <filename> <[+|-]rsha>\n"); >+ err = 1; >+ goto out; >+ } >+ >+ fname = talloc_asprintf(ctx, >+ "%s%s", >+ client_get_cur_dir(), >+ buf); >+ if (fname == NULL) { >+ err = 1; >+ goto out; >+ } >+ >+ while (next_token_talloc(ctx, &cmd_ptr, &buf, NULL)) { >+ const char *s = buf; >+ >+ while (*s) { >+ switch (*s++) { >+ case '+': >+ mode = ATTR_SET; >+ break; >+ case '-': >+ mode = ATTR_UNSET; >+ break; >+ case 'r': >+ attr[mode] |= FILE_ATTRIBUTE_READONLY; >+ break; >+ case 'h': >+ attr[mode] |= FILE_ATTRIBUTE_HIDDEN; >+ break; >+ case 's': >+ attr[mode] |= FILE_ATTRIBUTE_SYSTEM; >+ break; >+ case 'a': >+ attr[mode] |= FILE_ATTRIBUTE_ARCHIVE; >+ break; >+ default: >+ d_printf("setmode <filename> <perm=[+|-]rsha>\n"); >+ err = 1; >+ goto out; >+ } >+ } >+ } >+ >+ if (attr[ATTR_SET] == 0 && attr[ATTR_UNSET] == 0) { >+ d_printf("setmode <filename> <[+|-]rsha>\n"); >+ err = 1; >+ goto out; >+ } >+ >+ DEBUG(2, ("perm set %d %d\n", attr[ATTR_SET], attr[ATTR_UNSET])); >+ >+ /* ignore return value: server might not store DOS attributes */ >+ set_remote_attr(fname, attr[ATTR_SET], ATTR_SET); >+ set_remote_attr(fname, attr[ATTR_UNSET], ATTR_UNSET); >+out: >+ talloc_free(ctx); >+ return err; >+} >+ > /**************************************************************************** > iosize command > ***************************************************************************/ >diff --git a/source3/client/client_proto.h b/source3/client/client_proto.h >index 3e91ff0..54d3deb 100644 >--- a/source3/client/client_proto.h >+++ b/source3/client/client_proto.h >@@ -26,6 +26,11 @@ > struct cli_state; > struct file_info; > >+enum { >+ ATTR_UNSET, >+ ATTR_SET, >+}; >+ > /* The following definitions come from client/client.c */ > > const char *client_get_cur_dir(void); >@@ -36,6 +41,7 @@ NTSTATUS do_list(const char *mask, > const char *dir), > bool rec, > bool dirs); >+int set_remote_attr(const char *filename, uint16_t new_attr, int mode); > int cmd_iosize(void); > > /* The following definitions come from client/dnsbrowse.c */ >diff --git a/source3/client/clitar.c b/source3/client/clitar.c >index e4d391a..2d5c566 100644 >--- a/source3/client/clitar.c >+++ b/source3/client/clitar.c >@@ -121,11 +121,6 @@ enum tar_selection { > TAR_EXCLUDE, /* X flag */ > }; > >-enum { >- ATTR_UNSET, >- ATTR_SET, >-}; >- > struct tar { > TALLOC_CTX *talloc_ctx; > >@@ -216,7 +211,6 @@ static int make_remote_path(const char *full_path); > static int max_token (const char *str); > static NTSTATUS is_subpath(const char *sub, const char *full, > bool *_subpath_match); >-static int set_remote_attr(const char *filename, uint16 new_attr, int mode); > > /** > * tar_get_ctx - retrieve global tar context handle >@@ -384,89 +378,6 @@ out: > } > > /** >- * cmd_setmode - interactive command to set DOS attributes >- * >- * Read a filename and mode from the client command line and update >- * the file DOS attributes. >- */ >-int cmd_setmode(void) >-{ >- const extern char *cmd_ptr; >- char *buf; >- char *fname = NULL; >- uint16 attr[2] = {0}; >- int mode = ATTR_SET; >- int err = 0; >- bool ok; >- TALLOC_CTX *ctx = talloc_new(NULL); >- if (ctx == NULL) { >- return 1; >- } >- >- ok = next_token_talloc(ctx, &cmd_ptr, &buf, NULL); >- if (!ok) { >- DBG(0, ("setmode <filename> <[+|-]rsha>\n")); >- err = 1; >- goto out; >- } >- >- fname = talloc_asprintf(ctx, >- "%s%s", >- client_get_cur_dir(), >- buf); >- if (fname == NULL) { >- err = 1; >- goto out; >- } >- >- while (next_token_talloc(ctx, &cmd_ptr, &buf, NULL)) { >- const char *s = buf; >- >- while (*s) { >- switch (*s++) { >- case '+': >- mode = ATTR_SET; >- break; >- case '-': >- mode = ATTR_UNSET; >- break; >- case 'r': >- attr[mode] |= FILE_ATTRIBUTE_READONLY; >- break; >- case 'h': >- attr[mode] |= FILE_ATTRIBUTE_HIDDEN; >- break; >- case 's': >- attr[mode] |= FILE_ATTRIBUTE_SYSTEM; >- break; >- case 'a': >- attr[mode] |= FILE_ATTRIBUTE_ARCHIVE; >- break; >- default: >- DBG(0, ("setmode <filename> <perm=[+|-]rsha>\n")); >- err = 1; >- goto out; >- } >- } >- } >- >- if (attr[ATTR_SET] == 0 && attr[ATTR_UNSET] == 0) { >- DBG(0, ("setmode <filename> <[+|-]rsha>\n")); >- err = 1; >- goto out; >- } >- >- DBG(2, ("perm set %d %d\n", attr[ATTR_SET], attr[ATTR_UNSET])); >- >- /* ignore return value: server might not store DOS attributes */ >- set_remote_attr(fname, attr[ATTR_SET], ATTR_SET); >- set_remote_attr(fname, attr[ATTR_UNSET], ATTR_UNSET); >-out: >- talloc_free(ctx); >- return err; >-} >- >-/** > * tar_parse_args - parse and set tar command line arguments > * @flag: string pointing to tar options > * @val: number of tar arguments >@@ -1631,41 +1542,6 @@ out: > return status; > } > >-/** >- * set_remote_attr - set DOS attributes of a remote file >- * @filename: path to the file name >- * @new_attr: attribute bit mask to use >- * @mode: one of ATTR_SET or ATTR_UNSET >- * >- * Update the file attributes with the one provided. >- */ >-static int set_remote_attr(const char *filename, uint16 new_attr, int mode) >-{ >- extern struct cli_state *cli; >- uint16 old_attr; >- NTSTATUS status; >- >- status = cli_getatr(cli, filename, &old_attr, NULL, NULL); >- if (!NT_STATUS_IS_OK(status)) { >- DBG(0, ("cli_getatr failed: %s\n", nt_errstr(status))); >- return 1; >- } >- >- if (mode == ATTR_SET) { >- new_attr |= old_attr; >- } else { >- new_attr = old_attr & ~new_attr; >- } >- >- status = cli_setatr(cli, filename, new_attr, 0); >- if (!NT_STATUS_IS_OK(status)) { >- DBG(1, ("cli_setatr failed: %s\n", nt_errstr(status))); >- return 1; >- } >- >- return 0; >-} >- > > /** > * make_remote_path - recursively make remote dirs >@@ -1932,12 +1808,6 @@ int cmd_tarmode(void) > return 1; > } > >-int cmd_setmode(void) >-{ >- NOT_IMPLEMENTED; >- return 1; >-} >- > int cmd_tar(void) > { > NOT_IMPLEMENTED; >-- >2.6.0.rc0.131.gf624c3d > > >From 2072ab03fea8ffb4a1fec20416dfca71599548e6 Mon Sep 17 00:00:00 2001 >From: Jeremy Allison <jra@samba.org> >Date: Wed, 16 Sep 2015 12:42:46 -0700 >Subject: [PATCH 2/4] s3: smbd: Remove unused parameter from > build_stream_path(). > >Signed-off-by: Jeremy Allison <jra@samba.org> >Reviewed-by: Ralph Boehme <slow@samba.org> >(cherry picked from commit 94e7e707783036b57babc73d320d2a3d8c0648d6) >--- > source3/smbd/filename.c | 4 +--- > 1 file changed, 1 insertion(+), 3 deletions(-) > >diff --git a/source3/smbd/filename.c b/source3/smbd/filename.c >index e632796..32e736e 100644 >--- a/source3/smbd/filename.c >+++ b/source3/smbd/filename.c >@@ -32,7 +32,6 @@ > > static NTSTATUS build_stream_path(TALLOC_CTX *mem_ctx, > connection_struct *conn, >- const char *orig_path, > struct smb_filename *smb_fname); > > /**************************************************************************** >@@ -981,7 +980,7 @@ NTSTATUS unix_convert(TALLOC_CTX *ctx, > smb_fname->stream_name = stream; > > /* Check path now that the base_name has been converted. */ >- status = build_stream_path(ctx, conn, orig_path, smb_fname); >+ status = build_stream_path(ctx, conn, smb_fname); > if (!NT_STATUS_IS_OK(status)) { > goto fail; > } >@@ -1233,7 +1232,6 @@ int get_real_filename(connection_struct *conn, const char *path, > > static NTSTATUS build_stream_path(TALLOC_CTX *mem_ctx, > connection_struct *conn, >- const char *orig_path, > struct smb_filename *smb_fname) > { > NTSTATUS status; >-- >2.6.0.rc0.131.gf624c3d > > >From a3b51627077ef78ef5c6d93772bc8ca3795f4959 Mon Sep 17 00:00:00 2001 >From: Jeremy Allison <jra@samba.org> >Date: Wed, 16 Sep 2015 12:03:34 -0700 >Subject: [PATCH 3/4] s3: smbd: Fix opening/creating :stream files on the root > share directory. > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=11522 > >Signed-off-by: Jeremy Allison <jra@samba.org> >Reviewed-by: Ralph Boehme <slow@samba.org> >(cherry picked from commit 74fd4f93efe92516fc507edf71a588660782879e) >--- > source3/smbd/filename.c | 23 +++++++++++++++++++++++ > 1 file changed, 23 insertions(+) > >diff --git a/source3/smbd/filename.c b/source3/smbd/filename.c >index 32e736e..d610cf1 100644 >--- a/source3/smbd/filename.c >+++ b/source3/smbd/filename.c >@@ -370,6 +370,29 @@ NTSTATUS unix_convert(TALLOC_CTX *ctx, > */ > *stream = '\0'; > stream = tmp; >+ >+ if (smb_fname->base_name[0] == '\0') { >+ /* >+ * orig_name was just a stream name. >+ * This is a stream on the root of >+ * the share. Replace base_name with >+ * a "." >+ */ >+ smb_fname->base_name = >+ talloc_strdup(smb_fname, "."); >+ if (smb_fname->base_name == NULL) { >+ status = NT_STATUS_NO_MEMORY; >+ goto err; >+ } >+ if (SMB_VFS_STAT(conn, smb_fname) != 0) { >+ status = map_nt_error_from_unix(errno); >+ goto err; >+ } >+ DEBUG(5, ("conversion finished %s -> %s\n", >+ orig_path, >+ smb_fname->base_name)); >+ goto done; >+ } > } > } > >-- >2.6.0.rc0.131.gf624c3d > > >From f4d0369ea111083983ecb9fc50ea96979391b1e8 Mon Sep 17 00:00:00 2001 >From: Jeremy Allison <jra@samba.org> >Date: Fri, 18 Sep 2015 11:06:42 -0700 >Subject: [PATCH 4/4] s3: tests: smbclient test to ensure we can create and see > a :foobar stream on the top level directory in a share. > >Regression test for: > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=11522 > >Remember to remove the ARCHIVE attribute from the toplevel >share when done (can only be done over SMB2+). > >Back-ported from master 6ce3643e45bac6660ae69123738c4b39d7bc1864 > >Signed-off-by: Jeremy Allison <jra@samba.org> >Reviewed-by: Ralph Boehme <slow@samba.org> >--- > source3/script/tests/test_smbclient_s3.sh | 36 +++++++++++++++++++++++++++++++ > 1 file changed, 36 insertions(+) > >diff --git a/source3/script/tests/test_smbclient_s3.sh b/source3/script/tests/test_smbclient_s3.sh >index e79228f..108de87 100755 >--- a/source3/script/tests/test_smbclient_s3.sh >+++ b/source3/script/tests/test_smbclient_s3.sh >@@ -896,6 +896,38 @@ EOF > fi > } > >+# Test creating a stream on the root of the share directory filname - :foobar >+test_toplevel_stream() >+{ >+ tmpfile=$PREFIX/smbclient_interactive_prompt_commands >+ cat > $tmpfile <<EOF >+put ${PREFIX}/smbclient_interactive_prompt_commands :foobar >+allinfo \\ >+setmode \\ -a >+quit >+EOF >+ cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP -mSMB3 $ADDARGS < $tmpfile 2>&1' >+ eval echo "$cmd" >+ out=`eval $cmd` >+ ret=$? >+ rm -f $tmpfile >+ >+ if [ $ret != 0 ] ; then >+ echo "$out" >+ echo "failed creating toplevel stream :foobar with error $ret" >+ false >+ return >+ fi >+ >+ echo "$out" | grep '^stream:.*:foobar' >+ ret=$? >+ if [ $ret != 0 ] ; then >+ echo "$out" >+ echo "failed creating toplevel stream :foobar" >+ false >+ fi >+} >+ > > LOGDIR_PREFIX=test_smbclient_s3 > >@@ -980,6 +1012,10 @@ testit "list a share with a mangled name + acl_xattr object" \ > test_mangled_names || \ > failed=`expr $failed + 1` > >+testit "creating a :stream at root of share" \ >+ test_toplevel_stream || \ >+ failed=`expr $failed + 1` >+ > testit "rm -rf $LOGDIR" \ > rm -rf $LOGDIR || \ > failed=`expr $failed + 1` >-- >2.6.0.rc0.131.gf624c3d >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Flags:
slow
:
review+
Actions:
View
Attachments on
bug 11522
:
11444
|
11449
|
11450
| 11451