From 7f7c58389ec2474d56e50aea2db3b201409e8fe3 Mon Sep 17 00:00:00 2001 From: Tony Hutter Date: Wed, 10 Sep 2025 14:55:58 -0700 Subject: [PATCH] ZTS: Print warning if running ZTS user_run test locally Print a warning if you're attempting to run a ZTS test that calls 'user_run', and the ephemeral user doesn't have permissions to access the test binaries. This can happen if you're running ZTS from a local git repo. In that case the test user (say, 'testuser1') may need access to the ZTS binaries in: /home//zfs/tests/zfs-tests/bin/ ... but 'testuser1' doesn't have permission to enter your home dir: /home/ The warning will help alert users to what is going on. This will not be an issue when ZTS is actually installed on the system (via 'make install' or from packages). Reviewed-by: Brian Behlendorf Signed-off-by: Tony Hutter Closes #17721 --- tests/zfs-tests/include/libtest.shlib | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/zfs-tests/include/libtest.shlib b/tests/zfs-tests/include/libtest.shlib index 23e89599c..a9a4a90bc 100644 --- a/tests/zfs-tests/include/libtest.shlib +++ b/tests/zfs-tests/include/libtest.shlib @@ -2881,6 +2881,28 @@ function user_run log_note "user: $user" log_note "cmd: $*" + if ! sudo -Eu $user test -x $PATH ; then + log_note "-------------------------------------------------" + log_note "Warning: $user doesn't have permissions on $PATH" + log_note "" + log_note "This usually happens when you're running ZTS locally" + log_note "from inside the ZFS source dir, and are attempting to" + log_note "run a test that calls user_run. The ephemeral user" + log_note "($user) that ZTS is creating does not have permission" + log_note "to traverse to $PATH, or the binaries in $PATH are" + log_note "not the right permissions." + log_note "" + log_note "To get around this, copy your ZFS source directory" + log_note "to a world-accessible location (like /tmp), and " + log_note "change the permissions on your ZFS source dir " + log_note "to allow access." + log_note "" + log_note "Also, verify that /dev/zfs is RW for others:" + log_note "" + log_note " sudo chmod o+rw /dev/zfs" + log_note "-------------------------------------------------" + fi + typeset out=$TEST_BASE_DIR/out typeset err=$TEST_BASE_DIR/err