RainbowHackerHorse / vzvol

vzvol is a general use ZFS zvol management tool, that handles creation, destruction, listing, and formatting with various FSes, in an easy to use single program
BSD 2-Clause "Simplified" License
31 stars 5 forks source link

FreeBSD 11.1: doesn't work when run with cwd /root (or /tmp, or /usr/local/bin) #16

Closed adriaandegroot closed 6 years ago

adriaandegroot commented 6 years ago

Congratulations on getting into the ports tree! vzvol sounds like it'd be awesome to use.

Which is a way of saying "but ..". I'll file issues here instead of FreeBSD's bugtracker, so there are fewer intermediates. Some of these problems might come down to packaging, rather than upstream -- in which case I'll re-report as a PR for olgeni.

I've installed vzvol from ports (built in poudriere locally), version 0.5.5. Running the script as root produces only an error message:

root@beastie:~ # which vzvol
/usr/local/bin/vzvol
root@beastie:~ # /usr/local/bin/vzvol
.: cannot open ../lib/shared/*: No such file or directory
adriaandegroot commented 6 years ago

.. the error message, of course, doesn't always happen when running as root. It does when I run it from root's home-dir, which is /root, and the problem is this bit of code in vzvol:

if [ -d ../lib ]; then
        vzvol_libdir=../lib
else 
        vzvol_libdir=/usr/local/lib/vzvol/lib
fi

When in /root, ../lib refers to /lib, which exists, and then the shared-functions-list inclusion goes bad. That if should probably be patched out, because it's also a security problem: you'll end up sourcing stuff from any ../lib/shared/freebsd that happens to be lying around if you're unlucky with cwd when you run the script.

RainbowHackerHorse commented 6 years ago

Good point. This was meant to ease use of vzvol when running directly from the git repo. I'll figure out what to do about this later this week. I could just force it to use a hard-coded directory and remove the if, but that breaks the "you dont have to install it, just git/clone it" part. Might make more sense to check the location of vzvol on disk, cut the binary and bin dir out of the path, and load lib.