[SCM] Samba Shared Repository - branch master updated

Jeremy Allison jra at samba.org
Tue Mar 28 19:37:02 UTC 2017


The branch, master has been updated
       via  60e45a2 s3/smbd: make copy chunk asynchronous
       via  a849a12 vfs_default: move check for fsp->op validity
       via  0622811 s3/smbd: optimize copy-chunk by merging chunks if possible
       via  8bc94a9 s3/smbd: implement a serializing async copy-chunk loop
       via  6314dda s3/smbd: move cc_copy into fsctl_srv_copychunk_state
       via  f8ef3a5 vfs_default: let copy_chunk_send use const from IDL
       via  dc4bd3f s3/smbd: move copychunk ioctl limits to IDL
       via  0558715 tdb/tools: add documentation for the tdbbackup -n option
       via  26dbe68 s3-libsmb: support rename and replace for SMB1
       via  057aa39 s3-libsmb: fail rename and replace inside cifs variant
       via  3154c4c s3-libsmb: cli_cifs_rename_send()
       via  ae17989 libcli: introduce smbXcli_conn_support_passthrough()
       via  401be64 manpages: update smbclient manpage with rename -f option
       via  3ccb427 smbclient: add -f option to rename command
       via  200dbca s3: libsmb: add replace support to cli_rename()
       via  a67802f s3: libsmb: add replace support to SMB2 rename
       via  b224b20 lib: Avoid an includes.h
       via  2ad26a6 lib: Avoid an includes.h
       via  0865fea lib: Avoid an includes.h
       via  aea4e4c lib: Avoid an includes.h
       via  d13496f lib: Avoid an includes.h
       via  d98c726 lib: Avoid an includes.h
       via  6e9d3b0 lib: Remove an unnecessary include
       via  7459289 lib: Remove unused winbind_get_groups and _get_sid_aliases
      from  4e734fc s3: Test for CVE-2017-2619 regression with "follow symlinks = no" - part 2

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


- Log -----------------------------------------------------------------
commit 60e45a2d25401eaf9a15a86d19114670ccfde259
Author: Ralph Boehme <slow at samba.org>
Date:   Sun Mar 12 18:13:48 2017 +0100

    s3/smbd: make copy chunk asynchronous
    
    Just use SMB_VFS_PREAD_SEND/RECV and SMB_VFS_PWRITE_SEND/RECV in a
    sensible loop.
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Tue Mar 28 21:36:18 CEST 2017 on sn-devel-144

commit a849a124388ae511d1f7b3cdafb2fa52a395d284
Author: Ralph Boehme <slow at samba.org>
Date:   Sun Mar 12 17:23:09 2017 +0100

    vfs_default: move check for fsp->op validity
    
    Move the check whether fsp->of is valid out of the copy loop in
    vfswrap_copy_chunk_send().
    
    It's sufficient to check src_fsp->op and dest_fsp->op once before the
    copy loop. fsp->op can only be NULL for internal opens (cf file_new()),
    it's not expected to become NULL behind our backs.
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 0622811faba117372e24854c09c3568ebdb6b2f9
Author: Ralph Boehme <slow at samba.org>
Date:   Tue Mar 21 18:34:22 2017 +0100

    s3/smbd: optimize copy-chunk by merging chunks if possible
    
    Merge chunks with adjacent ranges. This results in fewer IO requests for
    the typical server-side file copy usecase: just one 16 MB copy instead
    of sixteen 1 MB.
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 8bc94a9f9d54134489bf4c98ced8e60e2712ddf4
Author: Ralph Boehme <slow at samba.org>
Date:   Tue Mar 21 09:17:03 2017 +0100

    s3/smbd: implement a serializing async copy-chunk loop
    
    Later commits will make the low level copy-chunk implementation async
    using a thread pool. That means the individual chunks may be scheduled
    and copied out-of-order at the low level.
    
    According to conversation with MS Dochelp, a server implementation
    must process individual chunks in order.
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 6314dda7fe0a83a3e16fe59d87232782817daadc
Author: Ralph Boehme <slow at samba.org>
Date:   Tue Mar 21 08:26:37 2017 +0100

    s3/smbd: move cc_copy into fsctl_srv_copychunk_state
    
    No change, in behaviour, just preperational stuff to unroll the core
    copy loop.
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit f8ef3a579b092d1647a38ea184659c2c675e6e83
Author: Ralph Boehme <slow at samba.org>
Date:   Sun Mar 12 17:18:39 2017 +0100

    vfs_default: let copy_chunk_send use const from IDL
    
    This also increases the buffer size from 8 MB to the current value of
    COPYCHUNK_MAX_TOTAL_LEN which is 16 MB.
    
    For the typical case when vfswrap_copy_chunk_send is called from the SMB
    layer for an copy_chunk ioctl() the parameter "num" is guaranteed to be
    at most 1 MB though.
    
    It will only be larger for special callers like vfs_fruit for their
    special implementation of copyfile where num will be the size of a file
    to copy.
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit dc4bd3f7515bef6f1cd6b51468d1b7642e763d6f
Author: Ralph Boehme <slow at samba.org>
Date:   Wed Mar 8 15:07:06 2017 +0100

    s3/smbd: move copychunk ioctl limits to IDL
    
    This will be needed in the next commit in vfs_default.
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 0558715b5b125ffa7948f06451ea979c7045b20c
Author: Björn Baumbach <bb at sernet.de>
Date:   Mon Mar 27 17:43:07 2017 +0200

    tdb/tools: add documentation for the tdbbackup -n option
    
    Signed-off-by: Björn Baumbach <bb at sernet.de>
    Reviewed-by: Jeremy Allison <jra at samba.org

