Re-apply path sanitizer, as mount(8) still mangles it
Prior to util-linux 2.36.2, if a file or directory in the current working directory was named 'dataset' then mount(8) would prepend the current working directory to the dataset. Eventually, we should be able to drop this workaround. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Sterling Jensen <sterlingjensen@users.noreply.github.com> Closes #11295 Closes #11462
This commit is contained in:
parent
f8c4d63a26
commit
03f036cbcc
|
@ -50,6 +50,21 @@ libzfs_handle_t *g_zfs;
|
|||
static void
|
||||
parse_dataset(const char *target, char **dataset)
|
||||
{
|
||||
/*
|
||||
* Prior to util-linux 2.36.2, if a file or directory in the
|
||||
* current working directory was named 'dataset' then mount(8)
|
||||
* would prepend the current working directory to the dataset.
|
||||
* Check for it and strip the prepended path when it is added.
|
||||
*/
|
||||
char cwd[PATH_MAX];
|
||||
if (getcwd(cwd, PATH_MAX) == NULL) {
|
||||
perror("getcwd");
|
||||
return;
|
||||
}
|
||||
int len = strlen(cwd);
|
||||
if (strncmp(cwd, target, len) == 0)
|
||||
target += len;
|
||||
|
||||
/* Assume pool/dataset is more likely */
|
||||
strlcpy(*dataset, target, PATH_MAX);
|
||||
|
||||
|
|
|
@ -32,7 +32,9 @@ typeset -r fs=$TESTPOOL/$TESTFS
|
|||
function cleanup
|
||||
{
|
||||
cd $STF_SUITE
|
||||
[[ -d $TESTDIR/$$ ]] && (rm -rf $TESTDIR/$$ || log_fail)
|
||||
if [[ -d $TESTDIR/$$ ]]; then
|
||||
log_must rm -rf $TESTDIR/$$
|
||||
fi
|
||||
mounted && zfs $mountcmd $TESTPOOL
|
||||
return 0
|
||||
}
|
||||
|
@ -50,13 +52,25 @@ force_unmount $fs
|
|||
|
||||
log_note "Verify mount(8) does not canonicalize before calling helper"
|
||||
# Canonicalization is confused by files in PWD matching [device|mountpoint]
|
||||
mkdir -p $TESTDIR/$$/$TESTPOOL && cd $TESTDIR/$$ || log_fail
|
||||
log_must mkdir -p $TESTDIR/$$/$TESTPOOL
|
||||
log_must cd $TESTDIR/$$
|
||||
# The env flag directs zfs to exec /bin/mount, which then calls helper
|
||||
log_must eval ZFS_MOUNT_HELPER=1 zfs $mountcmd -v $TESTPOOL
|
||||
# mount (2.35.2) still suffers from a cosmetic PWD prefix bug
|
||||
log_must mounted $TESTPOOL
|
||||
force_unmount $TESTPOOL
|
||||
|
||||
log_note "Verify CWD prefix filter <dataset> <path>"
|
||||
log_must cd /
|
||||
log_must zfs set mountpoint=legacy $TESTPOOL
|
||||
log_must mkdir -p $mntpoint
|
||||
log_must mount -t zfs $TESTPOOL $mntpoint
|
||||
log_must ismounted $TESTPOOL
|
||||
log_must umount $mntpoint
|
||||
log_must zfs set mountpoint=$mntpoint $TESTPOOL
|
||||
log_must cd -
|
||||
force_unmount $TESTPOOL
|
||||
|
||||
log_note "Verify '-f <dataset> <path>' fakemount"
|
||||
log_must $helper -f $fs $mntpoint
|
||||
log_mustnot ismounted $fs
|
||||
|
@ -75,4 +89,4 @@ log_note "Verify '<device> <path>'"
|
|||
log_must $helper ${vdevs[0]} $mntpoint
|
||||
log_must mounted $mntpoint
|
||||
|
||||
log_pass "zfs mount helper correctly handles both device and pool strings"
|
||||
log_pass "zfs mount helper correctly handles both device and pool strings"
|
||||
|
|
Loading…
Reference in New Issue