Subject: Making xfs (etc.) bind to localhost instead of INADDR_ANY
To: None <current-users@netbsd.org>
From: Alan Barrett <apb@cequrux.com>
List: current-users
Date: 05/16/2005 14:56:13
How do I prevent xfs(1) from binding to INADDR_ANY? I'd like it to
listen on 127.0.0.1:7100, not on 0.0.0.0:7100. And similarly for other
X applications.
After several layers of macros and function calls, it seems to get to
SocketINETCreateListener() in xsrc/xfree/xc/lib/xtrans/Xtranssock.c,
which unconditionally does this:
((struct sockaddr_in *)&sockname)->sin_addr.s_addr = htonl(INADDR_ANY);
Would bad things happen to other X applications if I just patched
it to use htonl(0x7f000001) instead?
Alternatively, does anybody have a systrace policy
that will intercept attempts to bind to INADDR_ANY,
and force them to bind to 127.0.0.1 instead?
--apb (Alan Barrett)