aboutsummaryrefslogtreecommitdiffstats
path: root/lib/helper.c
diff options
context:
space:
mode:
authorMattias Nissler <mnissler@chromium.org>2018-08-31 09:44:04 +0200
committerNikolaus Rath <Nikolaus@rath.org>2018-10-09 20:36:22 +0100
commitda7c9b228aaf31f37684e106b75262055ca440de (patch)
tree548cb7e54d87af7c2cfdcde3dcb01d0f184f0315 /lib/helper.c
parent64e11073b9347fcf9c6d1eea143763ba9e946f70 (diff)
downloadlibfuse-da7c9b228aaf31f37684e106b75262055ca440de.tar.gz
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.
Diffstat (limited to 'lib/helper.c')
-rw-r--r--lib/helper.c18
1 files changed, 18 insertions, 0 deletions
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;
+}