1 |
On Sun, Oct 17, 2010 at 8:37 AM, Alan McKinnon <alan.mckinnon@×××××.com>wrote: |
2 |
|
3 |
> Apparently, though unproven, at 15:03 on Sunday 17 October 2010, Nikos |
4 |
> Chantziaras did opine thusly: |
5 |
> |
6 |
> > On 10/17/2010 04:00 PM, Nikos Chantziaras wrote: |
7 |
> > > On 09/22/2010 09:48 PM, Andrey Vul wrote: |
8 |
> > >> When I launch X programs via sudo, I get the following: |
9 |
> > >> |
10 |
> > >> $sudo gui-admin |
11 |
> > >> No protocol specified |
12 |
> > >> gui-admin: cannot connect to X server :0 |
13 |
> > >> |
14 |
> > >> ( Assume gui-admin is an X program ) |
15 |
> > >> |
16 |
> > >> But (gk|kde)su(do)? works. This is somewhat confusing. |
17 |
> > > |
18 |
> > > I just discovered something. Keeping HOME is not really recommended, |
19 |
> > > because the programs that run as root will then use your user's |
20 |
> > > configuration files and sometimes will set 'root' as their owner. As |
21 |
> you |
22 |
> > > can imagine, this is not a good thing. |
23 |
> > > |
24 |
> > > It seems what X programs really need is the .Xauthority file of the |
25 |
> > > current X session. All you have to do is add this line to your |
26 |
> ~/.bashrc: |
27 |
> > > |
28 |
> > > export XAUTHORITY="$HOME/.Xauthority" |
29 |
> > > |
30 |
> > > Then you don't have to configure sudoers to keep the HOME env var. |
31 |
> > |
32 |
> > (I have the tendency to press the "Send" button too soon...) |
33 |
> > |
34 |
> > Setting XAUTHORITY in the user's .bashrc also means that you don't have |
35 |
> > to modify /etc/sudoers *in any way*, not even DISPLAY needs to be kept. |
36 |
> > Setting XAUTHORITY is *all* what is needed. |
37 |
> |
38 |
> |
39 |
> I owe you a beer :-) |
40 |
> |
41 |
> One little export and this annoying thingy has now gone away: |
42 |
> |
43 |
> $ sudo vi /etc/fstab |
44 |
> Password: |
45 |
> No protocol specified |
46 |
> |
47 |
> |
48 |
> You have NO IDEA how long that has annoyed me and how long I've been |
49 |
> searching |
50 |
> for a solution. Make that two beers! |
51 |
> |
52 |
> I'm a bit surprised, but this fix actually does work, even without any |
53 |
special arrangement to |
54 |
env_keep XAUTHORITY. But I still don't like it any better than my own |
55 |
solution |
56 |
|
57 |
echo -n ".mybashrc: " |
58 |
xhost +root@localhost |
59 |
|
60 |
which I place in my .mybashrc, where I keep all of my .bashrc |
61 |
customizations. My way, it can |
62 |
remind me what's going on, and seems more direct. It also works if I "su" |
63 |
to root. As an old-timer on Unix, I often forget sudo. I don't like it |
64 |
much anyway because it won't get me into root if something goes wrong in |
65 |
bootup: with this in mind, I need a root PW anyway, until that bottleneck |
66 |
gets fixed. |
67 |
|
68 |
The above form is actually only used in a debugging mode I've defined, and |
69 |
is silent otherwise. |
70 |
|
71 |
++ kevin |
72 |
|
73 |
-- |
74 |
Kevin O'Gorman, PhD |