[SCM] Samba Shared Repository - branch master updated

Stefan Metzmacher metze at samba.org
Thu Jun 22 15:18:04 UTC 2017


The branch, master has been updated
       via  e9b4978 tevent: version 0.9.32
       via  d7f649b tevent: include the finish location in tevent_req_default_print()
       via  bb11cf2 dsdb: Rework schema_init module to always use valid memory
       via  2c7ed6c s3:test_smbclient_s3.sh: pass the protocol (NT1) to the script
       via  a4c1960 s3:test_smbclient_s3.sh: make it explizit where we want to force SMB1 or SMB3
       via  4eb29ce s3:test_acl_xattr.sh: use -mNT1 for the 'getfacl' commands
       via  ade9926 s3:torture: use CLI_FULL_CONNECTION_DISABLE_SMB1 in run_oplock_cancel()
       via  740c2da s3:torture: add torture_open_connection_flags()
       via  0a81af6 s3:libsmb: add CLI_FULL_CONNECTION_DISABLE_SMB1
       via  1e35c63 s3:pylibsmb: use CLI_FULL_CONNECTION_FORCE_SMB1 in py_cli_state_init()
       via  5b9a2e5 s3:torture: use CLI_FULL_CONNECTION_FORCE_SMB1 in run_chain2()
       via  09ca0ed s3:torture: use CLI_FULL_CONNECTION_FORCE_SMB1 in run_tcon_devtype_test()
       via  d5020c8 s3:torture pass flags to torture_open_connection_share()
       via  2726c1a s3:client: smbclient -L can't do workgroup listing over SMB2/3
       via  b18a04b s3:torture: use CLI_FULL_CONNECTION_FORCE_SMB1 in torture_open_connection_share()
       via  5a05b0b s3:libsmb: add CLI_FULL_CONNECTION_FORCE_SMB1
       via  5be4d6d s3:torture: make use of smb_protocol_types_string() in run_smb2_negprot()
       via  5032264 libcli/smb: add smb_protocol_types_string()
       via  38f1aeb s3:libsmb: add support for SMB2 to cli_nt_delete_on_close*()
       via  8d4005b s3:libsmb: add cli_smb2_delete_on_close*()
       via  07eb10b s3:libsmb: normalize leading slashes in cli_resolve_path()
       via  8c4cef2 s3:libsmb: no longer pass remote_realm to cli_state_create()
       via  b38570e s3:libsmb: remove unused cli_state_remote_realm()
       via  5f6f4ea s3:rpc_server/spoolss: allow spoolss_connect_to_client() to use SMB2
       via  e73202a python/tests: test SMB1 and SMB2/3 in auth_log.py
      from  73a7d15 dnsserver/common: Use cached dnsHostName to reduce database reads

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


- Log -----------------------------------------------------------------
commit e9b4978a764839a142d9f7c166db436bdabea82c
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Jun 20 12:17:32 2017 +0200

    tevent: version 0.9.32
    
    * Fix mutex locking in tevent_threaded_context_destructor().
    * Fix a memleak on FreeBSD.
    * Re-init threading in tevent_re_initialise().
    * Include the finish location in tevent_req_default_print().
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    
    Autobuild-User(master): Stefan Metzmacher <metze at samba.org>
    Autobuild-Date(master): Thu Jun 22 17:17:33 CEST 2017 on sn-devel-144

