Open Vladimir-csp opened 9 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.
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:
Options for helper (from umount.nfs help):
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).