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

Karolin Seeger kseeger at samba.org
Thu Jan 14 12:22:04 UTC 2016


The branch, v4-3-test has been updated
       via  2c72956 Revert "winbind: Retry after SESSION_EXPIRED error in ping-dc"
       via  52b5636 winbindd: Retry on expired session in cm_connect_netlogon
       via  dded902 winbindd: Retry on expired session in cm_connect_sam
       via  423120f winbindd: Retry on expired session in cm_connect_lsa
       via  a0f2f52 winbindd: Remove double retry from some ADS methods
       via  fa875e3 winbindd: Add retry also for ADS method calls
       via  39e6b5b winbindd: Reset connection for expired session before reconnecting
       via  40bc9b0 vfs_shadow_copy2: add a blackbox test suite
       via  0998c40 vfs_shadow_copy2: fix case where snapshots are outside the share
       via  a453c78 vfs_shadow_copy2: add shadow_copy2_do_convert()
       via  db70921 s3:smbd/oplock obey kernel oplock setting when releasing oplocks
       via  43ade9a selftest: more dfree command and smbclient disk usage tests
       via  21d362e smbclient: query disk usage relative to current directory
      from  ae2a575 VERSION: Bump version up to 4.3.5...

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


- Log -----------------------------------------------------------------
commit 2c729567a09bfd982b13304281f09fb515ee0664
Author: Christof Schmitt <cs at samba.org>
Date:   Thu Jan 7 13:27:49 2016 -0700

    Revert "winbind: Retry after SESSION_EXPIRED error in ping-dc"
    
    This reverts commit a2670f15dea27c10e3827216adf572f9c3894f85.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11670
    
    cm_connect_netlogon now handles the retry for an expired session.
    
    Signed-off-by: Christof Schmitt <cs at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Wed Jan 13 03:35:57 CET 2016 on sn-devel-144
    
    (cherry picked from commit 6f3656c47d8ae6a3ac10591ffd7a60797775b469)
    
    Autobuild-User(v4-3-test): Karolin Seeger <kseeger at samba.org>
    Autobuild-Date(v4-3-test): Thu Jan 14 13:21:52 CET 2016 on sn-devel-104

commit 52b563627b46119cbcae63bf092a0b5206c03616
Author: Christof Schmitt <cs at samba.org>
Date:   Tue Jan 5 15:10:45 2016 -0700

    winbindd: Retry on expired session in cm_connect_netlogon
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11670
    
    Signed-off-by: Christof Schmitt <cs at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit aa3883eae6e7891efb1e6f9ec74e6073bee43250)

commit dded9027ed942d556c56a5441faab528141cef13
Author: Christof Schmitt <cs at samba.org>
Date:   Thu Jan 7 15:03:22 2016 -0700

    winbindd: Retry on expired session in cm_connect_sam
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11670
    
    Signed-off-by: Christof Schmitt <cs at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 276d604aa5ccc32d18b69c04ae13e2dc7c21f3ee)

commit 423120f176921e06058f97e4e3cdd18252ac2003
Author: Christof Schmitt <cs at samba.org>
Date:   Wed Jan 6 14:15:30 2016 -0700

    winbindd: Retry on expired session in cm_connect_lsa
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11670
    
    Signed-off-by: Christof Schmitt <cs at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 3b6b5456424be6997b32c23b7c149c8060c3102d)

commit a0f2f52f3c6b54111fceea494534541162c8c2b2
Author: Christof Schmitt <cs at samba.org>
Date:   Tue Jan 5 14:42:09 2016 -0700

    winbindd: Remove double retry from some ADS methods
    
    The retry through the new reconnect_ads layer is enough. This structure
    also makes the distinction between retry layer and actual methods call a
    bit clearer.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11670
    
    Signed-off-by: Christof Schmitt <cs at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 4c6804e414087fb61e66133cefbe5590d1d9b283)

commit fa875e3d953dcd3a6d2e77350df51cf2b6136058
Author: Christof Schmitt <cs at samba.org>
Date:   Tue Jan 5 14:37:30 2016 -0700

    winbindd: Add retry also for ADS method calls
    
    RPC calls can return IO_DEVICE_ERROR on expired SMB2 sessions. Retrying
    on a new connection avoids surfacing this error to winbindd clients.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11670
    
    Signed-off-by: Christof Schmitt <cs at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit e4adf55e242aa5f000570bf554fcd15d7e86c126)

