From ff0fc5af12bc4c702664d1e9e48d158ba42ebc2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Wed, 23 Mar 2022 02:21:56 +0100 Subject: [PATCH] tests: pam: use absolute path to module .so MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: John Kennedy Reviewed-by: Ryan Moeller Signed-off-by: Ahelenia ZiemiaƄska Closes #13259 --- tests/zfs-tests/tests/functional/pam/.gitignore | 1 + tests/zfs-tests/tests/functional/pam/Makefile.am | 3 +++ tests/zfs-tests/tests/functional/pam/cleanup.ksh | 6 +----- tests/zfs-tests/tests/functional/pam/setup.ksh | 1 + .../pam/{utilities.kshlib => utilities.kshlib.in} | 13 +++++++------ 5 files changed, 13 insertions(+), 11 deletions(-) create mode 100644 tests/zfs-tests/tests/functional/pam/.gitignore rename tests/zfs-tests/tests/functional/pam/{utilities.kshlib => utilities.kshlib.in} (75%) 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" ] } -