commit 26dbe684dced5702ec89a20c44de2d4b737abbde
Author: Uri Simchoni <uri at samba.org>
Date:   Sun Mar 26 12:02:09 2017 +0300

    s3-libsmb: support rename and replace for SMB1
    
    Add cli_smb1_rename_send() which renames a file via
    setting FileRenameInformation.
    
    Curretly this path is invoked only if replacing
    an existing file is requested. This is because as far
    as I can see, Windows uses CIFS rename for anything below
    SMB2.
    
    Signed-off-by: Uri Simchoni <uri at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 057aa39e6abea241a3785458460eaef8c30f8659
Author: Uri Simchoni <uri at samba.org>
Date:   Sun Mar 26 09:14:43 2017 +0300

    s3-libsmb: fail rename and replace inside cifs variant
    
    Another refactoring step - fail request to rename and
    replace existing file from within the CIFS version,
    allowing the soon-to-be-added SMB version to succeed.
    
    Signed-off-by: Uri Simchoni <uri at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 3154c4cb701950d777766bbef1410182bb2569c4
Author: Uri Simchoni <uri at samba.org>
Date:   Sun Mar 26 08:54:42 2017 +0300

    s3-libsmb: cli_cifs_rename_send()
    
    Pure refactoring - current rename is [MS-CIFS] - style
    rename. In later patch we'll introduce [MS-SMB] rename.
    
    Signed-off-by: Uri Simchoni <uri at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit ae17989de4b608981efb0342c233893cfae3b554
Author: Uri Simchoni <uri at samba.org>
Date:   Sun Mar 26 08:10:34 2017 +0300

    libcli: introduce smbXcli_conn_support_passthrough()
    
    This routine queries the client connenction whether
    it supports query/set InfoLevels beyond 1000 (which,
    in Windows OS, is a pass-through mechanism to the
    file system).
    
    Signed-off-by: Uri Simchoni <uri at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 401be6431c0821ee19ff08fbf5536fa870c9df66
Author: Uri Simchoni <uri at samba.org>
Date:   Tue Mar 21 23:56:35 2017 +0200

    manpages: update smbclient manpage with rename -f option
    
    Document the -f option of the rename command.
    
    Signed-off-by: Uri Simchoni <uri at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 3ccb427ace78f828792f9c8f3cc1478ae38301b1
Author: Uri Simchoni <uri at samba.org>
Date:   Tue Mar 21 23:26:05 2017 +0200

    smbclient: add -f option to rename command
    
    This option causes the rename to request that the
    destination file / directory be replaced if it exists.
    
    Supported only in SMB2 and higher protocol.
    
    Signed-off-by: Uri Simchoni <uri at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 200dbca238772b64e7c055d82d985045f92f6bcb
