[SCM] Samba Shared Repository - branch v4-5-test updated

Karolin Seeger kseeger at samba.org
Mon Oct 31 15:32:06 UTC 2016


The branch, v4-5-test has been updated
       via  5eb8a18 ctdb-packaging: Move CTDB tests to /usr/local/share/ctdb/tests/
       via  ffa364b s3:smbd: only pass UCF_PREP_CREATEFILE to filename_convert() if we may create a new file
       via  0828385 Revert "ctdb-common: Use SCHED_RESET_ON_FORK when setting SCHED_FIFO"
       via  351c726 s3: vfs: streams_depot. Use conn->connectpath not conn->cwd.
       via  8f8c4b1 s3: selftest: Add test for orphan 'lost-XXX' directories in streams_depot.
       via  bfa537d s3: vfs: Remove files/directories after the streams are deleted.
       via  71d5a11 s3: torture: vfstest. unlink cmd must be stream aware.
       via  bd1aa3b smbd: in ntlm auth, do not map empty domain in case of \user at realm
       via  351cbb6 winbindd: do not modify credentials in NTLM passthrough
       via  e310d4c selftest: test NTLM user at realm authentication
       via  af7f99f ctdb-conn: add missing variable initialization
      from  e70b87b Merge tag 'samba-4.5.1' into v4-5-test

https://git.samba.org/?p=samba.git;a=shortlog;h=v4-5-test


- Log -----------------------------------------------------------------
commit 5eb8a186faa519cf25d71058f0a29888349a1b07
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Oct 11 11:30:37 2016 +1100

    ctdb-packaging: Move CTDB tests to /usr/local/share/ctdb/tests/
    
    In time, other things will end up in /use/local/share/ctdb/.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12104
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    (cherry picked from commit fd8e562069e3c01720be62069b7d58d14c10afd5)
    
    Autobuild-User(v4-5-test): Karolin Seeger <kseeger at samba.org>
    Autobuild-Date(v4-5-test): Mon Oct 31 16:31:39 CET 2016 on sn-devel-144

commit ffa364bcd0022f3e397906fb48bf858582bc05e4
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Oct 13 12:42:59 2016 +0200

    s3:smbd: only pass UCF_PREP_CREATEFILE to filename_convert() if we may create a new file
    
    This fixes a regression introduced by commit
    f98d10af2a05f0261611f4cabdfe274cd9fe91c0
    (smbd: Always use UCF_PREP_CREATEFILE for filename_convert calls to resolve a path for open)
    
    The main problem was that Windows client seem to verify
    the access to user.V2\ntuser.ini is rejected with NT_STATUS_ACCESS_DENIED,
    using the machine credentials.
    
    Passing UCF_PREP_CREATEFILE to filename_convert() triggers a code path
    that implements a dropbox behaviour. A dropbox is a directory with only -wx permissions,
    so get_real_filename fails with EACCESS, it needs to list the directory.
    EACCESS is ignored with UCF_PREP_CREATEFILE.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=10297
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Tue Oct 25 05:33:36 CEST 2016 on sn-devel-144
    
    (cherry picked from commit 759416582c54a16aacbef0e0dfe4649bddff8c5e)

commit 0828385796d4ea966e857620b80b44d18d039cfc
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Mon Oct 24 18:24:54 2016 +1100

    Revert "ctdb-common: Use SCHED_RESET_ON_FORK when setting SCHED_FIFO"
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12392
    
    Feature SCHED_RESET_ON_FORK is completely broken on RHEL6 and RHEL7
    distributions.  So do not rely on SCHED_RESET_ON_FORK for now.
    
    This reverts commit 1be8564e553ce044426dbe7b3987edf514832940.
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>
    
    Autobuild-User(master): Martin Schwenke <martins at samba.org>
    Autobuild-Date(master): Tue Oct 25 11:28:28 CEST 2016 on sn-devel-144
    
    (cherry picked from commit 71b69b0169dc6e2843325f1567f64b6acd43e6b8)

