The canonical application of FUSE is reimplementing some existing file system
in user space. We have NTFS and exFAT in Ports as example. These FUSE daemons
follow the same policy as the mount(8) command - the mounting is only allowed
for root, unless vfs.usermount is set 1, which poses certain security risks.
There are, however, other usages of FUSE that do not involve real file systems:
- kio-fuse, a KDE module that allows arbitrary non-KDE applications to access remote files via protocols supported by KIO (sftp, ftp, smb, etc.).
- AppImage, a "one app = one file" format for program's distribution. An AppImage is a tiny runtime code coupled with a squashfs blob that contains an actual application together with all its dependencies.
- xdg-document-portal, a D-Bus service that allows sandboxed applications to access files on the host system in a controlled way.
All these examples run as an unprivileged user, yet require mounting a FUSE
file system. As a solution, the libfuse project provides the fusermount
utility, which is a SUID variant of mount(8), but constrained to mounting
fusefs only.
On FreeBSD we already have mount_fusefs(8), which gets called even when
the libfuse code runs as root. This change implements the support necessary
for mount_fusefs to act in the "fusermount" mode:
- The program is now installed with SUID bit set.
- If we're running in the "fusermount" mode, perform various checks on the mount point.
- Add the "-u" flag to allow unmounting by unprivileged user.
- The "fusermount" mode is disabled if getuid() == 0 or vfs.usermount=1.