[SCM] Samba Shared Repository - branch master updated

Jeremy Allison jra at samba.org
Mon Nov 16 21:19:05 UTC 2020


The branch, master has been updated
       via  7bd040f60a0 libsmb: Remove unused sync cli_smb2_rename()
       via  1fdcfdcffb9 libsmb: Make cli_rename_send()/recv() smb2-capable
       via  db1fa2392d7 libsmb: Make cli_rename_send()/_recv() a proper tevent_req engine
       via  1ce7c596beb libsmb: Make cli_smb2_rename async
       via  2ea885f96f9 libsmb: Make get_fnum_from_path() async
       via  42be033b0b0 pylibsmb: Move set_acl() to python
       via  3b81cc900f5 pylibsmb: Add set_sd()
       via  97fca81af09 libsmb: Remove unused sync cli_smb2_set_security_descriptor()
       via  e617cb5fa1d libsmb: Make cli_set_security_descriptor() async
       via  c68943786d3 torture3: cli_set_security_descriptor() does smb2 as well
       via  472c16d5540 pylibsmb: Move get_acl() to python
       via  57f8e7eb113 pylibsmb: Add get_sd()
       via  edf26b29cf6 libsmb: Remove unused sync cli_smb2_query_security_descriptor()
       via  207ca06189e libsmb: Make cli_query_security_descriptor() async
       via  c6fef155d07 torture3: cli_query_security_descriptor() does smb2 as well
       via  25628907241 pylibsmb: Export a few SMB constants
       via  d33cec8d448 pylibsmb: Merge remove_dir() into its only caller
       via  5ee42dd0e9c pylibsmb: Merge unlink_file() into its only caller
       via  13aecb22f75 pylibsmb: Move deltree to python code
       via  2cff5990daa pylibsmb: Add a compatible python-level wrapper
      from  26ba04a4d19 libcli: smb2: Never print length if smb2_signing_key_valid() fails for crypto blob.

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


- Log -----------------------------------------------------------------
commit 7bd040f60a070c037d2cbcebb01d5d9869475662
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Nov 13 16:32:16 2020 +0100

    libsmb: Remove unused sync cli_smb2_rename()
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Mon Nov 16 21:18:16 UTC 2020 on sn-devel-184

