bfs_fuse: Allow non-root to mount BFS partitions.
* Most FUSE options are only allowed for root, so don't add these options when user is not root. * Fixes ticket #8254. Signed-off-by: Augustin Cavalier <[email protected]> Coding style looks OK to me and there are multiple comments that it works, so just merging it.
This commit is contained in:
committed by
Augustin Cavalier
parent
73e180c9b9
commit
ef9b129675
@@ -9,6 +9,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <syslog.h>
|
#include <syslog.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "fssh.h"
|
#include "fssh.h"
|
||||||
|
|
||||||
@@ -479,6 +480,9 @@ fssh_fuse_session(const char* device, const char* mntPoint, const char* fsName,
|
|||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
if (getuid() == 0 && geteuid() == 0 && getgid() == 0 && getegid() == 0) {
|
||||||
|
// only add FUSE options when user is root
|
||||||
|
|
||||||
char* fuseOptions = NULL;
|
char* fuseOptions = NULL;
|
||||||
|
|
||||||
// default FUSE options
|
// default FUSE options
|
||||||
@@ -509,13 +513,18 @@ fssh_fuse_session(const char* device, const char* mntPoint, const char* fsName,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run the fuse_main() loop.
|
if (fuse_opt_add_arg(&fuseArgs, "-o") < 0
|
||||||
if (fuse_opt_add_arg(&fuseArgs, "-s") < 0
|
|
||||||
|| fuse_opt_add_arg(&fuseArgs, "-o") < 0
|
|
||||||
|| fuse_opt_add_arg(&fuseArgs, fuseOptions) < 0) {
|
|| fuse_opt_add_arg(&fuseArgs, fuseOptions) < 0) {
|
||||||
unmount_volume(device, mntPoint);
|
unmount_volume(device, mntPoint);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Run the fuse_main() loop.
|
||||||
|
if (fuse_opt_add_arg(&fuseArgs, "-s") < 0) {
|
||||||
|
unmount_volume(device, mntPoint);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
initialiseFuseOps(&gFUSEOperations);
|
initialiseFuseOps(&gFUSEOperations);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user