commit d7f649b7044a5579d321cc1cfa7893a8221f6412
Author: Stefan Metzmacher <metze at samba.org>
Date:   Wed Jun 14 16:59:10 2017 +0200

    tevent: include the finish location in tevent_req_default_print()
    
    It's verify useful when debugging code without a debugger to
    be able to use tevent_req_print() in DEBUG statements.
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit bb11cf2c06bd49351b18da40e4fecbf5ed7f30ac
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Thu Jun 8 23:05:26 2017 +1200

    dsdb: Rework schema_init module to always use valid memory
    
    The schema can go away unless the second argument (the memory context) is supplied
    
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit 2c7ed6c283d0c67e73d7a963b3691d3de6954119
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Jun 20 09:03:02 2017 +0200

    s3:test_smbclient_s3.sh: pass the protocol (NT1) to the script
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit a4c1960a2d8d9188d84e0acecf8b7d38e0974f89
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Jun 20 09:03:02 2017 +0200

    s3:test_smbclient_s3.sh: make it explizit where we want to force SMB1 or SMB3
    
    We need to use -mNT1 or -mSMB3 at the end of the command line in order
    to overwrite possible '-m' arguments in $ADDARGS.
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 4eb29ce3266a8c05047ecf33a98d1dbdbbbd63c6
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon Jun 19 15:44:27 2017 +0200

    s3:test_acl_xattr.sh: use -mNT1 for the 'getfacl' commands
    
    The getfacl command is SMB1 only and will most likely never
    be part the SMB3 unix extensions.
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit ade99269689b6c6b7fc0e9f5e603b393cc00de1f
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon Jun 19 10:00:32 2017 +0200

    s3:torture: use CLI_FULL_CONNECTION_DISABLE_SMB1 in run_oplock_cancel()
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 740c2dad3e4dd3d5f2b408ccdb751ae96527e3d5
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon Jun 19 10:00:15 2017 +0200

    s3:torture: add torture_open_connection_flags()
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 0a81af6824c72b52b4be42003401741132f41b79
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon Jun 19 09:57:28 2017 +0200

    s3:libsmb: add CLI_FULL_CONNECTION_DISABLE_SMB1
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 1e35c63f4e665d42e9a844d9f9385d591bdfc7e0
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Jun 20 08:02:40 2017 +0200

    s3:pylibsmb: use CLI_FULL_CONNECTION_FORCE_SMB1 in py_cli_state_init()
    
    For now we only support SMB1, as most of the cli_*_send() function don't
    support SMB2, it's only plugged into the sync wrapper functions currently.
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 5b9a2e520db0b609958f0b37b15b3e891478d8c9
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon Jun 19 09:46:55 2017 +0200

    s3:torture: use CLI_FULL_CONNECTION_FORCE_SMB1 in run_chain2()
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 09ca0ed6747ecbc458751d1e10da66edb09d0868
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon Jun 19 09:45:26 2017 +0200

    s3:torture: use CLI_FULL_CONNECTION_FORCE_SMB1 in run_tcon_devtype_test()
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit d5020c8bedfd66989511656b0cd8dd36a2927fe1
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon Jun 19 09:45:05 2017 +0200

    s3:torture pass flags to torture_open_connection_share()
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 2726c1a1b0c69d618248b607eca2b0845ddda41d
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon Jun 19 08:49:05 2017 +0200

    s3:client: smbclient -L can't do workgroup listing over SMB2/3
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit b18a04b4bb6aec9bd1fd9a23997197605fb7922e
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon Jun 19 08:17:27 2017 +0200

    s3:torture: use CLI_FULL_CONNECTION_FORCE_SMB1 in torture_open_connection_share()
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 5a05b0b169fcc2de10e31a17c9ad3cc55cb01445
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon Jun 19 08:16:57 2017 +0200

    s3:libsmb: add CLI_FULL_CONNECTION_FORCE_SMB1
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 5be4d6d50e35b4fec440bdd092c3ba87a6fa7669
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon Jun 19 21:53:49 2017 +0200

    s3:torture: make use of smb_protocol_types_string() in run_smb2_negprot()
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 503226406b8d178f753f85f5128ccb5e180a1ccc
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon Jun 19 21:52:54 2017 +0200

    libcli/smb: add smb_protocol_types_string()
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 38f1aeba7e15d510d266214431953f10d3434532
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Jun 20 08:35:47 2017 +0200

    s3:libsmb: add support for SMB2 to cli_nt_delete_on_close*()
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 8d4005b07b08d5673b75d5d79f9b3d6936596fae
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Jun 20 08:35:13 2017 +0200

    s3:libsmb: add cli_smb2_delete_on_close*()
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 07eb10b7457adc9a994284d7e7ea12bbb3f5d2f5
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon Jun 19 14:13:37 2017 +0200

    s3:libsmb: normalize leading slashes in cli_resolve_path()
    
    As we try to pass the path to an SMB2 server, we should have
    just one leading backslash (which then gets ignored in
    cli_smb2_create_fnum_send()).
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 8c4cef218af2f5464223e56bbde8d50acce79155
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Dec 8 14:06:39 2016 +0100

    s3:libsmb: no longer pass remote_realm to cli_state_create()
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit b38570e5020fed0a6ba91d8cce7d8af1523bee90
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Dec 8 14:06:16 2016 +0100

    s3:libsmb: remove unused cli_state_remote_realm()
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 5f6f4ea01ad2ef22d2d7b3742f77f5743042cb62
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon Jun 19 15:46:54 2017 +0200

    s3:rpc_server/spoolss: allow spoolss_connect_to_client() to use SMB2
    
    It's just required that we can run DCERPC over the connection.
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit e73202aaec4f8c2199ea29fc666064239c11942a
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Jun 20 08:26:45 2017 +0200

    python/tests: test SMB1 and SMB2/3 in auth_log.py
    
    We should do this explicitly in order to make
    the tests independent of 'client max protocol'.
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

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