Author: Uri Simchoni <uri at samba.org>
Date:   Tue Mar 21 23:13:07 2017 +0200

    s3: libsmb: add replace support to cli_rename()
    
    Adds support for replacing the destination file at
    the higher-level cli_rename(). This is actually supported
    only by SMB2, and fails with invalid parameter with SMB1.
    
    Signed-off-by: Uri Simchoni <uri at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit a67802fad505738a10f3c73392db9e6235f13b62
Author: Uri Simchoni <uri at samba.org>
Date:   Tue Mar 21 23:02:48 2017 +0200

    s3: libsmb: add replace support to SMB2 rename
    
    SMB2 rename operation supports replacing the
    destination file if it exists.
    
    Signed-off-by: Uri Simchoni <uri at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit b224b2033df9543e1b580885956a65161bd50db5
Author: Volker Lendecke <vl at samba.org>
Date:   Sun Jan 8 19:52:47 2017 +0000

    lib: Avoid an includes.h
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 2ad26a63c9d155448efcdcf9db0ada9a267e12d8
Author: Volker Lendecke <vl at samba.org>
Date:   Sun Jan 8 19:52:47 2017 +0000

    lib: Avoid an includes.h
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 0865fea4fcd8c540b59accdf24c27d09f580ae02
Author: Volker Lendecke <vl at samba.org>
Date:   Sun Jan 8 19:52:47 2017 +0000

    lib: Avoid an includes.h
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit aea4e4cbd3a56f99c4d2ef628540cbb760b15bb3
Author: Volker Lendecke <vl at samba.org>
Date:   Sun Jan 8 19:52:47 2017 +0000

    lib: Avoid an includes.h
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit d13496f3879cb7592f540e4aa1b0faf45c56f967
Author: Volker Lendecke <vl at samba.org>
Date:   Sun Jan 8 19:52:47 2017 +0000

    lib: Avoid an includes.h
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit d98c7263e037b8e9c67b1267c5ac6811a07d930e
Author: Volker Lendecke <vl at samba.org>
Date:   Sun Jan 8 19:52:47 2017 +0000

    lib: Avoid an includes.h
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 6e9d3b05de473bd1bdef66dad8155d5233aa6d25
Author: Volker Lendecke <vl at samba.org>
Date:   Sun Jan 8 19:46:17 2017 +0000

    lib: Remove an unnecessary include
    
    This comes in via samba_util.h already
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 745928955190284480bbd3fe9f5e5570086d36dc
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Jan 3 14:05:51 2017 +0000

    lib: Remove unused winbind_get_groups and _get_sid_aliases
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

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

Summary of changes:
 docs-xml/manpages/smbclient.1.xml                  |   7 +-
 lib/tdb/man/tdbbackup.8.xml                        |   8 +
 lib/util/charset/codepoints.c                      |   4 +-
 lib/util/charset/iconv.c                           |   8 +-
 lib/util/rbtree.c                                  |   2 +-
 lib/util/rfc1738.c                                 |   4 +-
 lib/util/util_pw.c                                 |   3 +-
 lib/util/util_tdb.c                                |   6 +-
 libcli/smb/smbXcli_base.c                          |  17 ++
 libcli/smb/smbXcli_base.h                          |   1 +
 librpc/idl/ioctl.idl                               |   4 +
 source3/client/client.c                            |  10 +-
 source3/include/includes.h                         |   1 -
 source3/lib/winbind_util.c                         |  83 -------
 source3/lib/winbind_util.h                         |  10 -
 source3/libsmb/cli_smb2_fnum.c                     |   9 +-
 source3/libsmb/cli_smb2_fnum.h                     |   5 +-
 source3/libsmb/clifile.c                           | 150 +++++++++--
 source3/libsmb/libsmb_dir.c                        |  10 +-
 source3/libsmb/proto.h                             |  14 +-
 source3/modules/vfs_default.c                      | 273 ++++++++++++++-------
 ...passdb-0.26.0.sigs => samba-passdb-0.27.0.sigs} |   2 -
 source3/smbd/smb2_ioctl_network_fs.c               | 258 ++++++++++++-------
 source3/torture/nbio.c                             |   2 +-
 source3/torture/torture.c                          |  14 +-
 source3/wscript_build                              |   2 +-
 26 files changed, 577 insertions(+), 330 deletions(-)
 copy source3/passdb/ABI/{samba-passdb-0.26.0.sigs => samba-passdb-0.27.0.sigs} (99%)


