2016-09-06 09:55:43 +03:00
#!/bin/sh
# Blackbox tests for different password settings
#
# Copyright (c) 2006-2007 Jelmer Vernooij <jelmer@samba.org>
# Copyright (c) 2006-2008 Andrew Bartlett <abartlet@samba.org>
# Copyright (c) 2016 Andreas Schneider <asn@samba.org>
2023-03-13 16:32:50 +03:00
if [ $# -lt 7 ] ; then
2022-04-22 16:46:05 +03:00
cat <<EOF
2023-03-13 16:32:50 +03:00
Usage: test_passwords_settings.sh SERVER USERNAME PASSWORD REALM DOMAIN PREFIX CONFIGURATION
2016-09-06 09:55:43 +03:00
EOF
2022-04-22 16:46:05 +03:00
exit 1
2016-09-06 09:55:43 +03:00
fi
SERVER = $1
USERNAME = $2
PASSWORD = $3
REALM = $4
DOMAIN = $5
PREFIX = $6
2023-03-13 16:32:50 +03:00
CONFIGURATION = ${ 7 }
shift 7
2016-09-06 09:55:43 +03:00
failed = 0
samba_bindir = " $BINDIR "
smbclient = " $samba_bindir /smbclient "
samba_tool = " $samba_bindir /samba-tool "
smbpasswd = " $samba_bindir /smbpasswd "
texpect = " $samba_bindir /texpect "
newuser = " $samba_tool user create "
SMB_UNC = " // $SERVER /tmp "
2022-04-22 16:46:05 +03:00
. $( dirname $0 ) /subunit.sh
. $( dirname $0 ) /common_test_fns.inc
2016-09-06 09:55:43 +03:00
2022-12-22 10:36:26 +03:00
samba_kinit = $( system_or_builddir_binary kinit " ${ BINDIR } " samba4kinit)
2022-04-22 16:46:05 +03:00
do_kinit( )
{
2016-09-06 09:55:43 +03:00
principal = " $1 "
password = " $2 "
shift
shift
2022-06-13 16:58:34 +03:00
kerberos_kinit " $samba_kinit " " $principal " " $password " " $@ "
2016-09-06 09:55:43 +03:00
}
selftest: Woraround uid wrapper issues when using bash shell
UID_WRAPPER_ROOT=1 is not working properly when tests run in bash shell
instead of dash. After some debugging the reason may be dash spawns a
subshell to run commands, but bash calls execve instead. Traces attached
as reference:
/bin/sh -> dash:
[2(2)/2 at 17s, 1 errors] samba.blackbox.pdbtest(nt4_dc)(nt4_dc:local)
UWRAP_DEBUG(3145) - uwrap_init: Initialize uid_wrapper
UWRAP_DEBUG(3145) - uwrap_init_env: uwrap_init_env
UWRAP_DEBUG(3145) - uwrap_init: Enabled uid_wrapper as root (real uid=1000)
UWRAP_DEBUG(3145) - uwrap_init: Successfully initialized uid_wrapper
UWRAP_DEBUG(3144) - uwrap_init: Initialize uid_wrapper
UWRAP_DEBUG(3144) - uwrap_init_env: uwrap_init_env
UWRAP_DEBUG(3144) - uwrap_init: Enabled uid_wrapper as root (real uid=1000)
UWRAP_DEBUG(3144) - uwrap_init: Successfully initialized uid_wrapper
/bin/sh -> bash:
[2(2)/2 at 17s, 1 errors] samba.blackbox.pdbtest(nt4_dc)(nt4_dc:local)
UWRAP_DEBUG(3352) - uwrap_export_ids: uwrap_export_ids
UWRAP_DEBUG(3354) - uwrap_export_ids: uwrap_export_ids
UWRAP_DEBUG(3354) - uwrap_init: Initialize uid_wrapper
UWRAP_DEBUG(3354) - uwrap_init_env: uwrap_init_env
UWRAP_DEBUG(3354) - uwrap_init_env: Initialize ruid with 1000
UWRAP_DEBUG(3354) - uwrap_init_env: Initalize euid with 1000
UWRAP_DEBUG(3354) - uwrap_init_env: Initalize suid with 1000
UWRAP_DEBUG(3354) - uwrap_init_env: Initialize ruid with 1000
UWRAP_DEBUG(3354) - uwrap_init_env: Initalize egid with 1000
UWRAP_DEBUG(3354) - uwrap_init_env: Initalize sgid with 1000
UWRAP_DEBUG(3354) - uwrap_init_env: Initalize groups with 4,24,27,30,46,108,1000
UWRAP_DEBUG(3354) - uwrap_init: Enabled uid_wrapper as user (real uid=1000)
UWRAP_DEBUG(3354) - uwrap_init: Successfully initialized uid_wrapper
UWRAP_DEBUG(3353) - uwrap_export_ids: uwrap_export_ids
UWRAP_DEBUG(3353) - uwrap_init: Initialize uid_wrapper
UWRAP_DEBUG(3353) - uwrap_init_env: uwrap_init_env
UWRAP_DEBUG(3353) - uwrap_init_env: Initialize ruid with 1000
UWRAP_DEBUG(3353) - uwrap_init_env: Initalize euid with 1000
UWRAP_DEBUG(3353) - uwrap_init_env: Initalize suid with 1000
UWRAP_DEBUG(3353) - uwrap_init_env: Initialize ruid with 1000
UWRAP_DEBUG(3353) - uwrap_init_env: Initalize egid with 1000
UWRAP_DEBUG(3353) - uwrap_init_env: Initalize sgid with 1000
UWRAP_DEBUG(3353) - uwrap_init_env: Initalize groups with 4,24,27,30,46,108,1000
UWRAP_DEBUG(3353) - uwrap_init: Enabled uid_wrapper as user (real uid=1000)
UWRAP_DEBUG(3353) - uwrap_init: Successfully initialized uid_wrapper
Signed-off-by: Samuel Cabrero <scabrero@suse.de>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2019-03-14 12:20:52 +03:00
test_smbpasswd( )
{
user = $1
newpass = $2
2023-03-13 16:32:50 +03:00
_config = " $( echo " ${ CONFIGURATION } " | cut -d '=' -f 2) "
selftest: Woraround uid wrapper issues when using bash shell
UID_WRAPPER_ROOT=1 is not working properly when tests run in bash shell
instead of dash. After some debugging the reason may be dash spawns a
subshell to run commands, but bash calls execve instead. Traces attached
as reference:
/bin/sh -> dash:
[2(2)/2 at 17s, 1 errors] samba.blackbox.pdbtest(nt4_dc)(nt4_dc:local)
UWRAP_DEBUG(3145) - uwrap_init: Initialize uid_wrapper
UWRAP_DEBUG(3145) - uwrap_init_env: uwrap_init_env
UWRAP_DEBUG(3145) - uwrap_init: Enabled uid_wrapper as root (real uid=1000)
UWRAP_DEBUG(3145) - uwrap_init: Successfully initialized uid_wrapper
UWRAP_DEBUG(3144) - uwrap_init: Initialize uid_wrapper
UWRAP_DEBUG(3144) - uwrap_init_env: uwrap_init_env
UWRAP_DEBUG(3144) - uwrap_init: Enabled uid_wrapper as root (real uid=1000)
UWRAP_DEBUG(3144) - uwrap_init: Successfully initialized uid_wrapper
/bin/sh -> bash:
[2(2)/2 at 17s, 1 errors] samba.blackbox.pdbtest(nt4_dc)(nt4_dc:local)
UWRAP_DEBUG(3352) - uwrap_export_ids: uwrap_export_ids
UWRAP_DEBUG(3354) - uwrap_export_ids: uwrap_export_ids
UWRAP_DEBUG(3354) - uwrap_init: Initialize uid_wrapper
UWRAP_DEBUG(3354) - uwrap_init_env: uwrap_init_env
UWRAP_DEBUG(3354) - uwrap_init_env: Initialize ruid with 1000
UWRAP_DEBUG(3354) - uwrap_init_env: Initalize euid with 1000
UWRAP_DEBUG(3354) - uwrap_init_env: Initalize suid with 1000
UWRAP_DEBUG(3354) - uwrap_init_env: Initialize ruid with 1000
UWRAP_DEBUG(3354) - uwrap_init_env: Initalize egid with 1000
UWRAP_DEBUG(3354) - uwrap_init_env: Initalize sgid with 1000
UWRAP_DEBUG(3354) - uwrap_init_env: Initalize groups with 4,24,27,30,46,108,1000
UWRAP_DEBUG(3354) - uwrap_init: Enabled uid_wrapper as user (real uid=1000)
UWRAP_DEBUG(3354) - uwrap_init: Successfully initialized uid_wrapper
UWRAP_DEBUG(3353) - uwrap_export_ids: uwrap_export_ids
UWRAP_DEBUG(3353) - uwrap_init: Initialize uid_wrapper
UWRAP_DEBUG(3353) - uwrap_init_env: uwrap_init_env
UWRAP_DEBUG(3353) - uwrap_init_env: Initialize ruid with 1000
UWRAP_DEBUG(3353) - uwrap_init_env: Initalize euid with 1000
UWRAP_DEBUG(3353) - uwrap_init_env: Initalize suid with 1000
UWRAP_DEBUG(3353) - uwrap_init_env: Initialize ruid with 1000
UWRAP_DEBUG(3353) - uwrap_init_env: Initalize egid with 1000
UWRAP_DEBUG(3353) - uwrap_init_env: Initalize sgid with 1000
UWRAP_DEBUG(3353) - uwrap_init_env: Initalize groups with 4,24,27,30,46,108,1000
UWRAP_DEBUG(3353) - uwrap_init: Enabled uid_wrapper as user (real uid=1000)
UWRAP_DEBUG(3353) - uwrap_init: Successfully initialized uid_wrapper
Signed-off-by: Samuel Cabrero <scabrero@suse.de>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2019-03-14 12:20:52 +03:00
tmpfile = $PREFIX /smbpasswd_change_password_script
2022-04-22 16:46:05 +03:00
cat >$tmpfile <<EOF
selftest: Woraround uid wrapper issues when using bash shell
UID_WRAPPER_ROOT=1 is not working properly when tests run in bash shell
instead of dash. After some debugging the reason may be dash spawns a
subshell to run commands, but bash calls execve instead. Traces attached
as reference:
/bin/sh -> dash:
[2(2)/2 at 17s, 1 errors] samba.blackbox.pdbtest(nt4_dc)(nt4_dc:local)
UWRAP_DEBUG(3145) - uwrap_init: Initialize uid_wrapper
UWRAP_DEBUG(3145) - uwrap_init_env: uwrap_init_env
UWRAP_DEBUG(3145) - uwrap_init: Enabled uid_wrapper as root (real uid=1000)
UWRAP_DEBUG(3145) - uwrap_init: Successfully initialized uid_wrapper
UWRAP_DEBUG(3144) - uwrap_init: Initialize uid_wrapper
UWRAP_DEBUG(3144) - uwrap_init_env: uwrap_init_env
UWRAP_DEBUG(3144) - uwrap_init: Enabled uid_wrapper as root (real uid=1000)
UWRAP_DEBUG(3144) - uwrap_init: Successfully initialized uid_wrapper
/bin/sh -> bash:
[2(2)/2 at 17s, 1 errors] samba.blackbox.pdbtest(nt4_dc)(nt4_dc:local)
UWRAP_DEBUG(3352) - uwrap_export_ids: uwrap_export_ids
UWRAP_DEBUG(3354) - uwrap_export_ids: uwrap_export_ids
UWRAP_DEBUG(3354) - uwrap_init: Initialize uid_wrapper
UWRAP_DEBUG(3354) - uwrap_init_env: uwrap_init_env
UWRAP_DEBUG(3354) - uwrap_init_env: Initialize ruid with 1000
UWRAP_DEBUG(3354) - uwrap_init_env: Initalize euid with 1000
UWRAP_DEBUG(3354) - uwrap_init_env: Initalize suid with 1000
UWRAP_DEBUG(3354) - uwrap_init_env: Initialize ruid with 1000
UWRAP_DEBUG(3354) - uwrap_init_env: Initalize egid with 1000
UWRAP_DEBUG(3354) - uwrap_init_env: Initalize sgid with 1000
UWRAP_DEBUG(3354) - uwrap_init_env: Initalize groups with 4,24,27,30,46,108,1000
UWRAP_DEBUG(3354) - uwrap_init: Enabled uid_wrapper as user (real uid=1000)
UWRAP_DEBUG(3354) - uwrap_init: Successfully initialized uid_wrapper
UWRAP_DEBUG(3353) - uwrap_export_ids: uwrap_export_ids
UWRAP_DEBUG(3353) - uwrap_init: Initialize uid_wrapper
UWRAP_DEBUG(3353) - uwrap_init_env: uwrap_init_env
UWRAP_DEBUG(3353) - uwrap_init_env: Initialize ruid with 1000
UWRAP_DEBUG(3353) - uwrap_init_env: Initalize euid with 1000
UWRAP_DEBUG(3353) - uwrap_init_env: Initalize suid with 1000
UWRAP_DEBUG(3353) - uwrap_init_env: Initialize ruid with 1000
UWRAP_DEBUG(3353) - uwrap_init_env: Initalize egid with 1000
UWRAP_DEBUG(3353) - uwrap_init_env: Initalize sgid with 1000
UWRAP_DEBUG(3353) - uwrap_init_env: Initalize groups with 4,24,27,30,46,108,1000
UWRAP_DEBUG(3353) - uwrap_init: Enabled uid_wrapper as user (real uid=1000)
UWRAP_DEBUG(3353) - uwrap_init: Successfully initialized uid_wrapper
Signed-off-by: Samuel Cabrero <scabrero@suse.de>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2019-03-14 12:20:52 +03:00
expect New SMB password:
send ${ newpass } \n
expect Retype new SMB password:
send ${ newpass } \n
EOF
2023-03-13 16:32:50 +03:00
cmd = 'UID_WRAPPER_INITIAL_RUID=0 UID_WRAPPER_INITIAL_EUID=0 $texpect $tmpfile $smbpasswd -L -c ${_config} $user'
selftest: Woraround uid wrapper issues when using bash shell
UID_WRAPPER_ROOT=1 is not working properly when tests run in bash shell
instead of dash. After some debugging the reason may be dash spawns a
subshell to run commands, but bash calls execve instead. Traces attached
as reference:
/bin/sh -> dash:
[2(2)/2 at 17s, 1 errors] samba.blackbox.pdbtest(nt4_dc)(nt4_dc:local)
UWRAP_DEBUG(3145) - uwrap_init: Initialize uid_wrapper
UWRAP_DEBUG(3145) - uwrap_init_env: uwrap_init_env
UWRAP_DEBUG(3145) - uwrap_init: Enabled uid_wrapper as root (real uid=1000)
UWRAP_DEBUG(3145) - uwrap_init: Successfully initialized uid_wrapper
UWRAP_DEBUG(3144) - uwrap_init: Initialize uid_wrapper
UWRAP_DEBUG(3144) - uwrap_init_env: uwrap_init_env
UWRAP_DEBUG(3144) - uwrap_init: Enabled uid_wrapper as root (real uid=1000)
UWRAP_DEBUG(3144) - uwrap_init: Successfully initialized uid_wrapper
/bin/sh -> bash:
[2(2)/2 at 17s, 1 errors] samba.blackbox.pdbtest(nt4_dc)(nt4_dc:local)
UWRAP_DEBUG(3352) - uwrap_export_ids: uwrap_export_ids
UWRAP_DEBUG(3354) - uwrap_export_ids: uwrap_export_ids
UWRAP_DEBUG(3354) - uwrap_init: Initialize uid_wrapper
UWRAP_DEBUG(3354) - uwrap_init_env: uwrap_init_env
UWRAP_DEBUG(3354) - uwrap_init_env: Initialize ruid with 1000
UWRAP_DEBUG(3354) - uwrap_init_env: Initalize euid with 1000
UWRAP_DEBUG(3354) - uwrap_init_env: Initalize suid with 1000
UWRAP_DEBUG(3354) - uwrap_init_env: Initialize ruid with 1000
UWRAP_DEBUG(3354) - uwrap_init_env: Initalize egid with 1000
UWRAP_DEBUG(3354) - uwrap_init_env: Initalize sgid with 1000
UWRAP_DEBUG(3354) - uwrap_init_env: Initalize groups with 4,24,27,30,46,108,1000
UWRAP_DEBUG(3354) - uwrap_init: Enabled uid_wrapper as user (real uid=1000)
UWRAP_DEBUG(3354) - uwrap_init: Successfully initialized uid_wrapper
UWRAP_DEBUG(3353) - uwrap_export_ids: uwrap_export_ids
UWRAP_DEBUG(3353) - uwrap_init: Initialize uid_wrapper
UWRAP_DEBUG(3353) - uwrap_init_env: uwrap_init_env
UWRAP_DEBUG(3353) - uwrap_init_env: Initialize ruid with 1000
UWRAP_DEBUG(3353) - uwrap_init_env: Initalize euid with 1000
UWRAP_DEBUG(3353) - uwrap_init_env: Initalize suid with 1000
UWRAP_DEBUG(3353) - uwrap_init_env: Initialize ruid with 1000
UWRAP_DEBUG(3353) - uwrap_init_env: Initalize egid with 1000
UWRAP_DEBUG(3353) - uwrap_init_env: Initalize sgid with 1000
UWRAP_DEBUG(3353) - uwrap_init_env: Initalize groups with 4,24,27,30,46,108,1000
UWRAP_DEBUG(3353) - uwrap_init: Enabled uid_wrapper as user (real uid=1000)
UWRAP_DEBUG(3353) - uwrap_init: Successfully initialized uid_wrapper
Signed-off-by: Samuel Cabrero <scabrero@suse.de>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2019-03-14 12:20:52 +03:00
eval echo " $cmd "
out = $( eval $cmd )
ret = $?
rm -f $tmpfile
if [ $ret -ne 0 ] ; then
echo " Failed to change user password $user "
return 1
fi
}
2016-09-06 09:55:43 +03:00
testit "reset password policies beside of minimum password age of 0 days" \
2023-03-13 16:32:50 +03:00
$VALGRIND $PYTHON $samba_tool domain passwordsettings set \
" ${ CONFIGURATION } " --complexity= default --history-length= default --min-pwd-length= default --min-pwd-age= 0 --max-pwd-age= default || failed = $( expr $failed + 1)
2016-09-06 09:55:43 +03:00
TEST_USERNAME = " $( mktemp -u alice-XXXXXX) "
TEST_PASSWORD = "testPaSS@00%"
TEST_PASSWORD_NEW = "testPaSS@01%"
2018-05-15 20:27:23 +03:00
TEST_PASSWORD_NON_ASCII = "Täst123"
2016-09-06 09:55:43 +03:00
TEST_PASSWORD_SHORT = "secret"
TEST_PASSWORD_WEAK = "Supersecret"
TEST_PRINCIPAL = " $TEST_USERNAME @ $REALM "
testit "create user locally" \
2023-03-13 16:32:50 +03:00
$VALGRIND $PYTHON $newuser $TEST_USERNAME $TEST_PASSWORD \
" ${ CONFIGURATION } " || failed = $( expr $failed + 1)
2016-09-06 09:55:43 +03:00
###########################################################
### Test normal operation as user
###########################################################
2016-09-20 10:46:34 +03:00
KRB5CCNAME_PATH = " $PREFIX /test_password_settings_krb5ccache "
rm -f $KRB5CCNAME_PATH
KRB5CCNAME = " FILE: $KRB5CCNAME_PATH "
2016-09-06 09:55:43 +03:00
export KRB5CCNAME
testit "kinit with user password" \
2022-04-22 16:46:05 +03:00
do_kinit $TEST_PRINCIPAL $TEST_PASSWORD || failed = $( expr $failed + 1)
2016-09-06 09:55:43 +03:00
test_smbclient "Test login with user kerberos ccache" \
2022-04-22 16:46:05 +03:00
"ls" " $SMB_UNC " --use-krb5-ccache= $KRB5CCNAME || failed = $( expr $failed + 1)
2016-09-06 09:55:43 +03:00
2016-09-20 10:46:34 +03:00
rm -f $KRB5CCNAME_PATH
2016-09-06 09:55:43 +03:00
###########################################################
### Change the users password
###########################################################
testit "change user password with 'samba-tool user password' (unforced)" \
2023-03-13 16:32:50 +03:00
$VALGRIND $PYTHON $samba_tool user password " ${ CONFIGURATION } " -W$DOMAIN -U$TEST_USERNAME %$TEST_PASSWORD -k no --newpassword= $TEST_PASSWORD_NEW || failed = $( expr $failed + 1)
2016-09-06 09:55:43 +03:00
TEST_PASSWORD_OLD = $TEST_PASSWORD
TEST_PASSWORD = $TEST_PASSWORD_NEW
TEST_PASSWORD_NEW = "testPaSS@02%"
2018-05-15 20:27:23 +03:00
testit "kinit with user password" \
2022-04-22 16:46:05 +03:00
do_kinit $TEST_PRINCIPAL $TEST_PASSWORD || failed = $( expr $failed + 1)
2018-05-15 20:27:23 +03:00
test_smbclient "Test login with user kerberos ccache" \
2022-04-22 16:46:05 +03:00
"ls" " $SMB_UNC " --use-krb5-ccache= $KRB5CCNAME || failed = $( expr $failed + 1)
2018-05-15 20:27:23 +03:00
###########################################################
### Change the users password
###########################################################
testit "change user (non-ascii) password with 'samba-tool user password' (unforced)" \
2023-03-13 16:32:50 +03:00
$VALGRIND $PYTHON $samba_tool user password " ${ CONFIGURATION } " -W$DOMAIN -U$TEST_USERNAME %$TEST_PASSWORD -k no --newpassword= $TEST_PASSWORD_NON_ASCII || failed = $( expr $failed + 1)
2018-05-15 20:27:23 +03:00
TEST_PASSWORD_OLD = $TEST_PASSWORD_NEW
TEST_PASSWORD = $TEST_PASSWORD_NON_ASCII
2016-09-06 09:55:43 +03:00
testit "kinit with user password" \
2022-04-22 16:46:05 +03:00
do_kinit $TEST_PRINCIPAL $TEST_PASSWORD || failed = $( expr $failed + 1)
2016-09-06 09:55:43 +03:00
test_smbclient "Test login with user kerberos ccache" \
2022-04-22 16:46:05 +03:00
"ls" " $SMB_UNC " --use-krb5-ccache= $KRB5CCNAME || failed = $( expr $failed + 1)
2016-09-06 09:55:43 +03:00
#
# These tests demonstrate that a credential cache in the environment does not
# override a username/password, even an incorrect one, on the command line
#
testit_expect_failure "Test login with user kerberos ccache, but wrong password specified" \
2023-04-11 05:04:59 +03:00
$VALGRIND $smbclient //$SERVER /tmp -c 'ls' --use-krb5-ccache= $KRB5CCNAME -U$TEST_PRINCIPAL %invalidpass || failed = $( expr $failed + 1)
2016-09-06 09:55:43 +03:00
testit_expect_failure "Test login with user kerberos ccache, but old password specified" \
2023-04-11 05:04:59 +03:00
$VALGRIND $smbclient //$SERVER /tmp -c 'ls' --use-krb5-ccache= $KRB5CCNAME -U$TEST_PRINCIPAL %$TEST_PASSWORD_OLD || failed = $( expr $failed + 1)
2016-09-06 09:55:43 +03:00
2016-09-20 10:46:34 +03:00
rm -f $KRB5CCNAME_PATH
2016-09-06 09:55:43 +03:00
###########################################################
### Set the password with smbpasswd
###########################################################
testit "set user password with smbpasswd" \
2022-04-22 16:46:05 +03:00
test_smbpasswd $TEST_USERNAME $TEST_PASSWORD_NEW ||
failed = $( expr $failed + 1)
2016-09-06 09:55:43 +03:00
TEST_PASSWORD = $TEST_PASSWORD_NEW
TEST_PASSWORD_NEW = "testPaSS@03%"
test_smbclient "Test login with user (ntlm)" \
2022-04-22 16:46:05 +03:00
"ls" " $SMB_UNC " --use-kerberos= disabled -U$TEST_PRINCIPAL %$TEST_PASSWORD || failed = $( expr $failed + 1)
2016-09-06 09:55:43 +03:00
2023-03-13 16:32:50 +03:00
testit "set password on user locally" $VALGRIND $PYTHON $samba_tool user setpassword $TEST_USERNAME " ${ CONFIGURATION } " --newpassword= $TEST_PASSWORD_NEW --must-change-at-next-login || failed = $( expr $failed + 1)
2016-09-06 09:55:43 +03:00
TEST_PASSWORD = $TEST_PASSWORD_NEW
TEST_PASSWORD_NEW = "testPaSS@04%"
test_smbclient_expect_failure "Test login with user (NT_STATUS_PASSWORD_MUST_CHANGE)" \
2023-04-11 05:23:00 +03:00
"ls" " $SMB_UNC " --use-kerberos= disabled -U$TEST_PRINCIPAL %$TEST_PASSWORD || failed = $( expr $failed + 1)
2016-09-06 09:55:43 +03:00
testit "change user password with 'samba-tool user password' (after must change flag set)" \
2023-03-13 16:32:50 +03:00
$VALGRIND $PYTHON $samba_tool user password " ${ CONFIGURATION } " -W$DOMAIN -U$DOMAIN /$TEST_USERNAME %$TEST_PASSWORD -k no --newpassword= $TEST_PASSWORD_NEW || failed = $( expr $failed + 1)
2016-09-06 09:55:43 +03:00
TEST_PASSWORD = $TEST_PASSWORD_NEW
TEST_PASSWORD_NEW = "testPaSS@05%"
2022-04-22 16:46:05 +03:00
test_smbclient "Test login with user kerberos" 'ls' " $SMB_UNC " --use-kerberos= required -U$TEST_PRINCIPAL %$TEST_PASSWORD || failed = $( expr $failed + 1)
2016-09-06 09:55:43 +03:00
2016-09-20 10:46:34 +03:00
rm -f $KRB5CCNAME_PATH
2022-04-22 16:46:05 +03:00
cat >$PREFIX /tmpsmbpasswdscript <<EOF
2016-09-06 09:55:43 +03:00
expect Old SMB password:
password ${ TEST_PASSWORD } \n
expect New SMB password:
send ${ TEST_PASSWORD_NEW } \n
expect Retype new SMB password:
send ${ TEST_PASSWORD_NEW } \n
EOF
2023-03-13 16:32:50 +03:00
config = " $( echo " ${ CONFIGURATION } " | cut -d '=' -f 2) "
2016-09-06 09:55:43 +03:00
testit "change user password with smbpasswd (after must change flag set)" \
2023-03-13 16:32:50 +03:00
$texpect $PREFIX /tmpsmbpasswdscript $smbpasswd -r $SERVER -c ${ config } -U $TEST_USERNAME || failed = $( expr $failed + 1)
2016-09-06 09:55:43 +03:00
TEST_PASSWORD = $TEST_PASSWORD_NEW
TEST_PASSWORD_NEW = "testPaSS@06%"
test_smbclient "Test login with user kerberos" \
2022-04-22 16:46:05 +03:00
"ls" " $SMB_UNC " --use-kerberos= required -U$TEST_PRINCIPAL %$TEST_PASSWORD || failed = $( expr $failed + 1)
2016-09-06 09:55:43 +03:00
2016-09-20 10:46:34 +03:00
rm -f $KRB5CCNAME_PATH
2016-09-06 09:55:43 +03:00
testit_expect_failure "try to set a non-complex password (command should not succeed)" \
2023-04-11 05:04:59 +03:00
$VALGRIND $PYTHON $samba_tool user password " ${ CONFIGURATION } " -W$DOMAIN " -U $DOMAIN / $TEST_USERNAME % $TEST_PASSWORD " -k no --newpassword= " $TEST_PASSWORD_WEAK " || failed = $( expr $failed + 1)
2016-09-06 09:55:43 +03:00
testit "allow non-complex passwords" \
2023-03-13 16:32:50 +03:00
$VALGRIND $PYTHON $samba_tool domain passwordsettings set " ${ CONFIGURATION } " --complexity= off || failed = $( expr $failed + 1)
2016-09-06 09:55:43 +03:00
testit "try to set a non-complex password (command should succeed)" \
2023-03-13 16:32:50 +03:00
$VALGRIND $PYTHON $samba_tool user password " ${ CONFIGURATION } " -W$DOMAIN " -U $DOMAIN / $TEST_USERNAME % $TEST_PASSWORD " -k no --newpassword= " $TEST_PASSWORD_WEAK " || failed = $( expr $failed + 1)
2016-09-06 09:55:43 +03:00
TEST_PASSWORD = $TEST_PASSWORD_WEAK
test_smbclient "test login with non-complex password" \
2022-04-22 16:46:05 +03:00
"ls" " $SMB_UNC " --use-kerberos= disabled -U$TEST_PRINCIPAL %$TEST_PASSWORD || failed = $( expr $failed + 1)
2016-09-06 09:55:43 +03:00
testit_expect_failure "try to set a short password (command should not succeed)" \
2023-04-11 05:04:59 +03:00
$VALGRIND $PYTHON $samba_tool user password " ${ CONFIGURATION } " -W$DOMAIN " -U $DOMAIN / $TEST_USERNAME % $TEST_PASSWORD " -k no --newpassword= " $TEST_PASSWORD_SHORT " || failed = $( expr $failed + 1)
2016-09-06 09:55:43 +03:00
testit "allow short passwords (length 1)" \
2023-03-13 16:32:50 +03:00
$VALGRIND $PYTHON $samba_tool domain passwordsettings set " ${ CONFIGURATION } " --min-pwd-length= 1 || failed = $( expr $failed + 1)
2016-09-06 09:55:43 +03:00
testit "try to set a short password (command should succeed)" \
2023-03-13 16:32:50 +03:00
$VALGRIND $PYTHON $samba_tool user password " ${ CONFIGURATION } " -W$DOMAIN " -U $DOMAIN / $TEST_USERNAME % $TEST_PASSWORD " -k no --newpassword= " $TEST_PASSWORD_SHORT " || failed = $( expr $failed + 1)
2016-09-06 09:55:43 +03:00
TEST_PASSWORD = $TEST_PASSWORD_SHORT
TEST_PASSWORD_NEW = "testPaSS@07%"
testit "require minimum password age of 1 day" \
2023-03-13 16:32:50 +03:00
$VALGRIND $PYTHON $samba_tool domain passwordsettings set " ${ CONFIGURATION } " --min-pwd-age= 1 || failed = $( expr $failed + 1)
2016-09-06 09:55:43 +03:00
testit "show password settings" \
2023-03-13 16:32:50 +03:00
$VALGRIND $PYTHON $samba_tool domain passwordsettings show " ${ CONFIGURATION } " || failed = $( expr $failed + 1)
2016-09-06 09:55:43 +03:00
testit_expect_failure "try to change password too quickly (command should not succeed)" \
2023-04-11 05:04:59 +03:00
$VALGRIND $PYTHON $samba_tool user password " ${ CONFIGURATION } " -W$DOMAIN " -U $DOMAIN / $TEST_USERNAME % $TEST_PASSWORD " -k no --newpassword= " $TEST_PASSWORD_NEW " || failed = $( expr $failed + 1)
2016-09-06 09:55:43 +03:00
testit "reset password policies" \
2023-03-13 16:32:50 +03:00
$VALGRIND $PYTHON $samba_tool domain passwordsettings set " ${ CONFIGURATION } " --complexity= default --history-length= default --min-pwd-length= default --min-pwd-age= default --max-pwd-age= default || failed = $( expr $failed + 1)
2016-09-06 09:55:43 +03:00
testit " delete user $TEST_USERNAME " \
2023-03-13 16:32:50 +03:00
$VALGRIND $PYTHON $samba_tool user delete $TEST_USERNAME -U" $USERNAME % $PASSWORD " " ${ CONFIGURATION } " -k no || failed = $( expr $failed + 1)
2016-09-06 09:55:43 +03:00
2016-09-20 10:46:34 +03:00
rm -f $PREFIX /tmpuserpassfile $PREFIX /tmpsmbpasswdscript
rm -f $KRB5CCNAME_PATH
2016-09-06 09:55:43 +03:00
exit $failed