|
|
e4ff3b |
From 8e3e85e329f5cbd989936b0df8a0ac06906a4824 Mon Sep 17 00:00:00 2001
|
|
|
e4ff3b |
From: Isaac Boukris <iboukris@gmail.com>
|
|
|
e4ff3b |
Date: Tue, 14 Apr 2020 16:19:05 +0300
|
|
|
e4ff3b |
Subject: [PATCH] auth: add SASL/GSSAPI tests
|
|
|
e4ff3b |
|
|
|
e4ff3b |
---
|
|
|
e4ff3b |
tests/data/krb5.conf | 32 ++++++
|
|
|
e4ff3b |
tests/data/slapd-sasl-gssapi.conf | 65 ++++++++++++
|
|
|
e4ff3b |
tests/scripts/conf.sh | 3 +
|
|
|
e4ff3b |
tests/scripts/defines.sh | 5 +
|
|
|
e4ff3b |
tests/scripts/setup_kdc.sh | 144 +++++++++++++++++++++++++++
|
|
|
e4ff3b |
tests/scripts/test077-sasl-gssapi | 159 ++++++++++++++++++++++++++++++
|
|
|
e4ff3b |
6 files changed, 408 insertions(+)
|
|
|
e4ff3b |
create mode 100644 tests/data/krb5.conf
|
|
|
e4ff3b |
create mode 100644 tests/data/slapd-sasl-gssapi.conf
|
|
|
e4ff3b |
create mode 100755 tests/scripts/setup_kdc.sh
|
|
|
e4ff3b |
create mode 100755 tests/scripts/test077-sasl-gssapi
|
|
|
e4ff3b |
|
|
|
e4ff3b |
diff --git a/tests/data/krb5.conf b/tests/data/krb5.conf
|
|
|
e4ff3b |
new file mode 100644
|
|
|
e4ff3b |
index 000000000..739113742
|
|
|
e4ff3b |
--- /dev/null
|
|
|
e4ff3b |
+++ b/tests/data/krb5.conf
|
|
|
e4ff3b |
@@ -0,0 +1,32 @@
|
|
|
e4ff3b |
+[libdefaults]
|
|
|
e4ff3b |
+ default_realm = @KRB5REALM@
|
|
|
e4ff3b |
+ dns_lookup_realm = false
|
|
|
e4ff3b |
+ dns_lookup_kdc = false
|
|
|
e4ff3b |
+ default_ccache_name = FILE://@TESTDIR@/ccache
|
|
|
e4ff3b |
+ #udp_preference_limit = 1
|
|
|
e4ff3b |
+[realms]
|
|
|
e4ff3b |
+ @KRB5REALM@ = {
|
|
|
e4ff3b |
+ kdc = @KDCHOST@:@KDCPORT@
|
|
|
e4ff3b |
+ acl_file = @TESTDIR@/kadm.acl
|
|
|
e4ff3b |
+ database_name = @TESTDIR@/kdc.db
|
|
|
e4ff3b |
+ key_stash_file = @TESTDIR@/kdc.stash
|
|
|
e4ff3b |
+ }
|
|
|
e4ff3b |
+[kdcdefaults]
|
|
|
e4ff3b |
+ kdc_ports = @KDCPORT@
|
|
|
e4ff3b |
+ kdc_tcp_ports = @KDCPORT@
|
|
|
e4ff3b |
+[logging]
|
|
|
e4ff3b |
+ kdc = FILE:@TESTDIR@/kdc.log
|
|
|
e4ff3b |
+ admin_server = FILE:@TESTDIR@/kadm.log
|
|
|
e4ff3b |
+ default = FILE:@TESTDIR@/krb5.log
|
|
|
e4ff3b |
+
|
|
|
e4ff3b |
+#Heimdal
|
|
|
e4ff3b |
+[kdc]
|
|
|
e4ff3b |
+ database = {
|
|
|
e4ff3b |
+ dbname = @TESTDIR@/kdc.db
|
|
|
e4ff3b |
+ realm = @KRB5REALM@
|
|
|
e4ff3b |
+ mkey_file = @TESTDIR@/kdc.stash
|
|
|
e4ff3b |
+ log_file = @TESTDIR@/kdc.log
|
|
|
e4ff3b |
+ acl_file = @TESTDIR@/kadm.acl
|
|
|
e4ff3b |
+ }
|
|
|
e4ff3b |
+[hdb]
|
|
|
e4ff3b |
+ db-dir = @TESTDIR@
|
|
|
e4ff3b |
diff --git a/tests/data/slapd-sasl-gssapi.conf b/tests/data/slapd-sasl-gssapi.conf
|
|
|
e4ff3b |
new file mode 100644
|
|
|
e4ff3b |
index 000000000..611fc7097
|
|
|
e4ff3b |
--- /dev/null
|
|
|
e4ff3b |
+++ b/tests/data/slapd-sasl-gssapi.conf
|
|
|
e4ff3b |
@@ -0,0 +1,65 @@
|
|
|
e4ff3b |
+# stand-alone slapd config -- for testing (with indexing)
|
|
|
e4ff3b |
+# $OpenLDAP$
|
|
|
e4ff3b |
+## This work is part of OpenLDAP Software <http://www.openldap.org/>.
|
|
|
e4ff3b |
+##
|
|
|
e4ff3b |
+## Copyright 1998-2020 The OpenLDAP Foundation.
|
|
|
e4ff3b |
+## All rights reserved.
|
|
|
e4ff3b |
+##
|
|
|
e4ff3b |
+## Redistribution and use in source and binary forms, with or without
|
|
|
e4ff3b |
+## modification, are permitted only as authorized by the OpenLDAP
|
|
|
e4ff3b |
+## Public License.
|
|
|
e4ff3b |
+##
|
|
|
e4ff3b |
+## A copy of this license is available in the file LICENSE in the
|
|
|
e4ff3b |
+## top-level directory of the distribution or, alternatively, at
|
|
|
e4ff3b |
+## <http://www.OpenLDAP.org/license.html>.
|
|
|
e4ff3b |
+
|
|
|
e4ff3b |
+#
|
|
|
e4ff3b |
+include @SCHEMADIR@/core.schema
|
|
|
e4ff3b |
+include @SCHEMADIR@/cosine.schema
|
|
|
e4ff3b |
+#
|
|
|
e4ff3b |
+include @SCHEMADIR@/corba.schema
|
|
|
e4ff3b |
+include @SCHEMADIR@/java.schema
|
|
|
e4ff3b |
+include @SCHEMADIR@/inetorgperson.schema
|
|
|
e4ff3b |
+include @SCHEMADIR@/misc.schema
|
|
|
e4ff3b |
+include @SCHEMADIR@/nis.schema
|
|
|
e4ff3b |
+include @SCHEMADIR@/openldap.schema
|
|
|
e4ff3b |
+#
|
|
|
e4ff3b |
+include @SCHEMADIR@/duaconf.schema
|
|
|
e4ff3b |
+include @SCHEMADIR@/dyngroup.schema
|
|
|
e4ff3b |
+
|
|
|
e4ff3b |
+#
|
|
|
e4ff3b |
+pidfile @TESTDIR@/slapd.1.pid
|
|
|
e4ff3b |
+argsfile @TESTDIR@/slapd.1.args
|
|
|
e4ff3b |
+
|
|
|
e4ff3b |
+# SSL configuration
|
|
|
e4ff3b |
+TLSCACertificateFile @TESTDIR@/tls/ca/certs/testsuiteCA.crt
|
|
|
e4ff3b |
+TLSCertificateKeyFile @TESTDIR@/tls/private/localhost.key
|
|
|
e4ff3b |
+TLSCertificateFile @TESTDIR@/tls/certs/localhost.crt
|
|
|
e4ff3b |
+
|
|
|
e4ff3b |
+#
|
|
|
e4ff3b |
+rootdse @DATADIR@/rootdse.ldif
|
|
|
e4ff3b |
+
|
|
|
e4ff3b |
+#mod#modulepath ../servers/slapd/back-@BACKEND@/
|
|
|
e4ff3b |
+#mod#moduleload back_@BACKEND@.la
|
|
|
e4ff3b |
+#monitormod#modulepath ../servers/slapd/back-monitor/
|
|
|
e4ff3b |
+#monitormod#moduleload back_monitor.la
|
|
|
e4ff3b |
+
|
|
|
e4ff3b |
+
|
|
|
e4ff3b |
+#######################################################################
|
|
|
e4ff3b |
+# database definitions
|
|
|
e4ff3b |
+#######################################################################
|
|
|
e4ff3b |
+
|
|
|
e4ff3b |
+database @BACKEND@
|
|
|
e4ff3b |
+suffix "dc=example,dc=com"
|
|
|
e4ff3b |
+rootdn "cn=Manager,dc=example,dc=com"
|
|
|
e4ff3b |
+rootpw secret
|
|
|
e4ff3b |
+#~null~#directory @TESTDIR@/db.1.a
|
|
|
e4ff3b |
+#indexdb#index objectClass eq
|
|
|
e4ff3b |
+#indexdb#index mail eq
|
|
|
e4ff3b |
+#ndb#dbname db_1_a
|
|
|
e4ff3b |
+#ndb#include @DATADIR@/ndb.conf
|
|
|
e4ff3b |
+
|
|
|
e4ff3b |
+#monitor#database monitor
|
|
|
e4ff3b |
+
|
|
|
e4ff3b |
+sasl-realm @KRB5REALM@
|
|
|
e4ff3b |
+sasl-host localhost
|
|
|
e4ff3b |
diff --git a/tests/scripts/conf.sh b/tests/scripts/conf.sh
|
|
|
e4ff3b |
index 2a859d89d..5b477ed93 100755
|
|
|
e4ff3b |
--- a/tests/scripts/conf.sh
|
|
|
e4ff3b |
+++ b/tests/scripts/conf.sh
|
|
|
e4ff3b |
@@ -97,4 +97,7 @@ sed -e "s/@BACKEND@/${BACKEND}/" \
|
|
|
e4ff3b |
-e "s;@TESTWD@;${TESTWD};" \
|
|
|
e4ff3b |
-e "s;@DATADIR@;${DATADIR};" \
|
|
|
e4ff3b |
-e "s;@SCHEMADIR@;${SCHEMADIR};" \
|
|
|
e4ff3b |
+ -e "s;@KRB5REALM@;${KRB5REALM};" \
|
|
|
e4ff3b |
+ -e "s;@KDCHOST@;${KDCHOST};" \
|
|
|
e4ff3b |
+ -e "s;@KDCPORT@;${KDCPORT};" \
|
|
|
e4ff3b |
-e "/^#/d"
|
|
|
e4ff3b |
diff --git a/tests/scripts/defines.sh b/tests/scripts/defines.sh
|
|
|
e4ff3b |
index 26dab1bae..78dc1f8ae 100755
|
|
|
e4ff3b |
--- a/tests/scripts/defines.sh
|
|
|
e4ff3b |
+++ b/tests/scripts/defines.sh
|
|
|
e4ff3b |
@@ -108,6 +108,7 @@ REFCONSUMERCONF=$DATADIR/slapd-ref-consumer.conf
|
|
|
e4ff3b |
SCHEMACONF=$DATADIR/slapd-schema.conf
|
|
|
e4ff3b |
TLSCONF=$DATADIR/slapd-tls.conf
|
|
|
e4ff3b |
TLSSASLCONF=$DATADIR/slapd-tls-sasl.conf
|
|
|
e4ff3b |
+SASLGSSAPICONF=$DATADIR/slapd-sasl-gssapi.conf
|
|
|
e4ff3b |
GLUECONF=$DATADIR/slapd-glue.conf
|
|
|
e4ff3b |
REFINTCONF=$DATADIR/slapd-refint.conf
|
|
|
e4ff3b |
RETCODECONF=$DATADIR/slapd-retcode.conf
|
|
|
e4ff3b |
@@ -214,6 +215,7 @@ PORT3=`expr $BASEPORT + 3`
|
|
|
e4ff3b |
PORT4=`expr $BASEPORT + 4`
|
|
|
e4ff3b |
PORT5=`expr $BASEPORT + 5`
|
|
|
e4ff3b |
PORT6=`expr $BASEPORT + 6`
|
|
|
e4ff3b |
+KDCPORT=`expr $BASEPORT + 7`
|
|
|
e4ff3b |
URI1="ldap://${LOCALHOST}:$PORT1/"
|
|
|
e4ff3b |
URIP1="ldap://${LOCALIP}:$PORT1/"
|
|
|
e4ff3b |
URI2="ldap://${LOCALHOST}:$PORT2/"
|
|
|
e4ff3b |
@@ -239,6 +241,9 @@ SURIP5="ldaps://${LOCALIP}:$PORT5/"
|
|
|
e4ff3b |
SURI6="ldaps://${LOCALHOST}:$PORT6/"
|
|
|
e4ff3b |
SURIP6="ldaps://${LOCALIP}:$PORT6/"
|
|
|
e4ff3b |
|
|
|
e4ff3b |
+KRB5REALM="K5.REALM"
|
|
|
e4ff3b |
+KDCHOST=$LOCALHOST
|
|
|
e4ff3b |
+
|
|
|
e4ff3b |
# LDIF
|
|
|
e4ff3b |
LDIF=$DATADIR/test.ldif
|
|
|
e4ff3b |
LDIFADD1=$DATADIR/do_add.1
|
|
|
e4ff3b |
diff --git a/tests/scripts/setup_kdc.sh b/tests/scripts/setup_kdc.sh
|
|
|
e4ff3b |
new file mode 100755
|
|
|
e4ff3b |
index 000000000..1cb784075
|
|
|
e4ff3b |
--- /dev/null
|
|
|
e4ff3b |
+++ b/tests/scripts/setup_kdc.sh
|
|
|
e4ff3b |
@@ -0,0 +1,144 @@
|
|
|
e4ff3b |
+#! /bin/sh
|
|
|
e4ff3b |
+# $OpenLDAP$
|
|
|
e4ff3b |
+## This work is part of OpenLDAP Software <http://www.openldap.org/>.
|
|
|
e4ff3b |
+##
|
|
|
e4ff3b |
+## Copyright 1998-2020 The OpenLDAP Foundation.
|
|
|
e4ff3b |
+## All rights reserved.
|
|
|
e4ff3b |
+##
|
|
|
e4ff3b |
+## Redistribution and use in source and binary forms, with or without
|
|
|
e4ff3b |
+## modification, are permitted only as authorized by the OpenLDAP
|
|
|
e4ff3b |
+## Public License.
|
|
|
e4ff3b |
+##
|
|
|
e4ff3b |
+## A copy of this license is available in the file LICENSE in the
|
|
|
e4ff3b |
+## top-level directory of the distribution or, alternatively, at
|
|
|
e4ff3b |
+## <http://www.OpenLDAP.org/license.html>.
|
|
|
e4ff3b |
+
|
|
|
e4ff3b |
+export KRB5_TRACE=$TESTDIR/k5_trace
|
|
|
e4ff3b |
+export KRB5_CONFIG=$TESTDIR/krb5.conf
|
|
|
e4ff3b |
+export KRB5_KDC_PROFILE=$KRB5_CONFIG
|
|
|
e4ff3b |
+export KRB5_KTNAME=$TESTDIR/server.kt
|
|
|
e4ff3b |
+export KRB5_CLIENT_KTNAME=$TESTDIR/client.kt
|
|
|
e4ff3b |
+export KRB5CCNAME=$TESTDIR/client.ccache
|
|
|
e4ff3b |
+
|
|
|
e4ff3b |
+KDCLOG=$TESTDIR/setup_kdc.log
|
|
|
e4ff3b |
+KSERVICE=ldap/$LOCALHOST
|
|
|
e4ff3b |
+KUSER=kuser
|
|
|
e4ff3b |
+
|
|
|
e4ff3b |
+. $CONFFILTER < $DATADIR/krb5.conf > $KRB5_CONFIG
|
|
|
e4ff3b |
+
|
|
|
e4ff3b |
+PATH=${PATH}:/usr/lib/heimdal-servers:/usr/sbin:/usr/local/sbin
|
|
|
e4ff3b |
+
|
|
|
e4ff3b |
+echo "Trying Heimdal KDC..."
|
|
|
e4ff3b |
+
|
|
|
e4ff3b |
+kdc --version 2>&1 | grep Heimdal > $KDCLOG 2>&1
|
|
|
e4ff3b |
+RC=$?
|
|
|
e4ff3b |
+if test $RC = 0 ; then
|
|
|
e4ff3b |
+
|
|
|
e4ff3b |
+ kstash --random-key > $KDCLOG 2>&1
|
|
|
e4ff3b |
+ RC=$?
|
|
|
e4ff3b |
+ if test $RC != 0 ; then
|
|
|
e4ff3b |
+ echo "Heimdal: kstash failed, skipping GSSAPI tests"
|
|
|
e4ff3b |
+ exit 0
|
|
|
e4ff3b |
+ fi
|
|
|
e4ff3b |
+
|
|
|
e4ff3b |
+ flags="--realm-max-ticket-life=1h --realm-max-renewable-life=1h"
|
|
|
e4ff3b |
+ kadmin -l init $flags $KRB5REALM > $KDCLOG 2>&1
|
|
|
e4ff3b |
+ RC=$?
|
|
|
e4ff3b |
+ if test $RC != 0 ; then
|
|
|
e4ff3b |
+ echo "Heimdal: kadmin init failed, skipping GSSAPI tests"
|
|
|
e4ff3b |
+ exit 0
|
|
|
e4ff3b |
+ fi
|
|
|
e4ff3b |
+
|
|
|
e4ff3b |
+ kadmin -l add --random-key --use-defaults $KSERVICE > $KDCLOG 2>&1
|
|
|
e4ff3b |
+ RC=$?
|
|
|
e4ff3b |
+ if test $RC != 0 ; then
|
|
|
e4ff3b |
+ echo "Heimdal: kadmin add failed, skipping GSSAPI tests"
|
|
|
e4ff3b |
+ exit 0
|
|
|
e4ff3b |
+ fi
|
|
|
e4ff3b |
+
|
|
|
e4ff3b |
+ kadmin -l ext -k $KRB5_KTNAME $KSERVICE > $KDCLOG 2>&1
|
|
|
e4ff3b |
+ RC=$?
|
|
|
e4ff3b |
+ if test $RC != 0 ; then
|
|
|
e4ff3b |
+ echo "Heimdal: kadmin ext failed, skipping GSSAPI tests"
|
|
|
e4ff3b |
+ exit 0
|
|
|
e4ff3b |
+ fi
|
|
|
e4ff3b |
+
|
|
|
e4ff3b |
+ kadmin -l add --random-key --use-defaults $KUSER > $KDCLOG 2>&1
|
|
|
e4ff3b |
+ RC=$?
|
|
|
e4ff3b |
+ if test $RC != 0 ; then
|
|
|
e4ff3b |
+ echo "Heimdal: kadmin add failed, skipping GSSAPI tests"
|
|
|
e4ff3b |
+ exit 0
|
|
|
e4ff3b |
+ fi
|
|
|
e4ff3b |
+
|
|
|
e4ff3b |
+ kadmin -l ext -k $KRB5_CLIENT_KTNAME $KUSER > $KDCLOG 2>&1
|
|
|
e4ff3b |
+ RC=$?
|
|
|
e4ff3b |
+ if test $RC != 0 ; then
|
|
|
e4ff3b |
+ echo "Heimdal: kadmin ext failed, skipping GSSAPI tests"
|
|
|
e4ff3b |
+ exit 0
|
|
|
e4ff3b |
+ fi
|
|
|
e4ff3b |
+
|
|
|
e4ff3b |
+ kdc --addresses=$LOCALIP --ports="$KDCPORT/udp" > $KDCLOG 2>&1 &
|
|
|
e4ff3b |
+else
|
|
|
e4ff3b |
+ echo "Trying MIT KDC..."
|
|
|
e4ff3b |
+
|
|
|
e4ff3b |
+ kdb5_util create -r $KRB5REALM -s -P password > $KDCLOG 2>&1
|
|
|
e4ff3b |
+ RC=$?
|
|
|
e4ff3b |
+ if test $RC != 0 ; then
|
|
|
e4ff3b |
+ echo "MIT: kdb5_util create failed, skipping GSSAPI tests"
|
|
|
e4ff3b |
+ exit 0
|
|
|
e4ff3b |
+ fi
|
|
|
e4ff3b |
+
|
|
|
e4ff3b |
+ kadmin.local -q "addprinc -randkey $KSERVICE" > $KDCLOG 2>&1
|
|
|
e4ff3b |
+ RC=$?
|
|
|
e4ff3b |
+ if test $RC != 0 ; then
|
|
|
e4ff3b |
+ echo "MIT: admin addprinc failed, skipping GSSAPI tests"
|
|
|
e4ff3b |
+ exit 0
|
|
|
e4ff3b |
+ fi
|
|
|
e4ff3b |
+
|
|
|
e4ff3b |
+ kadmin.local -q "ktadd -k $KRB5_KTNAME $KSERVICE" > $KDCLOG 2>&1
|
|
|
e4ff3b |
+ RC=$?
|
|
|
e4ff3b |
+ if test $RC != 0 ; then
|
|
|
e4ff3b |
+ echo "MIT: kadmin ktadd failed, skipping GSSAPI tests"
|
|
|
e4ff3b |
+ exit 0
|
|
|
e4ff3b |
+ fi
|
|
|
e4ff3b |
+
|
|
|
e4ff3b |
+ kadmin.local -q "addprinc -randkey $KUSER" > $KDCLOG 2>&1
|
|
|
e4ff3b |
+ RC=$?
|
|
|
e4ff3b |
+ if test $RC != 0 ; then
|
|
|
e4ff3b |
+ echo "MIT: kadmin addprinc failed, skipping GSSAPI tests"
|
|
|
e4ff3b |
+ exit 0
|
|
|
e4ff3b |
+ fi
|
|
|
e4ff3b |
+
|
|
|
e4ff3b |
+ kadmin.local -q "ktadd -k $KRB5_CLIENT_KTNAME $KUSER" > $KDCLOG 2>&1
|
|
|
e4ff3b |
+ RC=$?
|
|
|
e4ff3b |
+ if test $RC != 0 ; then
|
|
|
e4ff3b |
+ echo "MIT: kadmin ktadd failed, skipping GSSAPI tests"
|
|
|
e4ff3b |
+ exit 0
|
|
|
e4ff3b |
+ fi
|
|
|
e4ff3b |
+
|
|
|
e4ff3b |
+ krb5kdc -n > $KDCLOG 2>&1 &
|
|
|
e4ff3b |
+fi
|
|
|
e4ff3b |
+
|
|
|
e4ff3b |
+KDCPROC=$!
|
|
|
e4ff3b |
+sleep 1
|
|
|
e4ff3b |
+
|
|
|
e4ff3b |
+kinit -kt $KRB5_CLIENT_KTNAME $KUSER > $KDCLOG 2>&1
|
|
|
e4ff3b |
+RC=$?
|
|
|
e4ff3b |
+if test $RC != 0 ; then
|
|
|
e4ff3b |
+ kill $KDCPROC
|
|
|
e4ff3b |
+ echo "SASL/GSSAPI: kinit failed, skipping GSSAPI tests"
|
|
|
e4ff3b |
+ exit 0
|
|
|
e4ff3b |
+fi
|
|
|
e4ff3b |
+
|
|
|
e4ff3b |
+pluginviewer -m GSSAPI > $TESTDIR/plugin_out 2>/dev/null
|
|
|
e4ff3b |
+RC=$?
|
|
|
e4ff3b |
+if test $RC != 0 ; then
|
|
|
e4ff3b |
+
|
|
|
e4ff3b |
+ saslpluginviewer -m GSSAPI > $TESTDIR/plugin_out 2>/dev/null
|
|
|
e4ff3b |
+ RC=$?
|
|
|
e4ff3b |
+ if test $RC != 0 ; then
|
|
|
e4ff3b |
+ kill $KDCPROC
|
|
|
e4ff3b |
+ echo "cyrus-sasl has no GSSAPI support, test skipped"
|
|
|
e4ff3b |
+ exit 0
|
|
|
e4ff3b |
+ fi
|
|
|
e4ff3b |
+fi
|
|
|
e4ff3b |
diff --git a/tests/scripts/test077-sasl-gssapi b/tests/scripts/test077-sasl-gssapi
|
|
|
e4ff3b |
new file mode 100755
|
|
|
e4ff3b |
index 000000000..64abe16fe
|
|
|
e4ff3b |
--- /dev/null
|
|
|
e4ff3b |
+++ b/tests/scripts/test077-sasl-gssapi
|
|
|
e4ff3b |
@@ -0,0 +1,159 @@
|
|
|
e4ff3b |
+#! /bin/sh
|
|
|
e4ff3b |
+# $OpenLDAP$
|
|
|
e4ff3b |
+## This work is part of OpenLDAP Software <http://www.openldap.org/>.
|
|
|
e4ff3b |
+##
|
|
|
e4ff3b |
+## Copyright 1998-2020 The OpenLDAP Foundation.
|
|
|
e4ff3b |
+## All rights reserved.
|
|
|
e4ff3b |
+##
|
|
|
e4ff3b |
+## Redistribution and use in source and binary forms, with or without
|
|
|
e4ff3b |
+## modification, are permitted only as authorized by the OpenLDAP
|
|
|
e4ff3b |
+## Public License.
|
|
|
e4ff3b |
+##
|
|
|
e4ff3b |
+## A copy of this license is available in the file LICENSE in the
|
|
|
e4ff3b |
+## top-level directory of the distribution or, alternatively, at
|
|
|
e4ff3b |
+## <http://www.OpenLDAP.org/license.html>.
|
|
|
e4ff3b |
+
|
|
|
e4ff3b |
+echo "running defines.sh"
|
|
|
e4ff3b |
+. $SRCDIR/scripts/defines.sh
|
|
|
e4ff3b |
+
|
|
|
e4ff3b |
+if test $WITH_SASL = no ; then
|
|
|
e4ff3b |
+ echo "SASL support not available, test skipped"
|
|
|
e4ff3b |
+ exit 0
|
|
|
e4ff3b |
+fi
|
|
|
e4ff3b |
+
|
|
|
e4ff3b |
+mkdir -p $TESTDIR $DBDIR1
|
|
|
e4ff3b |
+cp -r $DATADIR/tls $TESTDIR
|
|
|
e4ff3b |
+
|
|
|
e4ff3b |
+cd $TESTWD
|
|
|
e4ff3b |
+
|
|
|
e4ff3b |
+
|
|
|
e4ff3b |
+echo "Starting KDC for SASL/GSSAPI tests..."
|
|
|
e4ff3b |
+. $SRCDIR/scripts/setup_kdc.sh
|
|
|
e4ff3b |
+
|
|
|
e4ff3b |
+echo "Running slapadd to build slapd database..."
|
|
|
e4ff3b |
+. $CONFFILTER $BACKEND $MONITORDB < $SASLGSSAPICONF > $CONF1
|
|
|
e4ff3b |
+$SLAPADD -f $CONF1 -l $LDIFORDERED
|
|
|
e4ff3b |
+RC=$?
|
|
|
e4ff3b |
+if test $RC != 0 ; then
|
|
|
e4ff3b |
+ echo "slapadd failed ($RC)!"
|
|
|
e4ff3b |
+ kill $KDCPROC
|
|
|
e4ff3b |
+ exit $RC
|
|
|
e4ff3b |
+fi
|
|
|
e4ff3b |
+
|
|
|
e4ff3b |
+echo "Starting ldap:/// slapd on TCP/IP port $PORT1 and ldaps:/// slapd on $PORT2..."
|
|
|
e4ff3b |
+$SLAPD -f $CONF1 -h "$URI1 $SURI2" -d $LVL $TIMING > $LOG1 2>&1 &
|
|
|
e4ff3b |
+PID=$!
|
|
|
e4ff3b |
+if test $WAIT != 0 ; then
|
|
|
e4ff3b |
+ echo PID $PID
|
|
|
e4ff3b |
+ read foo
|
|
|
e4ff3b |
+fi
|
|
|
e4ff3b |
+KILLPIDS="$PID"
|
|
|
e4ff3b |
+
|
|
|
e4ff3b |
+sleep 1
|
|
|
e4ff3b |
+
|
|
|
e4ff3b |
+for i in 0 1 2 3 4 5; do
|
|
|
e4ff3b |
+ $LDAPSEARCH -s base -b "" -H $URI1 \
|
|
|
e4ff3b |
+ 'objectclass=*' > /dev/null 2>&1
|
|
|
e4ff3b |
+ RC=$?
|
|
|
e4ff3b |
+ if test $RC = 0 ; then
|
|
|
e4ff3b |
+ break
|
|
|
e4ff3b |
+ fi
|
|
|
e4ff3b |
+ echo "Waiting 5 seconds for slapd to start..."
|
|
|
e4ff3b |
+ sleep 5
|
|
|
e4ff3b |
+done
|
|
|
e4ff3b |
+
|
|
|
e4ff3b |
+if test $RC != 0 ; then
|
|
|
e4ff3b |
+ echo "ldapsearch failed ($RC)!"
|
|
|
e4ff3b |
+ kill $KDCPROC
|
|
|
e4ff3b |
+ test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
|
e4ff3b |
+ exit $RC
|
|
|
e4ff3b |
+fi
|
|
|
e4ff3b |
+
|
|
|
e4ff3b |
+$LDAPSEARCH -x -H $URI1 -s "base" -b "" supportedSASLMechanisms > $TESTOUT 2>&1
|
|
|
e4ff3b |
+RC=$?
|
|
|
e4ff3b |
+if test $RC != 0 ; then
|
|
|
e4ff3b |
+ echo "ldapsearch failed ($RC)!"
|
|
|
e4ff3b |
+ kill $KDCPROC
|
|
|
e4ff3b |
+ test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
|
e4ff3b |
+ exit $RC
|
|
|
e4ff3b |
+fi
|
|
|
e4ff3b |
+
|
|
|
e4ff3b |
+grep GSSAPI $TESTOUT
|
|
|
e4ff3b |
+RC=$?
|
|
|
e4ff3b |
+if test $RC != 0 ; then
|
|
|
e4ff3b |
+ echo "failed: GSSAPI mechanism not in supportedSASLMechanisms."
|
|
|
e4ff3b |
+ kill $KDCPROC
|
|
|
e4ff3b |
+ test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
|
e4ff3b |
+ exit $RC
|
|
|
e4ff3b |
+fi
|
|
|
e4ff3b |
+
|
|
|
e4ff3b |
+echo -n "Using ldapwhoami with SASL/GSSAPI: "
|
|
|
e4ff3b |
+$LDAPSASLWHOAMI -N -Y GSSAPI -H $URI1 > $TESTOUT 2>&1
|
|
|
e4ff3b |
+RC=$?
|
|
|
e4ff3b |
+if test $RC != 0 ; then
|
|
|
e4ff3b |
+ echo "ldapwhoami failed ($RC)!"
|
|
|
e4ff3b |
+ kill $KDCPROC
|
|
|
e4ff3b |
+ test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
|
e4ff3b |
+ exit $RC
|
|
|
e4ff3b |
+else
|
|
|
e4ff3b |
+ echo "success"
|
|
|
e4ff3b |
+fi
|
|
|
e4ff3b |
+
|
|
|
e4ff3b |
+echo -n "Validating mapped SASL/GSSAPI ID: "
|
|
|
e4ff3b |
+echo "dn:uid=$KUSER,cn=$KRB5REALM,cn=gssapi,cn=auth" > $TESTDIR/dn.out
|
|
|
e4ff3b |
+$CMP $TESTDIR/dn.out $TESTOUT > $CMPOUT
|
|
|
e4ff3b |
+RC=$?
|
|
|
e4ff3b |
+if test $RC != 0 ; then
|
|
|
e4ff3b |
+ echo "Comparison failed"
|
|
|
e4ff3b |
+ kill $KDCPROC
|
|
|
e4ff3b |
+ test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
|
e4ff3b |
+ exit $RC
|
|
|
e4ff3b |
+else
|
|
|
e4ff3b |
+ echo "success"
|
|
|
e4ff3b |
+fi
|
|
|
e4ff3b |
+
|
|
|
e4ff3b |
+if test $WITH_TLS = no ; then
|
|
|
e4ff3b |
+ echo "SASL/GSSAPI: TLS support not available, skipping TLS part."
|
|
|
e4ff3b |
+else
|
|
|
e4ff3b |
+ echo -n "Using ldapwhoami with SASL/GSSAPI with start-tls: "
|
|
|
e4ff3b |
+ $LDAPSASLWHOAMI -N -Y GSSAPI -H $URI1 -ZZ -o tls_reqcert=allow \
|
|
|
e4ff3b |
+ -o tls_cacert=$TESTDIR/tls/ca/certs/testsuiteCA.crt \
|
|
|
e4ff3b |
+ > $TESTOUT 2>&1
|
|
|
e4ff3b |
+ RC=$?
|
|
|
e4ff3b |
+ if test $RC != 0 ; then
|
|
|
e4ff3b |
+ echo "ldapwhoami failed ($RC)!"
|
|
|
e4ff3b |
+ kill $KDCPROC
|
|
|
e4ff3b |
+ test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
|
e4ff3b |
+ exit $RC
|
|
|
e4ff3b |
+ else
|
|
|
e4ff3b |
+ echo "success"
|
|
|
e4ff3b |
+ fi
|
|
|
e4ff3b |
+
|
|
|
e4ff3b |
+ echo -n "Using ldapwhoami with SASL/GSSAPI with ldaps: "
|
|
|
e4ff3b |
+ $LDAPSASLWHOAMI -N -Y GSSAPI -H $SURI2 -o tls_reqcert=allow \
|
|
|
e4ff3b |
+ -o tls_cacert=$TESTDIR/tls/ca/certs/testsuiteCA.crt \
|
|
|
e4ff3b |
+ > $TESTOUT 2>&1
|
|
|
e4ff3b |
+ RC=$?
|
|
|
e4ff3b |
+ if test $RC != 0 ; then
|
|
|
e4ff3b |
+ echo "ldapwhoami failed ($RC)!"
|
|
|
e4ff3b |
+ kill $KDCPROC
|
|
|
e4ff3b |
+ test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
|
e4ff3b |
+ exit $RC
|
|
|
e4ff3b |
+ else
|
|
|
e4ff3b |
+ echo "success"
|
|
|
e4ff3b |
+ fi
|
|
|
e4ff3b |
+fi
|
|
|
e4ff3b |
+
|
|
|
e4ff3b |
+kill $KDCPROC
|
|
|
e4ff3b |
+test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
|
e4ff3b |
+
|
|
|
e4ff3b |
+if test $RC != 0 ; then
|
|
|
e4ff3b |
+ echo ">>>>> Test failed"
|
|
|
e4ff3b |
+else
|
|
|
e4ff3b |
+ echo ">>>>> Test succeeded"
|
|
|
e4ff3b |
+ RC=0
|
|
|
e4ff3b |
+fi
|
|
|
e4ff3b |
+
|
|
|
e4ff3b |
+test $KILLSERVERS != no && wait
|
|
|
e4ff3b |
+
|
|
|
e4ff3b |
+exit $RC
|
|
|
e4ff3b |
--
|
|
|
e4ff3b |
2.29.2
|
|
|
e4ff3b |
|