commit 1fdcfdcffb91d4f5c89abe0e71abb84c31cb106a
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Nov 13 16:29:23 2020 +0100

    libsmb: Make cli_rename_send()/recv() smb2-capable
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit db1fa2392d7be0ca433fcd65035985595bbf0c20
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Nov 13 16:23:48 2020 +0100

    libsmb: Make cli_rename_send()/_recv() a proper tevent_req engine
    
    This will make it more obvious to add SMB2 soon
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 1ce7c596beb0ef539501366a1c79500dbd064922
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Nov 13 15:31:16 2020 +0100

    libsmb: Make cli_smb2_rename async
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 2ea885f96f98d735246d96fbd0cca99ee637f411
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Nov 13 12:59:55 2020 +0100

    libsmb: Make get_fnum_from_path() async
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 42be033b0b0c02413a74f984c8622b5baed2689a
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Nov 12 09:26:10 2020 +0100

    pylibsmb: Move set_acl() to python
    
    The previous code was not available in threaded environments
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 3b81cc900f5c7f7ee412601f0930aa0390752fbb
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Nov 10 21:25:56 2020 +0100

    pylibsmb: Add set_sd()
    
    setacl() on a fnum, available asynchronously
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 97fca81af098dd99a40a15aa181b4b32ed2e874a
Author: Volker Lendecke <vl at samba.org>
Date:   Mon Nov 9 21:43:19 2020 +0100

    libsmb: Remove unused sync cli_smb2_set_security_descriptor()
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit e617cb5fa1d13903abeb068f6fbe98b192bd33f3
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Nov 10 20:55:29 2020 +0100

    libsmb: Make cli_set_security_descriptor() async
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit c68943786d3c14e6340e2637746fe8a8c2f0b722
Author: Volker Lendecke <vl at samba.org>
Date:   Mon Nov 9 21:40:28 2020 +0100

    torture3: cli_set_security_descriptor() does smb2 as well
    
    Remove a direct caller
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 472c16d55407c9ffa5c36a7041689eb3d987a66c
Author: Volker Lendecke <vl at samba.org>
Date:   Wed Nov 11 13:20:39 2020 +0100

    pylibsmb: Move get_acl() to python
    
    The previous code was not available in threaded environments
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 57f8e7eb1131871a782f28e459ccb636fc605036
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Nov 10 21:25:56 2020 +0100

    pylibsmb: Add get_sd()
    
    getacl() on a fnum, available asynchronously
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit edf26b29cf66f98eb633792f442459b094c22e3b
Author: Volker Lendecke <vl at samba.org>
Date:   Mon Nov 9 21:43:19 2020 +0100

    libsmb: Remove unused sync cli_smb2_query_security_descriptor()
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 207ca06189e1bd3e536dbe35ff0ef0b763c5e152
Author: Volker Lendecke <vl at samba.org>
Date:   Mon Nov 9 21:37:10 2020 +0100

    libsmb: Make cli_query_security_descriptor() async
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit c6fef155d07f6eb255a21736cf512abc2dd19224
Author: Volker Lendecke <vl at samba.org>
Date:   Mon Nov 9 21:40:28 2020 +0100

    torture3: cli_query_security_descriptor() does smb2 as well
    
    Remove a direct caller
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 25628907241d14913423116a7a6e55eae7670c93
Author: Volker Lendecke <vl at samba.org>
Date:   Wed Nov 11 11:33:18 2020 +0100

    pylibsmb: Export a few SMB constants
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit d33cec8d4487129cc29398fb00e1d81ae8ce7fb9
Author: Volker Lendecke <vl at samba.org>
Date:   Mon Nov 9 19:48:21 2020 +0100

    pylibsmb: Merge remove_dir() into its only caller
    
    Now that delete_tree is in python code, align py_smb_rmdir() with the
    other functions.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 5ee42dd0e9c4405b5c8bf58fd16ef0878763a330
Author: Volker Lendecke <vl at samba.org>
Date:   Mon Nov 9 19:48:21 2020 +0100

    pylibsmb: Merge unlink_file() into its only caller
    
    Now that delete_tree is in python code, align py_smb_unlink() with the
    other functions.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 13aecb22f75f24d47a3163c701018f67e30a1a2c
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Nov 6 22:08:00 2020 +0100

    pylibsmb: Move deltree to python code
    
    This is much shorter. There's also another aspect: I'm working on
    improving cli_list() to not collect all files before starting to call
    the callback function. This means that the cli_list cb will be called
    from within tevent_loop_once(). In pylibsmb.c's deltree code this
    would create a nested event loop. By moving the deltree code into the
    python world this nested event loop is avoided. Now the python code
    will first collect everything and then start to delete, avoiding the
    nesting. A future development should make listing directories a
    generator or something like that.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 2cff5990daa324226a2c32245eef78019ef1b5bf
Author: Volker Lendecke <vl at samba.org>
Date:   Wed Nov 11 11:20:29 2020 +0100

    pylibsmb: Add a compatible python-level wrapper
    
    Right now this is empty, but it is the basis for moving complexity out
    or pylibsmb.c into python code.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

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

Summary of changes:
 python/samba/samba3/libsmb_samba_internal.py |  65 +++
 source3/libsmb/cli_smb2_fnum.c               | 626 +++++++++++++++------------
 source3/libsmb/cli_smb2_fnum.h               |  21 +-
 source3/libsmb/clifile.c                     | 123 ++++--
 source3/libsmb/clisecdesc.c                  | 355 +++++++++++----
 source3/libsmb/proto.h                       |  18 +
 source3/libsmb/pylibsmb.c                    | 258 +++--------
 source3/torture/test_smb2.c                  |  20 +-
 source3/wscript_build                        |   2 +-
 9 files changed, 869 insertions(+), 619 deletions(-)
 create mode 100644 python/samba/samba3/libsmb_samba_internal.py


Changeset truncated at 500 lines:

