diff options
author | Attila Fülöp <attila@fueloep.org> | 2021-11-14 17:36:12 +0100 |
---|---|---|
committer | Brian Behlendorf <behlendorf1@llnl.gov> | 2021-11-30 11:51:45 -0800 |
commit | 307db9282309ed202f7346637d1113eb8fabbbd7 (patch) | |
tree | eb0d4d9279def3bc2cc5eca46b846f7916276be9 | |
parent | b5c16861e9fa91871540a101e92013e05182fc2f (diff) |
pam_zfs_key: tests: clean up the generated pam service config file
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 <felix@dogcraft.de>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Attila Fülöp <attila@fueloep.org>
Closes #12765
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 62131c6d6..e41622d77 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 96ac59453..f146a6e5f 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 8179f398d..eb9976f2f 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 ef80f5a4f..d32803430 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 { |