Subject: Making xfs (etc.) bind to localhost instead of INADDR_ANY
To: None <>
From: Alan Barrett <>
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, not on  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 instead?

--apb (Alan Barrett)