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