2016-07-21 16:34:50 +03:00
#!/bin/sh
# Blackbox tests for pkinit and pac verification
2022-01-25 21:35:06 +03:00
#
2016-07-21 16:34:50 +03:00
# Copyright (C) 2006-2008 Stefan Metzmacher
2022-01-25 21:35:06 +03:00
# Copyright (C) 2022 Andreas Schneider
2016-07-21 16:34:50 +03:00
2022-01-25 21:35:06 +03:00
if [ $# -lt 6 ] ; then
2022-03-18 13:04:19 +03:00
cat <<EOF
2022-01-25 21:35:06 +03:00
Usage: test_pkinit_pac.sh SERVER USERNAME PASSWORD REALM DOMAIN PREFIX
2016-07-21 16:34:50 +03:00
EOF
2022-03-18 13:04:19 +03:00
exit 1
2016-07-21 16:34:50 +03:00
fi
SERVER = $1
USERNAME = $2
PASSWORD = $3
REALM = $4
DOMAIN = $5
PREFIX = $6
2022-01-25 21:35:06 +03:00
shift 6
2016-07-21 16:34:50 +03:00
failed = 0
2022-01-25 21:35:06 +03:00
samba_bindir = " $BINDIR "
2016-07-21 16:34:50 +03:00
2022-01-25 21:35:06 +03:00
samba_kinit = " $( command -v kinit) "
if [ -x " ${ samba_bindir } /samba4kinit " ] ; then
samba_kinit = " ${ samba_bindir } /samba4kinit "
fi
samba_smbtorture = " ${ samba_bindir } /smbtorture --basedir= $SELFTEST_TMPDIR "
2016-07-21 16:34:50 +03:00
2022-01-25 21:35:06 +03:00
. " $( dirname " $0 " ) " /subunit.sh
. " $( dirname " $0 " ) " /common_test_fns.inc
2016-07-21 16:34:50 +03:00
KRB5CCNAME_PATH = " $PREFIX /tmpccache "
2022-01-25 21:35:06 +03:00
rm -f " ${ KRB5CCNAME_PATH } "
2016-07-21 16:34:50 +03:00
KRB5CCNAME = " FILE: $KRB5CCNAME_PATH "
export KRB5CCNAME
2022-01-25 21:35:06 +03:00
USER_PRINCIPAL_NAME = " $( echo " ${ USERNAME } @ ${ REALM } " | tr "[:upper:]" "[:lower:]" ) "
kbase = " $( basename " ${ samba_kinit } " ) "
if [ " ${ kbase } " = "samba4kinit" ] ; then
# HEIMDAL
X509_USER_IDENTITY = " --pk-user=FILE: ${ PREFIX } /pkinit/USER- ${ USER_PRINCIPAL_NAME } -cert.pem, ${ PREFIX } /pkinit/USER- ${ USER_PRINCIPAL_NAME } -private-key.pem "
OPTION_RENEWABLE = "--renewable"
else
X509_USER_IDENTITY = " -X X509_user_identity=FILE: ${ PREFIX } /pkinit/USER- ${ USER_PRINCIPAL_NAME } -cert.pem, ${ PREFIX } /pkinit/USER- ${ USER_PRINCIPAL_NAME } -private-key.pem "
OPTION_RENEWABLE = "-r 1h"
fi
OPTION_REQUEST_PAC = "--request-pac"
2016-07-21 16:34:50 +03:00
2022-01-25 21:35:06 +03:00
testit "STEP1 kinit with pkinit (name specified)" \
" ${ samba_kinit } " " ${ OPTION_REQUEST_PAC } " " ${ OPTION_RENEWABLE } " \
2022-04-22 16:46:05 +03:00
" ${ X509_USER_IDENTITY } " " ${ USERNAME } @ ${ REALM } " ||
2022-03-18 13:05:23 +03:00
failed = $(( failed + 1 ))
testit "STEP1 remote.pac verification" \
2022-01-25 21:35:06 +03:00
" ${ samba_smbtorture } " ncacn_np:" ${ SERVER } " rpc.pac \
--workgroup= " ${ DOMAIN } " -U" ${ USERNAME } % ${ PASSWORD } " \
--option= torture:pkinit_ccache= " ${ KRB5CCNAME } " ||
2022-03-18 13:05:23 +03:00
failed = $(( failed + 1 ))
2016-07-21 16:34:50 +03:00
2022-01-25 21:35:06 +03:00
rm -f " ${ KRB5CCNAME_PATH } "
exit ${ failed }