Tcp To Unix (sockets).
A small wrapper program which switches TCP (actually, any AF_INET) sockets to Unix sockets transparently.
ttu is provided in two forms:
libttu.so-- the injection library (overridesbind,connect, etc) which does the magicttu-- small wrapper program to make usinglibttu.soeasier
ttu use LD_PRELOAD to inject the library into a program, silently overriding several socket-related system calls.
Basically, use libttu.so like this:
$ LD_PRELOAD="/path/to/libttu.so" TTU_BIND="..." TTU_CONNECT="..." program [args]...
Where:
/path/to/libttu.sois the absolute path to thelibttu.sobinary.TTU_BINDandTTU_CONNECTare optional and described here.program [args]are the usual command-line arguments to run the program.
ttu automates the above process, making it much easier to use:
$ ttu [-l "/path/to/libttu.so"] [-b bind-map] [-c connect-map] -- program [args]
Where:
/path/to/libttu.sois the absolute path to thelibttu.sobinary.-b bind-mapand-c connect-mapare optional and described here.program [args]are the usual command-line arguments to run the program.
The paramaters to ttu are the following:
TTU_BIND: A mapping of bindings (inet listening sockets) to unix sockets (aka a bind-map).TTU_CONNECT: A mapping of connections (inet connecting sockets) to unix sockets (aka a connect-map).
Socket mappings are in this format:
[ip-addr]:[port]=/path/to/socket.sock,[ip-addr]:[port]=/path/to/socket.sock, ...
Where:
ip-addris the ip address of the inet socket (optional, defaults to*).portis the port of the inet socket (optional, defaults to*)./path/to/socket.sockis the path to the socket (mandatory, the path is recommended to be an absolute path [to avoidchdir(2)problems])
In the above options, * acts as a wildcard. The order of preference in finding a socket to bind to is as follows:
- The exact match of
ip:portin the parameters. - The wildcard match of
*:portin the parameters. - The wildcard match of
ip:*in the parameters. - The wilcard match of
*:*in the parameters. - Passthrough and allow the socket to bind normally (no remapping).
If several different paramaters have the same mapping (such as 0.0.0.0:80=/tmp/a,0.0.0.0:80=/tmp/b or *:*=/tmp/a,*:*=/tmp/b), the last mapping in the option is obeyed.