Summary of changes:
 .../ABI/{tevent-0.9.31.sigs => tevent-0.9.32.sigs} |   0
 lib/tevent/tevent_req.c                            |   5 +-
 lib/tevent/wscript                                 |   2 +-
 libcli/smb/smb_util.h                              |   1 +
 libcli/smb/test_smb1cli_session.c                  |   1 +
 libcli/smb/util.c                                  |  38 ++++++
 python/samba/tests/auth_log.py                     |  49 +++++++-
 source3/client/client.c                            |  13 ++-
 source3/include/client.h                           |   3 +-
 source3/libsmb/cli_smb2_fnum.c                     | 127 +++++++++++++++++++++
 source3/libsmb/cli_smb2_fnum.h                     |   7 ++
 source3/libsmb/cliconnect.c                        |  11 +-
 source3/libsmb/clidfs.c                            |   7 ++
 source3/libsmb/clientgen.c                         |  13 ---
 source3/libsmb/clifile.c                           |  37 ++++--
 source3/libsmb/proto.h                             |   2 -
 source3/libsmb/pylibsmb.c                          |   9 +-
 source3/rpc_server/spoolss/srv_spoolss_nt.c        |   2 +-
 source3/script/tests/test_acl_xattr.sh             |  12 +-
 source3/script/tests/test_smbclient_s3.sh          |  43 +++----
 source3/selftest/tests.py                          |  10 +-
 source3/torture/proto.h                            |   1 +
 source3/torture/test_oplock_cancel.c               |  15 ++-
 source3/torture/test_smb2.c                        |  34 +-----
 source3/torture/torture.c                          |  34 ++++--
 source3/winbindd/winbindd_cm.c                     |   3 +-
 source4/dsdb/samdb/ldb_modules/schema_load.c       |  62 ++++++----
 27 files changed, 406 insertions(+), 135 deletions(-)
 copy lib/tevent/ABI/{tevent-0.9.31.sigs => tevent-0.9.32.sigs} (100%)


Changeset truncated at 500 lines:

diff --git a/lib/tevent/ABI/tevent-0.9.31.sigs b/lib/tevent/ABI/tevent-0.9.32.sigs
similarity index 100%
copy from lib/tevent/ABI/tevent-0.9.31.sigs
copy to lib/tevent/ABI/tevent-0.9.32.sigs
diff --git a/lib/tevent/tevent_req.c b/lib/tevent/tevent_req.c
index e309c3d..22f7a4f 100644
--- a/lib/tevent/tevent_req.c
+++ b/lib/tevent/tevent_req.c
@@ -31,14 +31,15 @@ char *tevent_req_default_print(struct tevent_req *req, TALLOC_CTX *mem_ctx)
 {
 	return talloc_asprintf(mem_ctx,
 			       "tevent_req[%p/%s]: state[%d] error[%lld (0x%llX)] "
-			       " state[%s (%p)] timer[%p]",
+			       " state[%s (%p)] timer[%p] finish[%s]",
 			       req, req->internal.create_location,
 			       req->internal.state,
 			       (unsigned long long)req->internal.error,
 			       (unsigned long long)req->internal.error,
 			       talloc_get_name(req->data),
 			       req->data,
-			       req->internal.timer
+			       req->internal.timer,
+			       req->internal.finish_location
 			       );
 }
 
