LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 04-28-2006, 07:32 AM   #1
flatpaw
LQ Newbie
 
Registered: Apr 2006
Posts: 4

Rep: Reputation: 0
Tomcat unable to access DNS in chroot


Hi

I'm developing a web application that needs to download files (docs, pdfs, anything really) from their URLs. The code uses java.net.URL.openStream() to connect to the URLs and perform the download. I've had the application running fine on Tomcat, but have recently moved Tomcat into a chroot jail and now the download functionality has stopped working. I'm getting a java.net.UnknownHostException which indicates that the code cannot resolve the hostname in the URL. As the code definitely works outside of the chroot I believe that Tomcat can no longer access DNS when in the chroot. So my question is how can I give Tomcat access to DNS while in the chroot?

Any help would be greatly appreciated.

P.S. I'm new to Linux (and Unix-type systems in general) so please forgive me if this is a daft question.

Thanks
 
Old 04-29-2006, 05:00 PM   #2
ataraxia
Member
 
Registered: Apr 2006
Location: Pittsburgh
Distribution: Debian Sid AMD64
Posts: 296

Rep: Reputation: 30
You need to have an /etc/resolv.conf inside your chroot. You can just copy your real one over.
 
Old 05-02-2006, 03:32 AM   #3
flatpaw
LQ Newbie
 
Registered: Apr 2006
Posts: 4

Original Poster
Rep: Reputation: 0
Thanks for your reply ataraxia. I tried what you suggested but it didn't work I'm afraid. I even tried mounting the entire /etc directory in the chroot but no success. Presumably whatever uses /etc/resolv.conf would have to be in the chroot too? I have /etc/hosts copied in my chroot and also had to mount /proc in there to fix some other problems I was having. Can you suggest anything else I might be missing?

Thanks again.
 
Old 05-02-2006, 05:38 PM   #4
ataraxia
Member
 
Registered: Apr 2006
Location: Pittsburgh
Distribution: Debian Sid AMD64
Posts: 296

Rep: Reputation: 30
Normally the consumer of resolv.conf is libc. I don't know how Java uses it.
 
Old 05-02-2006, 06:06 PM   #5
mrcheeks
Senior Member
 
Registered: Mar 2004
Location: far enough
Distribution: OS X 10.6.7
Posts: 1,690

Rep: Reputation: 50
If you are able to resolve a host using the ping command the java program should work.
 
Old 05-03-2006, 05:24 AM   #6
flatpaw
LQ Newbie
 
Registered: Apr 2006
Posts: 4

Original Poster
Rep: Reputation: 0
Thanks for the suggestions. I tried copying ping (and the libraries it needs) into my chroot jail and then running it while chrooted. It works for an IP address but not for a hostname, therefore it must be whatever does the resolution that isn't visible. Is it possible to set up the resolver in a chroot?
 
Old 05-03-2006, 09:42 AM   #7
flatpaw
LQ Newbie
 
Registered: Apr 2006
Posts: 4

Original Poster
Rep: Reputation: 0
Ok I've managed to solve this. The following are needed in the chroot:

/etc/resolv.config
/etc/nsswitch.config
/lib/libresolv.so.2
/lib/libnss*

Apparently the Name Service Switch (/etc/nsswitch.config) is called first when hostnames are being resolved. From my googling earlier I had actually tried copying this into the chroot but didn't have the required libraries in there too - when pinging you get an error saying that libresolv.so.2 is missing if its not there but nothing if the libnss* libraries are missing so I hadn't realised they were needed.

Thanks for your help.
 
  


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
Tomcat : unable to access the jsp pages minil Programming 11 01-28-2006 09:19 AM
DNS with SELinux vs chroot jail jcoder24 Linux - Security 3 09-29-2005 10:53 PM
ipchains ? Unable to access internet ... dns error ! mystique98ls Linux - Newbie 5 09-17-2004 09:06 AM
Unable to access tomcat, using ip in the URL MakingOfAGeek Linux - Newbie 0 11-14-2003 02:16 AM
Unable to shut down tomcat MakingOfAGeek Linux - Newbie 1 10-26-2003 07:48 AM


All times are GMT -5. The time now is 01:34 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