tests: pam: use absolute path to module .so

This is a valid configuration and both (a) skips the tests if it's
unbuilt/not installed and (b) makes it work even if installed outside
the system directory (like in /u/l/l/s instead of /l/s)

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: John Kennedy <john.kennedy@delphix.com>
Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #13259
This commit is contained in:
наб 2022-03-23 02:21:56 +01:00 committed by Brian Behlendorf
parent 7b6c4cbb1f
commit ff0fc5af12
5 changed files with 13 additions and 11 deletions

View File

@ -0,0 +1 @@
/utilities.kshlib

View File

@ -6,3 +6,6 @@ dist_pkgdata_SCRIPTS = \
pam_nounmount.ksh \ pam_nounmount.ksh \
pam_short_password.ksh \ pam_short_password.ksh \
utilities.kshlib utilities.kshlib
% : %.in
sed 's|@pammoduledir[@]|@pammoduledir@|g' $< > $@

View File

@ -26,8 +26,4 @@ rmconfig
destroy_pool $TESTPOOL destroy_pool $TESTPOOL
del_user ${username} del_user ${username}
del_group pamtestgroup del_group pamtestgroup
log_must rm -rf "$runstatedir" $TESTDIRS
rm -rf "$runstatedir"
for dir in $TESTDIRS; do
rm -rf $dir
done

View File

@ -23,6 +23,7 @@
. $STF_SUITE/tests/functional/pam/utilities.kshlib . $STF_SUITE/tests/functional/pam/utilities.kshlib
command -v pamtester > /dev/null || log_unsupported "pam tests require the pamtester utility to be installed" command -v pamtester > /dev/null || log_unsupported "pam tests require the pamtester utility to be installed"
[ -f "$pammodule" ] || log_unsupported "$pammodule missing"
DISK=${DISKS%% *} DISK=${DISKS%% *}
create_pool $TESTPOOL "$DISK" create_pool $TESTPOOL "$DISK"

View File

@ -24,24 +24,25 @@
username="pamtestuser" username="pamtestuser"
runstatedir="${TESTDIR}_run" runstatedir="${TESTDIR}_run"
pammodule="@pammoduledir@/pam_zfs_key.so"
pamservice="pam_zfs_key_test" pamservice="pam_zfs_key_test"
pamconfig="/etc/pam.d/${pamservice}" pamconfig="/etc/pam.d/${pamservice}"
function keystatus { function keystatus {
log_must [ "$(zfs list -Ho keystatus "$TESTPOOL/pam/${username}")" = "$1" ] log_must [ "$(get_prop keystatus "$TESTPOOL/pam/${username}")" = "$1" ]
} }
function genconfig { function genconfig {
for i in password auth session; do printf '%s\trequired\tpam_permit.so\n%s\toptional\t%s\t%s\n' \
printf "%s\trequired\tpam_permit.so\n%s\toptional\tpam_zfs_key.so\t%s\n" "$i" "$i" "$1" password password "$pammodule" "$1" \
done > "${pamconfig}" auth auth "$pammodule" "$1" \
session session "$pammodule" "$1" > "${pamconfig}"
} }
function rmconfig { function rmconfig {
log_must rm "${pamconfig}" log_must rm -f "${pamconfig}"
} }
function references { function references {
log_must [ "$(<"${runstatedir}/$(id -u ${username})")" = "$1" ] log_must [ "$(<"${runstatedir}/$(id -u ${username})")" = "$1" ]
} }