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