diff --git a/python/samba/samba3/libsmb_samba_internal.py b/python/samba/samba3/libsmb_samba_internal.py
new file mode 100644
index 00000000000..84729b2041d
--- /dev/null
+++ b/python/samba/samba3/libsmb_samba_internal.py
@@ -0,0 +1,65 @@
+# Copyright (C) Volker Lendecke <vl at samba.org> 2020
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+from samba.samba3.libsmb_samba_cwrapper import *
+from samba.dcerpc import security
+
+class Conn(LibsmbCConn):
+    def deltree(self, path):
+        if self.chkpath(path):
+            for entry in self.list(path):
+                self.deltree(path + "\\" + entry['name'])
+            self.rmdir(path)
+        else:
+            self.unlink(path)
+
+    SECINFO_DEFAULT_FLAGS = \
+        security.SECINFO_OWNER | \
+        security.SECINFO_GROUP | \
+        security.SECINFO_DACL | \
+        security.SECINFO_PROTECTED_DACL | \
+        security.SECINFO_UNPROTECTED_DACL | \
+        security.SECINFO_SACL | \
+        security.SECINFO_PROTECTED_SACL | \
+        security.SECINFO_UNPROTECTED_SACL
+
+    def get_acl(self,
+                filename,
+                sinfo = SECINFO_DEFAULT_FLAGS,
+                access_mask = security.SEC_FLAG_MAXIMUM_ALLOWED):
+        """Get security descriptor for file."""
+        fnum = self.create(
+            Name=filename,
+            DesiredAccess=access_mask,
+            ShareAccess=(FILE_SHARE_READ|FILE_SHARE_WRITE))
+        try:
+            sd = self.get_sd(fnum, sinfo)
+        finally:
+            self.close(fnum)
+        return sd
+
+    def set_acl(self,
+                filename,
+                sd,
+                sinfo = SECINFO_DEFAULT_FLAGS):
+        """Set security descriptor for file."""
+        fnum = self.create(
+            Name=filename,
+            DesiredAccess=security.SEC_FLAG_MAXIMUM_ALLOWED,
+            ShareAccess=(FILE_SHARE_READ|FILE_SHARE_WRITE))
+        try:
+            self.set_sd(fnum, sd, sinfo)
+        finally:
+            self.close(fnum)
diff --git a/source3/libsmb/cli_smb2_fnum.c b/source3/libsmb/cli_smb2_fnum.c
index b64ff087047..1313ee629c4 100644
--- a/source3/libsmb/cli_smb2_fnum.c
+++ b/source3/libsmb/cli_smb2_fnum.c
@@ -1817,43 +1817,83 @@ fail:
  Helper function for pathname operations.
 ***************************************************************/
 
