chiark / gitweb /
Debianize.
[preload-hacks] / noip.1
CommitLineData
e4976bb0 1.de VS
2.sp 1
3.RS
4.nf
5.ft B
6..
7.de VE
8.ft R
9.fi
10.RE
11.sp 1
12..
13.TH noip 1 "5 May 2005" "Straylight/Edgeware" "Preload hacks"
14.SH NAME
15noip \- run programs without the ability to use IP sockets
16.SH SYNOPSIS
17.B noip
18.RI [ command
19.RI [ args ...]]
20.SH DESCRIPTION
21The
22.B noip
23program runs
24.I command
25(by default, the user's shell, as determined by the
26.B SHELL
27environment variable) in an environment where attempts to use TCP/IP
28networking are (mostly) transparently translated into the use of
29Unix-domain sockets in a private directory.
30.PP
31There are many programs which use TCP/IP for their own internal
32communications needs, largely unnecessarily. This can present security
33problems: even if a program binds its listening sockets to
34.BR localhost ,
35other users on the same system can still connect, and many such programs
36don't seem to have authentication systems.
37.PP
38.B noip
39addresses this problem by intercepting a program's networking calls and
40making it use Unix-domain sockets in a private directory instead of
41TCP/IP. Now its communications are truly private to the running user.
42.SS The socket directory
43The
44.B noip
45program keeps its sockets in a directory whose name can be configured,
46but by default is
47.BI noip- \c
48.IR username ,
49where
50.I username
51is determined by the
52.B USER
53or
54.B LOGNAME
55environment variables, or is
56.BI uid- \c
57.IR realuid
58in the temporary directory, which in turn is determined by the
59.B TMPDIR
60or
61.B TMP
62environment variables, or is
63.BR /tmp .
64The sockets in this directory are simply named
65.IB dottedquad : port
66after the Internet sockets they represent.
67.PP
68If the socket directory does not exist when a program running under
69.B noip
70starts up, it is created and made readable and writable only by the
71current user. Also, it is scanned and any apparently stale sockets are
72removed.
73.SS Configuration
74The operation of
75.B noip
76is controlled by a configuration file. By default,
77.B noip
78reads configuration from
79.B .noip
80in the calling user's home directory, as determined by the
81.B HOME
82environment, or, failing that, looking up the
83.I real
84(not effective) user id in the password database.
85.PP
86The configuration file has a simple line-based format. A line is
87ignored if it consists only of whitespace, or if its first whitespace
88character is
89.RB ` # '.
90Otherwise, the first whitespace-delimited word is a keyword and the
91remainder of the line is a value. The following keywords are
92recognized.
93.TP
94.BR "debug " [\fInumber\fR]
95If
96.I number
97is nonzero, turn debugging on; if it is zero, turn debugging off. The
98default, if no
99.I number
100is given, is to turn debugging on. Debugging is written to standard
101error. Some debugging is produced before the configuration file is
102read; the environment variable
103.B NOIP_DEBUG
104can be used to control this.
105.TP
106.BI "socketdir " directory
107Store the Unix-domain sockets in
108.IR directory
109rather than the default.
110.TP
111.BI "realbind " acl-entry
112Add an entry to the
113.B realbind
114access control list (ACL). When a program attempts to
115.BR bind (2)
116a socket to an address, the
117.B realbind
118ACL is consulted. If the address is matched, then the program is
119allowed to bind a real Internet socket to that address; otherwise, the
120socket is bound to a Unix-domain socket.
121.TP
122.BI "realbind " acl-entry
123Add an entry to the
124.B realconnect
125access control list (ACL). When a program attempts to
126.BR connect (2)
127a socket to an address, or to contact another socket using
128.BR sendto (2)
129or
130.BR sendmsg (2),
131the
132.B realconnect
133ACL is consulted. If the destination address is matched, then the
134program is allowed to contact the real Internet socket; otherwise, the
135attempt is made to contact a Unix-domain socket.
136.PP
137(Aside: An attempt to connect to a remote host may not be a hopeless failure,
138even if a real IP socket is denied:
139.B noip
140deliberately makes no attempt to check that addresses being bound to
141sockets correspond to locally available addresses; and besides, sockets
142can be introduced into the directory by other programs simulating remote
143servers.)
144.PP
145An
146.I acl-entry
147has this format:
148.IP
149.BR + | \-
150.IR address \c
151.RB [ \- \c
152.IR address | \c
153.BR / \c
154.IR mask ]| \c
155.BR local | any
156.RB [ : \c
157.IR port [ \c
158.BI \- \c
159.IR port ]]
160.PP
161(The spaces in the above are optional.)
162.PP
163The leading sign says whether
164matching addresses should be
165.I accepted
166.RB (` + ')
167or
168.I denied
169.RB (` \- ').
170.PP
171The IP-address portion may be any of the following
172.TP
173.B any
174Matches all addresses.
175.TP
176.B local
177Matches the address of one of the machine's network interfaces.
178.TP
179.I address
180Matches just the given address
181.TP
182.IB address \- address
183Matches any address which falls in the given range. Addresses are
184compared lexicographically, with octets to the left given precedence
185over octets to the right.
186.TP
187.IB address / mask
188Matches an address in the given network. The
189.I mask
190may be a netmask in dotted-quad form, or a one-bit-count.
191.PP
192The port portion may be omitted (which means `match any port'), or may
193be a single
194.I port
195or a range
196.IB port \- port
197to match.
198.PP
199Range comparisons are always inclusive of both endpoints.
200.PP
201ACL entries are processed in the order they appear in the configuration
202file. The default action of an ACL, used if none of its entries match,
203is the opposite of the last actual entry in the list: if the last entry
204says `accept', then the default is to deny, and vice-versa. If the ACL
205is empty, the default is to deny all addresses.
206.PP
207For example, it may be useful to allow access at least to a DNS server.
208This can be accomplished by adding a line
209.VS
210realconnect +1.2.3.4:52
211.VE
212to the configuration file, where 1.2.3.4 is the IP address of one of
213your DNS server.
214.SS Example applications
215SLIME is an Emacs extension for doing interactive programming with Lisp
216systems. It communicates with the Lisp system using TCP sockets, since
217Unix-domain sockets are unavailable on Windows, and besides, they are
218less well supported by Lisp implementations. Unfortunately, when the
219author wrote this program, SLIME applied no authentication on its TCP
220port, allowing any local user to take over the running Lisp. Worse,
221some Lisps are unable to bind a listening socket to a particular
222address, leaving the socket potentially available to anyone on the
223network. By running Emacs under
224.BR noip ,
225the security hole is closed completely and no messing with
226authentication secrets is needed.
227.PP
228SSH is an excellent tool for secure communications over hostile
229networks. In particular, its ability to forward TCP connections to a
230port on one side of an SSH tunnel to the other side is very useful.
231However, such a forwarded port is available to all users on the source
232side of the tunnel. Using
233.B noip
234and a suitable configuration, a user can restrict access to a forwarded
235port to himself or a small group.
236.SH BUGS
237.B noip
238is implemented as an
239.B LD_PRELOAD
240hack. It won't work on setuid programs. Also, perhaps more
241importantly, it can't do anything a
242.I malicious
243program use of networking: a program could theoretically issue sockets
244system calls directly instead of using the C library calls that
245.B noip
246intercepts. It is intended only as a tool for enhancing the security of
247software written by well-meaning programmers who don't understand the
248security aspects of writing networking code.
249.PP
250It's very hard to tell exactly what state a Unix-domain socket is in.
251If the filesystem object isn't there, it's not active, but if it
252.I is
253then the socket might be in use or it might be stale.
254.B noip
255consults
256.B /proc/net/unix
257to decide whether a socket is in use, but this can fail in two ways.
258Firstly, if the socket is created and renamed, the kernel doesn't
259notice, and
260.B noip
261will think that the new name is stale. Secondly, if the socket is
262created, used, unlinked while it's still in use, and recreated, then
263.B noip
264will think that it's in use when in fact it's gone stale. Don't mess
265with
266.BR noip 's
267sockets unless you know what you're doing.
268.PP
269The procedure to replace a Unix-domain socket by an Internet one is
270fairly thorough, but there are some missing cases. In particular, if
271the socket being bound or connected is a duplicate (using
272.BR dup (2))
273then only one of the copies will be fixed. Similarly, copies owned by
274child processes will be unaffected.
275.PP
276This manual is surprisingly long and complicated for such a simple hack.
277.SH AUTHOR
278Mark Wooding, <mdw@nsict.org>