commit 351c726fcbae5f49b1d5e087dbebca1a37caa56d
Author: Jeremy Allison <jra at samba.org>
Date:   Fri Oct 21 11:04:02 2016 -0700

    s3: vfs: streams_depot. Use conn->connectpath not conn->cwd.
    
    conn->cwd can change over the life of the connection,
    conn->connectpath remains static.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12387
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Uri Simchoni <uri at samba.org>
    
    Autobuild-User(master): Uri Simchoni <uri at samba.org>
    Autobuild-Date(master): Mon Oct 24 23:52:48 CEST 2016 on sn-devel-144
    
    (cherry picked from commit 1366385d1c3e9ac0556e954864e60e72f6906942)

commit 8f8c4b1bdbbba0dfa47cb8de4bb44823ab49fd0b
Author: Jeremy Allison <jra at samba.org>
Date:   Wed Oct 19 16:33:52 2016 -0700

    s3: selftest: Add test for orphan 'lost-XXX' directories in streams_depot.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12384
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Uri Simchoni <uri at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Fri Oct 21 04:48:52 CEST 2016 on sn-devel-144
    
    (cherry picked from commit ad60b8cc48b1095ce97170eed3d09fca7181a3bc)

commit bfa537d5e2b4406e39d342a24719c8c772a56d1e
Author: Jeremy Allison <jra at samba.org>
Date:   Wed Oct 19 11:56:49 2016 -0700

    s3: vfs: Remove files/directories after the streams are deleted.
    
    By the time we get to SMB_VFS_UNLINK/SMB_VFS_RMDIR the ACL
    checks have already been done.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12384
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Uri Simchoni <uri at samba.org>
    (cherry picked from commit b17c9fdc51c10313eed32d6e078ed7050a342d0f)

commit 71d5a11ea3a4b7e75c852495f3b6676984bdc01d
Author: Jeremy Allison <jra at samba.org>
Date:   Thu Oct 20 13:33:09 2016 -0700

    s3: torture: vfstest. unlink cmd must be stream aware.
    
    Otherwise the following patch breaks vfstest stream-depot test.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12384
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Uri Simchoni <uri at samba.org>
    (cherry picked from commit 4e93ea2340b7589769d55085aaa71070a2d7e416)

commit bd1aa3b6324c73702e67fd7e0fb041658df66eec
Author: Uri Simchoni <uri at samba.org>
Date:   Sat Oct 22 22:47:08 2016 +0300

    smbd: in ntlm auth, do not map empty domain in case of \user at realm
    
    When mapping user and domain during NTLM authentication, an empty domain
    is mapped to the local SAM db. However, an empty domain may legitimately
    be used if the user field has both user and domain in upn at realm format.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12375
    
    Signed-off-by: Uri Simchoni <uri at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 3f82db56cbf2727abd465e28ac02ad2242b47c29)

commit 351cbb6c0121a0ce34c3f98cfd5bcda8732db926
Author: Uri Simchoni <uri at samba.org>
Date:   Sat Oct 22 22:40:26 2016 +0300

    winbindd: do not modify credentials in NTLM passthrough
    
    When doing NTLM validation of credentials, do not modify the
    credentials - they might be used in the calculation of
    the response.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12375
    
    Signed-off-by: Uri Simchoni <uri at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 8e88b56ebc314a5e3a722d63ca23b4a49b7ac2dc)

commit e310d4cb51b43d3b1011007eced402d4d53497cc
Author: Uri Simchoni <uri at samba.org>
Date:   Sat Oct 22 13:33:42 2016 +0300

    selftest: test NTLM user at realm authentication
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12375
    
    Signed-off-by: Uri Simchoni <uri at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 6e4c66e339d2eb11c5cb981aac2e20fcff464025)

commit af7f99f2a5571b39ebf6195f560a6cb257f4462a
Author: Ralph Wuerthner <ralph.wuerthner at de.ibm.com>
Date:   Mon Oct 10 16:26:05 2016 +0200

    ctdb-conn: add missing variable initialization
    
    Avoid potential crash in TALLOC_FREE(hdr).
    
    Signed-off-by: Ralph Wuerthner <ralph.wuerthner at de.ibm.com>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>
    (cherry picked from commit 4194c0797f78293fe48105ce5af70f36a3c233a8)
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12372
    ctdb: bad free in ctdbd_migrate()

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