-static NTSTATUS get_fnum_from_path(struct cli_state *cli,
-				const char *name,
-				uint32_t desired_access,
-				uint16_t *pfnum)
+struct get_fnum_from_path_state {
+	struct tevent_context *ev;
+	struct cli_state *cli;
+	const char *name;
+	uint32_t desired_access;
+	uint16_t fnum;
+};
+
+static void get_fnum_from_path_opened_file(struct tevent_req *subreq);
+static void get_fnum_from_path_opened_reparse(struct tevent_req *subreq);
+static void get_fnum_from_path_opened_dir(struct tevent_req *subreq);
+
+static struct tevent_req *get_fnum_from_path_send(
+	TALLOC_CTX *mem_ctx,
+	struct tevent_context *ev,
+	struct cli_state *cli,
+	const char *name,
+	uint32_t desired_access)
 {
-	NTSTATUS status;
+	struct tevent_req *req = NULL, *subreq = NULL;
+	struct get_fnum_from_path_state *state = NULL;
 	size_t namelen = strlen(name);
-	TALLOC_CTX *frame = talloc_stackframe();
-	uint32_t create_options = 0;
 
-	/* SMB2 is pickier about pathnames. Ensure it doesn't
-	   end in a '\' */
+	req = tevent_req_create(
+		mem_ctx, &state, struct get_fnum_from_path_state);
+	if (req == NULL) {
+		return NULL;
+	}
+	state->ev = ev;
+	state->cli = cli;
+	state->name = name;
+	state->desired_access = desired_access;
+
+	/*
+	 * SMB2 is pickier about pathnames. Ensure it doesn't end in a
+	 * '\'
+	 */
 	if (namelen > 0 && name[namelen-1] == '\\') {
-		char *modname = talloc_strdup(frame, name);
-		if (modname == NULL) {
-			status = NT_STATUS_NO_MEMORY;
-			goto fail;
+		state->name = talloc_strndup(state, name, namelen-1);
+		if (tevent_req_nomem(state->name, req)) {
+			return tevent_req_post(req, ev);
 		}
-		modname[namelen-1] = '\0';
-		name = modname;
 	}
 
-	/* Try to open a file handle first. */
-	status = cli_smb2_create_fnum(cli,
-			name,
-			0,			/* create_flags */
-			SMB2_IMPERSONATION_IMPERSONATION,
-			desired_access,
-			0, /* file attributes */
-			FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, /* share_access */
-			FILE_OPEN,		/* create_disposition */
-			create_options,
-			NULL,
-			pfnum,
-			NULL,
-			NULL,
-			NULL);
+	subreq = cli_smb2_create_fnum_send(
+		state,		/* mem_ctx, */
+		ev,		/* ev */
+		cli,		/* cli */
+		state->name,	/* fname */
+		0,		/* create_flags */
+		SMB2_IMPERSONATION_IMPERSONATION, /* impersonation_level */
+		desired_access,	/* desired_access */
+		0,		/* file_attributes */
+		FILE_SHARE_READ|
+		FILE_SHARE_WRITE|
+		FILE_SHARE_DELETE, /* share_access */
+		FILE_OPEN,	/* create_disposition */
+		0,		/* create_options */
+		NULL);		/* in_cblobs */
+	if (tevent_req_nomem(subreq, req)) {
+		return tevent_req_post(req, ev);
+	}
+	tevent_req_set_callback(subreq, get_fnum_from_path_opened_file, req);
+	return req;
+}
+
+static void get_fnum_from_path_opened_file(struct tevent_req *subreq)
+{
+	struct tevent_req *req = tevent_req_callback_data(
+		subreq, struct tevent_req);
+	struct get_fnum_from_path_state *state = tevent_req_data(
+		req, struct get_fnum_from_path_state);
+	NTSTATUS status;
+
+	status = cli_smb2_create_fnum_recv(
+		subreq, &state->fnum, NULL, NULL, NULL);
+	TALLOC_FREE(subreq);
 
 	if (NT_STATUS_EQUAL(status, NT_STATUS_STOPPED_ON_SYMLINK)) {
 		/*
@@ -1862,43 +1902,117 @@ static NTSTATUS get_fnum_from_path(struct cli_state *cli,
 		 * component and try again. Eventually we will have to
 		 * deal with the returned path unprocessed component. JRA.
 		 */
-		create_options |= FILE_OPEN_REPARSE_POINT;
-		status = cli_smb2_create_fnum(cli,
-			name,
-			0,			/* create_flags */
-			SMB2_IMPERSONATION_IMPERSONATION,
-			desired_access,
-			0, /* file attributes */
-			FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, /* share_access */
-			FILE_OPEN,		/* create_disposition */
-			create_options,
-			NULL,
-			pfnum,
-			NULL,
-			NULL,
-			NULL);
+		subreq = cli_smb2_create_fnum_send(
+			state,		/* mem_ctx, */
+			state->ev,	/* ev */
+			state->cli,	/* cli */
+			state->name,	/* fname */
+			0,		/* create_flags */
+			SMB2_IMPERSONATION_IMPERSONATION, /* impersonation */
+			state->desired_access, /* desired_access */
+			0,		/* file_attributes */
+			FILE_SHARE_READ|
+			FILE_SHARE_WRITE|
+			FILE_SHARE_DELETE, /* share_access */
+			FILE_OPEN,	/* create_disposition */
+			FILE_OPEN_REPARSE_POINT, /* create_options */
+			NULL);		/* in_cblobs */
+		if (tevent_req_nomem(subreq, req)) {
+			return;
+		}
+		tevent_req_set_callback(
+			subreq, get_fnum_from_path_opened_reparse, req);
+		return;
 	}
 
 	if (NT_STATUS_EQUAL(status, NT_STATUS_FILE_IS_A_DIRECTORY)) {
-		create_options |= FILE_DIRECTORY_FILE;
-		status = cli_smb2_create_fnum(cli,
-			name,
-			0,			/* create_flags */
-			SMB2_IMPERSONATION_IMPERSONATION,
-			desired_access,
-			FILE_ATTRIBUTE_DIRECTORY, /* file attributes */
-			FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, /* share_access */
-			FILE_OPEN,		/* create_disposition */
-			create_options,		/* create_options */
-			NULL,
-			pfnum,
-			NULL,
-			NULL,
-			NULL);
+		subreq = cli_smb2_create_fnum_send(
+			state,		/* mem_ctx, */
+			state->ev,	/* ev */
+			state->cli,	/* cli */
+			state->name,	/* fname */
+			0,		/* create_flags */
+			SMB2_IMPERSONATION_IMPERSONATION, /* impersonation */
+			state->desired_access, /* desired_access */
+			0,		/* file_attributes */
+			FILE_SHARE_READ|
+			FILE_SHARE_WRITE|
+			FILE_SHARE_DELETE, /* share_access */
+			FILE_OPEN,	/* create_disposition */
+			FILE_DIRECTORY_FILE, /* create_options */
+			NULL);		/* in_cblobs */
+		if (tevent_req_nomem(subreq, req)) {
+			return;
+		}
+		tevent_req_set_callback(
+			subreq, get_fnum_from_path_opened_dir, req);
+		return;
 	}
 
-  fail:
+	if (tevent_req_nterror(req, status)) {
+		return;
+	}
+	tevent_req_done(req);
+}
 
+static void get_fnum_from_path_opened_reparse(struct tevent_req *subreq)
+{
+	struct tevent_req *req = tevent_req_callback_data(
+		subreq, struct tevent_req);
+	struct get_fnum_from_path_state *state = tevent_req_data(
+		req, struct get_fnum_from_path_state);
+	NTSTATUS status = cli_smb2_create_fnum_recv(
+		subreq, &state->fnum, NULL, NULL, NULL);
+	tevent_req_simple_finish_ntstatus(subreq, status);
+}
+
+static void get_fnum_from_path_opened_dir(struct tevent_req *subreq)
+{
+	/* Abstraction violation, but these two are just the same... */
+	get_fnum_from_path_opened_reparse(subreq);
+}
+
+static NTSTATUS get_fnum_from_path_recv(
+	struct tevent_req *req, uint16_t *pfnum)
+{
+	struct get_fnum_from_path_state *state = tevent_req_data(
+		req, struct get_fnum_from_path_state);
+	NTSTATUS status = NT_STATUS_OK;
+
+	if (!tevent_req_is_nterror(req, &status)) {
+		*pfnum = state->fnum;
+	}
+	tevent_req_received(req);
+	return status;
+}
+
+static NTSTATUS get_fnum_from_path(struct cli_state *cli,
+				const char *name,
+				uint32_t desired_access,
+				uint16_t *pfnum)
+{
+	TALLOC_CTX *frame = talloc_stackframe();
+	struct tevent_context *ev = NULL;
+	struct tevent_req *req = NULL;
+	NTSTATUS status = NT_STATUS_NO_MEMORY;
+
+	if (smbXcli_conn_has_async_calls(cli->conn)) {
+		status = NT_STATUS_INVALID_PARAMETER;
+		goto fail;
+	}
+	ev = samba_tevent_context_init(frame);
+	if (ev == NULL) {
+		goto fail;
+	}
+	req = get_fnum_from_path_send(frame, ev, cli, name, desired_access);
+	if (req == NULL) {
+		goto fail;
+	}
+	if (!tevent_req_poll_ntstatus(req, ev, &status)) {
+		goto fail;
+	}
+	status = get_fnum_from_path_recv(req, pfnum);
+ fail:
 	TALLOC_FREE(frame);
 	return status;
 }
@@ -2799,138 +2913,6 @@ fail:
 	return status;
 }
 
