tests: clean-up pam server initiation

Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
This commit is contained in:
Nikos Mavrogiannopoulos
2019-11-15 15:54:31 +01:00
parent 6739529e05
commit ea845a57fc
5 changed files with 28 additions and 20 deletions

View File

@@ -21,7 +21,7 @@
# along with this file; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#this test can only be run as root
builddir=${builddir:-.}
OPENCONNECT=${OPENCONNECT:-/usr/sbin/openconnect}
@@ -116,16 +116,23 @@ launch_sr_server() {
}
launch_sr_pam_server() {
mkdir -p "data/$PAMDIR/"
test -f "${srcdir}/data/$PAMDIR/users.oath.templ" && cp "${srcdir}/data/$PAMDIR/users.oath.templ" "data/$PAMDIR/users.oath"
test -f "${srcdir}/data/$PAMDIR/passdb.templ" && cp "${srcdir}/data/$PAMDIR/passdb.templ" "data/$PAMDIR/passdb"
export PAM_WRAPPER_SERVICE_DIR=pam.$$.tmp
export NSS_WRAPPER_PASSWD=${srcdir}/data/pam/nss-passwd
export NSS_WRAPPER_GROUP=${srcdir}/data/pam/nss-group
test -z "${TEST_PAMDIR}" && exit 2
export PAM_WRAPPER_DEBUGLEVEL=3
export PAM_WRAPPER_SERVICE_DIR="${builddir}/pam.$$.tmp/"
mkdir -p "${PAM_WRAPPER_SERVICE_DIR}"
test -f "${srcdir}/${TEST_PAMDIR}/users.oath.templ" && cp "${srcdir}/${TEST_PAMDIR}/users.oath.templ" "${PAM_WRAPPER_SERVICE_DIR}/users.oath"
test -f "${srcdir}/${TEST_PAMDIR}/passdb.templ" && cp "${srcdir}/${TEST_PAMDIR}/passdb.templ" "${PAM_WRAPPER_SERVICE_DIR}/passdb"
test -f "${builddir}/${TEST_PAMDIR}/ocserv" && cp "${builddir}/${TEST_PAMDIR}/ocserv" "${PAM_WRAPPER_SERVICE_DIR}/"
sed -i -e 's|%PAM_WRAPPER_SERVICE_DIR%|'${PAM_WRAPPER_SERVICE_DIR}'|g' "${PAM_WRAPPER_SERVICE_DIR}/ocserv"
cp "${builddir}/data/pam/nss-passwd" "${PAM_WRAPPER_SERVICE_DIR}/"
cp "${builddir}/data/pam/nss-group" "${PAM_WRAPPER_SERVICE_DIR}/"
export NSS_WRAPPER_PASSWD=${PAM_WRAPPER_SERVICE_DIR}/nss-passwd
export NSS_WRAPPER_GROUP=${PAM_WRAPPER_SERVICE_DIR}/nss-group
if test -n "${VERBOSE}" && test "${VERBOSE}" -ge 1;then
LD_PRELOAD=libnss_wrapper.so:libpam_wrapper.so:libsocket_wrapper.so:libuid_wrapper.so PAM_WRAPPER_SERVICE_DIR="data/$PAMDIR" PAM_WRAPPER=1 UID_WRAPPER=1 UID_WRAPPER_ROOT=1 $SERV $* &
LD_PRELOAD=libnss_wrapper.so:libpam_wrapper.so:libsocket_wrapper.so:libuid_wrapper.so PAM_WRAPPER=1 UID_WRAPPER=1 UID_WRAPPER_ROOT=1 $SERV $* &
else
LD_PRELOAD=libnss_wrapper.so:libpam_wrapper.so:libsocket_wrapper.so:libuid_wrapper.so PAM_WRAPPER_SERVICE_DIR="data/$PAMDIR" PAM_WRAPPER=1 UID_WRAPPER=1 UID_WRAPPER_ROOT=1 $SERV $* >/dev/null 2>&1 &
LD_PRELOAD=libnss_wrapper.so:libpam_wrapper.so:libsocket_wrapper.so:libuid_wrapper.so PAM_WRAPPER=1 UID_WRAPPER=1 UID_WRAPPER_ROOT=1 $SERV $* >/dev/null 2>&1 &
fi
LOCALPID="$!";
unset NSS_WRAPPER_PASSWD
@@ -179,7 +186,8 @@ cleanup() {
ret=1
fi
wait
test -n "$SOCKDIR" && rm -rf $SOCKDIR
test -n "${PAM_WRAPPER_SERVICE_DIR}" && rm -rf ${PAM_WRAPPER_SERVICE_DIR}
test -n "${SOCKDIR}" && rm -rf ${SOCKDIR}
rm -f ${CONFIG}
return $ret
}

View File

@@ -1,5 +1,5 @@
#%PAM-1.0
auth required @PAMWRAPDIR@/pam_matrix.so passdb=./data/pam-single/passdb
account required @PAMWRAPDIR@/pam_matrix.so passdb=./data/pam-single/passdb
account required @PAMWRAPDIR@/pam_matrix.so passdb=./data/pam-single/passdb
session required @PAMWRAPDIR@/pam_matrix.so passdb=./data/pam-single/passdb
auth required @PAMWRAPDIR@/pam_matrix.so passdb=%PAM_WRAPPER_SERVICE_DIR%/passdb
account required @PAMWRAPDIR@/pam_matrix.so passdb=%PAM_WRAPPER_SERVICE_DIR%/passdb
account required @PAMWRAPDIR@/pam_matrix.so passdb=%PAM_WRAPPER_SERVICE_DIR%/passdb
session required @PAMWRAPDIR@/pam_matrix.so passdb=%PAM_WRAPPER_SERVICE_DIR%/passdb

View File

@@ -1,5 +1,5 @@
#%PAM-1.0
auth required @PAMWRAPDIR@/pam_matrix.so passdb=./data/pam/passdb
account required @PAMWRAPDIR@/pam_matrix.so passdb=./data/pam/passdb
account required @PAMWRAPDIR@/pam_matrix.so passdb=./data/pam/passdb
session required @PAMWRAPDIR@/pam_matrix.so passdb=./data/pam/passdb
auth required @PAMWRAPDIR@/pam_matrix.so passdb=%PAM_WRAPPER_SERVICE_DIR%/passdb
account required @PAMWRAPDIR@/pam_matrix.so passdb=%PAM_WRAPPER_SERVICE_DIR%/passdb
account required @PAMWRAPDIR@/pam_matrix.so passdb=%PAM_WRAPPER_SERVICE_DIR%/passdb
session required @PAMWRAPDIR@/pam_matrix.so passdb=%PAM_WRAPPER_SERVICE_DIR%/passdb

View File

@@ -29,7 +29,7 @@ VERBOSE=1
echo "Testing PAM backend with username-password... "
export PAMDIR=pam
export TEST_PAMDIR=data/pam
update_config test-pam.config
launch_sr_pam_server -d 1 -f -c ${CONFIG} & PID=$!
wait_server $PID

View File

@@ -27,7 +27,7 @@ PORT=6552
echo "Testing PAM acct backend with username-password... "
export PAMDIR=pam-single
export TEST_PAMDIR=data/pam-single
update_config test-pam-noauth.config
launch_sr_pam_server -d 1 -f -c ${CONFIG} & PID=$!