Summary of changes:
 ctdb/common/system_util.c                 |  8 +-----
 ctdb/packaging/RPM/ctdb.spec.in           |  4 +--
 ctdb/wscript                              |  2 +-
 source3/auth/auth_util.c                  | 10 +++++---
 source3/lib/ctdbd_conn.c                  |  2 +-
 source3/modules/vfs_streams_depot.c       | 21 ++++++++++++----
 source3/script/tests/test_smbclient_s3.sh | 41 +++++++++++++++++++++++++++++++
 source3/selftest/tests.py                 |  1 +
 source3/smbd/filename.c                   | 23 +++++++++++++++++
 source3/smbd/nttrans.c                    |  8 +++---
 source3/smbd/proto.h                      |  1 +
 source3/smbd/reply.c                      | 38 ++++++++++++++--------------
 source3/smbd/smb2_create.c                | 10 +++++---
 source3/torture/cmd_vfs.c                 |  8 ++++++
 source3/winbindd/winbindd_pam_auth_crap.c | 11 ++++-----
 15 files changed, 137 insertions(+), 51 deletions(-)


Changeset truncated at 500 lines:

diff --git a/ctdb/common/system_util.c b/ctdb/common/system_util.c
index 9fc6c44..9e897c2 100644
--- a/ctdb/common/system_util.c
+++ b/ctdb/common/system_util.c
@@ -68,14 +68,10 @@ bool set_scheduler(void)
 #else /* no AIX */
 #if HAVE_SCHED_SETSCHEDULER
 	struct sched_param p;
-	int policy = SCHED_FIFO;
 
 	p.sched_priority = 1;
 
-#ifdef SCHED_RESET_ON_FORK
-	policy |= SCHED_RESET_ON_FORK;
-#endif
-	if (sched_setscheduler(0, policy, &p) == -1) {
+	if (sched_setscheduler(0, SCHED_FIFO, &p) == -1) {
 		DEBUG(DEBUG_CRIT,("Unable to set scheduler to SCHED_FIFO (%s)\n",
 			 strerror(errno)));
 		return false;
@@ -108,7 +104,6 @@ void reset_scheduler(void)
 #endif
 #else /* no AIX */
 #if HAVE_SCHED_SETSCHEDULER
-#ifndef SCHED_RESET_ON_FORK
 	struct sched_param p;
 
 	p.sched_priority = 0;
@@ -117,7 +112,6 @@ void reset_scheduler(void)
 	}
 #endif
 #endif
-#endif
 }
 
 bool parse_ipv4(const char *s, unsigned port, struct sockaddr_in *sin)
diff --git a/ctdb/packaging/RPM/ctdb.spec.in b/ctdb/packaging/RPM/ctdb.spec.in
index ea97d8e..aae2c7e 100644
--- a/ctdb/packaging/RPM/ctdb.spec.in
+++ b/ctdb/packaging/RPM/ctdb.spec.in
@@ -257,8 +257,8 @@ test suite for ctdb
 
 %files tests
 %defattr(-,root,root)