-
-/***************************************************************
- Wrapper that allows SMB2 to query a security descriptor.
- Synchronous only.
-***************************************************************/
-
-NTSTATUS cli_smb2_query_security_descriptor(struct cli_state *cli,
-					uint16_t fnum,
-					uint32_t sec_info,
-					TALLOC_CTX *mem_ctx,
-					struct security_descriptor **ppsd)
-{
-	NTSTATUS status;
-	DATA_BLOB outbuf = data_blob_null;
-	struct security_descriptor *lsd = NULL;
-	TALLOC_CTX *frame = talloc_stackframe();
-
-	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;
-	}
-
-	if (smbXcli_conn_protocol(cli->conn) < PROTOCOL_SMB2_02) {
-		status = NT_STATUS_INVALID_PARAMETER;
-		goto fail;
-	}
-
-	/* getinfo on the returned handle with info_type SMB2_GETINFO_SEC (3) */
-
-	status = cli_smb2_query_info_fnum(
-		cli,
-		fnum,
-		3, /* in_info_type */
-		0, /* in_file_info_class */
-		0xFFFF, /* in_max_output_length */
-		NULL, /* in_input_buffer */
-		sec_info, /* in_additional_info */
-		0, /* in_flags */
-		frame,
-		&outbuf);
-
-	if (!NT_STATUS_IS_OK(status)) {
-		goto fail;
-	}
-
-	/* Parse the reply. */
-	status = unmarshall_sec_desc(mem_ctx,
-				outbuf.data,
-				outbuf.length,
-				&lsd);
-
-	if (!NT_STATUS_IS_OK(status)) {
-		goto fail;
-	}
-
-	if (ppsd != NULL) {
-		*ppsd = lsd;
-	} else {
-		TALLOC_FREE(lsd);
-	}
-
-  fail:
-
-	cli->raw_status = status;
-
-	TALLOC_FREE(frame);
-	return status;
-}
-
-/***************************************************************
- Wrapper that allows SMB2 to set a security descriptor.
- Synchronous only.
-***************************************************************/
-
-NTSTATUS cli_smb2_set_security_descriptor(struct cli_state *cli,
-					uint16_t fnum,
-					uint32_t sec_info,
-					const struct security_descriptor *sd)
-{
-	NTSTATUS status;
-	DATA_BLOB inbuf = data_blob_null;
-	TALLOC_CTX *frame = talloc_stackframe();
-
-	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;
-	}
-
-	if (smbXcli_conn_protocol(cli->conn) < PROTOCOL_SMB2_02) {
-		status = NT_STATUS_INVALID_PARAMETER;
-		goto fail;
-	}
-
-	status = marshall_sec_desc(frame,
-				sd,
-				&inbuf.data,
-				&inbuf.length);
-
-        if (!NT_STATUS_IS_OK(status)) {
-		goto fail;
-        }
-
-	/* setinfo on the returned handle with info_type SMB2_SETINFO_SEC (3) */
-
-	status = cli_smb2_set_info_fnum(
-		cli,
-		fnum,
-		3,			  /* in_info_type */
-		0,			  /* in_file_info_class */
-		&inbuf,			  /* in_input_buffer */
-		sec_info);		  /* in_additional_info */
-
-  fail:
-
-	cli->raw_status = status;
-
-	TALLOC_FREE(frame);
-	return status;
-}
-
-/***************************************************************
- Wrapper that allows SMB2 to query a security descriptor.
- Synchronous only.
-
-***************************************************************/
-
 struct cli_smb2_mxac_state {
 	struct tevent_context *ev;
 	struct cli_state *cli;
@@ -3108,85 +3090,75 @@ fail:
 	return status;
 }
 
-/***************************************************************
- Wrapper that allows SMB2 to rename a file.
- Synchronous only.
-***************************************************************/
+struct cli_smb2_rename_fnum_state {
+	DATA_BLOB inbuf;
+};
+
+static void cli_smb2_rename_fnum_done(struct tevent_req *subreq);
 
-NTSTATUS cli_smb2_rename(struct cli_state *cli,
-			 const char *fname_src,
-			 const char *fname_dst,
-			 bool replace)
+static struct tevent_req *cli_smb2_rename_fnum_send(
+	TALLOC_CTX *mem_ctx,
+	struct tevent_context *ev,
+	struct cli_state *cli,
+	uint16_t fnum,


-- 
Samba Shared Repository



More information about the samba-cvs mailing list