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