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

Karolin Seeger kseeger at samba.org
Mon Jan 7 14:57:05 UTC 2019


The branch, v4-8-test has been updated
       via  5067926e4fe s3:utils/smbget fix recursive download with empty source directories
       via  7aba48de14f s3:utils/smbget add error handling for mkdir() calls
       via  6058729541a s3:script/tests reduce code duplication
      from  74507e182c7 vfs_shadow_copy2: in fstat also convert fsp->fsp_name and fsp->base_fsp->fsp_name

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


- Log -----------------------------------------------------------------
commit 5067926e4fe7fce7790243bb938677d0c4182edb
Author: Christian Ambach <ambi at samba.org>
Date:   Tue Oct 23 20:05:04 2018 +0200

    s3:utils/smbget fix recursive download with empty source directories
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13199
    Signed-off-by: Christian Ambach <ambi at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    
    Autobuild-User(master): Andreas Schneider <asn at cryptomilk.org>
    Autobuild-Date(master): Fri Oct 26 09:58:07 CEST 2018 on sn-devel-144
    
    (cherry picked from commit fce0d1b290c7a2205f2454b268b55909d1044f1b)
    
    Autobuild-User(v4-8-test): Karolin Seeger <kseeger at samba.org>
    Autobuild-Date(v4-8-test): Mon Jan  7 15:56:31 CET 2019 on sn-devel-144

commit 7aba48de14f133b23839dc831beb562005a448a5
Author: Christian Ambach <ambi at samba.org>
Date:   Mon Oct 22 16:28:21 2018 +0200

    s3:utils/smbget add error handling for mkdir() calls
    
    Signed-off-by: Christian Ambach <ambi at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    (cherry picked from commit b89732c31be350828110fe46f2c655f77cb488f3)

commit 6058729541ae217c0c128c83925943f31eb60149
Author: Christian Ambach <ambi at samba.org>
Date:   Mon Oct 22 16:22:00 2018 +0200

    s3:script/tests reduce code duplication
    
    Signed-off-by: Christian Ambach <ambi at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    (cherry picked from commit 525b19fafb43bd97e3dfc1d3e7dc13955c0f387f)

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

Summary of changes:
 source3/script/tests/test_smbget.sh | 86 ++++++++++++++++++++++++++++++++-----
 source3/utils/smbget.c              | 11 ++++-
 2 files changed, 85 insertions(+), 12 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/script/tests/test_smbget.sh b/source3/script/tests/test_smbget.sh
index f21a131f840..b0ff75f5eb5 100755
--- a/source3/script/tests/test_smbget.sh
+++ b/source3/script/tests/test_smbget.sh
@@ -37,15 +37,18 @@ create_test_data()
 
 remove_test_data()
 {
-	rm -rf dir1 dir2 testfile
 	pushd $WORKDIR
 	rm -rf dir1 dir2 testfile
 	popd
 }
 
