diff options
author | Jeremy Allison <jra@samba.org> | 2014-08-27 13:15:29 -0700 |
---|---|---|
committer | David Disseldorp <ddiss@samba.org> | 2014-09-16 04:21:49 +0200 |
commit | df800ea6fb307abae785d3a5da60f4db70e9bc68 (patch) | |
tree | 37fc3a6ed0f9bf0e46e7f07dd169b429149a6909 | |
parent | 6d03aed15e1be4c126c2de4708d0b1cd112ba901 (diff) | |
download | samba-df800ea6fb307abae785d3a5da60f4db70e9bc68.tar.gz samba-df800ea6fb307abae785d3a5da60f4db70e9bc68.tar.xz samba-df800ea6fb307abae785d3a5da60f4db70e9bc68.zip |
Add test suite for iconv conversion fail of bad names over SMB1/SMB3.
Bug 10775 - smbd crashes when accessing garbage filenames
https://bugzilla.samba.org/show_bug.cgi?id=10775
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: David Disseldorp <ddiss@samba.org>
Autobuild-User(master): David Disseldorp <ddiss@samba.org>
Autobuild-Date(master): Tue Sep 16 04:21:49 CEST 2014 on sn-devel-104
-rwxr-xr-x | selftest/target/Samba3.pm | 37 | ||||
-rwxr-xr-x | source3/script/tests/test_smbclient_s3.sh | 144 |
2 files changed, 181 insertions, 0 deletions
diff --git a/selftest/target/Samba3.pm b/selftest/target/Samba3.pm index 554410580f..de40ced816 100755 --- a/selftest/target/Samba3.pm +++ b/selftest/target/Samba3.pm @@ -873,6 +873,9 @@ sub provision($$$$$$) my $msdfs_deeppath="$msdfs_shrdir/deeppath"; push(@dirs,$msdfs_deeppath); + my $badnames_shrdir="$shrdir/badnames"; + push(@dirs,$badnames_shrdir); + # this gets autocreated by winbindd my $wbsockdir="$prefix_abs/winbindd"; my $wbsockprivdir="$lockdir/winbindd_privileged"; @@ -925,6 +928,36 @@ sub provision($$$$$$) symlink "msdfs:$server_ip\\ro-tmp", "$msdfs_shrdir/msdfs-src1"; symlink "msdfs:$server_ipv6\\ro-tmp", "$msdfs_shrdir/deeppath/msdfs-src2"; + ## + ## create bad names in $badnames_shrdir + ## + ## (An invalid name, would be mangled to 8.3). + my $badname_target = "$badnames_shrdir/\340|\231\216\377\177"; + unless (open(BADNAME_TARGET, ">$badname_target")) { + warn("Unable to open $badname_target"); + return undef; + } + close(BADNAME_TARGET); + chmod 0666, $badname_target; + + ## (A bad name, would not be mangled to 8.3). + my $badname_target = "$badnames_shrdir/\240\276\346\327\377\177"; + unless (open(BADNAME_TARGET, ">$badname_target")) { + warn("Unable to open $badname_target"); + return undef; + } + close(BADNAME_TARGET); + chmod 0666, $badname_target; + + ## (A bad good name). + my $badname_target = "$badnames_shrdir/blank.txt"; + unless (open(BADNAME_TARGET, ">$badname_target")) { + warn("Unable to open $badname_target"); + return undef; + } + close(BADNAME_TARGET); + chmod 0666, $badname_target; + my $conffile="$libdir/server.conf"; my $nss_wrapper_pl = "$ENV{PERL} $self->{srcdir}/lib/nss_wrapper/nss_wrapper.pl"; @@ -1182,6 +1215,10 @@ sub provision($$$$$$) fruit:metadata = netatalk fruit:locking = netatalk fruit:encoding = native + +[badname-tmp] + path = $badnames_shrdir + guest ok = yes "; close(CONF); diff --git a/source3/script/tests/test_smbclient_s3.sh b/source3/script/tests/test_smbclient_s3.sh index 596cd425ff..67ac94a0d8 100755 --- a/source3/script/tests/test_smbclient_s3.sh +++ b/source3/script/tests/test_smbclient_s3.sh @@ -722,6 +722,146 @@ EOF fi } +# Test accessing an share with bad names (won't convert). +test_bad_names() +{ + cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/badname-tmp -I $SERVER_IP $ADDARGS -c ls 2>&1' + eval echo "$cmd" + out=`eval $cmd` + ret=$? + + if [ $ret != 0 ] ; then + echo "$out" + echo "failed accessing badname-tmp (SMB1) with error $ret" + false + return + fi + + echo "$out" | wc -l 2>&1 | grep 6 + ret=$? + if [ $ret != 0 ] ; then + echo "$out" + echo "failed listing \\badname-tmp - grep of number of lines (1) failed with $ret" + false + fi + + echo "$out" | grep 'Domain=.*OS=.*Server=' + ret=$? + if [ $ret != 0 ] ; then + echo "$out" + echo "failed listing \\badname-tmp - grep (1) failed with $ret" + false + fi + + echo "$out" | grep '^ \. *D' + ret=$? + if [ $ret != 0 ] ; then + echo "$out" + echo "failed listing \\badname-tmp - grep (2) failed with $ret" + false + fi + + echo "$out" | grep '^ \.\. *D' + ret=$? + if [ $ret != 0 ] ; then + echo "$out" + echo "failed listing \\badname-tmp - grep (3) failed with $ret" + false + fi + + echo "$out" | grep '^ blank.txt *N' + ret=$? + if [ $ret != 0 ] ; then + echo "$out" + echo "failed listing \\badname-tmp - grep (4) failed with $ret" + false + fi + + echo "$out" | grep '^ *$' + ret=$? + if [ $ret != 0 ] ; then + echo "$out" + echo "failed listing \\badname-tmp - grep (5) failed with $ret" + false + fi + + echo "$out" | grep 'blocks of size.*blocks available' + ret=$? + if [ $ret != 0 ] ; then + echo "$out" + echo "failed listing \\badname-tmp - grep (6) failed with $ret" + false + fi + + # Now check again with -mSMB3 + cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/badname-tmp -I $SERVER_IP -mSMB3 $ADDARGS -c ls 2>&1' + eval echo "$cmd" + out=`eval $cmd` + ret=$? + + if [ $ret != 0 ] ; then + echo "$out" + echo "failed accessing badname-tmp (SMB3) with error $ret" + false + return + fi + + echo "$out" | wc -l 2>&1 | grep 6 + ret=$? + if [ $ret != 0 ] ; then + echo "$out" + echo "failed listing \\badname-tmp - SMB3 grep of number of lines (1) failed with $ret" + false + fi + + echo "$out" | grep 'Domain=.*OS=.*Server=' + ret=$? + if [ $ret != 0 ] ; then + echo "$out" + echo "failed listing \\badname-tmp - SMB3 grep (1) failed with $ret" + false + fi + + echo "$out" | grep '^ \. *D' + ret=$? + if [ $ret != 0 ] ; then + echo "$out" + echo "failed listing \\badname-tmp - SMB3 grep (2) failed with $ret" + false + fi + + echo "$out" | grep '^ \.\. *D' + ret=$? + if [ $ret != 0 ] ; then + echo "$out" + echo "failed listing \\badname-tmp - SMB3 grep (3) failed with $ret" + false + fi + + echo "$out" | grep '^ blank.txt *N' + ret=$? + if [ $ret != 0 ] ; then + echo "$out" + echo "failed listing \\badname-tmp - SMB3 grep (4) failed with $ret" + false + fi + + echo "$out" | grep '^ *$' + ret=$? + if [ $ret != 0 ] ; then + echo "$out" + echo "failed listing \\badname-tmp - SMB3 grep (5) failed with $ret" + false + fi + + echo "$out" | grep 'blocks of size.*blocks available' + ret=$? + if [ $ret != 0 ] ; then + echo "$out" + echo "failed listing \\badname-tmp - SMB3 grep (6) failed with $ret" + false + fi +} LOGDIR_PREFIX=test_smbclient_s3 @@ -798,6 +938,10 @@ testit "list with backup privilege" \ test_backup_privilege_list || \ failed=`expr $failed + 1` +testit "list a share with bad names (won't convert)" \ + test_bad_names || \ + failed=`expr $failed + 1` + testit "rm -rf $LOGDIR" \ rm -rf $LOGDIR || \ failed=`expr $failed + 1` |