From 9d833025d9229e43b1e28e50a9f37ae9db141047 Mon Sep 17 00:00:00 2001
From: Jeroen Oortwijn <oortwijn@gmail.com>
Date: Thu, 29 Mar 2012 21:17:58 +0200
Subject: [PATCH] Allow non-root to mount BFS partition with bfs_fuse
* The 'allow_other' option is only allowed for non-root users when
'user_allow_other' is set in /etc/fuse.conf.
* Don't use this option when user is not root.
---
src/tools/fs_shell/fuse.cpp | 11 +++++++++--
1 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/src/tools/fs_shell/fuse.cpp b/src/tools/fs_shell/fuse.cpp
index 6ccd69a..dcc26a0 100644
a
|
b
|
|
9 | 9 | #include <stdio.h> |
10 | 10 | #include <stdlib.h> |
11 | 11 | #include <syslog.h> |
| 12 | #include <unistd.h> |
12 | 13 | |
13 | 14 | #include "fssh.h" |
14 | 15 | |
… |
… |
fssh_fuse_session(const char* device, const char* mntPoint, const char* fsName,
|
487 | 488 | char* fuseOptions = NULL; |
488 | 489 | |
489 | 490 | // default FUSE options |
| 491 | if (getuid() == 0 && geteuid() == 0 && getgid() == 0 && getegid() == 0) { |
| 492 | // only add option when user is root |
| 493 | if (fuse_opt_add_opt(&fuseOptions, "allow_other") < 0) { |
| 494 | unmount_volume(device, mntPoint); |
| 495 | return 1; |
| 496 | } |
| 497 | } |
490 | 498 | char* fsNameOption = NULL; |
491 | | if (fuse_opt_add_opt(&fuseOptions, "allow_other") < 0 |
492 | | || asprintf(&fsNameOption, "fsname=%s", device) < 0 |
| 499 | if (asprintf(&fsNameOption, "fsname=%s", device) < 0 |
493 | 500 | || fuse_opt_add_opt(&fuseOptions, fsNameOption) < 0) { |
494 | 501 | unmount_volume(device, mntPoint); |
495 | 502 | return 1; |