]> git.proxmox.com Git - mirror_zfs.git/commitdiff
tests: pam: use absolute path to module .so
authorнаб <nabijaczleweli@nabijaczleweli.xyz>
Wed, 23 Mar 2022 01:21:56 +0000 (02:21 +0100)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Sat, 2 Apr 2022 01:02:54 +0000 (18:02 -0700)
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 <behlendorf1@llnl.gov>
Reviewed-by: John Kennedy <john.kennedy@delphix.com>
Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #13259

tests/zfs-tests/tests/functional/pam/.gitignore [new file with mode: 0644]
tests/zfs-tests/tests/functional/pam/Makefile.am
tests/zfs-tests/tests/functional/pam/cleanup.ksh
tests/zfs-tests/tests/functional/pam/setup.ksh
tests/zfs-tests/tests/functional/pam/utilities.kshlib [deleted file]
tests/zfs-tests/tests/functional/pam/utilities.kshlib.in [new file with mode: 0644]

diff --git a/tests/zfs-tests/tests/functional/pam/.gitignore b/tests/zfs-tests/tests/functional/pam/.gitignore
new file mode 100644 (file)
index 0000000..ae55292
--- /dev/null
@@ -0,0 +1 @@
+/utilities.kshlib
index be881faccf3bfcbabfc9a88574f9e39bb7828340..2ae5f8ff0fa35cdd72097fa45394a6f7769a748e 100644 (file)
@@ -6,3 +6,6 @@ dist_pkgdata_SCRIPTS = \
        pam_nounmount.ksh \
        pam_short_password.ksh \
        utilities.kshlib
+
+% : %.in
+       sed 's|@pammoduledir[@]|@pammoduledir@|g' $< > $@
index e41622d771b4d5f91e397d65a7c397ea1b7666c7..8ea9c848b0abb91de4aa85d5a9a75869f44e1a1c 100755 (executable)
@@ -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
index 8ef9fbe0feedbefdab3aa7e8b19ffabd809f22c9..82370a211fcd2b302356141a4ac2e028e17fe1f3 100755 (executable)
@@ -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
deleted file mode 100644 (file)
index 6e9f900..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-#!/bin/ksh -p
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License (the "License").
-# You may not use this file except in compliance with the License.
-#
-# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
-# or http://www.opensolaris.org/os/licensing.
-# See the License for the specific language governing permissions
-# and limitations under the License.
-#
-# When distributing Covered Code, include this CDDL HEADER in each
-# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
-# If applicable, add the following below this CDDL HEADER, with the
-# fields enclosed by brackets "[]" replaced with your own identifying
-# information: Portions Copyright [yyyy] [name of copyright owner]
-#
-# CDDL HEADER END
-#
-
-. $STF_SUITE/include/libtest.shlib
-
-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 > "${pamconfig}"
-}
-
-function rmconfig {
-    log_must rm "${pamconfig}"
-}
-
-function references {
-    log_must [ "$(<"${runstatedir}/$(id -u ${username})")" = "$1" ]
-}
-
diff --git a/tests/zfs-tests/tests/functional/pam/utilities.kshlib.in b/tests/zfs-tests/tests/functional/pam/utilities.kshlib.in
new file mode 100644 (file)
index 0000000..29c6ada
--- /dev/null
@@ -0,0 +1,48 @@
+#!/bin/ksh -p
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+
+. $STF_SUITE/include/libtest.shlib
+
+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 [ "$(get_prop keystatus "$TESTPOOL/pam/${username}")" = "$1" ]
+}
+
+function genconfig {
+    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 -f "${pamconfig}"
+}
+
+function references {
+    log_must [ "$(<"${runstatedir}/$(id -u ${username})")" = "$1" ]
+}