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