2016-04-25 17:12:47 +03:00
#!/bin/sh
# this runs a smbclient based authentication tests
2019-11-27 23:06:10 +03:00
if [ $# -lt 6 ] ; then
2022-04-22 16:34:11 +03:00
cat <<EOF
2023-04-05 10:21:24 +03:00
Usage: test_smbclient_ntlm.sh SERVER USERNAME PASSWORD MAPTOGUEST SMBCLIENT PROTOCOL CONFIGURATION <smbclient arguments>
2016-04-25 17:12:47 +03:00
EOF
2022-04-22 16:34:11 +03:00
exit 1
2016-04-25 17:12:47 +03:00
fi
SERVER = " $1 "
USERNAME = " $2 "
PASSWORD = " $3 "
MAPTOGUEST = " $4 "
SMBCLIENT = " $5 "
2019-11-27 23:06:10 +03:00
PROTOCOL = " $6 "
2016-04-25 17:12:47 +03:00
SMBCLIENT = " $VALGRIND ${ SMBCLIENT } "
2023-04-05 10:21:24 +03:00
CONFIGURATION = ${ 7 }
shift 7
2016-04-25 17:12:47 +03:00
ADDARGS = " $* "
2022-04-22 16:34:11 +03:00
incdir = $( dirname $0 ) /../../../testprogs/blackbox
2016-04-25 17:12:47 +03:00
. $incdir /subunit.sh
2019-11-27 23:06:10 +03:00
if [ $PROTOCOL != "SMB3" -a $PROTOCOL != "NT1" ] ; then
2022-04-22 16:34:11 +03:00
cat <<EOF
2019-11-27 23:06:10 +03:00
Uexpected protocol specified $PROTOCOL
EOF
2022-04-22 16:34:11 +03:00
exit 1
2019-11-27 23:06:10 +03:00
fi
2016-04-25 17:12:47 +03:00
2019-11-27 23:06:10 +03:00
if [ $PROTOCOL = "NT1" ] ; then
testit "smbclient username.password.NT1OLD" $SMBCLIENT //$SERVER /IPC\$ $CONFIGURATION -U$USERNAME %$PASSWORD -mNT1 --option= clientusespnego = no --option= clientntlmv2auth = no -c quit $ADDARGS
testit "smbclient username.password.NT1NEW" $SMBCLIENT //$SERVER /IPC\$ $CONFIGURATION -U$USERNAME %$PASSWORD -mNT1 -c quit $ADDARGS
fi
if [ $PROTOCOL = "SMB3" ] ; then
testit "smbclient username.password.SMB3" $SMBCLIENT //$SERVER /IPC\$ $CONFIGURATION -U$USERNAME %$PASSWORD -mSMB3 -c quit $ADDARGS
fi
if [ $PROTOCOL = "NT1" ] ; then
testit "smbclient anonymous.nopassword.NT1OLD" $SMBCLIENT //$SERVER /IPC\$ $CONFIGURATION -U% -mNT1 --option= clientusespnego = no --option= clientntlmv2auth = no -c quit $ADDARGS
testit "smbclient anonymous.nopassword.NT1NEW" $SMBCLIENT //$SERVER /IPC\$ $CONFIGURATION -U% -mNT1 -c quit $ADDARGS
fi
if [ $PROTOCOL = "SMB3" ] ; then
testit "smbclient anonymous.nopassword.SMB3" $SMBCLIENT //$SERVER /IPC\$ $CONFIGURATION -U% -mSMB3 -c quit $ADDARGS
fi
2022-04-22 16:34:11 +03:00
if test x" ${ MAPTOGUEST } " = x"never" ; then
2019-11-27 23:06:10 +03:00
if [ $PROTOCOL = "NT1" ] ; then
testit_expect_failure "smbclient anonymous.badpassword.NT1NEW.fail" $SMBCLIENT //$SERVER /IPC\$ $CONFIGURATION -U%badpassword -mNT1 -c quit $ADDARGS
fi
if [ $PROTOCOL = "SMB3" ] ; then
testit_expect_failure "smbclient anonymous.badpassword.SMB3.fail" $SMBCLIENT //$SERVER /IPC\$ $CONFIGURATION -U%badpassword -mSMB3 -c quit $ADDARGS
fi
2016-04-25 17:12:47 +03:00
else
2019-11-27 23:06:10 +03:00
if [ $PROTOCOL = "NT1" ] ; then
testit "smbclient anonymous.badpassword.NT1NEW.guest" $SMBCLIENT //$SERVER /IPC\$ $CONFIGURATION -U%badpassword -mNT1 -c quit $ADDARGS
fi
if [ $PROTOCOL = "SMB3" ] ; then
testit "smbclient anonymous.badpassword.SMB3.guest" $SMBCLIENT //$SERVER /IPC\$ $CONFIGURATION -U%badpassword -mSMB3 -c quit $ADDARGS
fi
2016-04-28 03:24:52 +03:00
2019-11-27 23:06:10 +03:00
if [ $PROTOCOL = "NT1" ] ; then
testit "smbclient baduser.badpassword.NT1NEW.guest" $SMBCLIENT //$SERVER /IPC\$ $CONFIGURATION -Ubaduser%badpassword -mNT1 -c quit $ADDARGS
fi
if [ $PROTOCOL = "SMB3" ] ; then
testit "smbclient baduser.badpassword.SMB3.guest" $SMBCLIENT //$SERVER /IPC\$ $CONFIGURATION -Ubaduser%badpassword -mSMB3 -c quit $ADDARGS
fi
if [ $PROTOCOL = "NT1" ] ; then
2020-08-18 17:58:19 +03:00
testit_expect_failure "smbclient baduser.badpassword.NT1OLD.signfail" $SMBCLIENT //$SERVER /IPC\$ $CONFIGURATION -Ubaduser%badpassword -mNT1 --option= clientusespnego = no --option= clientntlmv2auth = no --client-protection= sign -c quit $ADDARGS
testit_expect_failure "smbclient baduser.badpassword.NT1NEW.signfail" $SMBCLIENT //$SERVER /IPC\$ $CONFIGURATION -Ubaduser%badpassword -mNT1 --client-protection= sign -c quit $ADDARGS
2019-11-27 23:06:10 +03:00
fi
if [ $PROTOCOL = "SMB3" ] ; then
2020-08-18 17:58:19 +03:00
testit_expect_failure "smbclient baduser.badpassword.SMB3.signfail" $SMBCLIENT //$SERVER /IPC\$ $CONFIGURATION -Ubaduser%badpassword -mSMB3 --client-protection= sign -c quit $ADDARGS
2019-11-27 23:06:10 +03:00
fi
2016-04-25 17:12:47 +03:00
fi