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