You are not logged in.

#1 2011-04-05 22:47:25

DarkSniper
Member
Registered: 2011-04-05
Posts: 74

[Solved] Running Thunar with sudo/su Causes GVFS Errors?

Hi, I switched from Xubuntu to Arch a few days ago, and am loving it so far, but I'm running into an issue when running Thunar with sudo or su. As a result, trash as root doesn't work. I'm not sure if this is related to GVFS, but drives also do not appear when running Thunar as root. Not too major, since it's just a slight inconvenience, and I only need root privileges with Thunar occasionally. Though it'd be awesome if someone knows how to fix this, since my searching has come up with nothing for a problem like this. When logging in as root itself, the problem doesn't occur,  it only happens when running it as my regular account through the sudo or su command.

Here's the terminal output with the errors:

[dark@YiffingInHell ~]$ su
Password:
[root@YiffingInHell dark]# thunar

(thunar:29855): GVFS-RemoteVolumeMonitor-WARNING **: cannot connect to the session bus: org.freedesktop.DBus.Error.NoReply: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken.

(thunar:29855): GVFS-RemoteVolumeMonitor-WARNING **: cannot connect to the session bus: org.freedesktop.DBus.Error.NoReply: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken.

(thunar:29855): GVFS-RemoteVolumeMonitor-WARNING **: cannot connect to the session bus: org.freedesktop.DBus.Error.NoReply: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken.

Last edited by DarkSniper (2011-04-06 02:43:46)


Failure is not an option... It comes bundled with Windows.

Offline

#2 2011-04-05 22:54:27

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 20,214

Re: [Solved] Running Thunar with sudo/su Causes GVFS Errors?

Use gksu or kdesu instead of sudo