commit 39e6b5b8d5d512e9dfcaaca613e9140e98b6897b
Author: Christof Schmitt <cs at samba.org>
Date:   Tue Jan 5 13:39:25 2016 -0700

    winbindd: Reset connection for expired session before reconnecting
    
    A RPC call on a expired SMB2 session returns IO_DEVICE_ERROR. In this
    case, reset the connection before issuing the same call
    again.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11670
    
    Signed-off-by: Christof Schmitt <cs at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit fb5b0cec3c0c2e0cf9cb04f8b52ee910ac245aeb)

commit 40bc9b04a0cc1d8f6f9727de43f532e9f416d8e5
Author: Uri Simchoni <uri at samba.org>
Date:   Thu Oct 29 22:24:30 2015 +0200

    vfs_shadow_copy2: add a blackbox test suite
    
    Add a blackbox test suite for vfs_shadow_copy2, testing
    parameters mountpoint, basedir, snapdir, snapdirseverywhere,
    and testing correct wide-link processing.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11580
    
    Signed-off-by: Uri Simchoni <uri at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>
    
    Autobuild-User(master): Michael Adam <obnox at samba.org>
    Autobuild-Date(master): Wed Jan 13 17:11:38 CET 2016 on sn-devel-144
    
    (cherry picked from commit 7362c27a62e3802fc8df975ce50115b683811f4a)

commit 0998c4093e7dd9e047aa50f8e56d440e23891260
Author: Uri Simchoni <uri at samba.org>
Date:   Mon Nov 2 09:08:53 2015 +0200

    vfs_shadow_copy2: fix case where snapshots are outside the share
    
    Adjust the connect path to the root of the share in the snapshot,
    or to the root of the snapshot if the snapshot is "inside" the
    share.
    
    This way snapshot symlink regarded as "wide links" if and only if
    they point outside the snapshot or they were wide links when
    the snapshot was taken.
    
    This allows mounting the snapshots outside the share's root.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11580
    
    Signed-off-by: Uri Simchoni <uri at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>
    (cherry picked from commit 8a49a63a5a5d8014d32179df1789186223443b35)

commit a453c78e43b79844fea244687e1b5a683d8b57ad
Author: Uri Simchoni <uri at samba.org>
Date:   Sun Nov 1 22:28:46 2015 +0200

    vfs_shadow_copy2: add shadow_copy2_do_convert()
    
    Add a new routine shadow_copy2_do_convert() which is
    like shadow_copy2_convert(), but beside calculating the
    path of the snapshot file, it also returns the minimum length
    of the subpath which is both inside the share and inside the
    same snapshot as the file in question, i.e. (at least in the
    classical case) the subdirectory of the the snapshot file's
    snapshot directory that corresponds to the file's share root.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11580
    
    Signed-off-by: Uri Simchoni <uri at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>
    (cherry picked from commit 3703bca4d9e494aec0b40243add3e076cf353601)

commit db7092129711f2671cca217336f1572440def52c
Author: Christian Ambach <ambi at samba.org>
Date:   Mon Jan 4 23:12:25 2016 +0100

    s3:smbd/oplock obey kernel oplock setting when releasing oplocks
    
    otherwise smbd asks the kernel to release an oplock that was never requested
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=11400
    
    Signed-off-by: Christian Ambach <ambi at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Wed Jan  6 08:58:56 CET 2016 on sn-devel-144
    
    (cherry picked from commit eda6aaf1533b69d093ba67ff5e22fcda0073dd3f)

commit 43ade9aa1bcb88c42d741fe81a4e364908d3172b
Author: Uri Simchoni <uri at samba.org>
Date:   Wed Jan 6 00:12:36 2016 +0200

    selftest: more dfree command and smbclient disk usage tests
    
    Add tests that cover disk usage printing by smbclient, as well
    as passing directory info to the "dfree command" script.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11662
    
    Signed-off-by: Uri Simchoni <uri at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Wed Jan  6 03:58:59 CET 2016 on sn-devel-144
    
    (cherry picked from commit 3e1b26bd6d0998c3af3d77f94eaac469434389be)