-%dir %{_datadir}/%{name}-tests
-%{_datadir}/%{name}-tests/*
+%dir %{_datadir}/%{name}/tests
+%{_datadir}/%{name}/tests/*
 %dir %{_libexecdir}/%{name}/tests
 %{_libexecdir}/%{name}/tests/*
 %{_bindir}/ctdb_run_tests
diff --git a/ctdb/wscript b/ctdb/wscript
index 5675849..c775cb5 100644
--- a/ctdb/wscript
+++ b/ctdb/wscript
@@ -209,7 +209,7 @@ def configure(conf):
                     conf.env.CTDB_RUNDIR))
 
     conf.env.CTDB_TEST_DATADIR = os.path.join(conf.env.EXEC_PREFIX,
-                                              'share/ctdb-tests')
+                                              'share/ctdb/tests')
     conf.env.CTDB_TEST_LIBEXECDIR = os.path.join(conf.env.LIBEXECDIR, 'ctdb/tests')
 
     # Allow unified compilation and separate compilation of utilities
diff --git a/source3/auth/auth_util.c b/source3/auth/auth_util.c
index 663c0bc..4ae1b71 100644
--- a/source3/auth/auth_util.c
+++ b/source3/auth/auth_util.c
@@ -107,6 +107,11 @@ NTSTATUS make_user_info_map(TALLOC_CTX *mem_ctx,
 	NTSTATUS result;
 	bool was_mapped;
 	char *internal_username = NULL;
+	bool upn_form = false;
+
+	if (client_domain[0] == '\0' && strchr(smb_name, '@')) {
+		upn_form = true;
+	}
 
 	was_mapped = map_username(talloc_tos(), smb_name, &internal_username);
 	if (!internal_username) {
@@ -126,10 +131,9 @@ NTSTATUS make_user_info_map(TALLOC_CTX *mem_ctx,
 	 * non-domain member box will also map to WORKSTATION\user.
 	 * This also deals with the client passing in a "" domain */
 
