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