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