LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
LinkBack Search this Thread
Old 03-14-2006, 09:19 PM   #1
hypexr
Member
 
Registered: Oct 2003
Location: USA Fresno Callifornia
Distribution: Gentoo (workstation), ArchLinux (file/mail server), Freebsd (web server), Ubuntu (laptop)
Posts: 115

Rep: Reputation: 16
cannot connect to X server :0.0


Ahhhh man, I've spent so many hours searching for an answer on google and here! I hope some one can help me.

I have a chrooted environment that I have set up on a few different computers. I need to run xwindows applications and on some of the it works and on some it doesn't. When it doesn't work, say for instance I am trying to start emacs, I get this error:

Code:
emacs: cannot connect to X server :0.0
I have tried setting

Code:
xhost +
before entering the chroot and when inside of it.

My DISPLAY variable is, echo $DISPLAY:

Code:
:0.0
normally and when chrooted.

I do not have any firewalls running on any of the machines.

I am thinking that it is a security option somewhere that is preventing the connection or something but I can not find where this would be.


Thanks,
Scott
 
Old 03-14-2006, 10:58 PM   #2
ilikejam
Senior Member
 
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 95
Hi.

Unless I'm mistaken (which is entirely possible), apps communicate with X through a socket at:
/tmp/.X11-unix/X0

If you're chrooted, you probably can't access that socket.

Dave
 
Old 03-14-2006, 11:36 PM   #3
tomdkat
Member
 
Registered: May 2003
Location: S.F. Bay Area
Distribution: Ubuntu 9.04 AMD64
Posts: 595

Rep: Reputation: 30
Quote:
Originally Posted by ilikejam
Hi.

Unless I'm mistaken (which is entirely possible), apps communicate with X through a socket at:
/tmp/.X11-unix/X0

If you're chrooted, you probably can't access that socket.
Sounds reasonable to me.

Also, when issuing the "xhost" command, use "xhost +localhost" so you won't open your X server up to the entire world.

Peace...
 
Old 03-15-2006, 01:22 AM   #4
hypexr
Member
 
Registered: Oct 2003
Location: USA Fresno Callifornia
Distribution: Gentoo (workstation), ArchLinux (file/mail server), Freebsd (web server), Ubuntu (laptop)
Posts: 115

Original Poster
Rep: Reputation: 16
I didn't have the socket in my /tmp! So I, probably rather foolishly, tried to copy it over to my chroot world. I chrooted in and got the same message, "cannot connect to X server :0.0".

I tried to get more information about this problem so I enabled X11forwarding. I then chrooted in and tried this:

Code:
ssh -X localhost xclock
Without the copied socket (/tmp/.X11-unix/X0) it shows me this:

Code:
Warning: No xauth data; using fake authentication data for X11 forwarding.
connect /tmp/.X11-unix/X10: No such file or directory
X connection to localhost:10.0 broken (explicit kill or server shutdown).
It can't find it so there is no hope of it connecting.

With the socket copied into the chrooted environment I get this:

Code:
connect /tmp/.X11-unix/X0: Connection refused
X connection to localhost:10.0 broken (explicit kill or server shutdown).
Its there now but connection refused. My access is being blocked or the socket is not valid after being copied.

So there is a difference and this socket seems to be my problem. I am going to check on the boxes that don't have the problem starting X applications in chroot tomorrow and see if the /tmp/.X11* directories exist in their chrooted environments. If not then maybe this is not a problem after all.

Thanks so much for the information, it has been so helpful!
 
Old 03-15-2006, 09:29 AM   #5
hypexr
Member
 
Registered: Oct 2003
Location: USA Fresno Callifornia
Distribution: Gentoo (workstation), ArchLinux (file/mail server), Freebsd (web server), Ubuntu (laptop)
Posts: 115

Original Poster
Rep: Reputation: 16
This morning I thought of adding a symbolic link to X0.

Code:
# ls -al /chenv/tmp/.X11-unix
lrwxrwxrwx  1 root root 25 Mar 15 07:25 X0 -> ../../../tmp/.X11-unix/X0
Here's the output after trying the same X11 forwarding test as above:

Code:
connect /tmp/.X11-unix/X0: Too many levels of symbolic links
X connection to localhost:10.0 broken (explicit kill or server shutdown).
I guess sym links are not an option.
 
Old 03-15-2006, 09:55 AM   #6
tomdkat
Member
 
Registered: May 2003
Location: S.F. Bay Area
Distribution: Ubuntu 9.04 AMD64
Posts: 595

Rep: Reputation: 30
Why not create a "tmp" directory in the directory you chroot to?

For example, if you chroot someone to "/home/bob", make sure "tmp" (with 777 permissions) exists in /home/bob (i.e. /home/bob/tmp). Then let X create it's directories and sockets as it sees fit.

Peace...
 
Old 03-15-2006, 10:22 AM   #7
hypexr
Member
 
Registered: Oct 2003
Location: USA Fresno Callifornia
Distribution: Gentoo (workstation), ArchLinux (file/mail server), Freebsd (web server), Ubuntu (laptop)
Posts: 115

