Re: ~/.hosts patch

From: Brian Candler <B.Candler_at_pobox.com>
Date: Tue, 4 Jul 2006 13:12:28 +0100
On Mon, Jul 03, 2006 at 02:55:04PM -0700, Brooks Davis wrote:
> The problem is that the client application using a port forwarded to
> localhost:port via ssh must connect to that port via the host name of
> the remote server or it will crash the remote server because it also
> passes localhost or 127.0.0.1 to the remote server over the TCP session
> and the server misbehaves in that case.  Yes it's a bug in both the
> remote server and the client/server protocol, but that's really beside
> the point.  Crappy software exists and sometimes we have to deal with
> it.
> 
> The simple fact is that I needed a hack like this and there wasn't
> another solution (with possible exception of a SOCKS proxy, which wasn't
> an option at the time) a ~/.hosts file would have been a nice way to
> implement part of it rather than actually adding the entry to /etc/hosts.

Well, assuming your client calls gethostbyname() then you could write a tiny
library which always returns 127.0.0.1, and use LD_PRELOAD to load it
beforehand.

Another solution (which doesn't require coding) would be to run the
application inside a jail, and either frig /etc/hosts there, or point
resolv.conf to a nameserver inside the jail, which has a '*' A record
mapping everything to 127.0.0.1

Regards,

Brian.
Received on Tue Jul 04 2006 - 10:12:41 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:57 UTC