On Sun, Oct 17, 2010 at 8:37 AM, Alan McKinnon <alan.mckin...@gmail.com>wrote:
> Apparently, though unproven, at 15:03 on Sunday 17 October 2010, Nikos > Chantziaras did opine thusly: > > > 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. > > > I owe you a beer :-) > > One little export and this annoying thingy has now gone away: > > $ sudo vi /etc/fstab > Password: > No protocol specified > > > You have NO IDEA how long that has annoyed me and how long I've been > searching > for a solution. Make that two beers! > > I'm a bit surprised, but this fix actually does work, even without any special arrangement to env_keep XAUTHORITY. But I still don't like it any better than my own solution echo -n ".mybashrc: " xhost +r...@localhost which I place in my .mybashrc, where I keep all of my .bashrc customizations. My way, it can remind me what's going on, and seems more direct. It also works if I "su" to root. As an old-timer on Unix, I often forget sudo. I don't like it much anyway because it won't get me into root if something goes wrong in bootup: with this in mind, I need a root PW anyway, until that bottleneck gets fixed. The above form is actually only used in a debugging mode I've defined, and is silent otherwise. ++ kevin -- Kevin O'Gorman, PhD