On 10/17/2010 04:00 PM, Nikos Chantziaras wrote:
On 09/22/2010 09:48 PM, Andrey Vul wrote:
When I launch X programs via sudo, I get the following:

$sudo gui-admin
No protocol specified
gui-admin: cannot connect to X server :0

( Assume gui-admin is an X program )

But (gk|kde)su(do)? works. This is somewhat confusing.

I just discovered something. Keeping HOME is not really recommended,
because the programs that run as root will then use your user's
configuration files and sometimes will set 'root' as their owner. As you
can imagine, this is not a good thing.

It seems what X programs really need is the .Xauthority file of the
current X session. All you have to do is add this line to your ~/.bashrc:

export XAUTHORITY="$HOME/.Xauthority"

Then you don't have to configure sudoers to keep the HOME env var.

(I have the tendency to press the "Send" button too soon...)

Setting XAUTHORITY in the user's .bashrc also means that you don't have to modify /etc/sudoers *in any way*, not even DISPLAY needs to be kept. Setting XAUTHORITY is *all* what is needed.


Reply via email to