From 376bd8dfc812dc60264154d2aaae2e5249e14387 Mon Sep 17 00:00:00 2001 From: szaka Date: Sun, 9 Mar 2008 13:11:25 +0000 Subject: [PATCH] fix 'dev' and 'suid' option handling and make them default for root mounts like other file systems do. They are always denied for setuid-root and unprivileged mounts (Bernhard Kaindl, Szabolcs Szakacsits) --- libfuse-lite/fusermount.c | 2 +- libfuse-lite/mount.c | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/libfuse-lite/fusermount.c b/libfuse-lite/fusermount.c index c321ce29..b0f16c19 100644 --- a/libfuse-lite/fusermount.c +++ b/libfuse-lite/fusermount.c @@ -276,7 +276,7 @@ static int find_mount_flag(const char *s, unsigned len, int *on, int *flag) *flag = mount_flags[i].flag; if (!mount_flags[i].safe && getuid() != 0) { *flag = 0; - fprintf(stderr, "%s: unsafe option %s ignored\n", + fprintf(stderr, "%s: unsafe option '%s' ignored\n", progname, opt); } return 1; diff --git a/libfuse-lite/mount.c b/libfuse-lite/mount.c index 712cdb53..0bb3aee5 100644 --- a/libfuse-lite/mount.c +++ b/libfuse-lite/mount.c @@ -214,7 +214,8 @@ int fuse_kern_mount(const char *mountpoint, struct fuse_args *args) char *mnt_opts = NULL; memset(&mo, 0, sizeof(mo)); - mo.flags = MS_NOSUID | MS_NODEV; + if (getuid()) + mo.flags = MS_NOSUID | MS_NODEV; if (args && fuse_opt_parse(args, &mo, fuse_mount_opts, fuse_mount_opt_proc) == -1) @@ -231,6 +232,10 @@ int fuse_kern_mount(const char *mountpoint, struct fuse_args *args) res = -1; if (get_mnt_flag_opts(&mnt_opts, mo.flags) == -1) goto out; + if (!(mo.flags & MS_NODEV) && fuse_opt_add_opt(&mnt_opts, "dev") == -1) + goto out; + if (!(mo.flags & MS_NOSUID) && fuse_opt_add_opt(&mnt_opts, "suid") == -1) + goto out; if (mo.kernel_opts && fuse_opt_add_opt(&mnt_opts, mo.kernel_opts) == -1) goto out; if (mo.mtab_opts && fuse_opt_add_opt(&mnt_opts, mo.mtab_opts) == -1)