resolver not working in a chroot

Matthew Seaman matthew at FreeBSD.org
Wed Jan 20 08:27:10 UTC 2016


On 20/01/2016 02:05, Perry Hutchison wrote:
> Matthew Seaman <matthew at freebsd.org> wrote:
>> On 01/19/16 09:45, Perry Hutchison wrote:
>>> The resolver is not working in a chroot (to the 10.2 memstick image,
>>> with its /tmp, /var/run, and /var/tmp made writable by mounting tmpfs
>>> on them):
>>>   # chroot -u 0 -g 0 -G 105,0,5,20,25 /mnt ping pkg.FreeBSD.org
>>>   ping: cannot resolve pkg.FreeBSD.org: Host name lookup failure
>>> but it works when not in a chroot:
>>>   # ping pkg.FreeBSD.org
>>>   PING pkg.FreeBSD.org (96.47.72.71): 56 data bytes
>>>   64 bytes from 96.47.72.71: icmp_seq=0 ttl=51 time=97.329 ms
>>>   ...
>>> What would cause this?
>>
>> You've mounted the 10.2 memstick image on /mnt?
> 
> Yes.
> 
>> Do you have a devfs mounted inside the chroot?  Try running:
>>
>>    # mount -t devfs devfs /mnt/dev
>>
>> and then try your chroot'ed command again.  Interesting to see
>> if that helps.
> 
> The mount command worked -- there's now a devfs in the chroot
> environment -- but it didn't help.  I still get the same error.
> I also tried running "mount -t devfs devfs /dev" in the chroot
> (after unmounting /mnt/dev), and that didn't help either.
> 
> There must be some difference in the lookup mechanisms between
> the resolver and host(1), since host(1) works in the chroot.

Yes.  host(1) uses only the DNS, whereas the general resolver functions
can use all sorts of resolution mechanisms -- see nsswitch.conf(5).

In order to track down exactly what the problem is I'd be running that
ping command under truss(1) to try and spot what the failure is.  That's
not guaranteed to work, nor is it generally completely obvious from the
truss output what the trouble may be.  My guess though is that something
is read-only which the system expects to be read-write.

	Cheers,

	Matthew



-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 957 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20160120/c9a8c09c/attachment.sig>


More information about the freebsd-questions mailing list