commit 21d362e9eb77d12d5f2f602097c20e5c50eaca80
Author: Uri Simchoni <uri at samba.org>
Date:   Wed Jan 6 00:08:25 2016 +0200

    smbclient: query disk usage relative to current directory
    
    When querying disk usage in the "dir" and "du" commands,
    use the current directory. This behavior is compatible
    with Windows command shell "dir" command.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11662
    
    Signed-off-by: Uri Simchoni <uri at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    
    (cherry picked from commit 275da6c5c7e7c5dd0581e919912eb82102903a46)

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

Summary of changes:
 selftest/target/Samba3.pm                          |  71 +++++
 source3/client/client.c                            |   2 +-
 source3/libsmb/cli_smb2_fnum.c                     |   5 +-
 source3/libsmb/cli_smb2_fnum.h                     |   1 +
 source3/libsmb/clifile.c                           |   5 +-
 source3/libsmb/proto.h                             |   3 +-
 source3/modules/vfs_shadow_copy2.c                 | 107 ++++++--
 source3/script/tests/test_dfree_command.sh         |  17 +-
 source3/script/tests/test_shadow_copy.sh           | 290 +++++++++++++++++++++
 source3/selftest/tests.py                          |   1 +
 source3/smbd/oplock.c                              |   3 +-
 source3/torture/nbio.c                             |   2 +-
 source3/winbindd/winbindd_ads.c                    |  26 +-
 source3/winbindd/winbindd_cache.c                  |   4 +-
 source3/winbindd/winbindd_cm.c                     | 104 ++++++++
 source3/winbindd/winbindd_dual_srv.c               |   8 -
 source3/winbindd/winbindd_ndr.c                    |   3 +
 source3/winbindd/winbindd_proto.h                  |   4 +
 source3/winbindd/winbindd_reconnect.c              |  38 +--
 ...nbindd_reconnect.c => winbindd_reconnect_ads.c} | 249 ++++++++----------
 source3/wscript_build                              |   1 +
 testprogs/blackbox/dfree.sh                        |   8 +-
 22 files changed, 732 insertions(+), 220 deletions(-)
 create mode 100755 source3/script/tests/test_shadow_copy.sh
 copy source3/winbindd/{winbindd_reconnect.c => winbindd_reconnect_ads.c} (50%)


Changeset truncated at 500 lines:

diff --git a/selftest/target/Samba3.pm b/selftest/target/Samba3.pm
index 931667e..d16c440 100755
--- a/selftest/target/Samba3.pm
+++ b/selftest/target/Samba3.pm
@@ -590,6 +590,8 @@ sub setup_fileserver($$)
 
 	my $dfree_share_dir="$share_dir/dfree";
 	push(@dirs, $dfree_share_dir);
+	push(@dirs, "$dfree_share_dir/subdir1");
+	push(@dirs, "$dfree_share_dir/subdir2");
 
 	my $fileserver_options = "
 [lowercase]
@@ -1092,6 +1094,15 @@ sub provision($$$$$$$$)
 	my $manglenames_shrdir="$shrdir/manglenames";
 	push(@dirs,$manglenames_shrdir);
 
+	my $shadow_tstdir="$shrdir/shadow";
+	push(@dirs,$shadow_tstdir);
+	my $shadow_mntdir="$shadow_tstdir/mount";
+	push(@dirs,$shadow_mntdir);
+	my $shadow_basedir="$shadow_mntdir/base";
+	push(@dirs,$shadow_basedir);
+	my $shadow_shrdir="$shadow_basedir/share";
+	push(@dirs,$shadow_shrdir);
+
 	# this gets autocreated by winbindd
 	my $wbsockdir="$prefix_abs/winbindd";
 	my $wbsockprivdir="$lockdir/winbindd_privileged";
@@ -1336,6 +1347,10 @@ sub provision($$$$$$$$)
 	# fruit:copyfile is a global option
 	fruit:copyfile = yes
 
