From 7297044ada625da583211f0a574410cddb4f7d8d Mon Sep 17 00:00:00 2001 From: Matthias Görgens Date: Wed, 12 Apr 2023 15:39:32 +0800 Subject: Fuse mount: make auto_unmount compatible with suid/dev mount options (#762) * Fuse mount: make auto_unmount compatible with suid/dev mount options > When you run as root, fuse normally does not call fusermount but uses > the mount system call directly. When you specify auto_unmount, it goes > through fusermount instead. However, fusermount is a setuid binary that > is normally called by regular users, so it cannot in general accept suid > or dev options. In this patch, we split up how fuse mounts as root when `auto_unmount` is specified. First, we mount using system calls directly, then we reach out to fusermount to set up auto_unmount only (with no actual mounting done in fusermount). Fixes: #148 --- example/passthrough_ll.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'example/passthrough_ll.c') diff --git a/example/passthrough_ll.c b/example/passthrough_ll.c index 8b2eb4b..070cef1 100644 --- a/example/passthrough_ll.c +++ b/example/passthrough_ll.c @@ -89,7 +89,7 @@ struct lo_data { int writeback; int flock; int xattr; - const char *source; + char *source; double timeout; int cache; int timeout_set; @@ -1240,7 +1240,11 @@ int main(int argc, char *argv[]) } } else { - lo.source = "/"; + lo.source = strdup("/"); + if(!lo.source) { + fuse_log(FUSE_LOG_ERR, "fuse: memory allocation failed\n"); + exit(1); + } } if (!lo.timeout_set) { switch (lo.cache) { @@ -1302,5 +1306,6 @@ err_out1: if (lo.root.fd >= 0) close(lo.root.fd); + free(lo.source); return ret ? 1 : 0; } -- cgit v1.2.3