chiark / gitweb /
noip.1: Describe ACL entries in terms of <address-range> and <port-range>.
[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
5b49f527 82environment, or, failing that, looking up the effective user id in the
83password database. However, if the environment variable
a6d9626b 84.B NOIP_CONFIG
85is set, then the file it names is read instead (assuming it exists; if
86it doesn't, no configuration is read).
e4976bb0 87.PP
88The configuration file has a simple line-based format. A line is
89ignored if it consists only of whitespace, or if its first whitespace
90character is
91.RB ` # '.
92Otherwise, the first whitespace-delimited word is a keyword and the
93remainder of the line is a value. The following keywords are
94recognized.
95.TP
96.BR "debug " [\fInumber\fR]
97If
98.I number
99is nonzero, turn debugging on; if it is zero, turn debugging off. The
100default, if no
101.I number
102is given, is to turn debugging on. Debugging is written to standard
103error. Some debugging is produced before the configuration file is
104read; the environment variable
105.B NOIP_DEBUG
106can be used to control this.
107.TP
108.BI "socketdir " directory
109Store the Unix-domain sockets in
110.IR directory
a6d9626b 111rather than the default. The environment variable
112.B NOIP_SOCKETDIR
113can also be used to control which directory is used for sockets.
e4976bb0 114.TP
f6049fdd 115.BI "autoports " min "\-" max
116Select which ports are used for implicit binding. Allocating ports can
117be a bit slow, since checking whether a Unix domain socket is in use is
118difficult. A wide range makes things easier, because
119.B noip
120starts by trying ports at random from the given range. The environment
121variable
122.B NOIP_AUTOPORTS
123can also be used to control which ports are assigned automatically.
124.TP
e4976bb0 125.BI "realbind " acl-entry
126Add an entry to the
127.B realbind
128access control list (ACL). When a program attempts to
129.BR bind (2)
130a socket to an address, the
131.B realbind
132ACL is consulted. If the address is matched, then the program is
133allowed to bind a real Internet socket to that address; otherwise, the
a6d9626b 134socket is bound to a Unix-domain socket. Three environment variables
135are consulted too:
136.BR NOIP_REALBIND_BEFORE ,
137.BR NOIP_REALBIND ,
138and
139.BR NOIP_REALBIND_AFTER .
140The
141.B _BEFORE
142rules are inserted at the front of the list; the
143.B _AFTER
144rules are appended on the end. Currently, the rules in
145.B NOIP_REALBIND
146are also put at the end (before the
147.B _AFTER
148rules), though this may change later.
e4976bb0 149.TP
a6d9626b 150.BI "realconnect " acl-entry
e4976bb0 151Add an entry to the
152.B realconnect
153access control list (ACL). When a program attempts to
154.BR connect (2)
155a socket to an address, or to contact another socket using
156.BR sendto (2)
157or
158.BR sendmsg (2),
159the
160.B realconnect
161ACL is consulted. If the destination address is matched, then the
162program is allowed to contact the real Internet socket; otherwise, the
a6d9626b 163attempt is made to contact a Unix-domain socket. Three environment variables
164are consulted too:
165.BR NOIP_REALCONNET_BEFORE ,
166.BR NOIP_REALCONNECT ,
167and
168.BR NOIP_REALCONNECT_AFTER .
169The
170.B _BEFORE
171rules are inserted at the front of the list; the
172.B _AFTER
173rules are appended on the end. Currently, the rules in
174.B NOIP_REALCONNECT
175are also put at the end (before the
176.B _AFTER
177rules), though this may change later.
e4976bb0 178.PP
179(Aside: An attempt to connect to a remote host may not be a hopeless failure,
180even if a real IP socket is denied:
181.B noip
182deliberately makes no attempt to check that addresses being bound to
183sockets correspond to locally available addresses; and besides, sockets
184can be introduced into the directory by other programs simulating remote
185servers.)
186.PP
187An
188.I acl-entry
a6d9626b 189is a comma-separated list of entries of the form:
e4976bb0 190.IP
191.BR + | \-
0a6ab6a1 192.I address-range
e4976bb0 193.RB [ : \c
0a6ab6a1 194.IR port-range ]
e4976bb0 195.PP
196(The spaces in the above are optional.)
197.PP
99222954 198The leading sign says whether matching addresses should be
e4976bb0 199.I accepted
200.RB (` + ')
201or
202.I denied
203.RB (` \- ').
204.PP
0a6ab6a1
MW
205The
206.I address-range
207portion may be any of the following.
e4976bb0 208.TP
209.B any
210Matches all addresses.
211.TP
212.B local
213Matches the address of one of the machine's network interfaces.
214.TP
215.I address
2a06ea0b 216Matches just the given IPv4 or IPv6 address. An
9314b85a 217.I address
2a06ea0b
MW
218may be enclosed in square brackets; IPv6 addresses must be so enclosed,
219because colons are significant in the rest of the ACL syntax.
e4976bb0 220.TP
221.IB address \- address
222Matches any address which falls in the given range. Addresses are
223compared lexicographically, with octets to the left given precedence
224over octets to the right.
225.TP
9314b85a
MW
226.IB address / prefix-length
227Matches an address in the given network.
e4976bb0 228.PP
0a6ab6a1
MW
229The
230.I port-range
231may be omitted (which means `match any port'), or may be a single
e4976bb0 232.I port
233or a range
234.IB port \- port
235to match.
236.PP
237Range comparisons are always inclusive of both endpoints.
238.PP
239ACL entries are processed in the order they appear in the configuration
240file. The default action of an ACL, used if none of its entries match,
241is the opposite of the last actual entry in the list: if the last entry
242says `accept', then the default is to deny, and vice-versa. If the ACL
243is empty, the default is to deny all addresses.
244.PP
245For example, it may be useful to allow access at least to a DNS server.
246This can be accomplished by adding a line
247.VS
a8be0591 248realconnect +1.2.3.4:53
e4976bb0 249.VE
250to the configuration file, where 1.2.3.4 is the IP address of one of
251your DNS server.
252.SS Example applications
253SLIME is an Emacs extension for doing interactive programming with Lisp
254systems. It communicates with the Lisp system using TCP sockets, since
255Unix-domain sockets are unavailable on Windows, and besides, they are
256less well supported by Lisp implementations. Unfortunately, when the
257author wrote this program, SLIME applied no authentication on its TCP
258port, allowing any local user to take over the running Lisp. Worse,
259some Lisps are unable to bind a listening socket to a particular
260address, leaving the socket potentially available to anyone on the
261network. By running Emacs under
262.BR noip ,
263the security hole is closed completely and no messing with
264authentication secrets is needed.
265.PP
266SSH is an excellent tool for secure communications over hostile
267networks. In particular, its ability to forward TCP connections to a
268port on one side of an SSH tunnel to the other side is very useful.
269However, such a forwarded port is available to all users on the source
270side of the tunnel. Using
271.B noip
272and a suitable configuration, a user can restrict access to a forwarded
273port to himself or a small group.
274.SH BUGS
275.B noip
276is implemented as an
277.B LD_PRELOAD
278hack. It won't work on setuid programs. Also, perhaps more
a8be0591 279importantly, it can't do anything to prevent a
e4976bb0 280.I malicious
a8be0591 281program's use of networking: a program could theoretically issue sockets
e4976bb0 282system calls directly instead of using the C library calls that
283.B noip
284intercepts. It is intended only as a tool for enhancing the security of
285software written by well-meaning programmers who don't understand the
286security aspects of writing networking code.
287.PP
288It's very hard to tell exactly what state a Unix-domain socket is in.
289If the filesystem object isn't there, it's not active, but if it
290.I is
291then the socket might be in use or it might be stale.
292.B noip
293consults
294.B /proc/net/unix
295to decide whether a socket is in use, but this can fail in two ways.
296Firstly, if the socket is created and renamed, the kernel doesn't
297notice, and
298.B noip
299will think that the new name is stale. Secondly, if the socket is
300created, used, unlinked while it's still in use, and recreated, then
301.B noip
302will think that it's in use when in fact it's gone stale. Don't mess
303with
304.BR noip 's
305sockets unless you know what you're doing.
306.PP
307The procedure to replace a Unix-domain socket by an Internet one is
308fairly thorough, but there are some missing cases. In particular, if
309the socket being bound or connected is a duplicate (using
310.BR dup (2))
311then only one of the copies will be fixed. Similarly, copies owned by
312child processes will be unaffected.
313.PP
314This manual is surprisingly long and complicated for such a simple hack.
315.SH AUTHOR
a8be0591 316Mark Wooding, <mdw@distorted.org.uk>