From 307db9282309ed202f7346637d1113eb8fabbbd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Attila=20F=C3=BCl=C3=B6p?= Date: Sun, 14 Nov 2021 17:36:12 +0100 Subject: [PATCH] pam_zfs_key: tests: clean up the generated pam service config file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove the generated pam service config file `/etc/pam.d/pam_zfs_key_test` on test cleanup, since the tests shouldn't alter system state. While here, move the pam service config file name into a variable. Reviewed-by: Felix Dörre Reviewed-by: Brian Behlendorf Signed-off-by: Attila Fülöp Closes #12765 --- tests/zfs-tests/tests/functional/pam/cleanup.ksh | 1 + tests/zfs-tests/tests/functional/pam/pam_basic.ksh | 8 ++++---- tests/zfs-tests/tests/functional/pam/pam_nounmount.ksh | 8 ++++---- tests/zfs-tests/tests/functional/pam/utilities.kshlib | 9 ++++++++- 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/tests/zfs-tests/tests/functional/pam/cleanup.ksh b/tests/zfs-tests/tests/functional/pam/cleanup.ksh index 62131c6d68a7..e41622d771b4 100755 --- a/tests/zfs-tests/tests/functional/pam/cleanup.ksh +++ b/tests/zfs-tests/tests/functional/pam/cleanup.ksh @@ -22,6 +22,7 @@ . $STF_SUITE/tests/functional/pam/utilities.kshlib +rmconfig destroy_pool $TESTPOOL del_user ${username} del_group pamtestgroup diff --git a/tests/zfs-tests/tests/functional/pam/pam_basic.ksh b/tests/zfs-tests/tests/functional/pam/pam_basic.ksh index 96ac59453694..f146a6e5f157 100755 --- a/tests/zfs-tests/tests/functional/pam/pam_basic.ksh +++ b/tests/zfs-tests/tests/functional/pam/pam_basic.ksh @@ -26,22 +26,22 @@ log_mustnot ismounted "$TESTPOOL/pam/${username}" keystatus unavailable genconfig "homes=$TESTPOOL/pam runstatedir=${runstatedir}" -echo "testpass" | pamtester pam_zfs_key_test ${username} open_session +echo "testpass" | pamtester ${pamservice} ${username} open_session references 1 log_must ismounted "$TESTPOOL/pam/${username}" keystatus available -echo "testpass" | pamtester pam_zfs_key_test ${username} open_session +echo "testpass" | pamtester ${pamservice} ${username} open_session references 2 log_must ismounted "$TESTPOOL/pam/${username}" keystatus available -log_must pamtester pam_zfs_key_test ${username} close_session +log_must pamtester ${pamservice} ${username} close_session references 1 log_must ismounted "$TESTPOOL/pam/${username}" keystatus available -log_must pamtester pam_zfs_key_test ${username} close_session +log_must pamtester ${pamservice} ${username} close_session references 0 log_mustnot ismounted "$TESTPOOL/pam/${username}" keystatus unavailable diff --git a/tests/zfs-tests/tests/functional/pam/pam_nounmount.ksh b/tests/zfs-tests/tests/functional/pam/pam_nounmount.ksh index 8179f398dfaf..eb9976f2f776 100755 --- a/tests/zfs-tests/tests/functional/pam/pam_nounmount.ksh +++ b/tests/zfs-tests/tests/functional/pam/pam_nounmount.ksh @@ -26,22 +26,22 @@ log_mustnot ismounted "$TESTPOOL/pam/${username}" keystatus unavailable genconfig "homes=$TESTPOOL/pam runstatedir=${runstatedir} nounmount" -echo "testpass" | pamtester pam_zfs_key_test ${username} open_session +echo "testpass" | pamtester ${pamservice} ${username} open_session references 1 log_must ismounted "$TESTPOOL/pam/${username}" keystatus available -echo "testpass" | pamtester pam_zfs_key_test ${username} open_session +echo "testpass" | pamtester ${pamservice} ${username} open_session references 2 keystatus available log_must ismounted "$TESTPOOL/pam/${username}" -log_must pamtester pam_zfs_key_test ${username} close_session +log_must pamtester ${pamservice} ${username} close_session references 1 keystatus available log_must ismounted "$TESTPOOL/pam/${username}" -log_must pamtester pam_zfs_key_test ${username} close_session +log_must pamtester ${pamservice} ${username} close_session references 0 keystatus available log_must ismounted "$TESTPOOL/pam/${username}" diff --git a/tests/zfs-tests/tests/functional/pam/utilities.kshlib b/tests/zfs-tests/tests/functional/pam/utilities.kshlib index ef80f5a4f12e..d328034300b1 100644 --- a/tests/zfs-tests/tests/functional/pam/utilities.kshlib +++ b/tests/zfs-tests/tests/functional/pam/utilities.kshlib @@ -24,6 +24,9 @@ username="pamtestuser" runstatedir="${TESTDIR}_run" +pamservice="pam_zfs_key_test" +pamconfig="/etc/pam.d/${pamservice}" + function keystatus { log_must [ "$(zfs list -Ho keystatus "$TESTPOOL/pam/${username}")" == "$1" ] } @@ -31,7 +34,11 @@ function keystatus { 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 > /etc/pam.d/pam_zfs_key_test + done > "${pamconfig}" +} + +function rmconfig { + log_must rm "${pamconfig}" } function references {