Bug 268320

Summary: sysutils/bsdisks: unmounting exFAT/NTFS volume from file manager as non-root
Product: Ports & Packages Reporter: fbsd470 <flurry123>
Component: Individual Port(s)Assignee: Gleb Popov <arrowd>
Status: Closed Not A Bug    
Severity: Affects Some People CC: grahamperrin
Priority: --- Keywords: needs-qa
Version: LatestFlags: bugzilla: maintainer-feedback? (arrowd)
Hardware: amd64   
OS: Any   
URL: https://www.freshports.org/sysutils/bsdisks/
Attachments:
Description Flags
Screenshot of Thunar none

Description fbsd470 2022-12-11 22:04:51 UTC
Hi, my system is FreeBSD 13.1 Release, Xfce 4.16, Thunar 4.16.11 and bsdisks 0.27. Mounting and unmounting UFS or FAT formatted USB sticks with Thunar works fine as non-root.
But as soon as I use NTFS or exFAT formatted sticks, unmounting is impossible as a normal user. Thunar says: "Operation not permitted." And in this case Thunar always shows two entries in locations, one for /dev/da1 and one for /dev/da1p1.

My workaround so far: open a terminal, become root and unmount the file system.

If I start an Xfce session with root privileges, unmounting NTFS/exFAT sticks with Thunar works.
 
