Fix handling of (no)suid and (no)dev options...
authorMiklos Szeredi <miklos@szeredi.hu>
Thu, 10 Jul 2008 19:30:43 +0000 (19:30 +0000)
committerMiklos Szeredi <miklos@szeredi.hu>
Thu, 10 Jul 2008 19:30:43 +0000 (19:30 +0000)
ChangeLog
util/mount.fuse.c

index dee8a3b1b5469ea3d6f9952727ebcdb8a83d775e..638dd3cb4a11b2e2a27f4a9e487800dea9876134 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2008-06-27  Miklos Szeredi <miklos@szeredi.hu>
+
+       * 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 <miklos@szeredi.hu>
 
        * Remove fuse kernel module sources.  Linux 2.6.27 will support
index 7bd0e83bc30b1d33144c74146ab5f827667a1a22..b388f9e9038b2c418234bb496a069ce21d7e3a0a 100644 (file)
@@ -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, '#');