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