Maybe the reason for this behavior is the usage of fusefs, but I'm not sure.
Comment 1 Graham Perrin freebsd_committer freebsd_triage 2022-12-12 03:18:14 UTC
(In reply to fbsd470 from comment #0)

> … two entries in locations, one for /dev/da1 and one for /dev/da1p1. …

What are the mount points? hier(7) draws attention to: 

/media/

<https://www.freebsd.org/cgi/man.cgi?query=hier&sektion=7&manpath=FreeBSD>


What's reported by the following command? 

sysrc -f /etc/rc.conf devfs_system_ruleset


Compare the content of your    /etc/devfs.rules    with the EXAMPLES near the foot of devfs.rules(5). 

<https://www.freebsd.org/cgi/man.cgi?query=devfs.rules&sektion=5&manpath=FreeBSD>
Comment 2 Gleb Popov freebsd_committer freebsd_triage 2022-12-12 04:31:47 UTC
Do you have fuse kernel module loading at the boot?
Comment 3 fbsd470 2022-12-12 12:56:22 UTC
Created attachment 238726 [details]
Screenshot of Thunar
Comment 4 fbsd470 2022-12-12 12:57:40 UTC
(In reply to Graham Perrin from comment #1)

Hi, here some additional information:

$ mount
/dev/da0p2 on / (ufs, local, soft-updates, journaled soft-updates)
devfs on /dev (devfs)
/dev/fuse on /media/Kingston_DataTraveler_3.0_4CEDFB790E84F541783D01D2 (fusefs)

$ cd /media
$ ls -l
total 32
drwxrwxrwx  1 fbsd  wheel  32768  1 Jan.  1970 Kingston_DataTraveler_3.0_4CEDFB790E84F541783D01D2

$ sysrc -f /etc/rc.conf devfs_system_ruleset
devfs_system_ruleset: system

$ cat /etc/devfs.rules
[system=10]
add path 'usb/*' mode 0660 group operator
add path 'md*' mode 0660 group operator
add path 'cd*' mode 0660 group operator
add path 'pass*' mode 0660 group operator
add path 'xpt*' mode 0660 group operator
add path 'da*' mode 0660 group operator

$ id
uid=1001(fbsd) gid=1001(fbsd) groups=1001(fbsd),0(wheel),5(operator),44(video),920(vboxusers)

$ cat /etc/sysctl.conf
...
vfs.usermount=1
Comment 5 fbsd470 2022-12-12 12:58:57 UTC
(In reply to Gleb Popov from comment #2)

Hi, fuse module is loaded by rc.conf:

$ cat /boot/loader.conf
autoboot_delay="1"
boot_mute="YES"
loader_logo="none"


$ cat /etc/rc.conf
...
dbus_enable="YES"
xdm_enable="YES"
kld_list="fusefs"
background_dhclient="YES"
cupsd_enable="YES"
devfs_system_ruleset="system"
Comment 6 Gleb Popov freebsd_committer freebsd_triage 2022-12-12 13:15:17 UTC
This is certainly strange - you even have vfs.usermount=1.

To rule out Xfce bugs, can you please try unmounting with manual dbus call? You can do that with qdbus (console) or qdbusviewer (GUI) utilities.
Comment 7 fbsd470 2022-12-12 13:35:24 UTC
(In reply to Gleb Popov from comment #6)

OK, I have installed qdbusviewer. But I have no idea how to perform a unmount with manual dbus call.
Can you help me with this?
Comment 8 Gleb Popov freebsd_committer freebsd_triage 2022-12-12 14:36:53 UTC
Switch to the "System" tab, find org.freedesktop.UDisks2 service, select it. In the right window go to /org/freedesktop/UDisks2/block_devices/your_device, find Unmount method, click it to call it.
Comment 9 fbsd470 2022-12-12 15:03:55 UTC
Thank you for the instructions. Unmounting with manual dbus call works, qdbusviewer says:

Received reply from:1.6
 (no arguments)

In addition the subfolder "Kingston_DataTraveler_3.0_4CEDFB790E84F541783D01D2" of /media is removed.
Comment 10 Gleb Popov freebsd_committer freebsd_triage 2022-12-12 15:07:22 UTC
Then the problem is with Xfce, Thunar or some its internal libraries.
Comment 11 Graham Perrin freebsd_committer freebsd_triage 2022-12-12 17:21:53 UTC
(In reply to fbsd470 from comment #5)

> kld_list="fusefs"

Do you have more than one kld_list line in the file?
Comment 12 fbsd470 2022-12-12 18:56:59 UTC
(In reply to Graham Perrin from comment #11)

no, just one.
Comment 13 fbsd470 2022-12-13 17:00:54 UTC
(In reply to Gleb Popov from comment #10)

Yes, seems you're right.

As a sort of workaround I want to create a small Thunar-Custom-Actions script for unmounting fuse file systems.
I have tried dbus-send and qdbus-qt5, but I can't make it. I have no idea what the args parameter should look like.

So far I have:
/usr/local/bin/qdbus-qt5 --system org.freedesktop.UDisks2 /org/freedesktop/UDisks2/block_devices/da1 org.freedesktop.UDisks2.Filesystem.Unmount

You mentioned a manual call with qdbus above. Could you give me a hint?

Many thanks in advance.
Comment 14 Gleb Popov freebsd_committer freebsd_triage 2022-12-14 13:50:51 UTC
(In reply to fbsd470 from comment #13)
Reading the qdbus-qt5 source, it seem impossible to call .Unmount :<

I guess, you'll have to come up with an incantation for dbus-send or/and open an issue upstream about the original bug.
Comment 15 fbsd470 2022-12-14 16:17:59 UTC
I did some additional "investigation" with dbus-monitor. Unmounting a FAT32 formatted USB device shows:

method call time=1671004956.095305 sender=:1.5 -> destination=:1.6 serial=10 path=/org/freedesktop/UDisks2/block_devices/da1s1; interface=org.freedesktop.UDisks2.Filesystem; member=Unmount
   array [
   ]
signal time=1671004956.121848 sender=:1.6 -> destination=(null destination) serial=17 path=/org/freedesktop/UDisks2/block_devices/da1s1; interface=org.freedesktop.DBus.Properties; member=PropertiesChanged
   string "org.freedesktop.UDisks2.Filesystem"
   array [
      dict entry(
         string "MountPoints"
         variant             array [
            ]
      )
   ]
   array [
   ]
...

When unmountig a USB device with exFAT/NTFS (fuse) file system the first part is completely missing, there is no call for the Unmount method.
So in the case of a fuse file system Thunar or gvfs seems to handle the unmount process completely different.
I'm afraid there is a "bug" deep inside Thunar or gvfs.

Anyway, thank you very much for your support :-)
Comment 16 fbsd470 2022-12-14 16:21:13 UTC
(In reply to fbsd470 from comment #15)

forgot to mention: I monitored unmounting as root
Comment 17 Gleb Popov freebsd_committer freebsd_triage 2022-12-17 16:24:06 UTC
Closing this as not our bug.

Note that Xfce 4.8 was committed recently, you might want to check of this problem is fixed in the new release.