Jip-Hop / jailmaker

Persistent Linux 'jails' on TrueNAS SCALE to install software (docker-compose, portainer, podman, etc.) with full access to all files via bind mounts thanks to systemd-nspawn!
GNU Lesser General Public License v3.0
313 stars 31 forks source link

No dataset created when path contains spaces #122

Closed Jip-Hop closed 1 month ago

Jip-Hop commented 1 month ago

In #118 we introduced a bug in this line:

https://github.com/Jip-Hop/jailmaker/blob/9661f4ff19b44470319b7e258f562c8076405dda/jlmkr.py#L930

It does not compare as intended in case one of the parent datasets (and possible the pool name) contain spaces: The contents of /proc/mounts contain the paths with spaces encoded as discussed in https://github.com/openzfs/zfs/issues/11182.

Which results in us doing this comparison:

/mnt/tank/name\040with\040blanks/jailmaker == /mnt/tank/name with blanks/jailmaker/jails and zfs == "zfs"

The comparison fails and we end up not creating datasets, but plain directories for new jails.

@templehasfallen FYI

Reproduction steps

  1. Prepare dataset with spaces

    zfs create -o compression=lz4 -o normalization=formD -o utf8only=on -o dnodesize=auto -o relatime=on -o acltype=posixacl "tank/name with blanks" 
    zfs create -o compression=lz4 -o normalization=formD -o utf8only=on -o dnodesize=auto -o relatime=on -o acltype=posixacl "tank/name with blanks/jailmaker"
  2. Copy the jlmkr.py file in the jailmaker dir and run jlmkr.py create test.

  3. Check in the TrueNAS GUI under Datasets that there's no child dataset created under the jailmaker dataset.

Impact

The impact is relatively low as TrueNAS GUI doesn't allow creating datasets with spaces in their name. However datasets created with spaces by using the cli will show up fine in the TrueNAS GUI. So jailmaker needs to support this too.

templehasfallen commented 1 month ago

While I see the issue, I cannot reproduce the bug as the jlmkr name validation fails me before I can get to jail creation. Tried both interactive and via jlmkr.py create test jail, jlmkr.py create "test jail" while I have a dataset jailmaker/jails/test jail.

I've written a small patch, just need to figure out how to reproduce the issue first to test it.

Jip-Hop commented 1 month ago

Thanks for looking into it. It's not the jail name which contains spaces but a parent dataset which contains the jailmaker dataset. The reproduction steps are in the issue.

templehasfallen commented 1 month ago

You're right, totally didn't think of that. Update the code in the PR with tested working code, test on 23.10.2 and 24.04-RC1. Should be fixed now