Skip to content

Commit

Permalink
pam_zfs_key: tests: clean up the generated pam service config file
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Attila Fülöp <[email protected]>
Closes openzfs#12765
  • Loading branch information
AttilaFueloep authored and nicman23 committed Aug 22, 2022
1 parent 3e98e43 commit d3fdd87
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
1 change: 1 addition & 0 deletions tests/zfs-tests/tests/functional/pam/cleanup.ksh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

. $STF_SUITE/tests/functional/pam/utilities.kshlib

rmconfig
destroy_pool $TESTPOOL
del_user ${username}
del_group pamtestgroup
Expand Down
8 changes: 4 additions & 4 deletions tests/zfs-tests/tests/functional/pam/pam_basic.ksh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions tests/zfs-tests/tests/functional/pam/pam_nounmount.ksh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
9 changes: 8 additions & 1 deletion tests/zfs-tests/tests/functional/pam/utilities.kshlib
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,21 @@

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" ]
}

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 {
Expand Down

0 comments on commit d3fdd87

Please sign in to comment.