[SCM] Samba Shared Repository - branch v4-9-test updated
Karolin Seeger
kseeger at samba.org
Mon Jan 7 13:24:03 UTC 2019
The branch, v4-9-test has been updated
via 41889196769 s3:utils/smbget fix recursive download with empty source directories
via b9a1a179e62 s3:utils/smbget add error handling for mkdir() calls
via a5c8e943d34 s3:script/tests reduce code duplication
from 2c51c8f8ac1 VERISON: Bump version up to 4.9.5...
https://git.samba.org/?p=samba.git;a=shortlog;h=v4-9-test
- Log -----------------------------------------------------------------
commit 41889196769973e879657df2bf36cce6ea86eeb8
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-9-test): Karolin Seeger <kseeger at samba.org>
Autobuild-Date(v4-9-test): Mon Jan 7 14:23:36 CET 2019 on sn-devel-144
commit b9a1a179e62b14e3831fbd12a50df0c52b8d372d
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 a5c8e943d34e0118ab0f98cb3ae77a8333e4fd92
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