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