diff --git a/lib/tevent/wscript b/lib/tevent/wscript
index 0c02f70..54f216d 100644
--- a/lib/tevent/wscript
+++ b/lib/tevent/wscript
@@ -1,7 +1,7 @@
 #!/usr/bin/env python
 
 APPNAME = 'tevent'
-VERSION = '0.9.31'
+VERSION = '0.9.32'
 
 blddir = 'bin'
 
diff --git a/libcli/smb/smb_util.h b/libcli/smb/smb_util.h
index 2884786..501b8dd 100644
--- a/libcli/smb/smb_util.h
+++ b/libcli/smb/smb_util.h
@@ -19,6 +19,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
+const char *smb_protocol_types_string(enum protocol_types protocol);
 char *attrib_string(TALLOC_CTX *mem_ctx, uint32_t attrib);
 uint32_t unix_perms_to_wire(mode_t perms);
 mode_t wire_perms_to_unix(uint32_t perms);
diff --git a/libcli/smb/test_smb1cli_session.c b/libcli/smb/test_smb1cli_session.c
index e924b32..d1e21d5 100644
--- a/libcli/smb/test_smb1cli_session.c
+++ b/libcli/smb/test_smb1cli_session.c
@@ -6,6 +6,7 @@
 #include "replace.h"
 #include <talloc.h>
 #include "libcli/util/ntstatus.h"
+#include "smb_constants.h"
 #include "smb_util.h"
 
 static const uint8_t smb1_session_setup_bytes[] = {
diff --git a/libcli/smb/util.c b/libcli/smb/util.c
index 7ef909c..6fdf35f 100644
--- a/libcli/smb/util.c
+++ b/libcli/smb/util.c
@@ -23,6 +23,44 @@
 #include "libcli/smb/smb_common.h"
 #include "system/filesys.h"
 
+const char *smb_protocol_types_string(enum protocol_types protocol)
+{
+	switch (protocol) {
+	case PROTOCOL_DEFAULT:
+		return "DEFAULT";
+	case PROTOCOL_NONE:
+		return "NONE";
+	case PROTOCOL_CORE:
+		return "CORE";
+	case PROTOCOL_COREPLUS:
+		return "COREPLUS";
+	case PROTOCOL_LANMAN1:
+		return "LANMAN1";
+	case PROTOCOL_LANMAN2:
+		return "LANMAN2";
+	case PROTOCOL_NT1:
+		return "NT1";
+	case PROTOCOL_SMB2_02:
+		return "SMB2_02";
+	case PROTOCOL_SMB2_10:
+		return "SMB2_10";
+	case PROTOCOL_SMB2_22:
+		return "SMB2_22";
+	case PROTOCOL_SMB2_24:
+		return "SMB2_24";
+	case PROTOCOL_SMB3_00:
+		return "SMB3_00";
+	case PROTOCOL_SMB3_02:
+		return "SMB3_02";
+	case PROTOCOL_SMB3_10:
+		return "SMB3_10";
+	case PROTOCOL_SMB3_11:
+		return "SMB3_11";
+	}
+
+	return "Invalid protocol_types value";
+}
+
 /**
  Return a string representing a CIFS attribute for a file.
 **/
diff --git a/python/samba/tests/auth_log.py b/python/samba/tests/auth_log.py
index ff84bef..65800c9 100644
--- a/python/samba/tests/auth_log.py
+++ b/python/samba/tests/auth_log.py
@@ -700,7 +700,7 @@ class AuthLogTests(samba.tests.auth_log_base.AuthLogTestBase):
                           len(messages),
                           "Did not receive the expected number of messages")
 