Original Poster
Rep: Reputation: 16
The tmp directory does exist. That is where I tried copying to socket to and then later tried creating the symbolic link in. Tnx
 
Old 03-15-2006, 10:44 AM   #8
tomdkat
Member
 
Registered: May 2003
Location: S.F. Bay Area
Distribution: Ubuntu 9.04 AMD64
Posts: 595

Rep: Reputation: 30
Quote:
Originally Posted by hypexr
The tmp directory does exist. That is where I tried copying to socket to and then later tried creating the symbolic link in. Tnx
Did you create "/tmp/.X11-unix/" or just "/tmp"? If you create the former, delete the .X11* stuff so "tmp" is empty and let X create the files it wants/needs there itself.

From your message above, it looks like you copied the ".X11-unix" parts of the path to the socket vs letting that get created automagically.

If that doesn't help, a Google search on 'ssh -X chroot' found THIS site, which might help.

Peace...
 
Old 03-15-2006, 05:22 PM   #9
hypexr
Member
 
Registered: Oct 2003
Location: USA Fresno Callifornia
Distribution: Gentoo (workstation), ArchLinux (file/mail server), Freebsd (web server), Ubuntu (laptop)
Posts: 115

Original Poster
Rep: Reputation: 16
Well, I did not have to create that tmp directory because it has always been in my chroot environment. I did try creating the .X11-unix and stuff but this was after trying it with just tmp in place.

Those files are not created in chroots environment after chrooting in because there has not been an xserver started in the chrooted environment. That is why I was trying to copy them and then tried to symbolic link them.

It appears, now, that my problem doesn't relate to this socket in tmp/.X11-unix because the machines that do not have a problem starting the x applications also do not have those files. So I am back to thinking this is a premissions thing but I am not sure how that can be when I have used xhost to allow the connection. I have also messed with xauth to see if I could get different results. Here is what I tried with xauth:

Code:
xauth extract - $DISPLAY > au.txt
cp au.txt /chrootdir
<commands to chroot in>
xauth merge - < au.txt
From what I have read this will set it up so that the user will have proper permissions to use the xserver, but for my situation this doesn't solve anything. My understanding is that xhost + is supose to open xserver to absolutely everyone so the xauth stuff above is probably redundant.

At this point I am pretty much stumped, again, and I'm tired of reading endless amounts of information that are not providing me any insight. Pushed to my list of-> cannot figure it out and not going to continue trying.

Tnx for the help.
 
Old 03-15-2006, 05:33 PM   #10
hypexr
Member
 
Registered: Oct 2003
Location: USA Fresno Callifornia
Distribution: Gentoo (workstation), ArchLinux (file/mail server), Freebsd (web server), Ubuntu (laptop)
Posts: 115

Original Poster
Rep: Reputation: 16
Woops. i accidently posted the message twice.. I can't delete this post?

Last edited by hypexr; 03-15-2006 at 05:35 PM.
 
Old 02-02-2012, 11:14 PM   #11
romagnolo
Member
 
Registered: Jul 2009
Location: Montaletto
Distribution: Debian GNU/Linux
Posts: 65

Rep: Reputation: 3
hypexr, I can confirm that after years the problem persist!
I've spent hours too, without solution.
The only nearest touch I got was to learn that a program called Xnest exists to provide such a feature, but in my debian it doesn't work because it appears restricted to ipv6 which I'm not going to set in. Maybe ipv4 could be switched with adequate configuration.
 
Old 02-03-2012, 10:51 PM   #12
romagnolo
Member
 
Registered: Jul 2009
Location: Montaletto
Distribution: Debian GNU/Linux
Posts: 65

Rep: Reputation: 3
I just got the solution in hands! (spent DAYS..)

Install openssh-server. If version < 4.9, apply an ad hoc patch as described in http://ulf.zeitform.de/en/documents/sshchroot.html

Then in the configuration file (/etc/ssh/sshd_config) insert:
Quote:
ChrootDirectory /your/chroot-environment
.
As pointed out in http://www.openbsd.org/cgi-bin/man.c...ry=sshd_config , all the directory path leading to the chroot must be root owned and no writable by anyone else.

To link an X session, connect to localhost with X11 forwarding:
Quote:
ssh -X localhost
.
Solved!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Unix-connect: can't connect to server jrdioko Linux - Software 1 01-08-2006 04:56 PM
Cannot connect to X server gmh04 Suse/Novell 3 03-24-2005 11:57 PM
Suddenly unable to connect to my web server and my ftp server. HELP! Silly22 Linux - Software 4 05-23-2004 04:42 PM
Is samba required to connect to a Windows Advanced server from RedHat 8.0 server? NemesisStar Linux - Hardware 1 10-20-2003 12:32 AM
Cannot connect to X server :0.0 Celorfin Linux - Newbie 3 10-09-2003 02:25 PM


All times are GMT -5. The time now is 12:03 PM.

Main Menu
 
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration