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