+clear_download_area() {
+	rm -rf dir1 dir2 testfile dir001 dir004
+}
+
 test_singlefile_guest()
 {
-	[ -e testfile ] && rm testfile
+	clear_download_area
 	echo "$SMBGET -v -a smb://$SERVER_IP/smbget/testfile"
 	$SMBGET -v -a smb://$SERVER_IP/smbget/testfile
 	if [ $? -ne 0 ]; then
@@ -62,7 +65,7 @@ test_singlefile_guest()
 
 test_singlefile_U()
 {
-	[ -e testfile ] && rm testfile
+	clear_download_area
 	$SMBGET -v -U$USERNAME%$PASSWORD smb://$SERVER_IP/smbget/testfile
 	if [ $? -ne 0 ]; then
 		echo 'ERROR: RC does not match, expected: 0'
@@ -78,7 +81,7 @@ test_singlefile_U()
 
 test_singlefile_smburl()
 {
-	[ -e testfile ] && rm testfile
+	clear_download_area
 	$SMBGET -w $DOMAIN smb://$USERNAME:$PASSWORD@$SERVER_IP/smbget/testfile
 	if [ $? -ne 0 ]; then
 		echo 'ERROR: RC does not match, expected: 0'
@@ -94,7 +97,7 @@ test_singlefile_smburl()
 
 test_singlefile_rcfile()
 {
-	[ -e testfile ] && rm testfile
+	clear_download_area
 	echo "user $USERNAME%$PASSWORD" > $TMPDIR/rcfile
 	$SMBGET -vn -f $TMPDIR/rcfile smb://$SERVER_IP/smbget/testfile
 	rc=$?
@@ -113,9 +116,28 @@ test_singlefile_rcfile()
 
 test_recursive_U()
 {
-	[ -e testfile ] && rm testfile
-	[ -d dir1 ] && rm -rf dir1
-	[ -d dir2 ] && rm -rf dir2
+	clear_download_area
+	$SMBGET -v -R -U$USERNAME%$PASSWORD smb://$SERVER_IP/smbget/
+	if [ $? -ne 0 ]; then
+		echo 'ERROR: RC does not match, expected: 0'
+		return 1
+	fi
+
+	cmp --silent $WORKDIR/testfile ./testfile && \
+	cmp --silent $WORKDIR/dir1/testfile1 ./dir1/testfile1 && \
+	cmp --silent $WORKDIR/dir2/testfile2 ./dir2/testfile2
+	if [ $? -ne 0 ]; then
+		echo 'ERROR: file content does not match'
+		return 1
+	fi
+
+	return 0
+}
+
+test_recursive_existing_dir()
+{
+	clear_download_area
+	mkdir dir1
 	$SMBGET -v -R -U$USERNAME%$PASSWORD smb://$SERVER_IP/smbget/
 	if [ $? -ne 0 ]; then
 		echo 'ERROR: RC does not match, expected: 0'
@@ -133,9 +155,42 @@ test_recursive_U()
 	return 0
 }
 
+
+test_recursive_with_empty() # see Bug 13199
+{
+	clear_download_area
+	# create some additional empty directories
+	mkdir -p $WORKDIR/dir001/dir002/dir003
+	mkdir -p $WORKDIR/dir004/dir005/dir006
+	$SMBGET -v -R -U$USERNAME%$PASSWORD smb://$SERVER_IP/smbget/
+	rc=$?
+	rm -rf $WORKDIR/dir001
+	rm -rf $WORKDIR/dir004
+	if [ $rc -ne 0 ]; then
+		echo 'ERROR: RC does not match, expected: 0'
+		return 1
+	fi
+
+	cmp --silent $WORKDIR/testfile ./testfile && \
+	cmp --silent $WORKDIR/dir1/testfile1 ./dir1/testfile1 && \
+	cmp --silent $WORKDIR/dir2/testfile2 ./dir2/testfile2
+	if [ $? -ne 0 ]; then
+		echo 'ERROR: file content does not match'
+		return 1
+	fi
+
+	if [ ! -d dir001/dir002/dir003 ] || [ ! -d dir004/dir005/dir006 ]; then
+		echo 'ERROR: empty directories are not present'
+		return 1
+	fi
+
+	return 0
+}
+
+
 test_resume()
 {
-	[ -e testfile ] && rm testfile
+	clear_download_area
 	cp $WORKDIR/testfile .
 	truncate -s 1024 testfile
 	$SMBGET -v -r -U$USERNAME%$PASSWORD smb://$SERVER_IP/smbget/testfile
@@ -155,6 +210,7 @@ test_resume()
 
 test_resume_modified()
 {
+	clear_download_area
 	dd if=/dev/urandom bs=1024 count=2 of=testfile
 	$SMBGET -v -r -U$USERNAME%$PASSWORD smb://$SERVER_IP/smbget/testfile
 	if [ $? -ne 1 ]; then
@@ -167,7 +223,7 @@ test_resume_modified()
 
 test_update()
 {
-	[ -e testfile ] && rm testfile
+	clear_download_area
 	$SMBGET -v -U$USERNAME%$PASSWORD smb://$SERVER_IP/smbget/testfile
 	if [ $? -ne 0 ]; then
 		echo 'ERROR: RC does not match, expected: 0'
@@ -220,6 +276,12 @@ testit "download single file with rcfile" test_singlefile_rcfile \
 testit "recursive download" test_recursive_U \
 	|| failed=`expr $failed + 1`
 
+testit "recursive download (existing target dir)" test_recursive_existing_dir \
+	|| failed=`expr $failed + 1`
+
+testit "recursive download with empty directories" test_recursive_with_empty \
+	|| failed=`expr $failed + 1`
+
 testit "resume download" test_resume \
 	|| failed=`expr $failed + 1`
 
@@ -229,7 +291,9 @@ testit "resume download (modified file)" test_resume_modified \
 testit "update" test_update \
 	|| failed=`expr $failed + 1`
 
-popd
+clear_download_area
+
+popd # TMPDIR
 
 remove_test_data
 
diff --git a/source3/utils/smbget.c b/source3/utils/smbget.c
index 4653c6894e0..49cca4efa2a 100644
--- a/source3/utils/smbget.c
+++ b/source3/utils/smbget.c
@@ -190,13 +190,22 @@ static bool smb_download_dir(const char *base, const char *name, int resume)
 	while (*relname == '/') {
 		relname++;
 	}
-	mkdir(relname, 0755);
+
+	if (strlen(relname) > 0) {
+		int rc = mkdir(relname, 0755);
+		if (rc == -1 && errno != EEXIST) {
+			fprintf(stderr, "Can't create directory %s: %s\n",
+				relname, strerror(errno));
+			return false;
+		}
+	}
 
 	tmpname = SMB_STRDUP(name);
 
 	while ((dirent = smbc_readdir(dirhandle))) {
 		char *newname;
 		if (!strcmp(dirent->name, ".") || !strcmp(dirent->name, "..")) {
+			ok = true;
 			continue;
 		}
 		if (asprintf(&newname, "%s/%s", tmpname, dirent->name) == -1) {


-- 
Samba Shared Repository



More information about the samba-cvs mailing list