aboutsummaryrefslogtreecommitdiffstats
path: root/lib
AgeCommit message (Collapse)AuthorLines
2018-10-09Add unprivileged option in `mount.fuse3`Mattias Nissler-1/+24
The unprivileged option allows to run the FUSE file system process without privileges by dropping capabilities and preventing them from being re-acquired via setuid / fscaps etc. To accomplish this, mount.fuse sets up the `/dev/fuse` file descriptor and mount itself and passes the file descriptor via the `/dev/fd/%u` mountpoint syntax to the FUSE file system.
2018-10-09Allow passing `/dev/fuse` file descriptor from parent processMattias Nissler-4/+44
This adds support for a mode of operation in which a privileged parent process opens `/dev/fuse` and takes care of mounting. The FUSE file system daemon can then run as an unprivileged child that merely processes requests on the FUSE file descriptor, which get passed using the special `/dev/fd/%u` syntax for the mountpoint parameter. The main benefit is that no privileged operations need to be performed by the FUSE file system daemon itself directly or indirectly, so the FUSE process can run with fully unprivileged and mechanisms like securebits and no_new_privs can be used to prevent subprocesses from re-acquiring privilege via setuid, fscaps, etc. This reduces risk in case the FUSE file system gets exploited by malicious file system data. Below is an example that illustrates this. Note that I'm using shell for presentation purposes, the expectation is that the parent process will implement the equivalent of the `mount -i` and `capsh` commands. ``` \# example/hello can mount successfully with privilege $ sudo sh -c "LD_LIBRARY_PATH=build/lib ./example/hello /mnt/tmp" $ sudo cat /mnt/tmp/hello Hello World! $ sudo umount /mnt/tmp \# example/hello fails to mount without privilege $ sudo capsh --drop=all --secbits=0x2f -- -c 'LD_LIBRARY_PATH=build/lib ./example/hello -f /mnt/tmp' fusermount3: mount failed: Operation not permitted \# Passing FUSE file descriptor via /dev/fd/%u allows example/hello to work without privilege $ sudo sh -c ' exec 17<>/dev/fuse mount -i -o nodev,nosuid,noexec,fd=17,rootmode=40000,user_id=0,group_id=0 -t fuse hello /mnt/tmp capsh --drop=all --secbits=0x2f -- -c "LD_LIBRARY_PATH=build/lib example/hello /dev/fd/17" ' $ sudo cat /mnt/tmp/hello Hello World! $ sudo umount /mnt/tmp ```
2018-09-20Don't enable adaptive readdirplus unless fs has readdir() handler.Nikolaus Rath-1/+2
2018-09-17Do not include struct fuse_buf in struct fuse_workerNikolaus Rath-10/+9
This is only used in fuse_do_work(), so we can put it on the stack.
2018-08-29return different non-zero error codes (#290)Oded Arbel-6/+6
Return different error codes from fuse_main()
2018-08-26Fix memory leak of FUSE modulesRostislav-3/+23
2018-08-26Fix invalid free of memory pointer in 'struct fuse_buf'Rostislav-1/+2
2018-08-25Make meson build scripts subprojects friendlyMartin Blanchard-1/+3
Multiple meson build scripts improvements including: * Bump meson requirement to 0.40.1 (0.40 already required) * Declare a dependency object for main library * Stop using add_global_arguments() * Various minor style fixes
2018-07-25Remove unused member of 'struct fuse_dh'Rostislav Skudnov-1/+0
2018-07-21Fix readdir() bug when a non-zero offset is specified in filler (#269)Rostislav-11/+15
The bug occurs when a filesystem client reads a directory until the end, seeks using seekdir() to some valid non-zero position and calls readdir(). A valid 'struct dirent *' is expected, but NULL is returned instead. Pseudocode demonstrating the bug: DIR *dp = opendir("some_dir"); struct dirent *de = readdir(dp); /* Get offset of the second entry */ long offset = telldir(dp); /* Read directory until the end */ while (de) de = readdir(de); seekdir(dp, offset); de = readdir(dp); /* de must contain the second entry, but NULL is returned instead */ The reason of the bug is that when the end of directory is reached, the kernel calls FUSE_READDIR op with an offset at the end of directory, so the filesystem's .readdir callback never calls the filler function, and we end up with dh->filled set to 1. After seekdir(), FUSE_READDIR is called again with a new offset, but this time the filesystem's .readdir callback is never called, and an empty reply is returned. Fix by setting dh->filled to 1 only when zero offsets are given to filler function.
2018-05-18rename: perform user mode dir loop check when not done in kernelBill Zissimooulos-10/+12
Fix conditionals as per maintainer's request.
2018-05-18rename: perform user mode dir loop check when not done in kernelBill Zissimooulos-3/+59
Linux performs the dir loop check (rename(a, a/b/c) or rename(a/b/c, a), etc.) in kernel. Unfortunately other systems do not perform this check (e.g. FreeBSD). This results in a deadlock in get_path2, because libfuse did not expect to handle such cases. We add a check_dir_loop function that performs the dir loop check in user mode and enable it on systems that need it.
2018-04-13Drop unneeded void cast for actually used local variableTomohiro Kusumi-1/+0
`int sig` is acutually used, so `(void) sig;` is unneeded.
2018-02-09Fix uninitialised read in fuse_new_30() (#231) (#234)Ashley Pittman-0/+3
Ensure that conf is always zero before it's read from to prevent sporadic failure at startup if higher layers were build against version 3.0 Signed-off-by: Ashley Pittman <ashley.m.pittman@intel.com>
2017-11-27Spelling (#223)Josh Soref-2/+2
Fix spelling errors
2017-11-03Backed out d92bf83Nikolaus Rath-1/+1
This change is bogus. fuse_module_factory_t is already a pointer type. Additionally, if dlsym returns NULL, then you will be dereferencing it causing a segfault. In my testing, a segfault will happen even if dlsym returns successfully. Thanks to Michael Theall for spotting!
2017-09-27Adding pointer dereferencing after calling dlsym()Sangwoo Moon-1/+1
dlsym() resolves the location of the loaded symbol, therefore dlsym() returns the type (fuse_module_factory_t *), not (fuse_module_factory_t). Added pinter dereferencing to correctly refer the factory function.
2017-09-25fuse_lib_ioctl(): don't call memcpy with NULL argumentNikolaus Rath-1/+1
This was detected by using clang's undefined behavior sanitizer, but didn't seem to cause problems in practice.
2017-09-25Link with -lrt to support ancient libcNikolaus Rath-1/+4
Fixes: #207.
2017-09-19Correctly define fusermount3 path.Nikolaus Rath-1/+1
2017-09-19Make *_loop_mt() available in version 3.0 againNikolaus Rath-2/+2
The old versions of these symbols were defined with version tag FUSE_3.0, so this is what we have to use in the .symver directive.
2017-09-19Fix versioned symbols in version scriptNikolaus Rath-1/+4
According to "How to Write Shared Libraries" by Ulrich Drepper (https://www.akkadia.org/drepper/dsohowto.pdf), the version script should contain the exported name of the versioned symbol once in each tag for which it has been defined by .symver.
2017-09-19Don't use external symbol names in internal filesNikolaus Rath-7/+6
The fuse_session_loop_mt() and fuse_loop_mt() symbols are only visible when linking against the shared object. The code in lib/, however, is compiled *into* the shared object and should thus use the internal names of these functions. Surprisingly enough, the code still worked before - but only when link time optimization was disabled. Unfortunately, we still can't compile with LTO because it seems that enabling LTO somehow makes the tagged symbols vanish. Without lto, we have: $ nm lib/libfuse3.so | grep fuse_new 0000000000011070 T fuse_new_30 0000000000010a00 t fuse_new_31 0000000000011070 T fuse_new@FUSE_3.0 0000000000010a00 T fuse_new@@FUSE_3.1 and with LTO: $ nm lib/libfuse3.so | grep fuse_new 0000000000019a70 T fuse_new_30 0000000000019270 t fuse_new_31 See also issue #198.
2017-09-11fuse_kern_unmount(): close fd before calling umountNikolaus Rath-1/+1
This is what the Linux version does, and it fixes a timeout under FreeBSD when the kernel sends a FUSE_DESTROY request that is never answered.
2017-08-25do_init(): print missing capabilities if there are any.Nikolaus Rath-1/+2
2017-08-24Dropped support for building with autotoolsNikolaus Rath-43/+0
It's just too much pain to keep it working.
2017-08-24Add idle_threads mount option.Joseph Dodge-12/+58
2017-08-24Allow inode cache invalidation in high-level APISławek Rudnicki-0/+41
We re-introduce the functionality of invalidating the caches for an inode specified by path by adding a new routine fuse_invalidate_path. This is useful for network-based file systems which use the high-level API, enabling them to notify the kernel about external changes. This is a revival of Miklos Szeredi's original code for the fuse_invalidate routine.
2017-08-23fuse_loop_mt(): on error, return errno rather than -1.Nikolaus Rath-1/+1
2017-08-23fuse_loop(): don't return non-zero if there was no errorNikolaus Rath-0/+4
2017-08-22Document and unify error codes of fuse_lowlevel_notify_*Nikolaus Rath-3/+9
2017-08-22Fix two compiler warnings.Nikolaus Rath-1/+1
2017-08-22Allow building without iconv.Nikolaus Rath-1/+7
cfg.has('HAVE_ICONV') was always true.
2017-08-14directly call fuse_new_31() instead of fuse_new() internallyuserwithuid-3/+4
this fixes building with lto, which failed since commit 503e32d01e4db00e90d7acfd81ab05386559069f
2017-08-11fuse_lib_init(): don't set FUSE_CAP_EXPORT_SUPPORT unconditionallyNikolaus Rath-1/+2
FreeBSD kernel does not support this.
2017-08-11fuse_kern_unmount(): fix variable type.Nikolaus Rath-1/+2
2017-08-11Fix unused variable warnings under FreeBSD.Nikolaus Rath-2/+2
2017-08-07Fix support for FUSE_POSIX_ACLMarcin Sulikowski-0/+2
The kernel may set the FUSE_POSIX_ACL flag in the FUSE_INIT request to notify the userspace daemon that the OS does support POSIX ACLs for FUSE file systems. If the filesystem implementation wants to enable POSIX ACLs, it has to reply with the FUSE_POSIX_ACL flag set. However, the reply to the kernel never includes this flag, even if the implementation expresses the need by setting the FUSE_CAP_POSIX_ACL flag in the fuse_conn_info::want variable passed to its init callback. We modify the library to handle requests for FUSE_CAP_POSIX_ACL correctly, i.e., set the FUSE_POSIX_ACL flag in the FUSE_INIT reply to the kernel. Signed-off-by: Marcin Sulikowski <marcin.sulikowski@editshare.com>
2017-08-06Released 3.1.1Nikolaus Rath-1/+1
2017-08-03Simplify and fix FreeBSD fsname handlingNikolaus Rath-29/+10
This should simplify the code a lot. It also corrects a bug in that the (former) add_default_fsname() function actually set the -osubtype option.
2017-08-03Simply #ifdefsNikolaus Rath-53/+0
mount_bsd.c is only used when compiling for *BSD, and FreeBSD is the only BSD that supports FUSE. So there really is no need to check if this file is compiled under FreeBSD.
2017-08-03FreeBSD: supprt fsname= optionBaptiste Daroussin-0/+30
2017-08-03FreeBSD: use unmount(2) and add missing FreeBSD mount optionBaptiste Daroussin-0/+12
2017-08-01Fix compiler warnings of gcc-5.4.xBanglang-1/+1
Signed-off-by: Banglang <banglang.huang@foxmail.com>
2017-07-13Only declare fuse_new_30() when FUSE_USE_VERSION == 30Nikolaus Rath-24/+26
This function shouldn't be called when using a newer fuse version, so we should not define it in that case.
2017-07-13fuse_new_30(): call fuse_new_31(), not fuse_new()Nikolaus Rath-1/+1
I believe this function call is resolved by the compiler, not the linker, so this seems safer. Thanks to Chris Clayton for spotting this.
2017-07-08Fixup symbol versioning for GCC 4.xNikolaus Rath-4/+7
GCC 4.8 doesn't like to rename fuse_new_30 to fuse_new, if we also define an implementation for fuse_new.
2017-07-08Added public fuse_lib_help(), bumped minor versionNikolaus Rath-53/+111
2017-07-08Fixed description of struct fuse_conn_info->time_granNikolaus Rath-1/+2
At least on Linux kernel 4.9, a value of zero gives more than 1-sec accuracy.
2017-07-07Don't use emacs' python-mode for meson filesNikolaus Rath-3/+0
There is a proper meson-mode now.