Mailinglist Archive: opensuse (4631 mails)

< Previous Next >
Re: [opensuse] Getting error "cannot connect to X server" when using sudo to run a program
  • From: "Andy Harrison" <aharrison@xxxxxxxxx>
  • Date: Thu, 18 Jan 2007 21:46:09 -0500
  • Message-id: <a22ff2940701181846g49de5488wc075d8e988fafbf5@xxxxxxxxxxxxxx>
On 1/18/07, Graham Smith <gqs@xxxxxxxxxxxxx> wrote:
xauth info on both systems are the same.
The output of xhost is the same.

I tried it myself and I get the exact same results. I've never seen
sudo misbehave this way and I use every day (though only Solaris and
FreeBSD) including for remotely displaying X apps like veritas
netbackup. Normally the environment variables are not completely
wiped out, but this is not the case here.

printenv HOME
printenv DISPLAY
sudo printenv HOME
sudo printenv DISPLAY

The DISPLAY variable is clearly getting flushed. The ONLY way I could
get it to work on my 10.2 system was:

cat /tmp/
if [ -z "$DISPLAY" ] ; then
export DISPLAY=":0.0"

sudo /tmp/

And up pops xcalc.

Obviously this method would fail if you wanted to tunnel the display
through ssh.

Just to make sure I'm not dreaming I tried it and here it is working
successfully on Solaris.

> printenv PWD
printenv DISPLAY
sudo printenv PWD
sudo printenv DISPLAY

DISPLAY is not getting squashed.

Andy Harrison
To unsubscribe, e-mail: opensuse+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: opensuse+help@xxxxxxxxxxxx

< Previous Next >