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