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@xxxxxxx> --- 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:
pgpGlm1OPMDV3.pgp
Description: PGP signature