+	#this does not mean that we use non-secure test env,
+	#it just means we ALLOW one to be configured.
+	allow insecure wide links = yes
+
 	# Begin extra options
 	$extra_options
 	# End extra options
@@ -1492,6 +1507,62 @@ sub provision($$$$$$$$)
 	shell_snap:delete command = $fake_snap_pl --delete
 	# a relative path here fails, the snapshot dir is no longer found
 	shadow:snapdir = $shrdir/.snapshots
+
+[shadow1]
+	path = $shadow_shrdir
+	comment = previous versions snapshots under mount point
+	vfs objects = shadow_copy2
+	shadow:mountpoint = $shadow_mntdir
+
+[shadow2]
+	path = $shadow_shrdir
+	comment = previous versions snapshots outside mount point
+	vfs objects = shadow_copy2
+	shadow:mountpoint = $shadow_mntdir
+	shadow:snapdir = $shadow_tstdir/.snapshots
+
+[shadow3]
+	path = $shadow_shrdir
+	comment = previous versions with subvolume snapshots, snapshots under base dir
+	vfs objects = shadow_copy2
+	shadow:mountpoint = $shadow_mntdir
+	shadow:basedir = $shadow_basedir
+	shadow:snapdir = $shadow_basedir/.snapshots
+
+[shadow4]
+	path = $shadow_shrdir
+	comment = previous versions with subvolume snapshots, snapshots outside mount point
+	vfs objects = shadow_copy2
+	shadow:mountpoint = $shadow_mntdir
+	shadow:basedir = $shadow_basedir
+	shadow:snapdir = $shadow_tstdir/.snapshots
+
+[shadow5]
+	path = $shadow_shrdir
+	comment = previous versions at volume root snapshots under mount point
+	vfs objects = shadow_copy2
+	shadow:mountpoint = $shadow_shrdir
+
+[shadow6]
+	path = $shadow_shrdir
+	comment = previous versions at volume root snapshots outside mount point
+	vfs objects = shadow_copy2
+	shadow:mountpoint = $shadow_shrdir
+	shadow:snapdir = $shadow_tstdir/.snapshots
+
+[shadow7]
+	path = $shadow_shrdir
+	comment = previous versions snapshots everywhere
+	vfs objects = shadow_copy2
+	shadow:mountpoint = $shadow_mntdir
+	shadow:snapdirseverywhere = yes
+
+[shadow_wl]
+	path = $shadow_shrdir
+	comment = previous versions with wide links allowed
+	vfs objects = shadow_copy2
+	shadow:mountpoint = $shadow_mntdir
+	wide links = yes
 	";
 	close(CONF);
 
diff --git a/source3/client/client.c b/source3/client/client.c
index 034b48a..ad56f26 100644
--- a/source3/client/client.c
+++ b/source3/client/client.c
@@ -312,7 +312,7 @@ static int do_dskattr(void)
 		return 1;
 	}
 
-	status = cli_disk_size(targetcli, &bsize, &total, &avail);
+	status = cli_disk_size(targetcli, targetpath, &bsize, &total, &avail);
 	if (!NT_STATUS_IS_OK(status)) {
 		d_printf("Error in dskattr: %s\n", nt_errstr(status));
 		return 1;
diff --git a/source3/libsmb/cli_smb2_fnum.c b/source3/libsmb/cli_smb2_fnum.c
index 816ad13..c9f4060 100644
--- a/source3/libsmb/cli_smb2_fnum.c
+++ b/source3/libsmb/cli_smb2_fnum.c
@@ -1592,7 +1592,8 @@ NTSTATUS cli_smb2_setattrE(struct cli_state *cli,
  Synchronous only.
 ***************************************************************/
 
-NTSTATUS cli_smb2_dskattr(struct cli_state *cli, uint64_t *bsize, uint64_t *total, uint64_t *avail)
+NTSTATUS cli_smb2_dskattr(struct cli_state *cli, const char *path,
+			  uint64_t *bsize, uint64_t *total, uint64_t *avail)
 {
 	NTSTATUS status;
 	uint16_t fnum = 0xffff;
@@ -1619,7 +1620,7 @@ NTSTATUS cli_smb2_dskattr(struct cli_state *cli, uint64_t *bsize, uint64_t *tota
 
 	/* First open the top level directory. */
 	status = cli_smb2_create_fnum(cli,
-			"",
+			path,
 			0,			/* create_flags */
 			FILE_READ_ATTRIBUTES,	/* desired_access */
 			FILE_ATTRIBUTE_DIRECTORY, /* file attributes */
diff --git a/source3/libsmb/cli_smb2_fnum.h b/source3/libsmb/cli_smb2_fnum.h
index c97bc76..ceb5629 100644
--- a/source3/libsmb/cli_smb2_fnum.h
+++ b/source3/libsmb/cli_smb2_fnum.h
@@ -117,6 +117,7 @@ NTSTATUS cli_smb2_setattrE(struct cli_state *cli,
                         time_t access_time,
                         time_t write_time);
 NTSTATUS cli_smb2_dskattr(struct cli_state *cli,
+			const char *path,
 			uint64_t *bsize,
 			uint64_t *total,
 			uint64_t *avail);
diff --git a/source3/libsmb/clifile.c b/source3/libsmb/clifile.c
index 9e1975b..364376b 100644
--- a/source3/libsmb/clifile.c
+++ b/source3/libsmb/clifile.c
@@ -4199,7 +4199,8 @@ NTSTATUS cli_dskattr(struct cli_state *cli, int *bsize, int *total, int *avail)
 	return status;
 }
 
-NTSTATUS cli_disk_size(struct cli_state *cli, uint64_t *bsize, uint64_t *total, uint64_t *avail)
+NTSTATUS cli_disk_size(struct cli_state *cli, const char *path, uint64_t *bsize,
+		       uint64_t *total, uint64_t *avail)
 {
 	uint64_t sectors_per_block;
 	uint64_t bytes_per_sector;
@@ -4207,7 +4208,7 @@ NTSTATUS cli_disk_size(struct cli_state *cli, uint64_t *bsize, uint64_t *total,
 	NTSTATUS status;
 
 	if (smbXcli_conn_protocol(cli->conn) >= PROTOCOL_SMB2_02) {
-		return cli_smb2_dskattr(cli, bsize, total, avail);
+		return cli_smb2_dskattr(cli, path, bsize, total, avail);
 	}
 
 	/*
diff --git a/source3/libsmb/proto.h b/source3/libsmb/proto.h
index 5ebcf5f..c32bba7 100644
--- a/source3/libsmb/proto.h
+++ b/source3/libsmb/proto.h
@@ -513,7 +513,8 @@ struct tevent_req *cli_dskattr_send(TALLOC_CTX *mem_ctx,
 NTSTATUS cli_dskattr_recv(struct tevent_req *req, int *bsize, int *total,
 			  int *avail);
 NTSTATUS cli_dskattr(struct cli_state *cli, int *bsize, int *total, int *avail);
-NTSTATUS cli_disk_size(struct cli_state *cli, uint64_t *bsize, uint64_t *total, uint64_t *avail);
+NTSTATUS cli_disk_size(struct cli_state *cli, const char *path, uint64_t *bsize,
+		       uint64_t *total, uint64_t *avail);
 struct tevent_req *cli_ctemp_send(TALLOC_CTX *mem_ctx,
 				struct tevent_context *ev,
 				struct cli_state *cli,
diff --git a/source3/modules/vfs_shadow_copy2.c b/source3/modules/vfs_shadow_copy2.c
index d1673a4..7ecdda5 100644
--- a/source3/modules/vfs_shadow_copy2.c
+++ b/source3/modules/vfs_shadow_copy2.c
@@ -434,10 +434,13 @@ static char *shadow_copy2_find_mount_point(TALLOC_CTX *mem_ctx,
  * Convert from a name as handed in via the SMB layer
  * and a timestamp into the local path of the snapshot
  * of the provided file at the provided time.
+ * Also return the path in the snapshot corresponding
+ * to the file's share root.
  */
-static char *shadow_copy2_convert(TALLOC_CTX *mem_ctx,
-				  struct vfs_handle_struct *handle,
-				  const char *name, time_t timestamp)
+static char *shadow_copy2_do_convert(TALLOC_CTX *mem_ctx,
+				     struct vfs_handle_struct *handle,
+				     const char *name, time_t timestamp,
+				     size_t *snaproot_len)
 {
 	struct smb_filename converted_fname;
 	char *result = NULL;
@@ -447,10 +450,11 @@ static char *shadow_copy2_convert(TALLOC_CTX *mem_ctx,
 	size_t pathlen;
 	char *insert = NULL;
 	char *converted = NULL;
-	size_t insertlen;
+	size_t insertlen, connectlen = 0;
 	int i, saved_errno;
 	size_t min_offset;
 	struct shadow_copy2_config *config;
+	size_t in_share_offset = 0;
 
 	SMB_VFS_HANDLE_GET_DATA(handle, config, struct shadow_copy2_config,
 				return NULL);
@@ -492,6 +496,13 @@ static char *shadow_copy2_convert(TALLOC_CTX *mem_ctx,
 			DEBUG(10, ("Found %s\n", converted));
 			result = converted;
 			converted = NULL;
+			if (snaproot_len != NULL) {
+				*snaproot_len = strlen(snapshot_path);
+				if (config->rel_connectpath != NULL) {
+					*snaproot_len +=
+					    strlen(config->rel_connectpath) + 1;
+				}
+			}
 			goto fail;
 		} else {
 			errno = ENOENT;
@@ -500,6 +511,7 @@ static char *shadow_copy2_convert(TALLOC_CTX *mem_ctx,
 		/* never reached ... */
 	}
 
+	connectlen = strlen(handle->conn->connectpath);
 	if (name[0] == 0) {
 		path = talloc_strdup(mem_ctx, handle->conn->connectpath);
 	} else {
@@ -575,6 +587,10 @@ static char *shadow_copy2_convert(TALLOC_CTX *mem_ctx,
 			goto fail;
 		}
 
+		if (offset >= connectlen) {
+			in_share_offset = offset;
+		}
+
 		memcpy(converted+offset, insert, insertlen);
 
 		offset += insertlen;
@@ -588,6 +604,9 @@ static char *shadow_copy2_convert(TALLOC_CTX *mem_ctx,
 			   ret, ret == 0 ? "ok" : strerror(errno)));
 		if (ret == 0) {
 			/* success */
+			if (snaproot_len != NULL) {
+				*snaproot_len = in_share_offset + insertlen;
+			}
 			break;
 		}
 		if (errno == ENOTDIR) {
@@ -624,6 +643,18 @@ fail:
 	return result;
 }
 
+/**
+ * Convert from a name as handed in via the SMB layer
+ * and a timestamp into the local path of the snapshot
+ * of the provided file at the provided time.
+ */
+static char *shadow_copy2_convert(TALLOC_CTX *mem_ctx,
+				  struct vfs_handle_struct *handle,
+				  const char *name, time_t timestamp)
+{
+	return shadow_copy2_do_convert(mem_ctx, handle, name, timestamp, NULL);
+}
+
 /*
   modify a sbuf return to ensure that inodes in the shadow directory
   are different from those in the main directory
@@ -1103,8 +1134,6 @@ static char *shadow_copy2_realpath(vfs_handle_struct *handle,
 	char *stripped = NULL;
 	char *tmp = NULL;
 	char *result = NULL;
-	char *inserted = NULL;
-	char *inserted_to, *inserted_end;
 	int saved_errno;
 
 	if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, fname,
@@ -1121,29 +1150,9 @@ static char *shadow_copy2_realpath(vfs_handle_struct *handle,
 	}
 
 	result = SMB_VFS_NEXT_REALPATH(handle, tmp);
-	if (result == NULL) {
-		goto done;
-	}
-
-	/*
-	 * Take away what we've inserted. This removes the @GMT-thingy
-	 * completely, but will give a path under the share root.
-	 */
-	inserted = shadow_copy2_insert_string(talloc_tos(), handle, timestamp);
-	if (inserted == NULL) {
-		goto done;
-	}
-	inserted_to = strstr_m(result, inserted);
-	if (inserted_to == NULL) {
-		DEBUG(2, ("SMB_VFS_NEXT_REALPATH removed %s\n", inserted));
-		goto done;
-	}
-	inserted_end = inserted_to + talloc_get_size(inserted) - 1;
-	memmove(inserted_to, inserted_end, strlen(inserted_end)+1);
 
 done:
 	saved_errno = errno;
-	TALLOC_FREE(inserted);
 	TALLOC_FREE(tmp);
 	TALLOC_FREE(stripped);
 	errno = saved_errno;
@@ -1777,6 +1786,51 @@ static int shadow_copy2_get_real_filename(struct vfs_handle_struct *handle,
 	return ret;
 }
 
+static const char *shadow_copy2_connectpath(struct vfs_handle_struct *handle,
+					    const char *fname)
+{
+	time_t timestamp;
+	char *stripped = NULL;
+	char *tmp = NULL;
+	char *result = NULL;
+	int saved_errno;
+	size_t rootpath_len = 0;
+
+	DBG_DEBUG("Calc connect path for [%s]\n", fname);
+
+	if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, fname,
+					 &timestamp, &stripped)) {
+		goto done;
+	}
+	if (timestamp == 0) {
+		return SMB_VFS_NEXT_CONNECTPATH(handle, fname);
+	}
+
+	tmp = shadow_copy2_do_convert(talloc_tos(), handle, stripped, timestamp,
+				      &rootpath_len);
+	if (tmp == NULL) {
+		goto done;
+	}
+
+	DBG_DEBUG("converted path is [%s] root path is [%.*s]\n", tmp,
+		  (int)rootpath_len, tmp);
+
+	tmp[rootpath_len] = '\0';
+	result = SMB_VFS_NEXT_REALPATH(handle, tmp);
+	if (result == NULL) {
+		goto done;
+	}
+
+	DBG_DEBUG("connect path is [%s]\n", result);
+
+done:
+	saved_errno = errno;
+	TALLOC_FREE(tmp);
+	TALLOC_FREE(stripped);
+	errno = saved_errno;
+	return result;
+}
+
 static uint64_t shadow_copy2_disk_free(vfs_handle_struct *handle,
 				       const char *path, uint64_t *bsize,
 				       uint64_t *dfree, uint64_t *dsize)
@@ -2078,6 +2132,7 @@ static struct vfs_fn_pointers vfs_shadow_copy2_fns = {
 	.chmod_acl_fn = shadow_copy2_chmod_acl,
 	.chflags_fn = shadow_copy2_chflags,
 	.get_real_filename_fn = shadow_copy2_get_real_filename,
+	.connectpath_fn = shadow_copy2_connectpath,
 };
 
 NTSTATUS vfs_shadow_copy2_init(void);
diff --git a/source3/script/tests/test_dfree_command.sh b/source3/script/tests/test_dfree_command.sh
index c9c3aa6..a60a52d 100755
--- a/source3/script/tests/test_dfree_command.sh
+++ b/source3/script/tests/test_dfree_command.sh
@@ -1,6 +1,7 @@
 #!/bin/sh
 #
-# Blackbox test for 'dfree command'
+# Blackbox test for 'dfree command' and smbclient "l"
+# command disk free printout.
 #
 
 if [ $# -lt 6 ]; then
@@ -26,15 +27,16 @@ test_smbclient_dfree() {
 	name="$1"
 	share="$2"
 	cmd="$3"
+    expected="$4"
 	shift
 	shift
+    shift
 	subunit_start_test "$name"
 	output=$($VALGRIND $smbclient //$SERVER/$share -c "$cmd" $@ 2>&1)
 	status=$?
 	if [ x$status = x0 ]; then
-		echo "$output" | grep "2000 blocks of size 1024. 20 blocks available" >/dev/null
-		status=$?
-		if [ x$status = x0 ]; then
+		received=$(echo "$output" | awk '/blocks of size/ {print $1, $5, $6}')
+		if [ "$expected" = "$received" ]; then
 			subunit_pass_test "$name"
 		else
 			echo "$output" | subunit_fail_test "$name"
@@ -46,6 +48,11 @@ test_smbclient_dfree() {
 }
 
 
-test_smbclient_dfree "Test dfree command" dfree "l" -U$USERNAME%$PASSWORD || failed=`expr $failed + 1`
+test_smbclient_dfree "Test dfree command share root SMB3" dfree "l" "2000 1024. 20" -U$USERNAME%$PASSWORD --option=clientmaxprotocol=SMB3 || failed=`expr $failed + 1`
+test_smbclient_dfree "Test dfree command share root NT1" dfree "l" "2000 1024. 20" -U$USERNAME%$PASSWORD --option=clientmaxprotocol=NT1 || failed=`expr $failed + 1`
+test_smbclient_dfree "Test dfree command subdir1 SMB3" dfree "cd subdir1; l" "8000 1024. 80" -U$USERNAME%$PASSWORD --option=clientmaxprotocol=SMB3 || failed=`expr $failed + 1`
+test_smbclient_dfree "Test dfree command subdir2 SMB3" dfree "cd subdir2; l" "32000 1024. 320" -U$USERNAME%$PASSWORD --option=clientmaxprotocol=SMB3 || failed=`expr $failed + 1`
+#SMB1 queries disk usage stat on the share's root, regardless of working directory
+test_smbclient_dfree "Test dfree command subdir1 NT1" dfree "cd subdir1; l" "2000 1024. 20" -U$USERNAME%$PASSWORD --option=clientmaxprotocol=NT1 || failed=`expr $failed + 1`
 
 exit $failed
diff --git a/source3/script/tests/test_shadow_copy.sh b/source3/script/tests/test_shadow_copy.sh
new file mode 100755
index 0000000..eecd5b8
--- /dev/null
+++ b/source3/script/tests/test_shadow_copy.sh
@@ -0,0 +1,290 @@
+#!/bin/bash
+#
+# Blackbox test for shadow_copy2 VFS.
+#
+
+if [ $# -lt 7 ]; then
+cat <<EOF
+Usage: test_shadow_copy SERVER SERVER_IP DOMAIN USERNAME PASSWORD WORKDIR SMBCLIENT
+EOF
+exit 1;
+fi
+
+SERVER=${1}
+SERVER_IP=${2}
+DOMAIN=${3}
+USERNAME=${4}
+PASSWORD=${5}
+WORKDIR=${6}
+SMBCLIENT=${7}
+shift 7
+SMBCLIENT="$VALGRIND ${SMBCLIENT}"
+ADDARGS="$*"
+
+incdir=`dirname $0`/../../../testprogs/blackbox
+. $incdir/subunit.sh
+
+SNAPSHOTS[0]='@GMT-2015.10.31-19.40.30'
+SNAPSHOTS[1]='@GMT-2016.10.31-19.40.30'
+SNAPSHOTS[2]='@GMT-2017.10.31-19.40.30'
+SNAPSHOTS[3]='@GMT-2018.10.31-19.40.30'
+SNAPSHOTS[4]='@GMT-2019.10.31-19.40.30'
+SNAPSHOTS[5]='@GMT-2020.10.31-19.40.30'
+SNAPSHOTS[6]='@GMT-2021.10.31-19.40.30'
+SNAPSHOTS[7]='@GMT-2022.10.31-19.40.30'
+SNAPSHOTS[8]='@GMT-2023.10.31-19.40.30'
+SNAPSHOTS[9]='@GMT-2024.10.31-19.40.30'
+
+# build a hierarchy of files, symlinks, and directories
+build_files()
+{
+    local rootdir
+    local prefix
+    local version
+    local destdir
+    rootdir=$1
+    prefix=$2
+    version=$3
+    if [ -n "$prefix" ] ; then
+        destdir=$rootdir/$prefix
+    else
+        destdir=$rootdir
+    fi
+
+    mkdir -p $destdir
+    if [ "$version" = "latest" ] ; then
+        #non-snapshot files
+        # for non-snapshot version, create legit files
+        # so that wide-link checks focus on snapshot files
+        touch $destdir/foo
+        mkdir -p $destdir/bar
+        touch $destdir/bar/baz
+        touch $destdir/bar/lfoo
+        touch $destdir/bar/letcpasswd
+        touch $destdir/bar/loutside
+    elif [ "$version" = "fullsnap" ] ; then


-- 
Samba Shared Repository



More information about the samba-cvs mailing list