cURL / Mailing Lists / curl-library / Single Mail

curl-library

curl/c-ares problem with a chroot'ed program

From: codemastr <codemstr_at_ptd.net>
Date: Wed, 4 Feb 2004 18:32:18 -0500

Ok here's the problem. libcurl calls ares_init() in Curl_addrinfo().
Curl_addrinfo() is called for each download. Here is the problem,
ares_init() loads /etc/resolv.conf. Once my program does chroot(),
/etc/resolv.conf is now "outside the root" and therefore inaccessible. As a
result, c-ares and libcurl can no longer determine my nameserver info.

There is a solution I've come up with that is the best I can think of.
(maybe someone can come up with a better method of implementation).

CURL_GLOBAL_ARES. If this is set in curl_global_init, then curl will call
ares_init, store the results in a global var (could result in threading
issues, though this global var should never be modified, only read therefore
I can't forsee any...), then Curl_addrinfo() will no longer call
ares_init(), instead, it will simply use this global var.

If CURL_GLOBAL_ARES is _not_ specified then everything works as it currently
does.

This should solve the problem since as long as I call curl_global_init
before chroot(), curl will store the resolv.conf info and it will work. This
also serves to make things faster since it doesn't have to read a file (or
on win look in the registry) each time a DNS query is to be made...

Suggestions/comments?

Dominick Meglio

-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
Received on 2004-02-05