Changeset truncated at 500 lines:

diff --git a/docs-xml/manpages/smbclient.1.xml b/docs-xml/manpages/smbclient.1.xml
index c8f4e40..059e14c 100644
--- a/docs-xml/manpages/smbclient.1.xml
+++ b/docs-xml/manpages/smbclient.1.xml
@@ -1000,10 +1000,13 @@
 		</varlistentry>
 
 		<varlistentry>
-		<term>rename <old filename> <new filename></term>
+		<term>rename <old filename> <new filename> [-f]</term>
 		<listitem><para>Rename files in the current working directory on the
 		server from <replaceable>old filename</replaceable> to
-		<replaceable>new filename</replaceable>. </para></listitem>
+		<replaceable>new filename</replaceable>. The optional
+		-f switch is supported only by SMB2 protocol and beyond,
+		and allows for superseding the destination file,
+		if it exists.</para></listitem>
 		</varlistentry>
 
 		<varlistentry>
diff --git a/lib/tdb/man/tdbbackup.8.xml b/lib/tdb/man/tdbbackup.8.xml
index 740b3d5..a73fb56 100644
--- a/lib/tdb/man/tdbbackup.8.xml
+++ b/lib/tdb/man/tdbbackup.8.xml
@@ -23,6 +23,7 @@
 		<arg choice="opt">-s suffix</arg>
 		<arg choice="opt">-v</arg>
 		<arg choice="opt">-h</arg>
+		<arg choice="opt">-n hashsize</arg>
 		<arg choice="opt">-l</arg>
 	</cmdsynopsis>
 </refsynopsisdiv>
@@ -71,6 +72,13 @@
 		</varlistentry>
 
 		<varlistentry>
+		<term>-n hashsize</term>
+		<listitem><para>
+		The <command>-n</command> option sets the hash size for the new backup tdb.
+		</para></listitem>
+		</varlistentry>
+
+		<varlistentry>
 		<term>-l</term>
 		<listitem><para>
 		This options disables any locking, by passing TDB_NOLOCK
diff --git a/lib/util/charset/codepoints.c b/lib/util/charset/codepoints.c
index 2c9a9c4..cfb0b27 100644
--- a/lib/util/charset/codepoints.c
+++ b/lib/util/charset/codepoints.c
@@ -20,10 +20,12 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 */
-#include "includes.h"
+#include "replace.h"
 #include "lib/util/charset/charset.h"
 #include "system/locale.h"
 #include "dynconfig/dynconfig.h"
+#include "lib/util/debug.h"
+#include "lib/util/byteorder.h"
 
 #ifdef strcasecmp
 #undef strcasecmp
diff --git a/lib/util/charset/iconv.c b/lib/util/charset/iconv.c
index e06fa2c..02c061c 100644
--- a/lib/util/charset/iconv.c
+++ b/lib/util/charset/iconv.c
@@ -18,11 +18,13 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-#include "includes.h"
-#include "../lib/util/dlinklist.h"
+#include "replace.h"
 #include "system/iconv.h"
 #include "system/filesys.h"
-#include "charset_proto.h"
+#include "lib/util/byteorder.h"
+#include "lib/util/dlinklist.h"
+#include "lib/util/charset/charset.h"
+#include "lib/util/charset/charset_proto.h"
 
 #ifdef strcasecmp
 #undef strcasecmp
diff --git a/lib/util/rbtree.c b/lib/util/rbtree.c
index f6868ca..b7add66 100644
--- a/lib/util/rbtree.c
+++ b/lib/util/rbtree.c
@@ -20,7 +20,7 @@
   linux/lib/rbtree.c
 */
 
