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