Fix bug in identification timout handling.
[fwd] / fw.1
CommitLineData
10a454ad 1.\" -*-nroff-*-
667fb920 2.\"
ee599f55 3.\" $Id: fw.1,v 1.17 2003/11/29 20:36:07 mdw Exp $
667fb920 4.\"
5.\" Manual page for fw
6.\"
7.\" (c) 1999 Straylight/Edgeware
8.\"
9.
10.\"----- Licensing notice ---------------------------------------------------
11.\"
12.\" This file is part of the `fw' port forwarder.
13.\"
14.\" `fw' is free software; you can redistribute it and/or modify
15.\" it under the terms of the GNU General Public License as published by
16.\" the Free Software Foundation; either version 2 of the License, or
17.\" (at your option) any later version.
18.\"
19.\" `fw' is distributed in the hope that it will be useful,
20.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
21.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22.\" GNU General Public License for more details.
23.\"
24.\" You should have received a copy of the GNU General Public License
25.\" along with `fw'; if not, write to the Free Software Foundation,
26.\" Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27.
28.\" ---- Revision history ---------------------------------------------------
29.\"
30.\" $Log: fw.1,v $
ee599f55 31.\" Revision 1.17 2003/11/29 20:36:07 mdw
32.\" Privileged outgoing connections.
33.\"
1c2054c7 34.\" Revision 1.16 2003/11/25 14:46:50 mdw
35.\" Update docco for new options.
36.\"
49f5947b 37.\" Revision 1.15 2003/01/24 20:13:04 mdw
38.\" Fix bogus examples. Explain quoting rules for `exec' endpoints.
39.\"
23be5eb0 40.\" Revision 1.14 2002/02/23 00:05:12 mdw
41.\" Fix spacing around full stops (at last!).
42.\"
6f427571 43.\" Revision 1.13 2002/02/22 23:45:01 mdw
44.\" Add option to change the listen(2) parameter.
45.\"
d1c182e7 46.\" Revision 1.12 2001/02/23 09:11:29 mdw
47.\" Update manual style.
48.\"
723210e6 49.\" Revision 1.11 2001/02/05 19:47:11 mdw
50.\" Minor fixings to wording.
51.\"
372a98e2 52.\" Revision 1.10 2001/02/03 20:30:03 mdw
53.\" Support re-reading config files on SIGHUP.
54.\"
fc170a33 55.\" Revision 1.9 2000/03/23 00:37:33 mdw
56.\" Add option to change user and group after initialization. Naughtily
57.\" reassign short equivalents of --grammar and --options.
58.\"
370e3c14 59.\" Revision 1.8 1999/12/22 15:44:43 mdw
60.\" Fix some errors, and document new option.
61.\"
d857515e 62.\" Revision 1.7 1999/10/22 22:45:15 mdw
63.\" Describe new socket connection options.
64.\"
333c51f4 65.\" Revision 1.6 1999/10/10 16:46:29 mdw
66.\" Include grammar and options references at the end of the manual.
67.\"
cdc917d3 68.\" Revision 1.5 1999/09/26 18:18:05 mdw
69.\" Remove a fixed bug from the list. Fix some nasty formatting
70.\" misfeatures.
71.\"
e73034b0 72.\" Revision 1.4 1999/08/19 18:32:48 mdw
73.\" Improve lexical analysis. In particular, `chmod' patterns don't have to
74.\" be quoted any more.
75.\"
96bc31ba 76.\" Revision 1.3 1999/07/30 06:49:00 mdw
77.\" Minor tidying and typo correction.
78.\"
667fb920 79.\" Revision 1.2 1999/07/26 23:31:04 mdw
80.\" Document lots of new features and syntax.
81.\"
82.
83.\"----- Various bits of fancy styling --------------------------------------
84.
85.\" --- Indented paragraphs with right-aligned tags ---
86.
10a454ad 87.de hP
88.IP
89\h'-\w'\fB\\$1\ \fP'u'\fB\\$1\ \fP\c
90..
667fb920 91.
92.\" --- Verbatim-oid typesetting ---
93.de VS
94.sp 1
95.RS
96.nf
97.ft B
98..
99.de VE
100.ft R
101.fi
102.RE
103.sp 1
104..
105.
333c51f4 106.\" --- Grammar markup ---
107.\"
108.\" This is mainly for the benefit of the automatic scripts which
109.\" generate the grammar summary.
110.
111.de GS
112.PP
113..
114.de GE
115.PP
116..
117.
118.de OS
119.PP
120..
121.de OD
122.RS
123..
124.de OE
125.RE
126..
127.
667fb920 128.\" --- Other bits of styling ---
129.
130.ie t \{\
131. ds o \(bu
132. ds ss \s8\u
133. ds se \d\s0
134. if \n(.g \{\
135. fam P
136. \}
137.\}
138.el \{\
139. ds o o
140. ds ss ^
141. ds se
142.\}
143.
144.\"--------------------------------------------------------------------------
145.
d1c182e7 146.TH fw 1 "1 July 1999" "Straylight/Edgeware" "fw port forwarder"
667fb920 147.
148.\"--------------------------------------------------------------------------
10a454ad 149.SH NAME
667fb920 150.
10a454ad 151fw \- port forwarder
667fb920 152.
153.\"--------------------------------------------------------------------------
10a454ad 154.SH SYNOPSIS
667fb920 155.
10a454ad 156.B fw
370e3c14 157.RB [ \-dlq ]
10a454ad 158.RB [ \-f
159.IR file ]
fc170a33 160.RB [ \-s
161.IR user ]
162.RB [ \-g
163.IR group ]
10a454ad 164.IR config-stmt ...
667fb920 165.
166.\"--------------------------------------------------------------------------
167.SH "DESCRIPTION"
168.
10a454ad 169The
170.B fw
171program is a simple port forwarder. It supports a number of features
172the author hasn't found in similar programs:
173.TP
174.I "Connection logging"
175Each connection attempt to the forwarder is logged, giving the time of
176the connection, the DNS-resolved hostname (if available), and the user
177name resulting from an RFC931 lookup. These lookups are done
178asynchronously to the main forwarder's operation.
179.TP
180.I "Access control"
181Each forwarded port may have an access control list attached to it.
182Only authorized hosts are allowed to connect. Access control checks are
183performed by quick checks on the client's IP address.
184.TP
185.I "Nonblocking single-process design"
186The internal structure of the server is completely nonblocking. The
187connections don't block; the reading and writing don't block; the name
188lookups don't block. This is all done in a single process, with the
189single exception of the DNS resolver.
667fb920 190.TP
191.I "Support for Unix-domain sockets"
192Connections from and to Unix-domain sockets can be handled just as
96bc31ba 193easily as more normal Internet sockets. Access control doesn't work on
667fb920 194Unix domain sockets, though. (Yet.)
10a454ad 195.SS "Command line options"
196The
197.B fw
198program understands a few simple command line options:
199.TP
200.B "\-h, \-\-help"
201Displays a screen of help text on standard output and exits
202successfully.
203.TP
204.B "\-v, \-\-version"
205Writes the version number to standard output and exits successfully.
206.TP
207.B "\-u, \-\-usage"
208Writes a terse usage summary to standard output and exits successfully.
209.TP
fc170a33 210.B "\-G, \-\-grammar"
211Writes a summary of the configuration file grammar to standard output
212and exits successfully.
213.TP
214.B "\-O, \-\-options"
215Writes a summary of the source and target options to standard output and
216exits successfully.
217.TP
10a454ad 218.BI "\-f, \-\-file=" file
219Read configuration information from
220.IR file .
667fb920 221Equivalent to an
222.RB ` include
223.IR file '
224configuration file statement.
10a454ad 225.TP
667fb920 226.B "\-d, \-\-daemon, \-\-fork"
10a454ad 227Forks into the background after reading the configuration and
228initializing properly.
667fb920 229.TP
370e3c14 230.B "\-l, \-\-syslog, \-\-log"
231Emit logging information to the system log, rather than standard error.
232.TP
fc170a33 233.B "\-q, \-\-quiet"
667fb920 234Don't output any logging information. This option is not recommended
235for normal use, although it can make system call traces clearer so I use
236it when debugging.
fc170a33 237.TP
238.BI "\-s, \-\-setuid=" user
239Change uid to that of
240.IR user ,
241which may be either a user name or uid number, after initializing all
242the sources. This will usually require elevated privileges.
243.TP
244.BI "\-g, \-\-setgid=" group
245Change gid to that of
246.IR group ,
247which may be either a group name or gid number, after initializing all
248the sources. If the operating system understands supplementary groups
249then the supplementary groups list is altered to include only
250.IR group .
10a454ad 251.PP
252Any further command line arguments are interpreted as configuration
253lines to be read. Configuration supplied in command line arguments has
254precisely the same syntax as configuration in files. If there are no
96bc31ba 255configuration statements on the command line, and no
10a454ad 256.B \-f
257options were supplied, configuration is read from standard input, if
258stdin is not a terminal.
667fb920 259.
260.\"--------------------------------------------------------------------------
261.SH "CONFIGURATION LANGUAGE"
262.
263The
264.B fw
265program has a fairly sophisticated configuration language to let you
266describe which things should be forwarded where and what special
267features there should be.
268.SS "Lexical structure"
269There are four types of characters.
270.TP
271.I "word constituent characters"
96bc31ba 272Word constituent characters are gathered together into words.
667fb920 273Depending on its surrounding context, a word might act as a keyword or a
274string. All alphanumerics are word constituents, as is the hyphen
275.RB ` \- '.
276Other characters may change their status in future versions.
277.TP
278.I "self-delimiting characters"
279Self-delimiting characters always stand alone. They act as punctuation,
280shaping the sequence of words into more complex grammatical forms. The
281characters
282.RB ` { ',
283.RB ` } ',
284.RB ` [ ',
285.RB ` ] ',
286.RB ` / ',
287.RB ` , ',
288.RB ` = ',
289.RB ` : ',
290.RB ` ; '
291and
292.RB ` . '
293are self-delimiting. Note that while some characters, e.g.,
294.RB ` [ '
295and
296.RB ` ; ',
372a98e2 297require escaping by the shell, they are mostly optional in the grammar
298and can tend to be omitted in quick hacks at the shell prompt.
667fb920 299.TP
300.I "whitespace characters"
301Whitespace characters separate words but are otherwise ignored. All
302`normal' whitespace characters (e.g., space, tab and newline) are
303considered to be whitespace for these purposes.
304.TP
305.I "special characters"
306There are three special characters. The
307.RB ` # '
308character, if it appears at the start of a word, introduces a
309.I comment
310which extends to the end of the current line or command-line argument.
311Within a word, it behaves like a normal word-constituent character. The
312backslash
313.RB ` \e '
314escapes the following character causing it to be interpreted as a word
315constituent regardless of its normal type. The double-quote
316.RB ` """" '
317escapes all characters other than backslashes up to the next
318double-quote and causes them to be regarded as word constituents. Note
319that you don't have to quote a whole word. The backslash can escape a
320quote character allowing you to insert it into a word if really
321necessary.
322.
323.SS "Basic syntax"
324The overall syntax looks a bit like this:
333c51f4 325.GS "Basic syntax"
667fb920 326.I file
10a454ad 327::=
667fb920 328.I empty
329|
330.I file
331.I stmt
332.RB [ ; ]
10a454ad 333.br
334.I stmt
335::=
667fb920 336.I option-stmt
337|
338.I fw-stmt
339.br
340.I fw-stmt
341::=
342.B fw
343.I source
344.I options
345.RB [ to | \-> ]
346.I target
347.I options
348.br
349.I options
350::=
351.B {
352.I option-seq
353.B }
354.br
355.I option-seq
356::=
357.I empty
358|
359.I option-stmt
360.RB [ ; ]
361.I option-seq
333c51f4 362.GE
667fb920 363If you prefer, the keyword
364.RB ` fw '
365may be spelt
366.RB ` forward '
367or
368.RB ` from '.
369All are equivalent.
370.
371.SS "Sources and targets"
372Forwarding is set up by attaching
373.I targets
374to
375.IR sources .
376Sources are things which are capable of
377.I initiating
378one end of a data flow on their own, while targets are things which are
379capable of setting up the other end on demand. In the case of a TCP
380port forwarder, the part which listens for incoming client connections
381is the source, while the part which sets up outgoing connections to the
382destination server is the target.
383.PP
384Essentially, all
385.B fw
386does is set up a collection of sources and targets based on your
387configuration file so that when a source decides to initiate a data
388flow, it tells its target to set its end up, and then squirts data back
389and forth between the two until there's no more.
390.PP
391Some sources are
392.IR persistent :
393they stay around indefinitely setting up multiple attachments to
394targets. Others are
395.IR transient :
396they set up one connection and then disappear. If all the sources
397defined are transient, then
398.B fw
399will quit when no more active sources remain and all connections have
400terminated.
401.PP
402The
403.B fw
404program is fairly versatile. It allows you to attach any supported type
405of source to any supported type of target. This will, I hope, be the
406case in all future versions.
407.PP
408The syntax of a
409.I source
410or
411.I target
412depend on the source or target type, and are therefore described in the
413sections specific to the various types.
414.
415.SS "Options structure"
416Most of the objects that
417.B fw
418knows about (including sources and targets, but also other more specific
419things such as socket address types) can have their behaviour modified
420by
421.IR options .
422The options available at a particular point in the configuration depend
423on the
424.IR context .
425A global option, outside of a
426.I fw-stmt
427has no context unless it is explicitly qualified, and affects global
723210e6 428behaviour. A local option, applied to a source or target in a
429.IR fw-stmt ,
667fb920 430has the context of the type of source or target to which it is applied,
431and affects only that source or target.
432.PP
433Note that it's important to distinguish between an option's context
434(which is affected by its qualification) and its local or global
435status. No matter how qualified, a global option will always control
436default options for objects, and a local option will only affect a
437specific source or target.
438.PP
439The syntax for qualifying options is like this:
333c51f4 440.GS "Option syntax"
667fb920 441.I option-stmt
442::=
443.I q-option
444.br
445.I q-option
446::=
447.I option
448.br
449 |
450.I prefix
23be5eb0 451.B .\&
667fb920 452.I q-option
453.br
454 |
455.I prefix
456.B {
457.I option-seq
458.B }
459.br
460.I prefix
461::=
462.I word
333c51f4 463.GE
667fb920 464Thus, you may qualify either an individual option or a sequence of
465options. The two are equivalent; for example,
466.VS
467exec.rlimit {
468 core = 0;
469 cpu = 60;
470}
471.VE
723210e6 472means the same as
667fb920 473.VS
474exec.rlimit.core = 0;
475exec.rlimit.cpu = 0;
476.VE
477For each option, there is a sequence of prefixes which maximally qualify
478that option. An option prefixed with this sequence is
479.IR "fully qualified" .
480In actual use, some or all of those prefixes may be omitted. However,
481it's possible for the option to become
482.I ambiguous
483if you do this. For example, the option
484.B fattr.owner
485may refer either to
486.B file.fattr.owner
487or to
488.BR socket.unix.fattr.owner .
489In this case, the ambiguity is benign: a local option will have as its
490context an appropriate source or target, and both global options
491actually control the same default. However, the option
492.B logging
493may mean either
494.B socket.logging
495or
496.BR exec.logging ,
497which have separate defaults, and which one you actually get depends on
498the exact implementation of
499.BR fw 's
500option parser. (Currently this would resolve to
501.BR exec.logging ,
502although this may change in a later version.)
503.PP
504In this manual, options are usually shown in their fully-qualified form.
505.
333c51f4 506.SS "File attributes for created files: `fattr'"
507Both the
508.B file
509and
510.B socket
511sources and targets can create new filesystem objects. The
512.B fattr
513options allow control over the attributes of the newly-created objects.
514Both
515.B file
516and
517.B socket
518use the same set of defaults, so a prefix of
519.B fattr
520is good enough for setting global options, and the implicit context
521disambiguates local options.
522.PP
523The following file attribute options are supported:
524.OS "File attribute options (`fattr')"
525.IB prefix .fattr.mode
526.RB [ = ]
527.I mode
528.OD
529Sets the permissions mode for a new file. The
530.I mode
531argument may be either an octal number or a
532.BR chmod (1)-style
533string which acts on the default permissions established by the
534prevailing
535.BR umask (2)
536setting. The characters
537.RB ` = '
538and
539.RB ` , '
540do not have to be quoted within the mode string.
541.OE
542.OS "File attribute options (`fattr')"
543.IB prefix .fattr.owner
544.RB [ = ]
545.I user
546.OD
547Sets the owner for newly created files. On non-broken systems you will
548need to be the superuser to set the owner on a file. The
549.I user
550may either be a numeric uid or a username. The default is not to change
551the owner of the file once it's created. The synonyms
552.B uid
553and
554.B user
555are accepted in place of
556.BR owner .
557.OE
558.OS "File attribute options (`fattr')"
559.IB prefix .fattr.group
560.RB [ = ]
561.I group
562.OD
563Sets the group for newly created files. You will usually need to be a
564member of the group in question order to set the group of a file. The
565.I group
566may either be a numeric gid or a group name. The default is not to
567change the group of the file once it's created. The synonym
568.B gid
569is accepted in place of
570.BR group .
571.OE
572.
667fb920 573.SS "The `file' source and target types"
574The
575.B file
576source and target allow data to move to and from objects other
577than sockets within the Unix filesystem. (Unix-domain sockets are
578handled using the
579.B socket
580source and target.)
581.PP
582If a
583.B file
584is used as a source, it is set up immediately.
585.PP
586The syntax of
587.B file
588sources and targets is like this:
333c51f4 589.GS "File sources and targets"
667fb920 590.I source
591::=
592.I file
593.br
594.I target
595::=
596.I file
597.br
598.I file
599::=
600.B file
23be5eb0 601.RB [ .\& ]
667fb920 602.I fspec
603.RB [ ,
604.IR fspec ]
605.br
606.I fspec
607::=
608.I fd-spec
609|
610.I name-spec
611|
612.I null-spec
613.br
614.I fd-spec
615::=
616.RB [[ : ] fd [ : ]]
617.IR number \c
618.RB | stdin | stdout
619.br
620.I name-spec
621::=
622.RB [[ : ] file [ : ]]
623.I file-name
624.br
625.I file-name
626::=
627.I path-seq
628|
629.B [
630.I path-seq
631.B ]
632.br
633.I path-seq
634::=
635.I path-elt
636|
637.I path-seq
638.I path-elt
639.br
640.I path-elt
641::=
642.B /
643|
644.I word
645.br
646.I null-spec
647::=
e73034b0 648.RB [ : ] null [ : ]
333c51f4 649.GE
667fb920 650The
651.I file
652specification describes two files, the first to be used as input, the
653second to be used as output, each described by an
654.IR fspec .
655.PP
656If none of the keywords
657.RB ` fd ',
658.RB ` name '
659or
660.RB ` null '
661are given, the type of an
662.I fspec
663is deduced from its nature: if it matches one of the strings
664.RB ` stdin '
665or
666.RB ` stdout ',
667or begins with a digit, it's considered to be a file descriptor;
668otherwise it's interpreted as a filename.
669.PP
670A
671.RB ` name '
672spec describes a file by its name within the filesystem. It is opened
673when needed and closed again after use. For output files, the precise
674behaviour is controlled by options described below.
675.PP
676A
677.RB ` null '
678spec attaches the input or output of the source or target to
679.BR /dev/null .
680.PP
681An
682.RB ` fd '
683spec uses an existing open file descriptor, given either by number or a
684symbolic name. The name
685.RB ` stdin '
686refers to standard input (file descriptor 0 on normal systems) and
687.RB ` stdout '
688refers to standard output (file descriptor 1). The names work in
689exactly the same way as the equivalent file descriptor numbers.
690.PP
691If the output
692.I fspec
693is omitted, the input
694.I fspec
695is used for both input and output. Exception: if the input refers to
696standard input then the output will refer to standard output instead.
697.PP
698All
699.B file
700options apply equally to sources and targets. The options are as
701follows:
333c51f4 702.OS "File options"
667fb920 703.B file.create
704.RB [ = ]
705.BR yes | no
333c51f4 706.OD
667fb920 707Whether to create the output file if it doesn't exist. If
708.B no
709(the default), an error is reported if the file doesn't exist. If
710.BR yes ,
711the file is created if it doesn't exist.
333c51f4 712.OE
713.OS "File options"
667fb920 714.B file.open
715.RB [ = ]
716.BR no | truncate | append
333c51f4 717.OD
667fb920 718Controls the behaviour if the output file already exists. If
719.BR no ,
720an error is reported. If
721.B truncate
722(the default), the existing file is replaced by the new data. If
723.BR append ,
724the new data is appended to the file.
333c51f4 725.OE
726.OS "File options"
727.BR file.fattr.*
728.OD
667fb920 729The
730.B file
731source and target also accept
732.B fattr
333c51f4 733options for controlling the attributes of the created file.
734.OE
667fb920 735.PP
333c51f4 736Under no circumstances will
737.B fw
738create a file through a `dangling' symbolic link.
667fb920 739.
740.SS "The `exec' source and target types"
741The
742.B exec
743source and target execute programs and allow access to their standard
744input and output streams. Both source and target have the same syntax,
745which is as follows:
333c51f4 746.GS "Exec source and target"
667fb920 747.I source
748::=
749.I exec
750.br
751.I target
752::=
753exec
754.br
755.I exec
756::=
757.BR exec
23be5eb0 758.RB [ .\& ]
667fb920 759.I cmd-spec
760.br
761.I cmd-spec
762::=
763.I shell-cmd
10a454ad 764|
667fb920 765.RI [ prog-name ]
766.B [
767.I argv0
768.I arg-seq
769.B ]
770.br
771.I arg-seq
772::=
773.I word
774|
775.I arg-seq
776.I word
777.br
778.I shell-cmd
779::=
780.I word
781.br
782.I argv0
783::=
784.I word
333c51f4 785.GE
667fb920 786If a single word is given, it is a
787.I shell-cmd
788and will be passed to the Bourne shell for execution. If a
789bracket-enclosed sequence of words is given, it is considered to be a
790list of arguments to pass to the program: if a
791.I prog-name
792is also supplied, it names the file containing the program to execute;
793otherwise the file named by the first argument
794.RI ( argv0 )
795is used.
796.PP
49f5947b 797Note that the shell command or program name string must, if present,
798have any delimiter characters (including
799.RB ` / '
800and
801.RB ` . ')
802quoted; this is not required in the
803.RB ` [ '-enclosed
804argument list.
805.PP
667fb920 806The standard input and output of the program are forwarded to the other
807end of the connection. The standard error stream is caught by
808.B fw
809and logged.
810.PP
811The
812.B exec
813source and target both understand the same set of options. The list of
814options supported is as follows:
333c51f4 815.OS "Exec options"
667fb920 816.B exec.logging
817.RB [ = ]
818.BR yes | no
333c51f4 819.OD
667fb920 820Whether to log the start and end of executed programs. If
821.B yes
822(the default), a log message is emitted when the program is started
823listing its process id, and another is emitted when the program finishes
824giving its process id and exit status. If
825.BR no ,
826these messages are not emitted. However the standard error stream is
827still logged. The
828.B log
829abbreviation is accepted as a synonym for
830.BR logging .
333c51f4 831.OE
832.OS "Exec options"
667fb920 833.B exec.dir
834.RB [ = ]
835.I file-name
333c51f4 836.OD
667fb920 837Sets the current directory from which the the program should be run.
838The default is not to change directory. The synonyms
839.BR cd ,
840.B chdir
841and
842.B cwd
843are accepted in place of
844.BR dir .
333c51f4 845.OE
846.OS "Exec options"
667fb920 847.B exec.root
848.RB [ = ]
849.I file-name
333c51f4 850.OD
667fb920 851Sets the root directory for the program, using the
852.BR chroot (2)
853system call. You must be the superuser for this option to work. The
372a98e2 854default is not to set a root directory. The synonym
855.B chroot
856is accepted in place of
857.BR root .
333c51f4 858.OE
859.OS "Exec options"
667fb920 860.B exec.user
861.RB [ = ]
862.I user
333c51f4 863.OD
667fb920 864Sets the user (real and effective uid) to run the program as. This will
865usually require superuser privileges to work. The default is not to
866change uid. The synonym
867.B uid
868is accepted in place of
869.BR user .
333c51f4 870.OE
871.OS "Exec options"
667fb920 872.B exec.group
873.RB [ = ]
874.I group
333c51f4 875.OD
667fb920 876Sets the group (real and effective gid) to run the program as. If
877running with superuser privileges, the supplementary groups list is
878cleared at the same time. The default is not to change gid (or clear
879the supplementary groups list). The synonym
880.B gid
881is accepted in place of
882.BR group .
333c51f4 883.OE
884.OS "Exec options"
667fb920 885.BI exec.rlimit. limit \c
886.RB [ .hard | .soft ]
887.RB [ = ]
888.I value
333c51f4 889.OD
667fb920 890Set resource limits for the program. The
891.I limit
892may be one of the resource limit names described in
893.BR setrlimit (2),
894in lower-case and without the
895.B RLIMIT_
896prefix; for example,
897.B RLIMIT_CORE
898becomes simply
899.BR core .
900The
901.I value
902is a number, followed optionally by
903.B k
904to multiply by 1024 (2\*(ss10\*(se),
905.B m
906to multiply by 1048576 (2\*(ss20\*(se), or
907.B g
908to multiply by 1073741824 (2\*(ss30\*(se); purists can use upper-case
909versions of these if they want. If
910.B .hard
911or
912.B .soft
913was specified, only the hard or soft limit is set; otherwise both are
914set to the same value. Only the superuser can raise the hard limit.
915The soft limit cannot be set above the hard limit.
333c51f4 916.OE
917.OS "Exec options"
667fb920 918.B exec.env.clear
333c51f4 919.OD
667fb920 920Clears the program's environment.
333c51f4 921.OE
667fb920 922.PP
923.B exec.env.unset
924.I var
333c51f4 925.OD
667fb920 926Removes
927.I var
928from the program's environment. It is not an error if no variable named
929.I var
930exists.
333c51f4 931.OE
932.OS "Exec options"
667fb920 933.BR exec.env. [ set ]
934.I var
935.RB [ = ]
936.I value
333c51f4 937.OD
96bc31ba 938Assigns the variable
667fb920 939.I var
940the value
941.I value
942in the program's environment, possibly replacing the existing value.
943The
944.B set
945may be omitted if the
946.B env
947qualifier is present.
333c51f4 948.OE
667fb920 949.PP
950Note that environment variable modifications are performed in order,
951global modifications before local ones.
952.
953.SS "The `socket' source and target types"
954The
955.B socket
956source and target provide access to network services. Support is
957currently provided for TCP/IP and Unix-domain sockets, although other
958address types can be added with reasonable ease.
959.PP
960The syntax for socket sources and targets is:
333c51f4 961.GS "Socket source and target"
667fb920 962.ll +8i
963.I source
964::=
965.I socket-source
10a454ad 966.br
667fb920 967.I target
968::=
969.I socket-target
970.br
971.I socket-source
972::=
23be5eb0 973.RB [ socket [ .\& ]]
667fb920 974.RB [[ : ] \c
975.IR addr-type \c
976.RB [ : ]]
977.I source-addr
978.br
979.I socket-target
980::=
23be5eb0 981.RB [ socket [ .\& ]]
667fb920 982.RB [[ : ] \c
983.IR addr-type \c
984.RB [ : ]]
985.I target-addr
986.ll -8i
333c51f4 987.GE
667fb920 988The syntax of the source and target addresses depend on the address
989types, which are described below. The default address type, if no
990.I addr-type
991is given, is
992.BR inet .
993.PP
994Socket sources support options; socket targets do not. The source
995options provided are:
333c51f4 996.OS "Socket options"
667fb920 997.B socket.conn
998.RB [ = ]
d857515e 999.IR number | \c
1000.BR unlimited | one-shot
333c51f4 1001.OD
d857515e 1002Controls the behaviour of the source when it receives connections. A
667fb920 1003.I number
d857515e 1004limits the number of simultaneous connections. The value
1005.B unlimited
1006(or
1007.BR infinite )
1008removes any limit on the number of connections possible. The value
1009.B one-shot
1010will remove the socket source after a single successful connection.
1011(Connections refused by access control systems don't count here.)
1012The default is to apply a limit of 256 concurrent connections. Use of
1013the
1014.B unlimited
1015option is not recommended.
333c51f4 1016.OE
1017.OS "Socket options"
6f427571 1018.B socket.listen
1019.RB [ = ]
1020.I number
1021.OD
1022Sets the maximum of the kernel incoming connection queue for this socket
1023source. This is the number given to the
1024.BR listen (2)
1025system call. The default is 5.
1026.OE
1027.OS "Socket options"
667fb920 1028.B socket.logging
1029.RB [ = ]
1030.BR yes | no
333c51f4 1031.OD
667fb920 1032Whether to log incoming connections. If
1033.B yes
1034(the default) incoming connections are logged, together with information
1035about the client (where available) and whether the connection was
1036accepted or refused. If
1037.BR no ,
1038log messages are not generated.
333c51f4 1039.OE
667fb920 1040.PP
1041Address types also provide their own options.
1042.
1043.SS "The `inet' socket address type"
1044The
1045.B inet
1046address type provides access to TCP ports. The
1047.B inet
1048source and target addresses have the following syntax:
333c51f4 1049.GS "Socket source and target"
667fb920 1050.I inet-source-addr
10a454ad 1051::=
10a454ad 1052.RB [ port ]
1053.I port
667fb920 1054.br
1055.I inet-target-addr
1056::=
1057.I address
10a454ad 1058.RB [ : ]
1059.I port
10a454ad 1060.br
667fb920 1061.I address
10a454ad 1062::=
667fb920 1063.I addr-elt
1064|
1065.I address
1066.I addr-elt
10a454ad 1067.br
667fb920 1068.I addr-elt
10a454ad 1069::=
23be5eb0 1070.B .\&
10a454ad 1071|
667fb920 1072.I word
333c51f4 1073.GE
667fb920 1074A
1075.I port
1076may be given as a port number or a service name from the
1077.B /etc/services
1078file (or YP map if you do that sort of thing). A
1079.B hostname
1080may be a textual hostname or a numerical IP address.
1081.PP
1082The
1083.B inet
1084source address accepts the following options:
333c51f4 1085.OS "Socket options"
1c2054c7 1086.B socket.inet.source.addr
1087.RB [ = ]
1088.RR any | \c
1089.I addr
1090.OD
1091Specify the IP address on which to listen for incoming connections. The
1092default is
1093.BR any ,
1094which means to listen on all addresses, though it may be useful to
1095specify this explicitly, if the global setting is different.
1096.OE
1097.OS "Socket options"
1098.BR socket.inet.source. [ allow | deny ]
1099.RB [ host ]
1100.I addr
10a454ad 1101.RB [ /
1c2054c7 1102.IR addr ]
333c51f4 1103.OD
667fb920 1104Adds an entry to the source's access control list. If only one
1105.I address
1106is given, the entry applies only to that address; if two are given, the
1107first is a network address and the second is a netmask either in
1108dotted-quad format or a simple number of bits (e.g.,
1109.B /255.255.255.192
1110and
1111.B /26
1112mean the same), and the entry applies to any address which, when masked
1113by the netmask, is equal to the masked network address.
333c51f4 1114.OE
1c2054c7 1115.OS "Socket options"
1116.BR socket.inet.source. [ allow | deny ]
1117.B priv-port
1118.OD
1119Accept or reject connections from low-numbered `privileged' ports, in
1120the range 0--1023.
1121.OE
1122.OS "Socket options"
1123.B socket.inet.dest.addr
1124.RB [ = ]
1125.RR any | \c
1126.I addr
1127.OD
1128Specify the IP address to bind the local socket to when making an
1129outbound connection. The default is
1130.BR any ,
1131which means to use whichever address the kernel thinks is most
1132convenient. This option is useful if the destination is doing
1133host-based access control and your server is multi-homed.
1134.OE
ee599f55 1135.OS "Socket options"
1136.B socket.inet.dest.priv-port
1137.RB [=]
1138.BR yes | no
1139.OD
1140Make a privileged connection (i.e., from a low-numbered port) to the
1141target. This only works if
1142.B fw
1143was started with root privileges. However, it still works if
1144.B fw
1145has
1146.I dropped
1147privileges after initialization (the
1148.B \-s
1149option). Before dropping privileges,
1150.B fw
1151forks off a separate process which continues to run with root
1152privileges, and on demand passes sockets bound to privileged ports and
1153connected to the appropriate peer back to the main program. The
1154privileged child only passes back sockets connected to peer addresses
1155named in the configuration; even if the
1156.B fw
1157process is compromised, it can't make privileged connections to other
1158addresses. Note that because of this privilege separation, it's also
1159not possible to reconfigure
1160.B fw
1161to make privileged connections to different peer addresses later. by
1162changing configuration files and sending the daemon a
1163.BR SIGHUP .
1164.OE
10a454ad 1165.PP
333c51f4 1166The access control rules are examined in the order: local entries first,
1167then global ones, each in the order given in the configuration file.
1168The first matching entry is used. If no entries match, the behaviour is
1169the
667fb920 1170.I opposite
1171of the last entry tried. If there are no entries defined, the default
1172is to allow all clients.
667fb920 1173.
1174.SS "The `unix' socket address type"
10a454ad 1175The
667fb920 1176.B unix
1177address type allows access to Unix-domain sockets. The syntax for
1178.B unix
1179source and target addresses is like this:
333c51f4 1180.GS "Socket source and target"
1181.I unix-source-addr
667fb920 1182::=
333c51f4 1183.I file-name
667fb920 1184.br
333c51f4 1185.I unix-target-addr
667fb920 1186::=
1187.I file-name
333c51f4 1188.GE
1189The following options are supported by the
1190.B unix
1191source address type:
1192.OS "Socket options"
1193.BR socket.unix.fattr. *
1194.OD
667fb920 1195The
1196.B unix
1197source address accepts
1198.B fattr
333c51f4 1199options to control the attributes of the socket file created.
1200.OE
1201.PP
1202Sockets are removed if
10a454ad 1203.B fw
667fb920 1204exits normally (which it will do if it runs out of sources or
372a98e2 1205connections, or if
1206.B fw
1207shuts down in a clean way).
667fb920 1208.SH "EXAMPLES"
1209To forward the local port 25 to a main mail server:
1210.VS
1211from 25 to mailserv:25
1212.VE
1213To attach a fortune server to a Unix-domain socket:
1214.VS
1215from unix:/tmp/fortunes
1216to exec [/usr/games/fortune] { user nobody }
1217.VE
1218To fetch a fortune from the server:
1219.VS
1220from file stdin, stdout to unix:/tmp/fortunes
1221.VE
1222To emulate
1223.BR cat (1):
1224.VS
49f5947b 1225from file stdin, null to file null, stdout
667fb920 1226.VE
1227.
1228.\"--------------------------------------------------------------------------
372a98e2 1229.SH "SIGNAL HANDLING"
1230.
1231The
1232.B fw
1233program responds to various signals when it's running. If it receives
1234.B SIGTERM
1235or
1236.BR SIGINT ,
1237.B fw
1238performs a
1239.I graceful
1240shutdown: it removes all of its sources, and will exit when no more
1241connections are running. (Note that if the disposition
1242.B SIGINT
1243was to ignore it,
1244.B fw
1245does not re-enable the signal. You'll have to send
1246.B SIGTERM
1247in that case.) If
1248.B fw
1249receives
1250.BR SIGQUIT ,
1251it performs an
1252.I abrupt
1253shutdown: it removes all sources and extant connections and closes down
1254more-or-less immediately.
1255.PP
1256Finally, if any configuration files (other than standard input) were
1257provided to
1258.B fw
1259on its command line using the
1260.B \-f
1261option, a
1262.B SIGHUP
1263signal may be sent to instruct
1264.B fw
1265to reload its configuration. Any existing connections are allowed to
1266run their course. If no such configuration files are available,
1267.B fw
1268just logs a message about the signal and continues.
1269.PP
1270.
1271.\"--------------------------------------------------------------------------
333c51f4 1272.SH "GRAMMAR SUMMARY"
1273.
1274.SS "Basic syntax"
1275.I file
1276::=
1277.I empty
1278|
1279.I file
1280.I stmt
1281.RB [ ; ]
1282.br
1283.I stmt
1284::=
1285.I option-stmt
1286|
1287.I fw-stmt
1288.br
1289.I fw-stmt
1290::=
1291.B fw
1292.I source
1293.I options
1294.RB [ to | \-> ]
1295.I target
1296.I options
1297.br
1298.I options
1299::=
1300.B {
1301.I option-seq
1302.B }
1303.br
1304.I option-seq
1305::=
1306.I empty
1307|
1308.I option-stmt
1309.RB [ ; ]
1310.I option-seq
1311.
1312.SS "Option syntax"
1313.I option-stmt
1314::=
1315.I q-option
1316.br
1317.I q-option
1318::=
1319.I option
1320.br
1321 |
1322.I prefix
23be5eb0 1323.B .\&
333c51f4 1324.I q-option
1325.br
1326 |
1327.I prefix
1328.B {
1329.I option-seq
1330.B }
1331.br
1332.I prefix
1333::=
1334.I word
1335.
1336.SS "File source and target"
1337.I source
1338::=
1339.I file
1340.br
1341.I target
1342::=
1343.I file
1344.br
1345.I file
1346::=
1347.B file
23be5eb0 1348.RB [ .\& ]
333c51f4 1349.I fspec
1350.RB [ ,
1351.IR fspec ]
1352.br
1353.I fspec
1354::=
1355.I fd-spec
1356|
1357.I name-spec
1358|
1359.I null-spec
1360.br
1361.I fd-spec
1362::=
1363.RB [[ : ] fd [ : ]]
1364.IR number \c
1365.RB | stdin | stdout
1366.br
1367.I name-spec
1368::=
1369.RB [[ : ] file [ : ]]
1370.I file-name
1371.br
1372.I file-name
1373::=
1374.I path-seq
1375|
1376.B [
1377.I path-seq
1378.B ]
1379.br
1380.I path-seq
1381::=
1382.I path-elt
1383|
1384.I path-seq
1385.I path-elt
1386.br
1387.I path-elt
1388::=
1389.B /
1390|
1391.I word
1392.br
1393.I null-spec
1394::=
1395.RB [ : ] null [ : ]
1396.
1397.SS "Exec source and target"
1398.I source
1399::=
1400.I exec
1401.br
1402.I target
1403::=
1404exec
1405.br
1406.I exec
1407::=
1408.BR exec
23be5eb0 1409.RB [ .\& ]
333c51f4 1410.I cmd-spec
1411.br
1412.I cmd-spec
1413::=
1414.I shell-cmd
1415|
1416.RI [ prog-name ]
1417.B [
1418.I argv0
1419.I arg-seq
1420.B ]
1421.br
1422.I arg-seq
1423::=
1424.I word
1425|
1426.I arg-seq
1427.I word
1428.br
1429.I shell-cmd
1430::=
1431.I word
1432.br
1433.I argv0
1434::=
1435.I word
1436.
1437.SS "Socket source and target"
1438.ll +8i
1439.I source
1440::=
1441.I socket-source
1442.br
1443.I target
1444::=
1445.I socket-target
1446.br
1447.I socket-source
1448::=
23be5eb0 1449.RB [ socket [ .\& ]]
333c51f4 1450.RB [[ : ] \c
1451.IR addr-type \c
1452.RB [ : ]]
1453.I source-addr
1454.br
1455.I socket-target
1456::=
23be5eb0 1457.RB [ socket [ .\& ]]
333c51f4 1458.RB [[ : ] \c
1459.IR addr-type \c
1460.RB [ : ]]
1461.I target-addr
1462.ll -8i
1463.PP
1464.I inet-source-addr
1465::=
1466.RB [ port ]
1467.I port
1468.br
1469.I inet-target-addr
1470::=
1471.I address
1472.RB [ : ]
1473.I port
1474.br
1475.I address
1476::=
1477.I addr-elt
1478|
1479.I address
1480.I addr-elt
1481.br
1482.I addr-elt
1483::=
23be5eb0 1484.B .\&
333c51f4 1485|
1486.I word
1487.PP
1488.I unix-source-addr
1489::=
1490.I file-name
1491.br
1492.I unix-target-addr
1493::=
1494.I file-name
1495.
1496.\"--------------------------------------------------------------------------
1497.SH "OPTION SUMMARY"
1498.
1499.SS "File attributes (`fattr')"
1500.IB prefix .fattr.mode
1501.RB [ = ]
1502.I mode
1503.br
1504.IB prefix .fattr.owner
1505.RB [ = ]
1506.I user
1507.br
1508.IB prefix .fattr.group
1509.RB [ = ]
1510.I group
1511.
1512.SS "File options"
1513.B file.create
1514.RB [ = ]
1515.BR yes | no
1516.br
1517.B file.open
1518.RB [ = ]
1519.BR no | truncate | append
1520.br
1521.BR file.fattr. *
1522.
1523.SS "Exec options"
1524.B exec.logging
1525.RB [ = ]
1526.BR yes | no
1527.br
1528.B exec.dir
1529.RB [ = ]
1530.I file-name
1531.br
1532.B exec.root
1533.RB [ = ]
1534.I file-name
1535.br
1536.B exec.user
1537.RB [ = ]
1538.I user
1539.br
1540.B exec.group
1541.RB [ = ]
1542.I group
1543.br
1544.BI exec.rlimit. limit \c
1545.RB [ .hard | .soft ]
1546.RB [ = ]
1547.I value
1548.br
1549.B exec.env.clear
1550.br
1551.B exec.env.unset
1552.I var
1553.br
1554.BR exec.env. [ set ]
1555.I var
1556.RB [ = ]
1557.I value
1558.
1559.SS "Socket options"
1560.B socket.conn
1561.RB [ = ]
d857515e 1562.IR number | \c
1563.BR unlimited | one-shot
333c51f4 1564.br
6f427571 1565.B socket.listen
1566.RB [ = ]
1567.I number
1568.br
333c51f4 1569.B socket.logging
1570.RB [ = ]
1571.BR yes | no
1572.PP
1c2054c7 1573.BR socket.inet.source. [ allow | deny ]
1574.RB [ host ]
1575.I addr
333c51f4 1576.RB [ /
1c2054c7 1577.IR addr ]
1578.br
1579.BR socket.inet.source. [ allow | deny ]
1580.B priv-port
1581.br
1582.B socket.inet.source.addr
1583.RB [ = ]
1584.BR any | \c
1585.I addr
1586.br
1587.B socket.inet.dest.addr
1588.RB [ = ]
1589.BR any | \c
1590.I addr
ee599f55 1591.br
1592.B socket.inet.dest.priv-port
1593.RB [=]
1594.BR yes | no
333c51f4 1595.PP
1596.BR socket.unix.fattr. *
1597.
1598.\"--------------------------------------------------------------------------
10a454ad 1599.SH "BUGS"
667fb920 1600.
cdc917d3 1601The syntax for IP addresses and filenames is nasty.
10a454ad 1602.PP
d857515e 1603IPv6 is not supported yet. Because of
1604.BR fw 's
1605socket address architecture, it's probably not a major piece of work to
667fb920 1606add.
10a454ad 1607.PP
667fb920 1608Please inform me of any security problems you think you've identified in
1609this program. I take security very seriously, and I will fix security
1610holes as a matter of priority when I find out about them. I will be
1611annoyed if I have to read about problems on Bugtraq because they weren't
1612mailed to me first.
723210e6 1613.PP
1614The program is too complicated, and this manual page is too long.
667fb920 1615.
1616.\"--------------------------------------------------------------------------
10a454ad 1617.SH "AUTHOR"
667fb920 1618.
10a454ad 1619Mark Wooding, <mdw@nsict.org>
667fb920 1620.
1621.\"----- That's all, folks --------------------------------------------------