vasi / squashfuse

FUSE filesystem to mount squashfs archives
Other
288 stars 66 forks source link

Fix "No such file or directory" when launched with empty fd 0. #55

Closed kevin-vigor closed 3 years ago

kevin-vigor commented 3 years ago

If any of the first three file descriptors are closed when squashfuse is launched, it will get a fd <= 2 when it opens the squashfs image file.

Unfortunately fuse_daemonize() from libfuse unconditionally clobbers fds 0-2 by dup2-ing /dev/null over them. This made the squashfuse image inaccessible and things went very poorly.

Fix by simply making sure fds 0-2 are open before calling sqfs_ll_open() so it is guaranteed to get a safe fd.

Reproduction (previously failed with "No such file or directory", now succeeds): 0<&- squashfuse_ll fs.image /tmp/crap ls /tmp/crap