gksu is available available via pacman
kdesu is part of  kdebase-runtime (it brings in a lot of baggage if you don't already have KDE)

edit: Thank you to SS4 and his post here

Last edited by ewaller (2011-04-05 22:56:25)


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#3 2011-04-05 22:58:00

DarkSniper
Member
Registered: 2011-04-05
Posts: 74

Re: [Solved] Running Thunar with sudo/su Causes GVFS Errors?

ewaller wrote:

Use gksu or kdesu instead of sudo

gksu is available available via pacman
kdesu is part of  kdebase-runtime (it brings in a lot of baggage if you don't already have KDE)

Under gksu, The same problem still occurs, no trash or drives in the root thunar. It also seems to spit a different error at me when I do this.

[dark@YiffingInHell ~]$ gksu thunar
** Message: secret service operation failed: The name org.freedesktop.secrets was not provided by any .service files


Failure is not an option... It comes bundled with Windows.

Offline

#4 2011-04-05 23:01:30

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 20,214

Re: [Solved] Running Thunar with sudo/su Causes GVFS Errors?

How are you starting the session?

gdm, startx, Slim?


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#5 2011-04-05 23:18:14

DarkSniper
Member
Registered: 2011-04-05
Posts: 74

Re: [Solved] Running Thunar with sudo/su Causes GVFS Errors?

ewaller wrote:

How are you starting the session?

gdm, startx, Slim?

I'm using Slim, and the line in my ~/.xinitrc file which starts the session is "exec ck-launch-session dbus-launch startxfce4"

Though reading over the Slim wiki page a few more times, would "exec startxfce4" be more appropriate?


Failure is not an option... It comes bundled with Windows.

Offline

#6 2011-04-05 23:26:45

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 20,214

Re: [Solved] Running Thunar with sudo/su Causes GVFS Errors?

I vote for exec ck-launch-session startxfce4  That incantation has worked for me without the dbus-launch bit.

Are you starting the dbus daemon from the DAEMONS array in /etc/rc.conf  ??


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#7 2011-04-05 23:26:58

anonymous_user
Member
Registered: 2009-08-28
Posts: 3,059

Re: [Solved] Running Thunar with sudo/su Causes GVFS Errors?

Remember to edit the login_cmd line of your /etc/slim.conf too:

https://wiki.archlinux.org/index.php/Slim#PolicyKit

Offline

#8 2011-04-05 23:34:52

DarkSniper
Member
Registered: 2011-04-05
Posts: 74

Re: [Solved] Running Thunar with sudo/su Causes GVFS Errors?

Dbus is in the DAEMONS array in my /etc/rc.conf [It's the second one]

Ah! Maybe that was the issue, Somehow I never edited my /etc/slim.conf file.
I'll try rebooting and see if the changes in my slim.conf and .xinitrc files made any difference.

Edit: No luck, Thunar is still throwing those errors at me when ran with su or sudo, and still won't show trash or drives.

Last edited by DarkSniper (2011-04-05 23:40:08)


Failure is not an option... It comes bundled with Windows.

Offline

#9 2011-04-06 02:02:11

DarkSniper
Member
Registered: 2011-04-05
Posts: 74

Re: [Solved] Running Thunar with sudo/su Causes GVFS Errors?

Found a partial workaround. If I use "dbus-launch thunar" with sudo or su, it works properly, but I've found that it doesn't end the dbus processes upon closing thunar even with the --exit-with-session flag. As a result, the dbus processes accumulate and hog up resources. I find it somewhat odd that dbus works properly with my normal applications, but still refuses to cooperate with programs being run as root through sudo and su.

Everything else still seems to work fine without the dbus-launch command in my .xinitrc and slim.conf files, though the issue of sudo and su not using dbus is still there.

Edit: Found a workaround.
Read the manpage for dbus-launch, and found the --autolaunch flag. To use the flag, I found my dbus machine id in a text file ~/.dbus/session bus/ near the top of it. Since I couldn't find any other way to get dbus to work with su/sudo, I put it in a script so I can launch thunar as root, then dropped it in /usr/bin and ran chmod a+x on it. With this script, I can now run thunar with sudo, with dbus working, and it doesn't create a bunch of stuck dbus processes.

Here's the code for the script, in case anyone in the future encounters a similar issue:
#!/bin/bash
pathname="$1"
sudo dbus-launch --autolaunch <machine ID> --exit-with-session thunar $pathname
exit 0

[Replacing <machine ID> with your computer's real ID]

Last edited by DarkSniper (2011-04-06 02:43:05)


Failure is not an option... It comes bundled with Windows.

Offline

#10 2012-02-18 20:08:52

janek
Member
Registered: 2012-02-18
Posts: 3

Re: [Solved] Running Thunar with sudo/su Causes GVFS Errors?

Another possibility:

Description:
thunar as root (dbus session, disable trash, drives)

Solution:
add to root .bashrc file:
export DBUS_SESSION_BUS_ADDRESS=""

Run thunar as root ( I use pkexec from PolicyKit as su sudo equivalent):
pkexec thunar

Information from source:
https://bugs.launchpad.net/ubuntu/+sour … bug/336660

comment #3
[...] When you su to root from a terminal where you are logged in as another user the new "su-ed" user gonna inherit the environment variables from the parent shell user. [...]

[...] A program executed as root uses a different D-Bus session bus address compared when you execute that program as the jack user for instance. So the problem is that you switch to root, but the DBUS_SESSION_BUS_ADDRESS variable still points the the jack's dbus session bus address. [...]

comment #4
[...] It seems that DBUS_SESSION_BUS_ADDRESS is propagated not only through environment variable, but through X11 atom as well. [...]

Offline

#11 2012-02-19 13:14:06

DarkSniper
Member
Registered: 2011-04-05
Posts: 74

Re: [Solved] Running Thunar with sudo/su Causes GVFS Errors?

@janek: It's not good practice to necrobump threads that were posted nearly a year ago.
I have long since devised a better solution than my initial quick fix. I have created a small script that wraps sudo and fetches root's dbus variables, then sticks them before the command I want to run, so that they're run on root's session instead of mine. It's not the most elegant way, but it remains secure and has pretty much no overhead. I also prefer sudo over pkexec, having an agent popup when I enter the command is undesirable, since it's simpler and easier to just enter the password on the command line.

For searcher's sake, this is my little wrapper if anyone's interested in using it.
A small wrapper to go in your path, to be aliased to sudo in your bashrc

!#/bin/bash
#Fetch Root's Dbus Variables and Run The Command
/usr/bin/sudo $(/usr/bin/sudo sed '6q;d' /root/.dbus/session-bus/af16543424391ebcfb5f0c1000000ce2-0) \
$(/usr/bin/sudo sed '7q;d' /root/.dbus/session-bus/af16543424391ebcfb5f0c1000000ce2-0) \
$(/usr/bin/sudo sed '8q;d' /root/.dbus/session-bus/af16543424391ebcfb5f0c1000000ce2-0) "$@"

Then add this to a script that is run as root on boot. [This starts a session for root that allows the wrapper to connect]
Examples include /etc/rc.local; /etc/lxdm/LoginReady; or a systemd unit

dbus-launch --autolaunch af16543424391ebcfb5f0c1000000ce2

NOTE: The "af16543424391ebcfb5f0c1000000ce2" part is different for every system, you can find out what it is for your system by checking the name of the file in /root/.dbus/session-bus.


Failure is not an option... It comes bundled with Windows.

Offline

#12 2012-02-19 18:12:18

fsckd
Forum Fellow
Registered: 2009-06-15
Posts: 4,173

Re: [Solved] Running Thunar with sudo/su Causes GVFS Errors?

janek, welcome to the forums. posting to old threads such as this one is discouraged. You may read the reasons at Forum Etiquette: Necro-Bumping.
Closing.


aur S & M :: forum rules :: Community Ethos
Resources for Women, POC, LGBT*, and allies

Offline

Board footer

Powered by FluxBB