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