-	if (!is_trusted_domain(domain) &&
+	if (!upn_form && !is_trusted_domain(domain) &&
 	    !strequal(domain, my_sam_name()) &&
-	    !strequal(domain, get_global_sam_name()))
-	{
+	    !strequal(domain, get_global_sam_name())) {
 		if (lp_map_untrusted_to_domain())
 			domain = my_sam_name();
 		else
diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c
index 1f8ac94..118f3a0 100644
--- a/source3/lib/ctdbd_conn.c
+++ b/source3/lib/ctdbd_conn.c
@@ -765,7 +765,7 @@ int ctdbd_db_attach(struct ctdbd_connection *conn,
 int ctdbd_migrate(struct ctdbd_connection *conn, uint32_t db_id, TDB_DATA key)
 {
 	struct ctdb_req_call_old req;
-	struct ctdb_req_header *hdr;
+	struct ctdb_req_header *hdr = NULL;
 	struct iovec iov[2];
 	ssize_t nwritten;
 	int ret;
diff --git a/source3/modules/vfs_streams_depot.c b/source3/modules/vfs_streams_depot.c
index 83c9d97..aa54b8d 100644
--- a/source3/modules/vfs_streams_depot.c
+++ b/source3/modules/vfs_streams_depot.c
@@ -130,7 +130,8 @@ static char *stream_dir(vfs_handle_struct *handle,
 	check_valid = lp_parm_bool(SNUM(handle->conn),
 		      "streams_depot", "check_valid", true);
 
-	tmp = talloc_asprintf(talloc_tos(), "%s/.streams", handle->conn->cwd);
+	tmp = talloc_asprintf(talloc_tos(), "%s/.streams",
+		handle->conn->connectpath);
 
 	if (tmp == NULL) {
 		errno = ENOMEM;
@@ -725,8 +726,12 @@ static int streams_depot_unlink(vfs_handle_struct *handle,
 		return -1;
 	}
 
-	ret = SMB_VFS_NEXT_UNLINK(handle, smb_fname);
-	if (ret == 0) {
+	/*
+	 * We know the unlink should succeed as the ACL
+	 * check is already done in the caller. Remove the
+	 * file *after* the streams.
+	 */
+	{
 		char *dirname = stream_dir(handle, smb_fname_base,
 					   &smb_fname_base->st, false);
 
@@ -749,6 +754,7 @@ static int streams_depot_unlink(vfs_handle_struct *handle,
 		TALLOC_FREE(dirname);
 	}
 
+	ret = SMB_VFS_NEXT_UNLINK(handle, smb_fname);
 	TALLOC_FREE(smb_fname_base);
 	return ret;
 }
@@ -787,8 +793,12 @@ static int streams_depot_rmdir(vfs_handle_struct *handle,
 		return -1;
 	}
 
-	ret = SMB_VFS_NEXT_RMDIR(handle, smb_fname_base);
-	if (ret == 0) {
+	/*
+	 * We know the rmdir should succeed as the ACL
+	 * check is already done in the caller. Remove the
+	 * directory *after* the streams.
+	 */
+	{
 		char *dirname = stream_dir(handle, smb_fname_base,
 					   &smb_fname_base->st, false);
 
@@ -811,6 +821,7 @@ static int streams_depot_rmdir(vfs_handle_struct *handle,
 		TALLOC_FREE(dirname);
 	}
 
+	ret = SMB_VFS_NEXT_RMDIR(handle, smb_fname_base);
 	TALLOC_FREE(smb_fname_base);
 	return ret;
 }
diff --git a/source3/script/tests/test_smbclient_s3.sh b/source3/script/tests/test_smbclient_s3.sh
index 5e3db5d..22849bd 100755
--- a/source3/script/tests/test_smbclient_s3.sh
+++ b/source3/script/tests/test_smbclient_s3.sh
@@ -1060,6 +1060,43 @@ EOF
     fi
 }
 
+# Test creating then deleting a stream file doesn't leave a lost-XXXXX directory.
+test_streams_depot_delete()
+{
+    tmpfile=$PREFIX/smbclient_interactive_prompt_commands
+    rm -rf "$LOCAL_PATH/lost-*"
+
+    cat > $tmpfile <<EOF
+put ${PREFIX}/smbclient_interactive_prompt_commands foo:bar
+del foo
+ls lost*
+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 then deleting foo:bar with error $ret"
+	false
+	return
+    fi
+
+    echo "$out" | grep 'NT_STATUS_NO_SUCH_FILE listing \\lost\*'
+    ret=$?
+    if [ $ret != 0 ] ; then
+	echo "$out"
+	echo "deleting foo:bar left lost-XXX directory"
+	rm -rf "$LOCAL_PATH/lost-*"
+	false
+	return
+    fi
+}
+
+
 LOGDIR_PREFIX=test_smbclient_s3
 
 # possibly remove old logdirs:
@@ -1155,6 +1192,10 @@ testit "Ensure widelinks are restricted" \
     test_widelinks || \
     failed=`expr $failed + 1`
 
+testit "streams_depot can delete correctly" \
+    test_streams_depot_delete || \
+    failed=`expr $failed + 1`
+
 testit "rm -rf $LOGDIR" \
     rm -rf $LOGDIR || \
     failed=`expr $failed + 1`
diff --git a/source3/selftest/tests.py b/source3/selftest/tests.py
index 3e37ad1..7cfebd6 100755
--- a/source3/selftest/tests.py
+++ b/source3/selftest/tests.py
@@ -340,6 +340,7 @@ for t in tests:
             plansmbtorture4testsuite(t, env, '//$SERVER/tmp -U$DC_USERNAME@$REALM%$DC_PASSWORD --option=torture:addc=$DC_SERVER')
             plansmbtorture4testsuite(t, env, '//$SERVER/tmp -k yes -U$DC_USERNAME@$REALM%$DC_PASSWORD --option=torture:addc=$DC_SERVER', description='kerberos connection')
             plansmbtorture4testsuite(t, env, '//$SERVER/tmpguest -U% --option=torture:addc=$DC_SERVER', description='anonymous connection')
+            plansmbtorture4testsuite(t, env, '//$SERVER/tmp -k no -U$DC_USERNAME@$REALM%$DC_PASSWORD', description='ntlm user at realm')
     elif t == "raw.samba3posixtimedlock":
         plansmbtorture4testsuite(t, "nt4_dc", '//$SERVER_IP/tmpguest -U$USERNAME%$PASSWORD --option=torture:localdir=$SELFTEST_PREFIX/nt4_dc/share')
         plansmbtorture4testsuite(t, "ad_dc", '//$SERVER_IP/tmpguest -U$USERNAME%$PASSWORD --option=torture:localdir=$SELFTEST_PREFIX/ad_dc/share')
diff --git a/source3/smbd/filename.c b/source3/smbd/filename.c
index 7062060..a8cfb55 100644
--- a/source3/smbd/filename.c
+++ b/source3/smbd/filename.c
@@ -30,6 +30,29 @@
 #include "smbd/smbd.h"
 #include "smbd/globals.h"
 
+uint32_t filename_create_ucf_flags(struct smb_request *req, uint32_t create_disposition)
+{
+	uint32_t ucf_flags = 0;
+
+	if (req != NULL && req->posix_pathnames) {
+		ucf_flags |= UCF_POSIX_PATHNAMES;
+	}
+
+	switch (create_disposition) {
+	case FILE_OPEN:
+	case FILE_OVERWRITE:
+		break;
+	case FILE_SUPERSEDE:
+	case FILE_CREATE:
+	case FILE_OPEN_IF:
+	case FILE_OVERWRITE_IF:
+		ucf_flags |= UCF_PREP_CREATEFILE;
+		break;
+	}
+
+	return ucf_flags;
+}
+
 static NTSTATUS build_stream_path(TALLOC_CTX *mem_ctx,
 				  connection_struct *conn,
 				  struct smb_filename *smb_fname);
diff --git a/source3/smbd/nttrans.c b/source3/smbd/nttrans.c
index 05f3cae..5f122a9 100644
--- a/source3/smbd/nttrans.c
+++ b/source3/smbd/nttrans.c
@@ -461,8 +461,7 @@ void reply_ntcreate_and_X(struct smb_request *req)
 	int oplock_request;
 	uint8_t oplock_granted = NO_OPLOCK_RETURN;
 	struct case_semantics_state *case_state = NULL;
-	uint32_t ucf_flags = UCF_PREP_CREATEFILE |
-			(req->posix_pathnames ? UCF_POSIX_PATHNAMES : 0);
+	uint32_t ucf_flags;
 	TALLOC_CTX *ctx = talloc_tos();
 
 	START_PROFILE(SMBntcreateX);
@@ -536,6 +535,7 @@ void reply_ntcreate_and_X(struct smb_request *req)
 		}
 	}
 
+	ucf_flags = filename_create_ucf_flags(req, create_disposition);
 	status = filename_convert(ctx,
 				conn,
 				req->flags2 & FLAGS2_DFS_PATHNAMES,
@@ -1024,8 +1024,7 @@ static void call_nt_transact_create(connection_struct *conn,
 	int oplock_request;
 	uint8_t oplock_granted;
 	struct case_semantics_state *case_state = NULL;
-	uint32_t ucf_flags = UCF_PREP_CREATEFILE |
-			(req->posix_pathnames ? UCF_POSIX_PATHNAMES : 0);
+	uint32_t ucf_flags;
 	TALLOC_CTX *ctx = talloc_tos();
 
 	DEBUG(5,("call_nt_transact_create\n"));
@@ -1106,6 +1105,7 @@ static void call_nt_transact_create(connection_struct *conn,
 		}
 	}
 
+	ucf_flags = filename_create_ucf_flags(req, create_disposition);
 	status = filename_convert(ctx,
 				conn,
 				req->flags2 & FLAGS2_DFS_PATHNAMES,
diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h
index fb30a9e..352d28c 100644
--- a/source3/smbd/proto.h
+++ b/source3/smbd/proto.h
@@ -339,6 +339,7 @@ int fsp_stat(files_struct *fsp);
 
 /* The following definitions come from smbd/filename.c  */
 
+uint32_t filename_create_ucf_flags(struct smb_request *req, uint32_t create_disposition);
 NTSTATUS unix_convert(TALLOC_CTX *ctx,
 		      connection_struct *conn,
 		      const char *orig_path,
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c
index 4f1ecb1..0aec433 100644
--- a/source3/smbd/reply.c
+++ b/source3/smbd/reply.c
@@ -2111,8 +2111,7 @@ void reply_open(struct smb_request *req)
 	uint32_t create_options = 0;
 	uint32_t private_flags = 0;
 	NTSTATUS status;
-	uint32_t ucf_flags = UCF_PREP_CREATEFILE |
-			(req->posix_pathnames ? UCF_POSIX_PATHNAMES : 0);
+	uint32_t ucf_flags;
 	TALLOC_CTX *ctx = talloc_tos();
 
 	START_PROFILE(SMBopen);
@@ -2141,6 +2140,8 @@ void reply_open(struct smb_request *req)
 		goto out;
 	}
 
+	ucf_flags = filename_create_ucf_flags(req, create_disposition);
+
 	status = filename_convert(ctx,
 				conn,
 				req->flags2 & FLAGS2_DFS_PATHNAMES,
@@ -2265,8 +2266,7 @@ void reply_open_and_X(struct smb_request *req)
 	uint32_t create_disposition;
 	uint32_t create_options = 0;
 	uint32_t private_flags = 0;
-	uint32_t ucf_flags = UCF_PREP_CREATEFILE |
-			(req->posix_pathnames ? UCF_POSIX_PATHNAMES : 0);
+	uint32_t ucf_flags;
 	TALLOC_CTX *ctx = talloc_tos();
 
 	START_PROFILE(SMBopenX);
@@ -2313,6 +2313,8 @@ void reply_open_and_X(struct smb_request *req)
 		goto out;
 	}
 
+	ucf_flags = filename_create_ucf_flags(req, create_disposition);
+
 	status = filename_convert(ctx,
 				conn,
 				req->flags2 & FLAGS2_DFS_PATHNAMES,
@@ -2525,8 +2527,7 @@ void reply_mknew(struct smb_request *req)
 	uint32_t share_mode = FILE_SHARE_READ|FILE_SHARE_WRITE;
 	uint32_t create_disposition;
 	uint32_t create_options = 0;
-	uint32_t ucf_flags = UCF_PREP_CREATEFILE |
-			(req->posix_pathnames ? UCF_POSIX_PATHNAMES : 0);
+	uint32_t ucf_flags;
 	TALLOC_CTX *ctx = talloc_tos();
 
 	START_PROFILE(SMBcreate);
@@ -2540,6 +2541,14 @@ void reply_mknew(struct smb_request *req)
 	fattr = SVAL(req->vwv+0, 0);
 	oplock_request = CORE_OPLOCK_REQUEST(req->inbuf);
 
+	if (req->cmd == SMBmknew) {
+		/* We should fail if file exists. */
+		create_disposition = FILE_CREATE;
+	} else {
+		/* Create if file doesn't exist, truncate if it does. */
+		create_disposition = FILE_OVERWRITE_IF;
+	}
+
 	/* mtime. */
 	ft.mtime = convert_time_t_to_timespec(srv_make_unix_date3(req->vwv+1));
 
@@ -2550,6 +2559,7 @@ void reply_mknew(struct smb_request *req)
 		goto out;
 	}
 
+	ucf_flags = filename_create_ucf_flags(req, create_disposition);
 	status = filename_convert(ctx,
 				conn,
 				req->flags2 & FLAGS2_DFS_PATHNAMES,
@@ -2574,14 +2584,6 @@ void reply_mknew(struct smb_request *req)
 			 smb_fname_str_dbg(smb_fname)));
 	}
 
-	if(req->cmd == SMBmknew) {
-		/* We should fail if file exists. */
-		create_disposition = FILE_CREATE;
-	} else {
-		/* Create if file doesn't exist, truncate if it does. */
-		create_disposition = FILE_OVERWRITE_IF;
-	}
-
 	status = SMB_VFS_CREATE_FILE(
 		conn,					/* conn */
 		req,					/* req */
@@ -2658,8 +2660,7 @@ void reply_ctemp(struct smb_request *req)
 	char *s;
 	NTSTATUS status;
 	int i;
-	uint32_t ucf_flags = UCF_PREP_CREATEFILE |
-			(req->posix_pathnames ? UCF_POSIX_PATHNAMES : 0);
+	uint32_t ucf_flags;
 	TALLOC_CTX *ctx = talloc_tos();
 
 	START_PROFILE(SMBctemp);
@@ -2696,6 +2697,7 @@ void reply_ctemp(struct smb_request *req)
 			goto out;
 		}
 
+		ucf_flags = filename_create_ucf_flags(req, FILE_CREATE);
 		status = filename_convert(ctx, conn,
 				req->flags2 & FLAGS2_DFS_PATHNAMES,
 				fname,
@@ -6133,8 +6135,7 @@ void reply_mkdir(struct smb_request *req)
 	struct smb_filename *smb_dname = NULL;
 	char *directory = NULL;
 	NTSTATUS status;
-	uint32_t ucf_flags = UCF_PREP_CREATEFILE |
-			(req->posix_pathnames ? UCF_POSIX_PATHNAMES : 0);
+	uint32_t ucf_flags;
 	TALLOC_CTX *ctx = talloc_tos();
 
 	START_PROFILE(SMBmkdir);
@@ -6146,6 +6147,7 @@ void reply_mkdir(struct smb_request *req)
 		goto out;
 	}
 
+	ucf_flags = filename_create_ucf_flags(req, FILE_CREATE);
 	status = filename_convert(ctx, conn,
 				 req->flags2 & FLAGS2_DFS_PATHNAMES,
 				 directory,
diff --git a/source3/smbd/smb2_create.c b/source3/smbd/smb2_create.c
index 75da8a1..8211991 100644
--- a/source3/smbd/smb2_create.c
+++ b/source3/smbd/smb2_create.c
@@ -374,12 +374,12 @@ static bool smb2_lease_key_valid(const struct smb2_lease_key *key)
 	return ((key->data[0] != 0) || (key->data[1] != 0));
 }
 
-static NTSTATUS smbd_smb2_create_durable_lease_check(
+static NTSTATUS smbd_smb2_create_durable_lease_check(struct smb_request *smb1req,
 	const char *requested_filename, const struct files_struct *fsp,
 	const struct smb2_lease *lease_ptr)
 {
 	struct smb_filename *smb_fname = NULL;
-	uint32_t ucf_flags = UCF_PREP_CREATEFILE;
+	uint32_t ucf_flags;
 	NTSTATUS status;
 
 	if (lease_ptr == NULL) {
@@ -404,6 +404,7 @@ static NTSTATUS smbd_smb2_create_durable_lease_check(
 		return NT_STATUS_OBJECT_NAME_NOT_FOUND;
 	}
 
+	ucf_flags = filename_create_ucf_flags(smb1req, FILE_OPEN);
 	status = filename_convert(talloc_tos(), fsp->conn, false,
 				  requested_filename, ucf_flags,
 				  NULL, &smb_fname);
@@ -1057,7 +1058,7 @@ static struct tevent_req *smbd_smb2_create_send(TALLOC_CTX *mem_ctx,
 				   (unsigned)result->oplock_type, lease_ptr));
 
 			status = smbd_smb2_create_durable_lease_check(
-				fname, result, lease_ptr);
+				smb1req, fname, result, lease_ptr);
 			if (!NT_STATUS_IS_OK(status)) {
 				close_file(smb1req, result, SHUTDOWN_CLOSE);
 				tevent_req_nterror(req, status);
@@ -1078,7 +1079,7 @@ static struct tevent_req *smbd_smb2_create_send(TALLOC_CTX *mem_ctx,
 			info = FILE_WAS_OPENED;
 		} else {
 			struct smb_filename *smb_fname = NULL;
-			uint32_t ucf_flags = UCF_PREP_CREATEFILE;
+			uint32_t ucf_flags;
 
 			if (requested_oplock_level == SMB2_OPLOCK_LEVEL_LEASE) {
 				if (lease_ptr == NULL) {
@@ -1102,6 +1103,7 @@ static struct tevent_req *smbd_smb2_create_send(TALLOC_CTX *mem_ctx,
 				}
 			}
 
+			ucf_flags = filename_create_ucf_flags(smb1req, in_create_disposition);
 			status = filename_convert(req,


-- 
Samba Shared Repository



More information about the samba-cvs mailing list