-    def test_smb_anonymous(self):
+    def test_smb1_anonymous(self):
         def isLastExpectedMessage(msg):
             return (msg["type"] == "Authorization" and
                     msg["Authorization"]["serviceDescription"] == "SMB" and
@@ -712,7 +712,7 @@ class AuthLogTests(samba.tests.auth_log_base.AuthLogTestBase):
 
         path = "//%s/IPC$" % server
         auth = "-N"
-        call(["bin/smbclient", path, auth, "-c quit"])
+        call(["bin/smbclient", path, auth, "-mNT1", "-c quit"])
 
         messages = self.waitForMessages(isLastExpectedMessage)
         self.assertEquals(3,
@@ -745,6 +745,51 @@ class AuthLogTests(samba.tests.auth_log_base.AuthLogTestBase):
         self.assertEquals("ANONYMOUS LOGON",
                           msg["Authentication"]["becameAccount"])
 
+    def test_smb2_anonymous(self):
+        def isLastExpectedMessage(msg):
+            return (msg["type"] == "Authorization" and
+                    msg["Authorization"]["serviceDescription"] == "SMB2" and
+                    msg["Authorization"]["authType"] == "NTLMSSP" and
+                    msg["Authorization"]["account"] == "ANONYMOUS LOGON" and
+                    msg["Authorization"]["transportProtection"] == "SMB")
+
+        server   = os.environ["SERVER"]
+
+        path = "//%s/IPC$" % server
+        auth = "-N"
+        call(["bin/smbclient", path, auth, "-mSMB3", "-c quit"])
+
+        messages = self.waitForMessages(isLastExpectedMessage)
+        self.assertEquals(3,
+                          len(messages),
+                          "Did not receive the expected number of messages")
+
+        # Check the first message it should be an Authentication
+        msg = messages[0]
+        self.assertEquals("Authentication", msg["type"])
+        self.assertEquals("NT_STATUS_NO_SUCH_USER",
+                          msg["Authentication"]["status"])
+        self.assertEquals("SMB2",
+                          msg["Authentication"]["serviceDescription"])
+        self.assertEquals("NTLMSSP",
+                          msg["Authentication"]["authDescription"])
+        self.assertEquals("No-Password",
+                          msg["Authentication"]["passwordType"])
+
+        # Check the second message it should be an Authentication
+        msg = messages[1]
+        self.assertEquals("Authentication", msg["type"])
+        self.assertEquals("NT_STATUS_OK",
+                          msg["Authentication"]["status"])
+        self.assertEquals("SMB2",
+                          msg["Authentication"]["serviceDescription"])
+        self.assertEquals("NTLMSSP",
+                          msg["Authentication"]["authDescription"])
+        self.assertEquals("No-Password",
+                          msg["Authentication"]["passwordType"])
+        self.assertEquals("ANONYMOUS LOGON",
+                          msg["Authentication"]["becameAccount"])
+
     def test_smb_no_krb_spnego(self):
         def isLastExpectedMessage(msg):
             return (msg["type"] == "Authorization" and
diff --git a/source3/client/client.c b/source3/client/client.c
index 3285240..375d9e3 100644
--- a/source3/client/client.c
+++ b/source3/client/client.c
@@ -5646,16 +5646,21 @@ static int do_host_query(const char *query_host)
 		goto out;
 	}
 
-	if (port != NBT_SMB_PORT) {
+	if (port != NBT_SMB_PORT ||
+	    smbXcli_conn_protocol(cli->conn) > PROTOCOL_NT1)
+	{
+		int max_proto = MIN(max_protocol, PROTOCOL_NT1);
 
-		/* Workgroups simply don't make sense over anything
-		   else but port 139... */
+		/*
+		 * Workgroups simply don't make sense over anything
+		 * else but port 139 and SMB1.
+		 */
 
 		cli_shutdown(cli);
 		status = cli_cm_open(talloc_tos(), NULL,
 				     have_ip ? dest_ss_str : query_host,
 				     "IPC$", popt_get_cmdline_auth_info(),
-				     true, smb_encrypt, max_protocol,
+				     true, smb_encrypt, max_proto,
 				     NBT_SMB_PORT, name_type, &cli);
 		if (!NT_STATUS_IS_OK(status)) {
 			cli = NULL;
diff --git a/source3/include/client.h b/source3/include/client.h
index db8260d..1fe3f1c 100644
--- a/source3/include/client.h
+++ b/source3/include/client.h
@@ -87,7 +87,6 @@ struct cli_state {
 	char *dfs_mountpoint;
 
 	struct smbXcli_conn *conn;
-	const char *remote_realm;
 
 	struct {
 		uint32_t pid;
@@ -126,5 +125,7 @@ struct file_info {
 #define CLI_FULL_CONNECTION_FORCE_DOS_ERRORS 0x0080
 #define CLI_FULL_CONNECTION_FORCE_ASCII 0x0100
 #define CLI_FULL_CONNECTION_USE_NT_HASH 0x0200
+#define CLI_FULL_CONNECTION_FORCE_SMB1 0x0400
+#define CLI_FULL_CONNECTION_DISABLE_SMB1 0x0800
 
 #endif /* _CLIENT_H */
diff --git a/source3/libsmb/cli_smb2_fnum.c b/source3/libsmb/cli_smb2_fnum.c
index 351fccf..954f3fe 100644
--- a/source3/libsmb/cli_smb2_fnum.c
+++ b/source3/libsmb/cli_smb2_fnum.c
@@ -485,6 +485,133 @@ NTSTATUS cli_smb2_close_fnum(struct cli_state *cli, uint16_t fnum)
 	return status;
 }
 
+struct cli_smb2_delete_on_close_state {
+	struct cli_state *cli;
+	uint16_t fnum;
+	struct smb2_hnd *ph;
+	uint8_t data[1];
+	DATA_BLOB inbuf;
+};
+
+static void cli_smb2_delete_on_close_done(struct tevent_req *subreq);
+
+struct tevent_req *cli_smb2_delete_on_close_send(TALLOC_CTX *mem_ctx,
+					struct tevent_context *ev,
+					struct cli_state *cli,
+					uint16_t fnum,
+					bool flag)
+{
+	struct tevent_req *req = NULL;
+	struct cli_smb2_delete_on_close_state *state = NULL;
+	struct tevent_req *subreq = NULL;
+	uint8_t in_info_type;
+	uint8_t in_file_info_class;
+	NTSTATUS status;
+
+	req = tevent_req_create(mem_ctx, &state,
+				struct cli_smb2_delete_on_close_state);
+	if (req == NULL) {
+		return NULL;
+	}
+	state->cli = cli;
+	state->fnum = fnum;
+
+	if (smbXcli_conn_protocol(cli->conn) < PROTOCOL_SMB2_02) {
+		tevent_req_nterror(req, NT_STATUS_INVALID_PARAMETER);
+		return tevent_req_post(req, ev);
+	}
+
+	status = map_fnum_to_smb2_handle(cli, fnum, &state->ph);
+	if (tevent_req_nterror(req, status)) {
+		return tevent_req_post(req, ev);
+	}
+
+	/*
+	 * setinfo on the handle with info_type SMB2_SETINFO_FILE (1),
+	 * level 13 (SMB_FILE_DISPOSITION_INFORMATION - 1000).
+	 */
+	in_info_type = 1;
+	in_file_info_class = SMB_FILE_DISPOSITION_INFORMATION - 1000;
+	/* Setup data array. */
+	SCVAL(&state->data[0], 0, flag ? 1 : 0);
+	state->inbuf.data = &state->data[0];
+	state->inbuf.length = 1;
+
+	subreq = smb2cli_set_info_send(state, ev,
+				       cli->conn,
+				       cli->timeout,
+				       cli->smb2.session,
+				       cli->smb2.tcon,
+				       in_info_type,
+				       in_file_info_class,
+				       &state->inbuf, /* in_input_buffer */
+				       0, /* in_additional_info */
+				       state->ph->fid_persistent,
+				       state->ph->fid_volatile);
+	if (tevent_req_nomem(subreq, req)) {
+		return tevent_req_post(req, ev);
+	}
+	tevent_req_set_callback(subreq,
+				cli_smb2_delete_on_close_done,
+				req);
+	return req;
+}
+
+static void cli_smb2_delete_on_close_done(struct tevent_req *subreq)
+{
+	NTSTATUS status = smb2cli_set_info_recv(subreq);
+	tevent_req_simple_finish_ntstatus(subreq, status);
+}
+
+NTSTATUS cli_smb2_delete_on_close_recv(struct tevent_req *req)
+{
+	struct cli_smb2_delete_on_close_state *state =
+		tevent_req_data(req,
+		struct cli_smb2_delete_on_close_state);
+	NTSTATUS status;
+
+	if (tevent_req_is_nterror(req, &status)) {
+		state->cli->raw_status = status;
+		tevent_req_received(req);
+		return status;
+	}
+
+	state->cli->raw_status = NT_STATUS_OK;
+	tevent_req_received(req);
+	return NT_STATUS_OK;
+}
+
+NTSTATUS cli_smb2_delete_on_close(struct cli_state *cli, uint16_t fnum, bool flag)
+{
+	TALLOC_CTX *frame = talloc_stackframe();
+	struct tevent_context *ev;
+	struct tevent_req *req;
+	NTSTATUS status = NT_STATUS_NO_MEMORY;
+
+	if (smbXcli_conn_has_async_calls(cli->conn)) {
+		/*
+		 * Can't use sync call while an async call is in flight
+		 */
+		status = NT_STATUS_INVALID_PARAMETER;
+		goto fail;
+	}
+	ev = samba_tevent_context_init(frame);
+	if (ev == NULL) {
+		goto fail;
+	}
+	req = cli_smb2_delete_on_close_send(frame, ev, cli, fnum, flag);
+	if (req == NULL) {
+		goto fail;
+	}
+	if (!tevent_req_poll_ntstatus(req, ev, &status)) {
+		goto fail;
+	}
+	status = cli_smb2_delete_on_close_recv(req);
+ fail:
+	TALLOC_FREE(frame);
+	return status;
+}
+
 /***************************************************************
  Small wrapper that allows SMB2 to create a directory
  Synchronous only.
diff --git a/source3/libsmb/cli_smb2_fnum.h b/source3/libsmb/cli_smb2_fnum.h
index 43e0471..190ec59 100644
--- a/source3/libsmb/cli_smb2_fnum.h
+++ b/source3/libsmb/cli_smb2_fnum.h
@@ -54,6 +54,13 @@ struct tevent_req *cli_smb2_close_fnum_send(TALLOC_CTX *mem_ctx,
 					    uint16_t fnum);
 NTSTATUS cli_smb2_close_fnum_recv(struct tevent_req *req);
 NTSTATUS cli_smb2_close_fnum(struct cli_state *cli, uint16_t fnum);
+struct tevent_req *cli_smb2_delete_on_close_send(TALLOC_CTX *mem_ctx,
+					struct tevent_context *ev,
+					struct cli_state *cli,
+					uint16_t fnum,
+					bool flag);
+NTSTATUS cli_smb2_delete_on_close_recv(struct tevent_req *req);
+NTSTATUS cli_smb2_delete_on_close(struct cli_state *cli, uint16_t fnum, bool flag);
 NTSTATUS cli_smb2_mkdir(struct cli_state *cli, const char *dirname);
 NTSTATUS cli_smb2_rmdir(struct cli_state *cli, const char *dirname);
 NTSTATUS cli_smb2_unlink(struct cli_state *cli,const char *fname);
diff --git a/source3/libsmb/cliconnect.c b/source3/libsmb/cliconnect.c
index 3fa80a2..d98debc 100644
--- a/source3/libsmb/cliconnect.c
+++ b/source3/libsmb/cliconnect.c
@@ -2686,7 +2686,7 @@ static void cli_connect_nb_done(struct tevent_req *subreq)
 		return;
 	}
 
-	state->cli = cli_state_create(state, fd, state->desthost, NULL,
+	state->cli = cli_state_create(state, fd, state->desthost,
 				      state->signing_state, state->flags);
 	if (tevent_req_nomem(state->cli, req)) {
 		close(fd);
@@ -2780,6 +2780,15 @@ static struct tevent_req *cli_start_connection_send(
 		state->max_protocol = lp_client_max_protocol();
 	}
 
+	if (flags & CLI_FULL_CONNECTION_FORCE_SMB1) {
+		state->max_protocol = MIN(state->max_protocol, PROTOCOL_NT1);
+	}
+
+	if (flags & CLI_FULL_CONNECTION_DISABLE_SMB1) {
+		state->min_protocol = MAX(state->max_protocol, PROTOCOL_SMB2_02);
+		state->max_protocol = MAX(state->max_protocol, PROTOCOL_LATEST);
+	}
+
 	subreq = cli_connect_nb_send(state, ev, dest_host, dest_ss, port,
 				     0x20, my_name, signing_state, flags);
 	if (tevent_req_nomem(subreq, req)) {
diff --git a/source3/libsmb/clidfs.c b/source3/libsmb/clidfs.c
index 75012b2..060c4e9 100644
--- a/source3/libsmb/clidfs.c
+++ b/source3/libsmb/clidfs.c
@@ -919,6 +919,13 @@ NTSTATUS cli_resolve_path(TALLOC_CTX *ctx,
 		root_tcon = rootcli->smb1.tcon;
 	}
 
+	/*
+	 * Avoid more than one leading directory separator
+	 */
+	while (IS_DIRECTORY_SEP(path[0]) && IS_DIRECTORY_SEP(path[1])) {
+		path++;
+	}
+
 	if (!smbXcli_tcon_is_dfs_share(root_tcon)) {
 		*targetcli = rootcli;
 		*pp_targetpath = talloc_strdup(ctx, path);
diff --git a/source3/libsmb/clientgen.c b/source3/libsmb/clientgen.c
index 2b53a93..039176e 100644
--- a/source3/libsmb/clientgen.c
+++ b/source3/libsmb/clientgen.c
@@ -75,7 +75,6 @@ struct GUID cli_state_client_guid;
 struct cli_state *cli_state_create(TALLOC_CTX *mem_ctx,
 				   int fd,
 				   const char *remote_name,
-				   const char *remote_realm,
 				   int signing_state, int flags)
 {
 	struct cli_state *cli = NULL;
@@ -209,13 +208,6 @@ struct cli_state *cli_state_create(TALLOC_CTX *mem_ctx,
 
 	smb2_capabilities = SMB2_CAP_ALL;
 
-	if (remote_realm) {
-		cli->remote_realm = talloc_strdup(cli, remote_realm);
-		if (cli->remote_realm == NULL) {
-			goto error;
-		}
-	}
-
 	cli->conn = smbXcli_conn_create(cli, fd, remote_name,
 					signing_state,
 					smb1_capabilities,
@@ -308,11 +300,6 @@ void cli_shutdown(struct cli_state *cli)
 	_cli_shutdown(cli);
 }
 
-const char *cli_state_remote_realm(struct cli_state *cli)
-{
-	return cli->remote_realm;
-}
-
 uint16_t cli_state_get_vc_num(struct cli_state *cli)
 {
 	return cli->smb1.vc_num;
diff --git a/source3/libsmb/clifile.c b/source3/libsmb/clifile.c
index cc1d1e4..1455fbd 100644
--- a/source3/libsmb/clifile.c
+++ b/source3/libsmb/clifile.c
@@ -1803,12 +1803,8 @@ struct doc_state {
 	uint8_t data[1];
 };
 
-static void cli_nt_delete_on_close_done(struct tevent_req *subreq)
-{
-	NTSTATUS status = cli_trans_recv(subreq, NULL, NULL, NULL, 0, NULL,
-					 NULL, 0, NULL, NULL, 0, NULL);
-	tevent_req_simple_finish_ntstatus(subreq, status);
-}
+static void cli_nt_delete_on_close_smb1_done(struct tevent_req *subreq);
+static void cli_nt_delete_on_close_smb2_done(struct tevent_req *subreq);
 
 struct tevent_req *cli_nt_delete_on_close_send(TALLOC_CTX *mem_ctx,
 					struct tevent_context *ev,
@@ -1824,6 +1820,18 @@ struct tevent_req *cli_nt_delete_on_close_send(TALLOC_CTX *mem_ctx,
 		return NULL;
 	}
 


-- 
Samba Shared Repository



More information about the samba-cvs mailing list