IgnorantGuru / udevil

Mount without password
http://ignorantguru.github.com/udevil/
GNU General Public License v3.0
130 stars 30 forks source link

support umount external helper #55

Open Vladimir-csp opened 9 years ago

Vladimir-csp commented 9 years ago

By using external helper, umount command will redirect request to udevil. This mechanism should work by adding uhelper=udevil mount option to mounts and adding /sbin/umount.udevil binary.

From umount man:

The syntax of external unmount helpers is:

/sbin/umount.suffix {directory|device} [-flnrv] [-t type.subtype]

where suffix is the filesystem type or a value from a "uhelper=" or "helper=" mtab option. The -t option can be used for filesystems with subtypes support (for example /sbin/mount.fuse -t fuse.sshfs).

The uhelper= (unprivileged unmount helper) mount option can be used when non-root users need to be able to unmount a mountpoint which is not defined in /etc/fstab (e.g. devices mounted by udisk).

The helper= mount option redirects all unmount requests to the /sbin/umount.type helper independently of UID.

Options for helper (from umount.nfs help):

-f force unmount -v verbose -n Do not update /etc/mtab -r remount -l lazy unmount

So if user or something in the system decides to unmount udevil-controlled mountpoint with simple umount command, it would be actually unmounted with udevil (cleaning dir, etc).

DBMandrake commented 8 years ago

This would be quite useful for us on OSMC as well.

When trying to unmount a disk through the Kodi GUI it simply calls "umount mountpoint" but because it runs as an unprivileged user this will fail. When we were using udisks/udisks-glue the /sbin/umount.udisks helper would allow Kodi to unmount disks as a non privileged user.

As it stands now we would have to patch the Kodi source (in fact we have) to check for the presence of /usr/bin/udevil and call udevil umount instead of umount however this is yet one more of many patches to maintain...

I had a quick look at adding a shell based /sbin/umount.udevil helper script:

#!/bin/sh exec /usr/bin/udevil umount $@

Then in udevil.conf I added uhelper=udevil to all default_options and allowed_options so that all mounts mounted by udevil would have the correct uhelper option.

The final piece of the puzzle to make this work is that udevil must call mount with the -i option, otherwise you get an infinite loop where umount calls umount.udevil which calls udevil umount which calls umount....The -i option tells mount to ignore the uhelper argument, thus performing the actual umount instead of trying to pass it off to umount.udevil again.

Unfortunately adding any options to the umount command in udevil.conf is specifically prohibited: (why?)

# Be sure to specify the full path and include NO OPTIONS or other arguments. # These programs may also be specified as configure options when building # udevil. # THESE PROGRAMS ARE RUN AS ROOT # mount_program = /bin/mount # umount_program = /bin/umount # losetup_program = /sbin/losetup # setfacl_program = /usr/bin/setfacl

So unfortunately that prevents this approach from working.