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