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