blob: c528ec045a7afa0adab92d9305aa4881836df18a [file] [log] [blame]
diff -rupN fuse-2.8.6/util/fusermount.c fuse-2.8.6.patched/util/fusermount.c
--- fuse-2.8.6/util/fusermount.c 2011-09-13 00:23:14.000000000 -0700
+++ fuse-2.8.6.patched/util/fusermount.c 2011-10-19 08:48:44.346535813 -0700
@@ -613,6 +613,21 @@ static int add_option(char **optsp, cons
return 0;
}
+static int add_user_option(char **mnt_optsp, const char *user)
+{
+ if (getuid() != 0) {
+ if (user == NULL)
+ user = get_user_name();
+ if (user == NULL)
+ return -1;
+
+ if (add_option(mnt_optsp, "user=", strlen(user)) == -1)
+ return -1;
+ strcat(*mnt_optsp, user);
+ }
+ return 0;
+}
+
static int get_mnt_opts(int flags, char *opts, char **mnt_optsp)
{
int i;
@@ -633,15 +648,6 @@ static int get_mnt_opts(int flags, char
l = strlen(*mnt_optsp);
if ((*mnt_optsp)[l-1] == ',')
(*mnt_optsp)[l-1] = '\0';
- if (getuid() != 0) {
- const char *user = get_user_name();
- if (user == NULL)
- return -1;
-
- if (add_option(mnt_optsp, "user=", strlen(user)) == -1)
- return -1;
- strcat(*mnt_optsp, user);
- }
return 0;
}
@@ -694,6 +700,7 @@ static int do_mount(const char *mnt, cha
char *subtype = NULL;
char *source = NULL;
char *type = NULL;
+ char *user = NULL;
int check_empty = 1;
int blkdev = 0;
@@ -707,6 +714,7 @@ static int do_mount(const char *mnt, cha
unsigned len;
const char *fsname_str = "fsname=";
const char *subtype_str = "subtype=";
+ const char *user_str = "user=";
for (len = 0; s[len]; len++) {
if (s[len] == '\\' && s[len + 1])
len++;
@@ -719,6 +727,9 @@ static int do_mount(const char *mnt, cha
} else if (begins_with(s, subtype_str)) {
if (!get_string_opt(s, len, subtype_str, &subtype))
goto err;
+ } else if (begins_with(s, user_str)) {
+ if (!get_string_opt(s, len, user_str, &user))
+ goto err;
} else if (opt_eq(s, len, "blkdev")) {
if (getuid() != 0) {
fprintf(stderr,
@@ -775,6 +786,9 @@ static int do_mount(const char *mnt, cha
res = get_mnt_opts(flags, optbuf, &mnt_opts);
if (res == -1)
goto err;
+ res = add_user_option(&mnt_opts, user);
+ if (res == -1)
+ goto err;
sprintf(d, "fd=%i,rootmode=%o,user_id=%i,group_id=%i",
fd, rootmode, getuid(), getgid());