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