1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00

s3:utils/smbget add error handling for mkdir() calls

Signed-off-by: Christian Ambach <ambi@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
This commit is contained in:
Christian Ambach 2018-10-22 16:28:21 +02:00 committed by Andreas Schneider
parent 525b19fafb
commit b89732c31b
2 changed files with 33 additions and 1 deletions

View File

@ -134,6 +134,27 @@ test_recursive_U()
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'
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_resume()
{
clear_download_area
@ -222,6 +243,9 @@ 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 "resume download" test_resume \
|| failed=`expr $failed + 1`

View File

@ -190,7 +190,15 @@ 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);