From cb71b4372c963da8c9fef37eac3ddb60de02b2a3 Mon Sep 17 00:00:00 2001 From: Miklos Szeredi Date: Thu, 10 Jul 2008 19:30:43 +0000 Subject: [PATCH] Fix handling of (no)suid and (no)dev options... --- ChangeLog | 5 +++++ util/mount.fuse.c | 36 +++++++++++++++++++++++++++--------- 2 files changed, 32 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index dee8a3b..638dd3c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2008-06-27 Miklos Szeredi + + * Fix handling of (no)suid and (no)dev options if filesystem is + mounted from /etc/fstab or via mount(8). Reported by Jan Ondrej. + 2008-06-16 Miklos Szeredi * Remove fuse kernel module sources. Linux 2.6.27 will support diff --git a/util/mount.fuse.c b/util/mount.fuse.c index 7bd0e83..b388f9e 100644 --- a/util/mount.fuse.c +++ b/util/mount.fuse.c @@ -59,6 +59,20 @@ static void add_arg(char **cmdp, const char *opt) *cmdp = cmd; } +static char *add_option(const char *opt, char *options) +{ + int oldlen = options ? strlen(options) : 0; + + options = xrealloc(options, oldlen + 1 + strlen(opt) + 1); + if (!oldlen) + strcpy(options, opt); + else { + strcat(options, ","); + strcat(options, opt); + } + return options; +} + int main(int argc, char *argv[]) { char *type = NULL; @@ -69,6 +83,8 @@ int main(int argc, char *argv[]) char *command = NULL; char *setuid = NULL; int i; + int dev = 1; + int suid = 1; progname = argv[0]; basename = strrchr(argv[0], '/'); @@ -151,21 +167,23 @@ int main(int argc, char *argv[]) ignore = 1; if (!ignore) { - int oldlen = - options ? strlen(options) : 0; - options = xrealloc(options, oldlen + 1 + strlen(opt) + 1); - if (!oldlen) - strcpy(options, opt); - else { - strcat(options, ","); - strcat(options, opt); - } + if (strcmp(opt, "nodev") == 0) + dev = 0; + else if (strcmp(opt, "nosuid") == 0) + suid = 0; + + options = add_option(opt, options); } opt = strtok(NULL, ","); } } } + if (dev) + options = add_option("dev", options); + if (suid) + options = add_option("suid", options); + if (!type) { type = xstrdup(source); source = strchr(type, '#'); -- 2.30.2