From da7c9b228aaf31f37684e106b75262055ca440de Mon Sep 17 00:00:00 2001 From: Mattias Nissler Date: Fri, 31 Aug 2018 09:44:04 +0200 Subject: Add unprivileged option in `mount.fuse3` 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. --- lib/fuse_versionscript | 5 +++++ lib/helper.c | 18 ++++++++++++++++++ lib/meson.build | 2 +- 3 files changed, 24 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/fuse_versionscript b/lib/fuse_versionscript index e52dd86..2802bb4 100644 --- a/lib/fuse_versionscript +++ b/lib/fuse_versionscript @@ -148,6 +148,11 @@ FUSE_3.2 { fuse_loop_mt_31; } FUSE_3.1; +FUSE_3.3 { + global: + fuse_open_channel; +} FUSE_3.2; + # Local Variables: # indent-tabs-mode: t # End: diff --git a/lib/helper.c b/lib/helper.c index e1de362..5b80c6e 100644 --- a/lib/helper.c +++ b/lib/helper.c @@ -420,3 +420,21 @@ struct fuse_conn_info_opts* fuse_parse_conn_info_opts(struct fuse_args *args) } return opts; } + +int fuse_open_channel(const char *mountpoint, const char* options) +{ + struct mount_opts *opts = NULL; + int fd = -1; + const char *argv[] = { "", "-o", options }; + int argc = sizeof(argv) / sizeof(argv[0]); + struct fuse_args args = FUSE_ARGS_INIT(argc, (char**) argv); + + opts = parse_mount_opts(&args); + if (opts == NULL) + return -1; + + fd = fuse_kern_mount(mountpoint, opts); + destroy_mount_opts(opts); + + return fd; +} diff --git a/lib/meson.build b/lib/meson.build index 5dd8450..492abf7 100644 --- a/lib/meson.build +++ b/lib/meson.build @@ -32,7 +32,7 @@ libfuse = library('fuse3', libfuse_sources, version: meson.project_version(), soversion: '3', include_directories: include_dirs, dependencies: deps, install: true, link_depends: 'fuse_versionscript', - c_args: [ '-DFUSE_USE_VERSION=32', + c_args: [ '-DFUSE_USE_VERSION=33', '-DFUSERMOUNT_DIR="@0@"'.format(fusermount_path) ], link_args: ['-Wl,--version-script,' + meson.current_source_dir() + '/fuse_versionscript' ]) -- cgit v1.2.3