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/<your_username>/zfs/tests/zfs-tests/bin/

... but 'testuser1' doesn't have permission to enter your home dir:

/home/<your_username>

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 <behlendorf1@llnl.gov>
Signed-off-by: Tony Hutter <hutter2@llnl.gov>
Closes #17721
This commit is contained in:
Tony Hutter 2025-09-10 14:55:58 -07:00 committed by Brian Behlendorf
parent 177e9d07d0
commit 123bfc32f3

View File

@ -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