-#include "includes.h"
+#include "replace.h"
 #include "rbtree.h"
 
 #define	RB_RED		0
diff --git a/lib/util/rfc1738.c b/lib/util/rfc1738.c
index c8f0472..b285ae9 100644
--- a/lib/util/rfc1738.c
+++ b/lib/util/rfc1738.c
@@ -48,8 +48,8 @@
  *
  */
 
-#include "includes.h"
-
+#include "replace.h"
+#include <talloc.h>
 #include "lib/util/samba_util.h"
 
 /*
diff --git a/lib/util/util_pw.c b/lib/util/util_pw.c
index dae3a69..8035de4 100644
--- a/lib/util/util_pw.c
+++ b/lib/util/util_pw.c
@@ -24,7 +24,8 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-#include "includes.h"
+#include "replace.h"
+#include <talloc.h>
 #include "system/passwd.h"
 #include "lib/util/util_pw.h"
 
diff --git a/lib/util/util_tdb.c b/lib/util/util_tdb.c
index 9bf18dc..e3eefda 100644
--- a/lib/util/util_tdb.c
+++ b/lib/util/util_tdb.c
@@ -20,7 +20,11 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-#include "includes.h"
+#include "replace.h"
+#include <talloc.h>
+#include "libcli/util/ntstatus.h"
+#include "lib/util/memory.h"
+#include "lib/util/byteorder.h"
 #include "system/filesys.h"
 #include "../lib/tdb/include/tdb.h"
 #include "../lib/util/util_tdb.h"
diff --git a/libcli/smb/smbXcli_base.c b/libcli/smb/smbXcli_base.c
index 9521fc6..1fcf11e 100644
--- a/libcli/smb/smbXcli_base.c
+++ b/libcli/smb/smbXcli_base.c
@@ -468,6 +468,23 @@ bool smbXcli_conn_use_unicode(struct smbXcli_conn *conn)
 	return false;
 }
 
+/*
+ * [MS-SMB] 2.2.2.3.5 - SMB1 support for passing through
+ * query/set commands to the file system
+ */
+bool smbXcli_conn_support_passthrough(struct smbXcli_conn *conn)
+{
+	if (conn->protocol >= PROTOCOL_SMB2_02) {
+		return true;
+	}
+
+	if (conn->smb1.capabilities & CAP_W2K_SMBS) {
+		return true;
+	}
+
+	return false;
+}
+
 void smbXcli_conn_set_sockopt(struct smbXcli_conn *conn, const char *options)
 {
 	set_socket_options(conn->sock_fd, options);
diff --git a/libcli/smb/smbXcli_base.h b/libcli/smb/smbXcli_base.h
index 84f4a6b..1abeb2b 100644
--- a/libcli/smb/smbXcli_base.h
+++ b/libcli/smb/smbXcli_base.h
@@ -47,6 +47,7 @@ bool smbXcli_conn_dfs_supported(struct smbXcli_conn *conn);
 
 enum protocol_types smbXcli_conn_protocol(struct smbXcli_conn *conn);
 bool smbXcli_conn_use_unicode(struct smbXcli_conn *conn);
+bool smbXcli_conn_support_passthrough(struct smbXcli_conn *conn);
 
 void smbXcli_conn_set_sockopt(struct smbXcli_conn *conn, const char *options);
 const struct sockaddr_storage *smbXcli_conn_local_sockaddr(struct smbXcli_conn *conn);
diff --git a/librpc/idl/ioctl.idl b/librpc/idl/ioctl.idl
index eb2dc8a..f72f9d2 100644
--- a/librpc/idl/ioctl.idl
+++ b/librpc/idl/ioctl.idl
@@ -11,6 +11,10 @@ interface copychunk
 		uint8 context[4];
 	} req_resume_key_rsp;
 
