Dear XFCE developers,
Thunar run with root privileges shows all fstab entries in devices in the Shortcuts Side Pane. This is reproducible at least with Thunar 1.6.11 (on my main system - Debian Stretch) and with Thunar 1.8.2 (on my VM system - Debian Stretch + Thunar and its dependences from Sid/Stretch Backports). Specifically, I currently have the following in DEVICES in the Shortcuts Side Pane (when no USB, network or other devices are connected):
File System (this is ok -> non-root Thunar shows only this entry)
Filesystem root (this is LVM for "/" and it is redundant)
boot (this is partition for "/boot" and it is redundant)
When I had a separate LVM for "/home" it was shown also as "home" in root Thunar DEVICES. This behavior started with the update of libglib2.0-0 when I upgraded from version 2.42.1-1 (Debian Jessie) to later versions in Debian Stretch (currently 2.50.3-2) and also in Debian Sid (currently 2.58.1-2). Before the update from libglib2.0-0 2.42.1-1 both root and non-root Thunar showed just the "File System" entry in DEVICES in the Shortcuts Side Pane.
At first I reported this problem a while ago as a Debian bug, but probably most relevant is the info in libglib2 GNOME bug (https://gitlab.gnome.org/GNOME/glib/issues/1271).
Links to relevant Debian bugs (just for reference):
Thanks for reporting, I can confirm the bug as root.
Same for nautilus, so probably not a thunar bug.
Possibly related to gvfs.
I'm sorry, but I don't see how to fix this on Thunar's end, unless we introduce some clumsy filtering.
I found two glib merge requests that should address this:
One of them is targeting 2.58.2, let's see if it solves the problem.
I just tested this with Thunar 1.8.4-1 (running as root) on Debian Unstable with libglib2.0-0 version 2.58.3-1 and it seems that the behavior is still the same. Specifically, I currently have the following in DEVICES in the Shortcuts Side Pane (when no USB, network or other devices are connected):
File System (this is ok -> non-root Thunar shows only this entry)
Filesystem root (this is LVM for "/" and it is redundant)
Because the test system does not have separate partitions for "/boot" or "/home" these are not present.
The only way I found for hiding these devices is to hide them using the right click context menu in the Thunar Shortcuts Side Pane. This adds <property name="hidden-devices" type="array">...</property> to "~/.config/xfce4/xfconf/xfce-perchannel-xml/thunar.xml". But since UUIDs are used, it is not easily possible to create a general config for multiple systems.
Can some other device ID types (e.g. LVM volume name) be used in the "hidden-devices" property in "thunar.xml"? If not perhaps adding support for other device ID types could be easier than adding some "automatic clumsy filtering". Since this is just a minor cosmetic issue for me it would be sufficient if I could eliminate it by manually changing "thunar.xml" config so it works on all my systems.
After further testing I noticed that the "hidden-devices" property in "thunar.xml" sometimes uses strings like "Filesystem root" or "cdrom0" instead of UUIDs. However it seems to prefer UUIDs and only use the strings if UUID is already used (e.g. multiple LVM volumes on the same disk). Anyway it would be nice to know the method of selecting the device ID type to be used by the "hidden-devices" property and if I could somehow use this to create a general enough config for all my systems - basically something like this:
<property name="hidden-devices" type="array">
<value type="string" value="Filesystem root"/>
<value type="string" value="boot"/>
<value type="string" value="cdrom0"/>
could be sufficient for my purposes (except it seems not to work currently without the UUID).
I just done some testing on my current Debian 10 system. The problematic behavior described in this bug report still occurs with the following package versions:
as versions did not change much from those mentioned in comment 3. However, after removing the following packages:
the problematic behavior can be seen always, even when running Thunar as a normal (non-root) user. Thus, I can confirm it is definitely a result of something the gvfs should do (i.e. some filtering of devices) while probably using some functionality from libglib2? However when running Thunar as root with gvfs installed the filtering of devices by gvfs seems not to be done resulting in the problematic behavior.
If someone qualified can confirm that Thunar does use gvfs identically no matter under which user Thunar is run, then the problem should be in gvfs and we can try to report it as a gvfs bug. But I also found the following link "https://wiki.gnome.org/Projects/gvfs/doc" with a FAQ that discusses "Running applications under root". It seems to suggest that gvfs does not work well when used by an application run by root in a normal non-root session. I use the "Exec=pkexec /usr/bin/thunar /" command in a "*.desktop" file to start Thunar as root, thus I am not 100% sure the FAQ applies to my case, but it seems likely. This could also mean that if Thunar indeed uses gvfs when run by root it may be doing a wrong thing in the first place?
Since I use Thunar as root only for specific tasks like moving or deleting system configurations etc. I am not going to run whole XFCE session as root just to get a consistent and nice filtering of DEVICES section. Besides that would be wrong security-wise:). But it would be nice if Thunar would not depend on gvfs for the filtering of DEVICES section. Then I could improve my system in the future by purging gvfs with its bunch of dependency packages and try to find an alternative to it (i.e. could systemd automount be used instead of gvfs?).
In the mean time Thunar could be improved by adding a configuration option to hide the DEVICES section from the Shortcuts Side Pane. This option could perhaps be active by default when Thunar is run by root. Reasons are:
- Information from the gvfs FAQ "Running applications under root".
- The DEVICES section in root Thunar is more or less broken as it shows confusing and redundant devices + I also noticed that it does not show new connected devices such as USB disks (only after the device is mounted in a non-root Thunar it appears in the root Thunar).
- The DEVICES section is redundant in root Thunar as one can deal with DEVICES in standard non-root Thunar.
>In the mean time Thunar could be improved by adding a configuration option to hide the DEVICES
>section from the Shortcuts Side Pane. This option could perhaps be active by default when Thunar
>is run by root. Reasons are:
There is already an option for that, its called "hidden-devices" in the xfce4-setting-editor .
If you right-click on some free space at the very button of the ShortcutPane, you can toggle the visibility of specific devices.
This works well for me when using "sudo thunar" and it seems not to interfer with my user settings.
(In reply to Bakhelit from comment #5)
But I also found the following
> link "https://wiki.gnome.org/Projects/gvfs/doc" with a FAQ that discusses
> "Running applications under root". It seems to suggest that gvfs does not
> work well when used by an application run by root in a normal non-root
> session. I use the "Exec=pkexec /usr/bin/thunar /" command in a "*.desktop"
> file to start Thunar as root, thus I am not 100% sure the FAQ applies to my
> case, but it seems likely. This could also mean that if Thunar indeed uses
> gvfs when run by root it may be doing a wrong thing in the first place?
Yes, possibly it would make sense to disable gvfs when running as root ... though it looks like this is already done automatically ... dont know, you have to read the code to know details.
Disabeling gvfs forquick testing can be done like that: https://wiki.xfce.org/thunar/dev/temp_disable_gvfs
I tried running Thunar with gvfs disabled using:
env DBUS_SESSION_BUS_ADDRESS= /usr/bin/thunar
in the terminal as both root and non-root user. It worked only for root user. With a non-root user there was a "thunar-CRITICAL" error: "Name 'org.xfce.FileManager' lost on the message dbus, exitting.".
With regards to DEVICES section in the Shortcuts Side Pane in the root Thunar there was no change - the redundant/confusing devices entries were shown as described in initial report. Thus, probably root Thunar really does not use gvfs as you suggested - I may try to check the source code when I have some more time (as I am not really that familiar with Thunar source to know where to look for gvfs usage).
A problem with the "hidden-devices" option is that it can be used to hide just the specified unwanted devices unless I am missing something. Thus, one must create a specific configuration on each system. However, I could probably create a script to include the specific unwanted device IDs into a "thunar.xml" file template that will have the general configuration for all my systems with some placeholders for specific unwanted device IDs. So thanks for making me think about using the "hidden-devices" option again:).
Created attachment 9503
How gvfs is used in Thunar
So, I finally assembled what I found when looking at how gvfs is used in Thunar source code.
The previous attachment has notes that describe my search in 6 steps - just in case someone more qualified wants to check more quickly whether I missed something important.
Here is a summary:
From the found information it seems that Thunar checks gvfs availability (attachment step 4) in a way that is independent of user privilege checks (attachment steps 1-3). Also all gvfs availability checks I found are basically done just to decide which items or actions to show or use in context menus, dialogs and some other places (most of the items and actions are related to resolving the "Trash vs Delete" case or similar stuff). But I did not find any gvfs availability checks that would influence how the devices are loaded into the DEVICES section in the Shortcuts Side Pane.
After looking at how DEVICES shortcuts are handled in Thunar (attachment steps 5 and 6) it seems to me that gvfs is basically used indirectly by Thunar probably via the gio volume monitor in "thunar_device_monitor_init" function in "./thunar/thunar-device-monitor.c". Could it be that gio volume monitor (or gvfs itself) is smart enough to disable gvfs in root Thunar or is gvfs just broken so much that it appears disabled in this case (i.e. root application using gvfs in a non-root XFCE session)?
The end result however is that without the complete gvfs functionality Thunar does not properly filter the devices in the DEVICES section in the Shortcuts Side Pane and it results in the problems I reported initially. Only filtering of devices that is done by Thunar is based on the "hidden-devices" preference and on "can_eject || can_unmount || is_removable || can_mount" values in "thunar_device_monitor_volume_is_visible" function in "./thunar/thunar-device-monitor.c". Note that gvfs functionality seems not to be available under the root user and also may be unavailable under a non-root user if gvfs is not installed. So in my opinion using Thunar without the gvfs should be considered a plausible scenario that may not be the most common, but is still valid and useful.
I already implemented my workaround script that injects the unwanted device IDs into "hidden-devices" in my "thunar.xml". But it would be very nice if the info in this bug report helps you with some future version of Thunar that is going to improve the device filtering by excluding redundant devices such as "/", "/boot/" etc. or improve the "hidden-devices" and "hidden-bookmarks" mechanism, so that one can easily hide shortcuts using URI with wildcards (e.g. file:///home/*). However, it is not really urgent since I am fine with using the workaround for now and I am happy to at least know a bit about how nice Thunar source code is:).
Thank you for your research !
I linked the bug in https://wiki.xfce.org/thunar/dev/temp_disable_gvfs for further reference.
> But it would be very nice if the info in this bug report helps you with some future version of Thunar that is going to improve the device filtering by excluding redundant devices such as "/", "/boot/" etc. or improve the "hidden-devices" and "hidden-bookmarks" mechanism, so that one can easily hide shortcuts using URI with wildcards (e.g. file:///home/*).
Best open a new bug for this feature and close this one, in order to stay focused. You can reference the old bug there to explain your motivation.
-- GitLab Migration Automatic Message --
This bug has been migrated to xfce.org's GitLab instance and has been closed from further activity.
You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.xfce.org/xfce/thunar/-/issues/221.
Please create an account or use an existing account on one of our supported OAuth providers.
If you want to fork to submit patches and merge requests please continue reading here: https://docs.xfce.org/contribute/dev/git/start#gitlab_forks_and_merge_requests
Also feel free to reach out to us on the mailing list https://mail.xfce.org/mailman/listinfo/xfce4-dev