From: Petr Uzel <petr.uzel@suse.cz>
To: util-linux <util-linux@vger.kernel.org>
Cc: Miklos Szeredi <mszeredi@suse.cz>
Subject: [PATCH] umount: allow non-root umount of FUSE even if not in fstab
Date: Mon, 28 Mar 2011 16:04:56 +0200 [thread overview]
Message-ID: <20110328140454.GA4790@foxbat.suse.cz> (raw)
[-- Attachment #1: Type: text/plain, Size: 2766 bytes --]
Hi all,
I hacked the following patch with which it is possible to use
"umount $dir" instead of "fusermount -u $dir", which IMHO is an
improvement in usability. It seems to work (at least for me), however,
I have to admit that I don't like it very much, because:
- it complicates umount
- duplicates code from fusermount
- should (???) be implemented using umount helpers
With regard to uhelpers: I spent some time looking into the fuse code,
but I don't think it could be done easily - has anybody investigated
this?
Related discussion (from 2006):
http://sourceforge.net/mailarchive/forum.php?thread_name=1253960851.6399.43.camel%40localhost.localdomain&forum_name=fuse-devel
This feature addresses:
https://fate.novell.com/310710
---------- 8< ---------- 8< -----------
This patch introduces an exception to the "no non-root unmounts
unless the mount is in fstab", which is necessary to allow
unmounting FUSE filesystems with umount (originally, one
had to use fusermount -u).
Umount makes the same checks as fusermount -u does, namely:
- if the fstype starts with fuse/fuseblk
- compares the user_id stored in /etc/mtab (or /proc/mounts) with
real UID of the calling user
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
---
mount/umount.c | 27 +++++++++++++++++++++++++++
1 files changed, 27 insertions(+), 0 deletions(-)
diff --git a/mount/umount.c b/mount/umount.c
index 42671f4..f887c6f 100644
--- a/mount/umount.c
+++ b/mount/umount.c
@@ -592,6 +592,33 @@ umount_file (char *arg) {
_("umount: it seems %s is mounted multiple times"),
file);
+ /* If this is fuse-based filesystem, allow user unmount even
+ * if the FS is not in fstab.
+ *
+ * Based on fusermount code. */
+ if (strcmp(mc->m.mnt_type, "fuse") == 0 ||
+ strcmp(mc->m.mnt_type, "fuseblk") == 0 ||
+ strncmp(mc->m.mnt_type, "fuse.", 5) == 0 ||
+ strncmp(mc->m.mnt_type, "fuseblk.", 8) == 0) {
+ char *fuse_uidstr;
+ fuse_uidstr = get_option_value(mc->m.mnt_opts, "user=");
+ if (!fuse_uidstr)
+ fuse_uidstr = get_option_value(mc->m.mnt_opts, "user_id=");
+ if (fuse_uidstr) {
+ char uidstr[32];
+ unsigned uidlen;
+ uidlen = sprintf(uidstr, "%u", getuid());
+ if (strncmp(uidstr, fuse_uidstr, uidlen) == 0) {
+ if (verbose)
+ printf(_("Unmounting %s (FUSE filesystem, mounted by uid=%s)\n"),
+ arg, uidstr);
+ int ret = umount_one(arg, arg, arg, arg, NULL);
+ free(fuse_uidstr);
+ return ret;
+ }
+ }
+ }
+
/* If fstab contains the two lines
/dev/sda1 /mnt/zip auto user,noauto 0 0
/dev/sda4 /mnt/zip auto user,noauto 0 0
--
1.7.3.4
Petr
--
Petr Uzel
IRC: ptr_uzl @ freenode
[-- Attachment #2: Type: application/pgp-signature, Size: 198 bytes --]
next reply other threads:[~2011-03-28 14:04 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-28 14:04 Petr Uzel [this message]
2011-03-28 14:23 ` [PATCH] umount: allow non-root umount of FUSE even if not in fstab Miklos Szeredi
2011-03-29 8:08 ` Petr Uzel
2011-03-29 8:28 ` Karel Zak
2011-03-29 8:48 ` Miklos Szeredi
2011-03-29 10:13 ` Karel Zak
2011-03-28 22:03 ` Karel Zak
2011-03-29 8:46 ` Petr Uzel
2011-03-29 8:51 ` Miklos Szeredi
2011-03-29 8:56 ` Petr Uzel
2011-03-29 10:03 ` Karel Zak
2011-03-29 10:36 ` Karel Zak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110328140454.GA4790@foxbat.suse.cz \
--to=petr.uzel@suse.cz \
--cc=mszeredi@suse.cz \
--cc=util-linux@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox