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