Nikolaus Rath | dfbfd13 | 2015-12-20 13:52:30 -0800 | [diff] [blame] | 1 | libfuse |
| 2 | ======= |
| 3 | |
| 4 | About |
| 5 | ----- |
| 6 | |
| 7 | FUSE (Filesystem in Userspace) is an interface for userspace programs |
| 8 | to export a filesystem to the Linux kernel. The FUSE project consists |
| 9 | of two components: the *fuse* kernel module (maintained in the regular |
| 10 | kernel repositories) and the *libfuse* userspace library (maintained |
| 11 | in this repository). libfuse provides the reference implementation |
| 12 | for communicating with the FUSE kernel module. |
| 13 | |
| 14 | A FUSE file system is typically implemented as a standalone |
| 15 | application that links with libfuse. libfuse provides functions to |
| 16 | mount the file system, unmount it, read requests from the kernel, and |
| 17 | send responses back. libfuse offers two APIs: a "high-level", |
| 18 | synchronous API, and a "low-level" asynchronous API. In both cases, |
| 19 | incoming requests from the kernel are passed to the main program using |
| 20 | callbacks. When using the high-level API, the callbacks may work with |
| 21 | file names and paths instead of inodes, and processing of a request |
| 22 | finishes when the callback function returns. When using the low-level |
| 23 | API, the callbacks must work with inodes and responses must be sent |
| 24 | explicitly using a separate set of API functions. |
| 25 | |
| 26 | |
Nikolaus Rath | d45fec1 | 2019-04-29 11:55:56 -0700 | [diff] [blame] | 27 | Development Status |
| 28 | ------------------ |
| 29 | |
| 30 | libfuse is shipped by all major Linux distributions and has been in |
| 31 | production use across a wide range of systems for many years. However, |
| 32 | at present libfuse does not have any active, regular contributors. The |
| 33 | current maintainer continues to apply pull requests and makes regular |
| 34 | releases, but unfortunately has no capacity to do any development |
| 35 | beyond addressing high-impact issues. When reporting bugs, please |
| 36 | understand that unless you are including a pull request or are |
| 37 | reporting a critical issue, you will probably not get a response. If |
John Baber-Lucero | e6df67c | 2021-01-12 05:41:35 -0500 | [diff] [blame] | 38 | you are using libfuse, please consider contributing to the project. |
Nikolaus Rath | d45fec1 | 2019-04-29 11:55:56 -0700 | [diff] [blame] | 39 | |
| 40 | |
Nikolaus Rath | 8d6b758 | 2017-06-06 09:31:50 -0400 | [diff] [blame] | 41 | Supported Platforms |
| 42 | ------------------- |
| 43 | |
| 44 | * Linux (fully) |
| 45 | * BSD (mostly/best-effort) |
| 46 | * For OS-X, please use [OSXFUSE](https://osxfuse.github.io/) |
| 47 | |
| 48 | |
Nikolaus Rath | dfbfd13 | 2015-12-20 13:52:30 -0800 | [diff] [blame] | 49 | Installation |
| 50 | ------------ |
| 51 | |
Nikolaus Rath | 579c3b0 | 2015-12-21 19:17:47 -0800 | [diff] [blame] | 52 | You can download libfuse from |
John Baber-Lucero | e6df67c | 2021-01-12 05:41:35 -0500 | [diff] [blame] | 53 | https://github.com/libfuse/libfuse/releases. To build and install, you |
| 54 | must use [Meson](http://mesonbuild.com/) and |
Nikolaus Rath | e469e1f | 2018-10-16 06:06:19 -0700 | [diff] [blame] | 55 | [Ninja](https://ninja-build.org). After extracting the libfuse |
| 56 | tarball, create a (temporary) build directory and run Meson: |
Nikolaus Rath | 579c3b0 | 2015-12-21 19:17:47 -0800 | [diff] [blame] | 57 | |
Nikolaus Rath | d41f62c | 2017-09-12 14:01:04 +0100 | [diff] [blame] | 58 | $ mkdir build; cd build |
Nikolaus Rath | 9f96db7 | 2017-01-05 09:37:00 -0800 | [diff] [blame] | 59 | $ meson .. |
Nikolaus Rath | dfbfd13 | 2015-12-20 13:52:30 -0800 | [diff] [blame] | 60 | |
Nikolaus Rath | 9f96db7 | 2017-01-05 09:37:00 -0800 | [diff] [blame] | 61 | Normally, the default build options will work fine. If you |
Craig Chi | 032db1a | 2020-07-03 04:28:05 -0700 | [diff] [blame] | 62 | nevertheless want to adjust them, you can do so with the |
| 63 | *meson configure* command: |
Nikolaus Rath | 59e58de | 2016-03-29 15:30:57 -0700 | [diff] [blame] | 64 | |
Craig Chi | 032db1a | 2020-07-03 04:28:05 -0700 | [diff] [blame] | 65 | $ meson configure # list options |
| 66 | $ meson configure -D disable-mtab=true # set an option |
Nikolaus Rath | 59e58de | 2016-03-29 15:30:57 -0700 | [diff] [blame] | 67 | |
John Baber-Lucero | e6df67c | 2021-01-12 05:41:35 -0500 | [diff] [blame] | 68 | To build, test, and install libfuse, you then use Ninja: |
Nikolaus Rath | dfbfd13 | 2015-12-20 13:52:30 -0800 | [diff] [blame] | 69 | |
Nikolaus Rath | 9f96db7 | 2017-01-05 09:37:00 -0800 | [diff] [blame] | 70 | $ ninja |
Nikolaus Rath | e372d61 | 2017-04-10 17:08:58 -0700 | [diff] [blame] | 71 | $ sudo python3 -m pytest test/ |
Nikolaus Rath | 9f96db7 | 2017-01-05 09:37:00 -0800 | [diff] [blame] | 72 | $ sudo ninja install |
| 73 | |
| 74 | Running the tests requires the [py.test](http://www.pytest.org/) |
| 75 | Python module. Instead of running the tests as root, the majority of |
Nikolaus Rath | e372d61 | 2017-04-10 17:08:58 -0700 | [diff] [blame] | 76 | tests can also be run as a regular user if *util/fusermount3* is made |
| 77 | setuid root first: |
Nikolaus Rath | 9f96db7 | 2017-01-05 09:37:00 -0800 | [diff] [blame] | 78 | |
| 79 | $ sudo chown root:root util/fusermount3 |
| 80 | $ sudo chmod 4755 util/fusermount3 |
Nikolaus Rath | e372d61 | 2017-04-10 17:08:58 -0700 | [diff] [blame] | 81 | $ python3 -m pytest test/ |
Nikolaus Rath | 9f96db7 | 2017-01-05 09:37:00 -0800 | [diff] [blame] | 82 | |
Nikolaus Rath | dfbfd13 | 2015-12-20 13:52:30 -0800 | [diff] [blame] | 83 | Security implications |
| 84 | --------------------- |
| 85 | |
Nikolaus Rath | 9f96db7 | 2017-01-05 09:37:00 -0800 | [diff] [blame] | 86 | The *fusermount3* program is installed setuid root. This is done to |
| 87 | allow normal users to mount their own filesystem implementations. |
Nikolaus Rath | dfbfd13 | 2015-12-20 13:52:30 -0800 | [diff] [blame] | 88 | |
Nikolaus Rath | 9e3147f | 2017-01-12 10:10:34 -0800 | [diff] [blame] | 89 | To limit the harm that malicious users can do this way, *fusermount3* |
| 90 | enforces the following limitations: |
Nikolaus Rath | dfbfd13 | 2015-12-20 13:52:30 -0800 | [diff] [blame] | 91 | |
Emily Herbert | 74596e2 | 2019-10-24 17:46:19 -0400 | [diff] [blame] | 92 | - The user can only mount on a mountpoint for which they have write |
Nikolaus Rath | dfbfd13 | 2015-12-20 13:52:30 -0800 | [diff] [blame] | 93 | permission |
| 94 | |
Nikolaus Rath | 9e3147f | 2017-01-12 10:10:34 -0800 | [diff] [blame] | 95 | - The mountpoint must not be a sticky directory which isn't owned by |
| 96 | the user (like /tmp usually is) |
Nikolaus Rath | dfbfd13 | 2015-12-20 13:52:30 -0800 | [diff] [blame] | 97 | |
Nikolaus Rath | 43138fb | 2016-02-01 09:08:26 -0800 | [diff] [blame] | 98 | - No other user (including root) can access the contents of the |
| 99 | mounted filesystem (though this can be relaxed by allowing the use |
Nikolaus Rath | 9e3147f | 2017-01-12 10:10:34 -0800 | [diff] [blame] | 100 | of the *allow_other* and *allow_root* mount options in |
| 101 | */etc/fuse.conf*) |
Nikolaus Rath | 43138fb | 2016-02-01 09:08:26 -0800 | [diff] [blame] | 102 | |
Nikolaus Rath | dfbfd13 | 2015-12-20 13:52:30 -0800 | [diff] [blame] | 103 | |
Nikolaus Rath | 9e3147f | 2017-01-12 10:10:34 -0800 | [diff] [blame] | 104 | If you intend to use the *allow_other* mount options, be aware that |
| 105 | FUSE has an unresolved [security |
| 106 | bug](https://github.com/libfuse/libfuse/issues/15): if the |
| 107 | *default_permissions* mount option is not used, the results of the |
| 108 | first permission check performed by the file system for a directory |
| 109 | entry will be re-used for subsequent accesses as long as the inode of |
| 110 | the accessed entry is present in the kernel cache - even if the |
| 111 | permissions have since changed, and even if the subsequent access is |
| 112 | made by a different user. This is of little concern if the filesystem |
| 113 | is accessible only to the mounting user (which has full access to the |
| 114 | filesystem anyway), but becomes a security issue when other users are |
| 115 | allowed to access the filesystem (since they can exploit this to |
| 116 | perform operations on the filesystem that they do not actually have |
| 117 | permissions for). |
| 118 | |
| 119 | This bug needs to be fixed in the Linux kernel and has been known |
| 120 | since 2006 but unfortunately no fix has been applied yet. If you |
| 121 | depend on correct permission handling for FUSE file systems, the only |
| 122 | workaround is to use `default_permissions` (which does not currently |
| 123 | support ACLs), or to completely disable caching of directory entry |
| 124 | attributes. |
| 125 | |
Nikolaus Rath | dfbfd13 | 2015-12-20 13:52:30 -0800 | [diff] [blame] | 126 | Building your own filesystem |
| 127 | ------------------------------ |
| 128 | |
winndows | 717c8b8 | 2020-07-03 19:29:48 +0800 | [diff] [blame] | 129 | FUSE comes with several example file systems in the `example` |
Nikolaus Rath | 1c08ee9 | 2016-10-16 15:05:57 -0700 | [diff] [blame] | 130 | directory. For example, the *passthrough* examples mirror the contents |
| 131 | of the root directory under the mountpoint. Start from there and adapt |
Nikolaus Rath | dfbfd13 | 2015-12-20 13:52:30 -0800 | [diff] [blame] | 132 | the code! |
| 133 | |
| 134 | The documentation of the API functions and necessary callbacks is |
| 135 | mostly contained in the files `include/fuse.h` (for the high-level |
Nikolaus Rath | a1e8fc9 | 2016-01-28 18:00:24 -0800 | [diff] [blame] | 136 | API) and `include/fuse_lowlevel.h` (for the low-level API). An |
| 137 | autogenerated html version of the API is available in the `doc/html` |
| 138 | directory and at http://libfuse.github.io/doxygen. |
Nikolaus Rath | dfbfd13 | 2015-12-20 13:52:30 -0800 | [diff] [blame] | 139 | |
| 140 | |
| 141 | Getting Help |
| 142 | ------------ |
| 143 | |
| 144 | If you need help, please ask on the <fuse-devel@lists.sourceforge.net> |
| 145 | mailing list (subscribe at |
| 146 | https://lists.sourceforge.net/lists/listinfo/fuse-devel). |
| 147 | |
| 148 | Please report any bugs on the GitHub issue tracker at |
Nikolaus Rath | 579c3b0 | 2015-12-21 19:17:47 -0800 | [diff] [blame] | 149 | https://github.com/libfuse/libfuse/issues. |