2020-03-13 18:15:52 +03:00
#!/bin/sh
#
2023-06-22 07:04:03 +03:00
# Blackbox tests for weak crypto
2020-03-13 18:15:52 +03:00
# Copyright (c) 2020 Andreas Schneider <asn@samba.org>
#
if [ $# -lt 7 ] ; then
2022-04-22 16:46:06 +03:00
cat <<EOF
2020-03-13 18:15:52 +03:00
Usage: $0 SERVER USERNAME PASSWORD REALM DOMAIN PREFIX
EOF
2022-04-22 16:46:06 +03:00
exit 1
2020-03-13 18:15:52 +03:00
fi
SERVER = $1
USERNAME = $2
PASSWORD = $3
REALM = $4
DOMAIN = $5
PREFIX = $6
CONFIGURATION = $7
shift 7
failed = 0
2022-04-22 16:46:06 +03:00
. $( dirname $0 ) /subunit.sh
2020-03-13 18:15:52 +03:00
samba_bindir = " $BINDIR "
samba_testparm = " $BINDIR /testparm "
samba_rpcclient = " $samba_bindir /rpcclient "
# remove the --configfile=
configuration = " ${ CONFIGURATION ##*= } "
test_weak_crypto_allowed( )
{
2022-04-22 16:46:06 +03:00
local testparm_stderr_output_path = " $PREFIX /testparm_stderr_output "
2020-03-13 18:15:52 +03:00
2022-04-22 16:46:06 +03:00
$samba_testparm --suppress-prompt $configuration 2>$testparm_stderr_output_path >/dev/null
2020-03-13 18:15:52 +03:00
2022-04-22 16:46:06 +03:00
grep "Weak crypto is allowed" $testparm_stderr_output_path >/dev/null 2>& 1
if [ $ret -ne 0 ] ; then
echo "Invalid crypto state:"
cat $testparm_stderr_output_path
rm -f $testparm_stderr_output_path
return 1
fi
2020-03-13 18:15:52 +03:00
2022-04-22 16:46:06 +03:00
rm -f $testparm_stderr_output_path
2020-03-13 18:15:52 +03:00
2022-04-22 16:46:06 +03:00
return 0
2020-03-13 18:15:52 +03:00
}
unset GNUTLS_FORCE_FIPS_MODE
# Checks that testparm reports: Weak crypto is disallowed
2022-04-22 16:46:06 +03:00
testit "testparm-weak-crypto" test_weak_crypto_allowed || failed = $( expr $failed + 1)
2020-03-13 18:15:52 +03:00
# We should not be allowed to use NTLM for connecting
2023-04-11 05:04:59 +03:00
testit_expect_failure "rpclient.ntlm" $samba_rpcclient ncacn_np:${ SERVER_IP } [ ntlm] -U$USERNAME %$PASSWORD -c "getusername" || failed = $( expr $failed + 1)
2020-03-13 18:15:52 +03:00
GNUTLS_FORCE_FIPS_MODE = 1
export GNUTLS_FORCE_FIPS_MODE
exit $failed