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