summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Ambach <ambi@samba.org>2018-10-23 20:05:04 +0200
committerKarolin Seeger <kseeger@samba.org>2019-01-07 15:56:31 +0100
commit5067926e4fe7fce7790243bb938677d0c4182edb (patch)
tree9012d7eda0829dbe00f40715fb0834c091de2a22
parent7aba48de14f133b23839dc831beb562005a448a5 (diff)
downloadsamba-5067926e4fe7fce7790243bb938677d0c4182edb.tar.gz
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@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org> Autobuild-User(master): Andreas Schneider <asn@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@samba.org> Autobuild-Date(v4-8-test): Mon Jan 7 15:56:31 CET 2019 on sn-devel-144
-rwxr-xr-xsource3/script/tests/test_smbget.sh38
-rw-r--r--source3/utils/smbget.c1
2 files changed, 38 insertions, 1 deletions
diff --git a/source3/script/tests/test_smbget.sh b/source3/script/tests/test_smbget.sh
index 3f0aac53ad3..b0ff75f5eb5 100755
--- a/source3/script/tests/test_smbget.sh
+++ b/source3/script/tests/test_smbget.sh
@@ -43,7 +43,7 @@ remove_test_data()
}
clear_download_area() {
- rm -rf dir1 dir2 testfile
+ rm -rf dir1 dir2 testfile dir001 dir004
}
test_singlefile_guest()
@@ -155,6 +155,39 @@ test_recursive_existing_dir()
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()
{
clear_download_area
@@ -246,6 +279,9 @@ testit "recursive download" test_recursive_U \
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`
diff --git a/source3/utils/smbget.c b/source3/utils/smbget.c
index ca4bf310466..49cca4efa2a 100644
--- a/source3/utils/smbget.c
+++ b/source3/utils/smbget.c
@@ -205,6 +205,7 @@ static bool smb_download_dir(const char *base, const char *name, int resume)
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) {