diff --git a/tests/zfs-tests/tests/functional/pam/.gitignore b/tests/zfs-tests/tests/functional/pam/.gitignore new file mode 100644 index 0000000000..ae55292b08 --- /dev/null +++ b/tests/zfs-tests/tests/functional/pam/.gitignore @@ -0,0 +1 @@ +/utilities.kshlib diff --git a/tests/zfs-tests/tests/functional/pam/Makefile.am b/tests/zfs-tests/tests/functional/pam/Makefile.am index be881faccf..2ae5f8ff0f 100644 --- a/tests/zfs-tests/tests/functional/pam/Makefile.am +++ b/tests/zfs-tests/tests/functional/pam/Makefile.am @@ -6,3 +6,6 @@ dist_pkgdata_SCRIPTS = \ pam_nounmount.ksh \ pam_short_password.ksh \ utilities.kshlib + +% : %.in + sed 's|@pammoduledir[@]|@pammoduledir@|g' $< > $@ diff --git a/tests/zfs-tests/tests/functional/pam/cleanup.ksh b/tests/zfs-tests/tests/functional/pam/cleanup.ksh index e41622d771..8ea9c848b0 100755 --- a/tests/zfs-tests/tests/functional/pam/cleanup.ksh +++ b/tests/zfs-tests/tests/functional/pam/cleanup.ksh @@ -26,8 +26,4 @@ rmconfig destroy_pool $TESTPOOL del_user ${username} del_group pamtestgroup - -rm -rf "$runstatedir" -for dir in $TESTDIRS; do - rm -rf $dir -done +log_must rm -rf "$runstatedir" $TESTDIRS diff --git a/tests/zfs-tests/tests/functional/pam/setup.ksh b/tests/zfs-tests/tests/functional/pam/setup.ksh index 8ef9fbe0fe..82370a211f 100755 --- a/tests/zfs-tests/tests/functional/pam/setup.ksh +++ b/tests/zfs-tests/tests/functional/pam/setup.ksh @@ -23,6 +23,7 @@ . $STF_SUITE/tests/functional/pam/utilities.kshlib command -v pamtester > /dev/null || log_unsupported "pam tests require the pamtester utility to be installed" +[ -f "$pammodule" ] || log_unsupported "$pammodule missing" DISK=${DISKS%% *} create_pool $TESTPOOL "$DISK" diff --git a/tests/zfs-tests/tests/functional/pam/utilities.kshlib b/tests/zfs-tests/tests/functional/pam/utilities.kshlib.in similarity index 75% rename from tests/zfs-tests/tests/functional/pam/utilities.kshlib rename to tests/zfs-tests/tests/functional/pam/utilities.kshlib.in index 6e9f900913..29c6ada3db 100644 --- a/tests/zfs-tests/tests/functional/pam/utilities.kshlib +++ b/tests/zfs-tests/tests/functional/pam/utilities.kshlib.in @@ -24,24 +24,25 @@ username="pamtestuser" runstatedir="${TESTDIR}_run" +pammodule="@pammoduledir@/pam_zfs_key.so" pamservice="pam_zfs_key_test" pamconfig="/etc/pam.d/${pamservice}" function keystatus { - log_must [ "$(zfs list -Ho keystatus "$TESTPOOL/pam/${username}")" = "$1" ] + log_must [ "$(get_prop keystatus "$TESTPOOL/pam/${username}")" = "$1" ] } function genconfig { - for i in password auth session; do - printf "%s\trequired\tpam_permit.so\n%s\toptional\tpam_zfs_key.so\t%s\n" "$i" "$i" "$1" - done > "${pamconfig}" + printf '%s\trequired\tpam_permit.so\n%s\toptional\t%s\t%s\n' \ + password password "$pammodule" "$1" \ + auth auth "$pammodule" "$1" \ + session session "$pammodule" "$1" > "${pamconfig}" } function rmconfig { - log_must rm "${pamconfig}" + log_must rm -f "${pamconfig}" } function references { log_must [ "$(<"${runstatedir}/$(id -u ${username})")" = "$1" ] } -