Include grammar and options references at the end of the manual.
[fwd] / fw.1
1 .\" -*-nroff-*-
2 .\"
3 .\" $Id: fw.1,v 1.6 1999/10/10 16:46:29 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.6 1999/10/10 16:46:29 mdw
32 .\" Include grammar and options references at the end of the manual.
33 .\"
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 .\"
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 .\"
42 .\" Revision 1.3 1999/07/30 06:49:00 mdw
43 .\" Minor tidying and typo correction.
44 .\"
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 .
53 .de hP
54 .IP
55 \h'-\w'\fB\\$1\ \fP'u'\fB\\$1\ \fP\c
56 ..
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 .
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 .
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 .
112 .TH fw 1 "1 July 1999" fw
113 .
114 .\"--------------------------------------------------------------------------
115 .SH NAME
116 .
117 fw \- port forwarder
118 .
119 .\"--------------------------------------------------------------------------
120 .SH SYNOPSIS
121 .
122 .B fw
123 .RB [ \-dq ]
124 .RB [ \-f
125 .IR file ]
126 .IR config-stmt ...
127 .
128 .\"--------------------------------------------------------------------------
129 .SH "DESCRIPTION"
130 .
131 The
132 .B fw
133 program is a simple port forwarder. It supports a number of features
134 the author hasn't found in similar programs:
135 .TP
136 .I "Connection logging"
137 Each connection attempt to the forwarder is logged, giving the time of
138 the connection, the DNS-resolved hostname (if available), and the user
139 name resulting from an RFC931 lookup. These lookups are done
140 asynchronously to the main forwarder's operation.
141 .TP
142 .I "Access control"
143 Each forwarded port may have an access control list attached to it.
144 Only authorized hosts are allowed to connect. Access control checks are
145 performed by quick checks on the client's IP address.
146 .TP
147 .I "Nonblocking single-process design"
148 The internal structure of the server is completely nonblocking. The
149 connections don't block; the reading and writing don't block; the name
150 lookups don't block. This is all done in a single process, with the
151 single exception of the DNS resolver.
152 .TP
153 .I "Support for Unix-domain sockets"
154 Connections from and to Unix-domain sockets can be handled just as
155 easily as more normal Internet sockets. Access control doesn't work on
156 Unix domain sockets, though. (Yet.)
157 .SS "Command line options"
158 The
159 .B fw
160 program understands a few simple command line options:
161 .TP
162 .B "\-h, \-\-help"
163 Displays a screen of help text on standard output and exits
164 successfully.
165 .TP
166 .B "\-v, \-\-version"
167 Writes the version number to standard output and exits successfully.
168 .TP
169 .B "\-u, \-\-usage"
170 Writes a terse usage summary to standard output and exits successfully.
171 .TP
172 .BI "\-f, \-\-file=" file
173 Read configuration information from
174 .IR file .
175 Equivalent to an
176 .RB ` include
177 .IR file '
178 configuration file statement.
179 .TP
180 .B "\-d, \-\-daemon, \-\-fork"
181 Forks into the background after reading the configuration and
182 initializing properly.
183 .TP
184 .B "-q, \-\-quiet"
185 Don't output any logging information. This option is not recommended
186 for normal use, although it can make system call traces clearer so I use
187 it when debugging.
188 .PP
189 Any further command line arguments are interpreted as configuration
190 lines to be read. Configuration supplied in command line arguments has
191 precisely the same syntax as configuration in files. If there are no
192 configuration statements on the command line, and no
193 .B \-f
194 options were supplied, configuration is read from standard input, if
195 stdin is not a terminal.
196 .
197 .\"--------------------------------------------------------------------------
198 .SH "CONFIGURATION LANGUAGE"
199 .
200 The
201 .B fw
202 program has a fairly sophisticated configuration language to let you
203 describe which things should be forwarded where and what special
204 features there should be.
205 .SS "Lexical structure"
206 There are four types of characters.
207 .TP
208 .I "word constituent characters"
209 Word constituent characters are gathered together into words.
210 Depending on its surrounding context, a word might act as a keyword or a
211 string. All alphanumerics are word constituents, as is the hyphen
212 .RB ` \- '.
213 Other characters may change their status in future versions.
214 .TP
215 .I "self-delimiting characters"
216 Self-delimiting characters always stand alone. They act as punctuation,
217 shaping the sequence of words into more complex grammatical forms. The
218 characters
219 .RB ` { ',
220 .RB ` } ',
221 .RB ` [ ',
222 .RB ` ] ',
223 .RB ` / ',
224 .RB ` , ',
225 .RB ` = ',
226 .RB ` : ',
227 .RB ` ; '
228 and
229 .RB ` . '
230 are self-delimiting. Note that while some characters, e.g.,
231 .RB ` [ '
232 and
233 .RB ` ; ',
234 require escaping by the shell, they are strictly optional in the grammar
235 and can be omitted in quick hacks at the shell prompt.
236 .TP
237 .I "whitespace characters"
238 Whitespace characters separate words but are otherwise ignored. All
239 `normal' whitespace characters (e.g., space, tab and newline) are
240 considered to be whitespace for these purposes.
241 .TP
242 .I "special characters"
243 There are three special characters. The
244 .RB ` # '
245 character, if it appears at the start of a word, introduces a
246 .I comment
247 which extends to the end of the current line or command-line argument.
248 Within a word, it behaves like a normal word-constituent character. The
249 backslash
250 .RB ` \e '
251 escapes the following character causing it to be interpreted as a word
252 constituent regardless of its normal type. The double-quote
253 .RB ` """" '
254 escapes all characters other than backslashes up to the next
255 double-quote and causes them to be regarded as word constituents. Note
256 that you don't have to quote a whole word. The backslash can escape a
257 quote character allowing you to insert it into a word if really
258 necessary.
259 .
260 .SS "Basic syntax"
261 The overall syntax looks a bit like this:
262 .GS "Basic syntax"
263 .I file
264 ::=
265 .I empty
266 |
267 .I file
268 .I stmt
269 .RB [ ; ]
270 .br
271 .I stmt
272 ::=
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
299 .GE
300 If you prefer, the keyword
301 .RB ` fw '
302 may be spelt
303 .RB ` forward '
304 or
305 .RB ` from '.
306 All are equivalent.
307 .
308 .SS "Sources and targets"
309 Forwarding is set up by attaching
310 .I targets
311 to
312 .IR sources .
313 Sources are things which are capable of
314 .I initiating
315 one end of a data flow on their own, while targets are things which are
316 capable of setting up the other end on demand. In the case of a TCP
317 port forwarder, the part which listens for incoming client connections
318 is the source, while the part which sets up outgoing connections to the
319 destination server is the target.
320 .PP
321 Essentially, all
322 .B fw
323 does is set up a collection of sources and targets based on your
324 configuration file so that when a source decides to initiate a data
325 flow, it tells its target to set its end up, and then squirts data back
326 and forth between the two until there's no more.
327 .PP
328 Some sources are
329 .IR persistent :
330 they stay around indefinitely setting up multiple attachments to
331 targets. Others are
332 .IR transient :
333 they set up one connection and then disappear. If all the sources
334 defined are transient, then
335 .B fw
336 will quit when no more active sources remain and all connections have
337 terminated.
338 .PP
339 The
340 .B fw
341 program is fairly versatile. It allows you to attach any supported type
342 of source to any supported type of target. This will, I hope, be the
343 case in all future versions.
344 .PP
345 The syntax of a
346 .I source
347 or
348 .I target
349 depend on the source or target type, and are therefore described in the
350 sections specific to the various types.
351 .
352 .SS "Options structure"
353 Most of the objects that
354 .B fw
355 knows about (including sources and targets, but also other more specific
356 things such as socket address types) can have their behaviour modified
357 by
358 .IR options .
359 The options available at a particular point in the configuration depend
360 on the
361 .IR context .
362 A global option, outside of a
363 .I fw-stmt
364 has no context unless it is explicitly qualified, and affects global
365 behaviour. Local options, applied to a source or target in a
366 .I fw-stmt
367 has the context of the type of source or target to which it is applied,
368 and affects only that source or target.
369 .PP
370 Note that it's important to distinguish between an option's context
371 (which is affected by its qualification) and its local or global
372 status. No matter how qualified, a global option will always control
373 default options for objects, and a local option will only affect a
374 specific source or target.
375 .PP
376 The syntax for qualifying options is like this:
377 .GS "Option syntax"
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
400 .GE
401 Thus, you may qualify either an individual option or a sequence of
402 options. The two are equivalent; for example,
403 .VS
404 exec.rlimit {
405 core = 0;
406 cpu = 60;
407 }
408 .VE
409 is equivalent to
410 .VS
411 exec.rlimit.core = 0;
412 exec.rlimit.cpu = 0;
413 .VE
414 For each option, there is a sequence of prefixes which maximally qualify
415 that option. An option prefixed with this sequence is
416 .IR "fully qualified" .
417 In actual use, some or all of those prefixes may be omitted. However,
418 it's possible for the option to become
419 .I ambiguous
420 if you do this. For example, the option
421 .B fattr.owner
422 may refer either to
423 .B file.fattr.owner
424 or to
425 .BR socket.unix.fattr.owner .
426 In this case, the ambiguity is benign: a local option will have as its
427 context an appropriate source or target, and both global options
428 actually control the same default. However, the option
429 .B logging
430 may mean either
431 .B socket.logging
432 or
433 .BR exec.logging ,
434 which have separate defaults, and which one you actually get depends on
435 the exact implementation of
436 .BR fw 's
437 option parser. (Currently this would resolve to
438 .BR exec.logging ,
439 although this may change in a later version.)
440 .PP
441 In this manual, options are usually shown in their fully-qualified form.
442 .
443 .SS "File attributes for created files: `fattr'"
444 Both the
445 .B file
446 and
447 .B socket
448 sources and targets can create new filesystem objects. The
449 .B fattr
450 options allow control over the attributes of the newly-created objects.
451 Both
452 .B file
453 and
454 .B socket
455 use the same set of defaults, so a prefix of
456 .B fattr
457 is good enough for setting global options, and the implicit context
458 disambiguates local options.
459 .PP
460 The following file attribute options are supported:
461 .OS "File attribute options (`fattr')"
462 .IB prefix .fattr.mode
463 .RB [ = ]
464 .I mode
465 .OD
466 Sets the permissions mode for a new file. The
467 .I mode
468 argument may be either an octal number or a
469 .BR chmod (1)-style
470 string which acts on the default permissions established by the
471 prevailing
472 .BR umask (2)
473 setting. The characters
474 .RB ` = '
475 and
476 .RB ` , '
477 do 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
484 Sets the owner for newly created files. On non-broken systems you will
485 need to be the superuser to set the owner on a file. The
486 .I user
487 may either be a numeric uid or a username. The default is not to change
488 the owner of the file once it's created. The synonyms
489 .B uid
490 and
491 .B user
492 are 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
500 Sets the group for newly created files. You will usually need to be a
501 member of the group in question order to set the group of a file. The
502 .I group
503 may either be a numeric gid or a group name. The default is not to
504 change the group of the file once it's created. The synonym
505 .B gid
506 is accepted in place of
507 .BR group .
508 .OE
509 .
510 .SS "The `file' source and target types"
511 The
512 .B file
513 source and target allow data to move to and from objects other
514 than sockets within the Unix filesystem. (Unix-domain sockets are
515 handled using the
516 .B socket
517 source and target.)
518 .PP
519 If a
520 .B file
521 is used as a source, it is set up immediately.
522 .PP
523 The syntax of
524 .B file
525 sources and targets is like this:
526 .GS "File sources and targets"
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 ::=
585 .RB [ : ] null [ : ]
586 .GE
587 The
588 .I file
589 specification describes two files, the first to be used as input, the
590 second to be used as output, each described by an
591 .IR fspec .
592 .PP
593 If none of the keywords
594 .RB ` fd ',
595 .RB ` name '
596 or
597 .RB ` null '
598 are given, the type of an
599 .I fspec
600 is deduced from its nature: if it matches one of the strings
601 .RB ` stdin '
602 or
603 .RB ` stdout ',
604 or begins with a digit, it's considered to be a file descriptor;
605 otherwise it's interpreted as a filename.
606 .PP
607 A
608 .RB ` name '
609 spec describes a file by its name within the filesystem. It is opened
610 when needed and closed again after use. For output files, the precise
611 behaviour is controlled by options described below.
612 .PP
613 A
614 .RB ` null '
615 spec attaches the input or output of the source or target to
616 .BR /dev/null .
617 .PP
618 An
619 .RB ` fd '
620 spec uses an existing open file descriptor, given either by number or a
621 symbolic name. The name
622 .RB ` stdin '
623 refers to standard input (file descriptor 0 on normal systems) and
624 .RB ` stdout '
625 refers to standard output (file descriptor 1). The names work in
626 exactly the same way as the equivalent file descriptor numbers.
627 .PP
628 If the output
629 .I fspec
630 is omitted, the input
631 .I fspec
632 is used for both input and output. Exception: if the input refers to
633 standard input then the output will refer to standard output instead.
634 .PP
635 All
636 .B file
637 options apply equally to sources and targets. The options are as
638 follows:
639 .OS "File options"
640 .B file.create
641 .RB [ = ]
642 .BR yes | no
643 .OD
644 Whether 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 ,
648 the file is created if it doesn't exist.
649 .OE
650 .OS "File options"
651 .B file.open
652 .RB [ = ]
653 .BR no | truncate | append
654 .OD
655 Controls the behaviour if the output file already exists. If
656 .BR no ,
657 an error is reported. If
658 .B truncate
659 (the default), the existing file is replaced by the new data. If
660 .BR append ,
661 the new data is appended to the file.
662 .OE
663 .OS "File options"
664 .BR file.fattr.*
665 .OD
666 The
667 .B file
668 source and target also accept
669 .B fattr
670 options for controlling the attributes of the created file.
671 .OE
672 .PP
673 Under no circumstances will
674 .B fw
675 create a file through a `dangling' symbolic link.
676 .
677 .SS "The `exec' source and target types"
678 The
679 .B exec
680 source and target execute programs and allow access to their standard
681 input and output streams. Both source and target have the same syntax,
682 which is as follows:
683 .GS "Exec source and target"
684 .I source
685 ::=
686 .I exec
687 .br
688 .I target
689 ::=
690 exec
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
701 |
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
722 .GE
723 If a single word is given, it is a
724 .I shell-cmd
725 and will be passed to the Bourne shell for execution. If a
726 bracket-enclosed sequence of words is given, it is considered to be a
727 list of arguments to pass to the program: if a
728 .I prog-name
729 is also supplied, it names the file containing the program to execute;
730 otherwise the file named by the first argument
731 .RI ( argv0 )
732 is used.
733 .PP
734 The standard input and output of the program are forwarded to the other
735 end of the connection. The standard error stream is caught by
736 .B fw
737 and logged.
738 .PP
739 The
740 .B exec
741 source and target both understand the same set of options. The list of
742 options supported is as follows:
743 .OS "Exec options"
744 .B exec.logging
745 .RB [ = ]
746 .BR yes | no
747 .OD
748 Whether 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
751 listing its process id, and another is emitted when the program finishes
752 giving its process id and exit status. If
753 .BR no ,
754 these messages are not emitted. However the standard error stream is
755 still logged. The
756 .B log
757 abbreviation is accepted as a synonym for
758 .BR logging .
759 .OE
760 .OS "Exec options"
761 .B exec.dir
762 .RB [ = ]
763 .I file-name
764 .OD
765 Sets the current directory from which the the program should be run.
766 The default is not to change directory. The synonyms
767 .BR cd ,
768 .B chdir
769 and
770 .B cwd
771 are accepted in place of
772 .BR dir .
773 .OE
774 .OS "Exec options"
775 .B exec.root
776 .RB [ = ]
777 .I file-name
778 .OD
779 Sets the root directory for the program, using the
780 .BR chroot (2)
781 system call. You must be the superuser for this option to work. The
782 default is not to set a root directory. The synonyms
783 .BR cd ,
784 .B chdir
785 and
786 .B cwd
787 are accepted in place of
788 .B dir .
789 .OE
790 .OS "Exec options"
791 .B exec.user
792 .RB [ = ]
793 .I user
794 .OD
795 Sets the user (real and effective uid) to run the program as. This will
796 usually require superuser privileges to work. The default is not to
797 change uid. The synonym
798 .B uid
799 is accepted in place of
800 .BR user .
801 .OE
802 .OS "Exec options"
803 .B exec.group
804 .RB [ = ]
805 .I group
806 .OD
807 Sets the group (real and effective gid) to run the program as. If
808 running with superuser privileges, the supplementary groups list is
809 cleared at the same time. The default is not to change gid (or clear
810 the supplementary groups list). The synonym
811 .B gid
812 is accepted in place of
813 .BR group .
814 .OE
815 .OS "Exec options"
816 .BI exec.rlimit. limit \c
817 .RB [ .hard | .soft ]
818 .RB [ = ]
819 .I value
820 .OD
821 Set resource limits for the program. The
822 .I limit
823 may be one of the resource limit names described in
824 .BR setrlimit (2),
825 in lower-case and without the
826 .B RLIMIT_
827 prefix; for example,
828 .B RLIMIT_CORE
829 becomes simply
830 .BR core .
831 The
832 .I value
833 is a number, followed optionally by
834 .B k
835 to multiply by 1024 (2\*(ss10\*(se),
836 .B m
837 to multiply by 1048576 (2\*(ss20\*(se), or
838 .B g
839 to multiply by 1073741824 (2\*(ss30\*(se); purists can use upper-case
840 versions of these if they want. If
841 .B .hard
842 or
843 .B .soft
844 was specified, only the hard or soft limit is set; otherwise both are
845 set to the same value. Only the superuser can raise the hard limit.
846 The soft limit cannot be set above the hard limit.
847 .OE
848 .OS "Exec options"
849 .B exec.env.clear
850 .OD
851 Clears the program's environment.
852 .OE
853 .PP
854 .B exec.env.unset
855 .I var
856 .OD
857 Removes
858 .I var
859 from the program's environment. It is not an error if no variable named
860 .I var
861 exists.
862 .OE
863 .OS "Exec options"
864 .BR exec.env. [ set ]
865 .I var
866 .RB [ = ]
867 .I value
868 .OD
869 Assigns the variable
870 .I var
871 the value
872 .I value
873 in the program's environment, possibly replacing the existing value.
874 The
875 .B set
876 may be omitted if the
877 .B env
878 qualifier is present.
879 .OE
880 .PP
881 Note that environment variable modifications are performed in order,
882 global modifications before local ones.
883 .
884 .SS "The `socket' source and target types"
885 The
886 .B socket
887 source and target provide access to network services. Support is
888 currently provided for TCP/IP and Unix-domain sockets, although other
889 address types can be added with reasonable ease.
890 .PP
891 The syntax for socket sources and targets is:
892 .GS "Socket source and target"
893 .ll +8i
894 .I source
895 ::=
896 .I socket-source
897 .br
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
918 .GE
919 The syntax of the source and target addresses depend on the address
920 types, which are described below. The default address type, if no
921 .I addr-type
922 is given, is
923 .BR inet .
924 .PP
925 Socket sources support options; socket targets do not. The source
926 options provided are:
927 .OS "Socket options"
928 .B socket.conn
929 .RB [ = ]
930 .I number
931 .OD
932 Limits the number of simultaneous connections to this socket to the
933 .I number
934 given. The default is 256.
935 .OE
936 .OS "Socket options"
937 .B socket.logging
938 .RB [ = ]
939 .BR yes | no
940 .OD
941 Whether to log incoming connections. If
942 .B yes
943 (the default) incoming connections are logged, together with information
944 about the client (where available) and whether the connection was
945 accepted or refused. If
946 .BR no ,
947 log messages are not generated.
948 .OE
949 .PP
950 Address types also provide their own options.
951 .
952 .SS "The `inet' socket address type"
953 The
954 .B inet
955 address type provides access to TCP ports. The
956 .B inet
957 source and target addresses have the following syntax:
958 .GS "Socket source and target"
959 .I inet-source-addr
960 ::=
961 .RB [ port ]
962 .I port
963 .br
964 .I inet-target-addr
965 ::=
966 .I address
967 .RB [ : ]
968 .I port
969 .br
970 .I address
971 ::=
972 .I addr-elt
973 |
974 .I address
975 .I addr-elt
976 .br
977 .I addr-elt
978 ::=
979 .B .
980 |
981 .I word
982 .GE
983 A
984 .I port
985 may be given as a port number or a service name from the
986 .B /etc/services
987 file (or YP map if you do that sort of thing). A
988 .B hostname
989 may be a textual hostname or a numerical IP address.
990 .PP
991 The
992 .B inet
993 source address accepts the following options:
994 .OS "Socket options"
995 .BR socket.inet. [ allow | deny ]
996 .RB [ from ]
997 .I address
998 .RB [ /
999 .IR address ]
1000 .OD
1001 Adds an entry to the source's access control list. If only one
1002 .I address
1003 is given, the entry applies only to that address; if two are given, the
1004 first is a network address and the second is a netmask either in
1005 dotted-quad format or a simple number of bits (e.g.,
1006 .B /255.255.255.192
1007 and
1008 .B /26
1009 mean the same), and the entry applies to any address which, when masked
1010 by the netmask, is equal to the masked network address.
1011 .OE
1012 .PP
1013 The access control rules are examined in the order: local entries first,
1014 then global ones, each in the order given in the configuration file.
1015 The first matching entry is used. If no entries match, the behaviour is
1016 the
1017 .I opposite
1018 of the last entry tried. If there are no entries defined, the default
1019 is to allow all clients.
1020 .
1021 .SS "The `unix' socket address type"
1022 The
1023 .B unix
1024 address type allows access to Unix-domain sockets. The syntax for
1025 .B unix
1026 source and target addresses is like this:
1027 .GS "Socket source and target"
1028 .I unix-source-addr
1029 ::=
1030 .I file-name
1031 .br
1032 .I unix-target-addr
1033 ::=
1034 .I file-name
1035 .GE
1036 The following options are supported by the
1037 .B unix
1038 source address type:
1039 .OS "Socket options"
1040 .BR socket.unix.fattr. *
1041 .OD
1042 The
1043 .B unix
1044 source address accepts
1045 .B fattr
1046 options to control the attributes of the socket file created.
1047 .OE
1048 .PP
1049 Sockets are removed if
1050 .B fw
1051 exits normally (which it will do if it runs out of sources or
1052 connections, or if killed by SIGINT or SIGTERM).
1053 .SH "EXAMPLES"
1054 To forward the local port 25 to a main mail server:
1055 .VS
1056 from 25 to mailserv:25
1057 .VE
1058 To attach a fortune server to a Unix-domain socket:
1059 .VS
1060 from unix:/tmp/fortunes
1061 to exec [/usr/games/fortune] { user nobody }
1062 .VE
1063 To fetch a fortune from the server:
1064 .VS
1065 from file stdin, stdout to unix:/tmp/fortunes
1066 .VE
1067 To emulate
1068 .BR cat (1):
1069 .VS
1070 from stdin, null to null, stdout
1071 .VE
1072 .
1073 .\"--------------------------------------------------------------------------
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 ::=
1206 exec
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 .\"--------------------------------------------------------------------------
1379 .SH "BUGS"
1380 .
1381 The syntax for IP addresses and filenames is nasty.
1382 .PP
1383 IPv6 is not supported yet. It's probably not a major piece of work to
1384 add.
1385 .PP
1386 Please inform me of any security problems you think you've identified in
1387 this program. I take security very seriously, and I will fix security
1388 holes as a matter of priority when I find out about them. I will be
1389 annoyed if I have to read about problems on Bugtraq because they weren't
1390 mailed to me first.
1391 .
1392 .\"--------------------------------------------------------------------------
1393 .SH "AUTHOR"
1394 .
1395 Mark Wooding, <mdw@nsict.org>
1396 .
1397 .\"----- That's all, folks --------------------------------------------------