[PATCH] Fix for bug 11522: smbd can't create or open a stream name on the root directory of a share.
Jeremy Allison
jra at samba.org
Wed Sep 16 23:20:09 UTC 2015
An interesting log from an OEM lead me to look
into what happens when a client tries to create
a file named :streamname (no path, just stream :-).
On Windows this creates :streamname on the top
level directory of the share. For Samba, we
return NT_STATUS_OBJECT_NAME_NOT_FOUND :-(.
Fix attached (OK the first patch is a code
cleanup I noticed along the way). Includes
a regression test which we now pass !
Review + push appreciated.
Cheers,
Jeremy.
-------------- next part --------------
From 6fbaa6ccc4dbcdab66ff2f2334c77dbb919c971b Mon Sep 17 00:00:00 2001
From: Jeremy Allison <jra at samba.org>
Date: Wed, 16 Sep 2015 12:42:46 -0700
Subject: [PATCH 1/3] s3: smbd: Remove unused parameter from
build_stream_path().
Signed-off-by: Jeremy Allison <jra at samba.org>
---
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 6899d2a..e2c3fe4 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 afc06168b135d46bec45f5d8d493867bbef4156b Mon Sep 17 00:00:00 2001
From: Jeremy Allison <jra at samba.org>
Date: Wed, 16 Sep 2015 12:03:34 -0700
Subject: [PATCH 2/3] 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 at samba.org>
---
source3/smbd/filename.c | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/source3/smbd/filename.c b/source3/smbd/filename.c
index e2c3fe4..e6eca492 100644
--- a/source3/smbd/filename.c
+++ b/source3/smbd/filename.c
@@ -370,6 +370,28 @@ 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\n",
+ smb_fname->base_name));
+ goto done;
+ }
}
}
--
2.6.0.rc0.131.gf624c3d
From d873ca8d0cb0d8cb8e9225fecfaca11c23b348ce Mon Sep 17 00:00:00 2001
From: Jeremy Allison <jra at samba.org>
Date: Wed, 16 Sep 2015 16:12:15 -0700
Subject: [PATCH 3/3] 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
Signed-off-by: Jeremy Allison <jra at samba.org>
---
source3/script/tests/test_smbclient_s3.sh | 35 +++++++++++++++++++++++++++++++
1 file changed, 35 insertions(+)
diff --git a/source3/script/tests/test_smbclient_s3.sh b/source3/script/tests/test_smbclient_s3.sh
index 69c7452..be116bd 100755
--- a/source3/script/tests/test_smbclient_s3.sh
+++ b/source3/script/tests/test_smbclient_s3.sh
@@ -971,6 +971,37 @@ 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 \\
+quit
+EOF
+ cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $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
@@ -1059,6 +1090,10 @@ testit "server-side file copy" \
test_scopy || \
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
More information about the samba-technical
mailing list