+	const uint32 COPYCHUNK_MAX_CHUNKS = 256; /* 2k8r2 & win8 = 256 */
+	const uint32 COPYCHUNK_MAX_CHUNK_LEN = 1048576; /* 2k8r2 & win8 = 1048576 */
+	const uint32 COPYCHUNK_MAX_TOTAL_LEN = 16777216; /* 2k8r2 & win8 = 16777216 */
+
 	typedef struct {
 		hyper source_off;
 		hyper target_off;
diff --git a/source3/client/client.c b/source3/client/client.c
index 226eb27..d2ebea0 100644
--- a/source3/client/client.c
+++ b/source3/client/client.c
@@ -3833,10 +3833,11 @@ static int cmd_rename(void)
 	char *targetsrc;
 	char *targetdest;
         NTSTATUS status;
+	bool replace = false;
 
 	if (!next_token_talloc(ctx, &cmd_ptr,&buf,NULL) ||
 	    !next_token_talloc(ctx, &cmd_ptr,&buf2,NULL)) {
-		d_printf("rename <src> <dest>\n");
+		d_printf("rename <src> <dest> [-f]\n");
 		return 1;
 	}
 
@@ -3856,6 +3857,11 @@ static int cmd_rename(void)
 		return 1;
 	}
 
+	if (next_token_talloc(ctx, &cmd_ptr, &buf, NULL) &&
+	    strcsequal(buf, "-f")) {
+		replace = true;
+	}
+
 	status = cli_resolve_path(ctx, "", auth_info, cli, src, &targetcli,
 				  &targetsrc);
 	if (!NT_STATUS_IS_OK(status)) {
@@ -3870,7 +3876,7 @@ static int cmd_rename(void)
 		return 1;
 	}
 
