Ticket #8254: 0001-Allow-non-root-to-mount-BFS-partition-with-bfs_fuse.patch

File 0001-Allow-non-root-to-mount-BFS-partition-with-bfs_fuse.patch, 1.5 KB (added by idefix, 12 years ago)

Only set allow_other fuse option when user is root

  • src/tools/fs_shell/fuse.cpp

    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  
    99#include <stdio.h>
    1010#include <stdlib.h>
    1111#include <syslog.h>
     12#include <unistd.h>
    1213
    1314#include "fssh.h"
    1415
    fssh_fuse_session(const char* device, const char* mntPoint, const char* fsName,  
    487488    char* fuseOptions = NULL;
    488489
    489490    // 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    }
    490498    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
    493500        || fuse_opt_add_opt(&fuseOptions, fsNameOption) < 0) {
    494501        unmount_volume(device, mntPoint);
    495502        return 1;