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