-	status = cli_rename(targetcli, targetsrc, targetdest);
+	status = cli_rename(targetcli, targetsrc, targetdest, replace);
 	if (!NT_STATUS_IS_OK(status)) {
 		d_printf("%s renaming files %s -> %s \n",
 			nt_errstr(status),
diff --git a/source3/include/includes.h b/source3/include/includes.h
index a436427..e82bfad 100644
--- a/source3/include/includes.h
+++ b/source3/include/includes.h
@@ -303,7 +303,6 @@ typedef char fstring[FSTRING_LEN];
 /* Lists, trees, caching, database... */
 #include "../lib/util/samba_util.h"
 #include "../lib/util/util_net.h"
-#include "../lib/util/memory.h"
 #include "../lib/util/attr.h"
 #include "../lib/util/tsort.h"
 #include "../lib/util/dlinklist.h"
diff --git a/source3/lib/winbind_util.c b/source3/lib/winbind_util.c
index 852929e..427831f 100644
--- a/source3/lib/winbind_util.c
+++ b/source3/lib/winbind_util.c
@@ -274,74 +274,6 @@ bool winbind_allocate_gid(gid_t *gid)
 	return (ret == WBC_ERR_SUCCESS);
 }
 
-bool winbind_get_groups(TALLOC_CTX * mem_ctx, const char *account, uint32_t *num_groups, gid_t **_groups)
-{
-	wbcErr ret;
-	uint32_t ngroups;
-	gid_t *group_list = NULL;
-
-	ret = wbcGetGroups(account, &ngroups, &group_list);
-	if (ret != WBC_ERR_SUCCESS)
-		return false;
-
-	*_groups = talloc_array(mem_ctx, gid_t, ngroups);
-	if (*_groups == NULL) {
-	    wbcFreeMemory(group_list);
-	    return false;
-	}
-
-	memcpy(*_groups, group_list, ngroups* sizeof(gid_t));
-	*num_groups = ngroups;
-
-	wbcFreeMemory(group_list);
-	return true;
-}
-
-bool winbind_get_sid_aliases(TALLOC_CTX *mem_ctx,
-			     const struct dom_sid *dom_sid,
-			     const struct dom_sid *members,
-			     size_t num_members,
-			     uint32_t **pp_alias_rids,
-			     size_t *p_num_alias_rids)
-{
-	wbcErr ret;
-	struct wbcDomainSid domain_sid;
-	struct wbcDomainSid *sid_list = NULL;
-	size_t i;
-	uint32_t * rids;
-	uint32_t num_rids;
-
-	memcpy(&domain_sid, dom_sid, sizeof(*dom_sid));
-
-	sid_list = talloc_array(mem_ctx, struct wbcDomainSid, num_members);
-
-	for (i=0; i < num_members; i++) {
-	    memcpy(&sid_list[i], &members[i], sizeof(sid_list[i]));
-	}
-
-	ret = wbcGetSidAliases(&domain_sid,
-			       sid_list,
-			       num_members,
-			       &rids,
-			       &num_rids);
-	if (ret != WBC_ERR_SUCCESS) {
-		return false;
-	}
-
-	*pp_alias_rids = talloc_array(mem_ctx, uint32_t, num_rids);
-	if (*pp_alias_rids == NULL) {
-		wbcFreeMemory(rids);
-		return false;
-	}
-
-	memcpy(*pp_alias_rids, rids, sizeof(uint32_t) * num_rids);
-
-	*p_num_alias_rids = num_rids;
-	wbcFreeMemory(rids);
-
-	return true;
-}
-
 bool winbind_lookup_usersids(TALLOC_CTX *mem_ctx,
 			     const struct dom_sid *user_sid,
 			     uint32_t *p_num_sids,
@@ -470,21 +402,6 @@ bool winbind_allocate_gid(gid_t *gid)
 	return false;
 }
 
-bool winbind_get_groups(TALLOC_CTX *mem_ctx, const char *account, uint32_t *num_groups, gid_t **_groups)
-{
-	return false;
-}
-
-bool winbind_get_sid_aliases(TALLOC_CTX *mem_ctx,
-			     const struct dom_sid *dom_sid,
-			     const struct dom_sid *members,
-			     size_t num_members,
-			     uint32_t **pp_alias_rids,
-			     size_t *p_num_alias_rids)
-{
-	return false;
-}
-
 bool winbind_lookup_usersids(TALLOC_CTX *mem_ctx,
 			     const struct dom_sid *user_sid,
 			     uint32_t *p_num_sids,
diff --git a/source3/lib/winbind_util.h b/source3/lib/winbind_util.h
index 2a90092..c2bf0e0 100644
--- a/source3/lib/winbind_util.h
+++ b/source3/lib/winbind_util.h
@@ -48,16 +48,6 @@ bool winbind_lookup_rids(TALLOC_CTX *mem_ctx,
 			 const char ***names, enum lsa_SidType **types);
 bool winbind_allocate_uid(uid_t *uid);
 bool winbind_allocate_gid(gid_t *gid);
-bool winbind_get_groups(TALLOC_CTX *mem_ctx,
-			const char *account,
-			uint32_t *num_groups,
-			gid_t ** _groups);
-bool winbind_get_sid_aliases(TALLOC_CTX *mem_ctx,
-			     const struct dom_sid *dom_sid,
-		             const struct dom_sid *members,
-			     size_t num_members,
-			     uint32_t **pp_alias_rids,
-			     size_t *p_num_alias_rids);
 bool winbind_lookup_usersids(TALLOC_CTX *mem_ctx,
 			     const struct dom_sid *user_sid,
 			     uint32_t *p_num_sids,
diff --git a/source3/libsmb/cli_smb2_fnum.c b/source3/libsmb/cli_smb2_fnum.c
index 848e077..351fccf 100644
--- a/source3/libsmb/cli_smb2_fnum.c
+++ b/source3/libsmb/cli_smb2_fnum.c
@@ -2010,8 +2010,9 @@ NTSTATUS cli_smb2_set_security_descriptor(struct cli_state *cli,
 ***************************************************************/
 
 NTSTATUS cli_smb2_rename(struct cli_state *cli,
-			const char *fname_src,
-			const char *fname_dst)
+			 const char *fname_src,
+			 const char *fname_dst,
+			 bool replace)
 {
 	NTSTATUS status;
 	DATA_BLOB inbuf = data_blob_null;
@@ -2091,6 +2092,10 @@ NTSTATUS cli_smb2_rename(struct cli_state *cli,
 		goto fail;
 	}
 
+	if (replace) {
+		SCVAL(inbuf.data, 0, 1);
+	}
+
 	SIVAL(inbuf.data, 16, converted_size_bytes);
 	memcpy(inbuf.data + 20, converted_str, converted_size_bytes);
 
diff --git a/source3/libsmb/cli_smb2_fnum.h b/source3/libsmb/cli_smb2_fnum.h
index 12c42a2..43e0471 100644
--- a/source3/libsmb/cli_smb2_fnum.h
+++ b/source3/libsmb/cli_smb2_fnum.h
@@ -132,8 +132,9 @@ NTSTATUS cli_smb2_set_security_descriptor(struct cli_state *cli,
 			uint32_t sec_info,
 			const struct security_descriptor *sd);
 NTSTATUS cli_smb2_rename(struct cli_state *cli,
-			const char *fname_src,
-			const char *fname_dst);
+			 const char *fname_src,
+			 const char *fname_dst,
+			 bool replace);
 NTSTATUS cli_smb2_set_ea_fnum(struct cli_state *cli,
 			uint16_t fnum,
 			const char *ea_name,
diff --git a/source3/libsmb/clifile.c b/source3/libsmb/clifile.c
index 6b32bf1..cc1d1e4 100644
--- a/source3/libsmb/clifile.c
+++ b/source3/libsmb/clifile.c
@@ -992,29 +992,146 @@ NTSTATUS cli_posix_chown(struct cli_state *cli,
  Rename a file.
 ****************************************************************************/
 
-static void cli_rename_done(struct tevent_req *subreq);
+static struct tevent_req *cli_cifs_rename_send(TALLOC_CTX *mem_ctx,
+					       struct tevent_context *ev,
+					       struct cli_state *cli,
+					       const char *fname_src,
+					       const char *fname_dst,
+					       bool replace);
+
+static struct tevent_req *cli_smb1_rename_send(TALLOC_CTX *mem_ctx,
+					       struct tevent_context *ev,
+					       struct cli_state *cli,
+					       const char *fname_src,
+					       const char *fname_dst,
+					       bool replace);
 
-struct cli_rename_state {
+struct tevent_req *cli_rename_send(TALLOC_CTX *mem_ctx,
+				   struct tevent_context *ev,
+				   struct cli_state *cli,
+				   const char *fname_src,
+				   const char *fname_dst,
+				   bool replace)
+{
+	if (replace && smbXcli_conn_support_passthrough(cli->conn)) {
+		return cli_smb1_rename_send(mem_ctx, ev, cli, fname_src,
+					    fname_dst, replace);
+	} else {
+		return cli_cifs_rename_send(mem_ctx, ev, cli, fname_src,
+					    fname_dst, replace);
+	}
+}
+
+struct cli_smb1_rename_state {
+	uint8_t *data;
+};
+
+static void cli_smb1_rename_done(struct tevent_req *subreq);
+
+static struct tevent_req *cli_smb1_rename_send(TALLOC_CTX *mem_ctx,
+					       struct tevent_context *ev,
+					       struct cli_state *cli,
+					       const char *fname_src,
+					       const char *fname_dst,
+					       bool replace)
+{
+	NTSTATUS status;
+	struct tevent_req *req = NULL, *subreq = NULL;
+	struct cli_smb1_rename_state *state = NULL;
+	smb_ucs2_t *converted_str = NULL;
+	size_t converted_size_bytes = 0;
+
+	req = tevent_req_create(mem_ctx, &state, struct cli_smb1_rename_state);
+	if (req == NULL) {
+		return NULL;
+	}
+
+	if (!push_ucs2_talloc(talloc_tos(), &converted_str, fname_dst,
+			      &converted_size_bytes)) {
+		status = NT_STATUS_INVALID_PARAMETER;
+		goto fail;
+	}
+
+	/* W2K8 insists the dest name is not null
+	   terminated. Remove the last 2 zero bytes
+	   and reduce the name length. */
+
+	if (converted_size_bytes < 2) {
+		status = NT_STATUS_INVALID_PARAMETER;
+		goto fail;
+	}
+	converted_size_bytes -= 2;
+
+	state->data =
+	    talloc_zero_array(state, uint8_t, 12 + converted_size_bytes);
+	if (state->data == NULL) {
+		status = NT_STATUS_NO_MEMORY;
+		goto fail;
+	}


-- 
Samba Shared Repository



More information about the samba-cvs mailing list