Expunge CVS cruft.
[fwd] / fw.1
diff --git a/fw.1 b/fw.1
index 2d23b0d..d6634f3 100644 (file)
--- a/fw.1
+++ b/fw.1
@@ -1,6 +1,6 @@
 .\" -*-nroff-*-
 .\"
 .\" -*-nroff-*-
 .\"
-.\" $Id: fw.1,v 1.8 1999/12/22 15:44:43 mdw Exp $
+.\" $Id$
 .\"
 .\" Manual page for fw
 .\"
 .\"
 .\" Manual page for fw
 .\"
 .\" along with `fw'; if not, write to the Free Software Foundation,
 .\" Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 .
 .\" along with `fw'; if not, write to the Free Software Foundation,
 .\" Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 .
-.\" ---- Revision history ---------------------------------------------------
-.\" 
-.\" $Log: fw.1,v $
-.\" Revision 1.8  1999/12/22 15:44:43  mdw
-.\" Fix some errors, and document new option.
-.\"
-.\" Revision 1.7  1999/10/22 22:45:15  mdw
-.\" Describe new socket connection options.
-.\"
-.\" Revision 1.6  1999/10/10 16:46:29  mdw
-.\" Include grammar and options references at the end of the manual.
-.\"
-.\" Revision 1.5  1999/09/26 18:18:05  mdw
-.\" Remove a fixed bug from the list.  Fix some nasty formatting
-.\" misfeatures.
-.\"
-.\" Revision 1.4  1999/08/19 18:32:48  mdw
-.\" Improve lexical analysis.  In particular, `chmod' patterns don't have to
-.\" be quoted any more.
-.\"
-.\" Revision 1.3  1999/07/30 06:49:00  mdw
-.\" Minor tidying and typo correction.
-.\"
-.\" Revision 1.2  1999/07/26 23:31:04  mdw
-.\" Document lots of new features and syntax.
-.\"
-.
 .\"----- Various bits of fancy styling --------------------------------------
 .
 .\" --- Indented paragraphs with right-aligned tags ---
 .\"----- Various bits of fancy styling --------------------------------------
 .
 .\" --- Indented paragraphs with right-aligned tags ---
 .
 .\"--------------------------------------------------------------------------
 .
 .
 .\"--------------------------------------------------------------------------
 .
-.TH fw 1 "1 July 1999" fw
+.TH fw 1 "1 July 1999" "Straylight/Edgeware" "fw port forwarder"
 .
 .\"--------------------------------------------------------------------------
 .SH NAME
 .
 .\"--------------------------------------------------------------------------
 .SH NAME
@@ -129,6 +102,10 @@ fw \- port forwarder
 .RB [ \-dlq ]
 .RB [ \-f
 .IR file ]
 .RB [ \-dlq ]
 .RB [ \-f
 .IR file ]
+.RB [ \-s
+.IR user ]
+.RB [ \-g
+.IR group ]
 .IR config-stmt ...
 .
 .\"--------------------------------------------------------------------------
 .IR config-stmt ...
 .
 .\"--------------------------------------------------------------------------
@@ -175,6 +152,14 @@ Writes the version number to standard output and exits successfully.
 .B "\-u, \-\-usage"
 Writes a terse usage summary to standard output and exits successfully.
 .TP
 .B "\-u, \-\-usage"
 Writes a terse usage summary to standard output and exits successfully.
 .TP
+.B "\-G, \-\-grammar"
+Writes a summary of the configuration file grammar to standard output
+and exits successfully.
+.TP
+.B "\-O, \-\-options"
+Writes a summary of the source and target options to standard output and
+exits successfully.
+.TP
 .BI "\-f, \-\-file=" file
 Read configuration information from
 .IR file .
 .BI "\-f, \-\-file=" file
 Read configuration information from
 .IR file .
@@ -190,10 +175,24 @@ initializing properly.
 .B "\-l, \-\-syslog, \-\-log"
 Emit logging information to the system log, rather than standard error.
 .TP
 .B "\-l, \-\-syslog, \-\-log"
 Emit logging information to the system log, rather than standard error.
 .TP
-.B "-q, \-\-quiet"
+.B "\-q, \-\-quiet"
 Don't output any logging information.  This option is not recommended
 for normal use, although it can make system call traces clearer so I use
 it when debugging.
 Don't output any logging information.  This option is not recommended
 for normal use, although it can make system call traces clearer so I use
 it when debugging.
+.TP
+.BI "\-s, \-\-setuid=" user
+Change uid to that of
+.IR user ,
+which may be either a user name or uid number, after initializing all
+the sources.  This will usually require elevated privileges.
+.TP
+.BI "\-g, \-\-setgid=" group
+Change gid to that of
+.IR group ,
+which may be either a group name or gid number, after initializing all
+the sources.  If the operating system understands supplementary groups
+then the supplementary groups list is altered to include only
+.IR group .
 .PP
 Any further command line arguments are interpreted as configuration
 lines to be read.  Configuration supplied in command line arguments has
 .PP
 Any further command line arguments are interpreted as configuration
 lines to be read.  Configuration supplied in command line arguments has
@@ -240,8 +239,8 @@ are self-delimiting.  Note that while some characters, e.g.,
 .RB ` [ '
 and
 .RB ` ; ',
 .RB ` [ '
 and
 .RB ` ; ',
-require escaping by the shell, they are strictly optional in the grammar
-and can be omitted in quick hacks at the shell prompt.
+require escaping by the shell, they are mostly optional in the grammar
+and can tend to be omitted in quick hacks at the shell prompt.
 .TP
 .I "whitespace characters"
 Whitespace characters separate words but are otherwise ignored.  All
 .TP
 .I "whitespace characters"
 Whitespace characters separate words but are otherwise ignored.  All
@@ -371,8 +370,8 @@ on the
 A global option, outside of a
 .I fw-stmt
 has no context unless it is explicitly qualified, and affects global
 A global option, outside of a
 .I fw-stmt
 has no context unless it is explicitly qualified, and affects global
-behaviour.  Local options, applied to a source or target in a
-.I fw-stmt
+behaviour.  A local option, applied to a source or target in a
+.IR fw-stmt ,
 has the context of the type of source or target to which it is applied,
 and affects only that source or target.
 .PP
 has the context of the type of source or target to which it is applied,
 and affects only that source or target.
 .PP
@@ -394,7 +393,7 @@ The syntax for qualifying options is like this:
 .br
        |
 .I prefix
 .br
        |
 .I prefix
-.B .
+.B .\&
 .I q-option
 .br
        |
 .I q-option
 .br
        |
@@ -415,7 +414,7 @@ exec.rlimit {
   cpu = 60;
 }
 .VE
   cpu = 60;
 }
 .VE
-is equivalent to
+means the same as
 .VS
 exec.rlimit.core = 0;
 exec.rlimit.cpu = 0;
 .VS
 exec.rlimit.core = 0;
 exec.rlimit.cpu = 0;
@@ -544,7 +543,7 @@ sources and targets is like this:
 .I file
 ::=
 .B file
 .I file
 ::=
 .B file
-.RB  [ . ]
+.RB  [ .\& ]
 .I fspec
 .RB [ ,
 .IR fspec ]
 .I fspec
 .RB [ ,
 .IR fspec ]
@@ -565,7 +564,7 @@ sources and targets is like this:
 .br
 .I name-spec
 ::=
 .br
 .I name-spec
 ::=
-.RB [[ : ] file [ : ]]
+.RB [[ : ] name [ : ]]
 .I file-name
 .br
 .I file-name
 .I file-name
 .br
 .I file-name
@@ -701,7 +700,7 @@ exec
 .I exec
 ::=
 .BR exec
 .I exec
 ::=
 .BR exec
-.RB [ . ]
+.RB [ .\& ]
 .I cmd-spec
 .br
 .I cmd-spec
 .I cmd-spec
 .br
 .I cmd-spec
@@ -740,6 +739,15 @@ otherwise the file named by the first argument
 .RI ( argv0 )
 is used.
 .PP
 .RI ( argv0 )
 is used.
 .PP
+Note that the shell command or program name string must, if present,
+have any delimiter characters (including
+.RB ` / '
+and 
+.RB ` . ')
+quoted; this is not required in the
+.RB ` [ '-enclosed
+argument list.
+.PP
 The standard input and output of the program are forwarded to the other
 end of the connection.  The standard error stream is caught by
 .B fw
 The standard input and output of the program are forwarded to the other
 end of the connection.  The standard error stream is caught by
 .B fw
@@ -788,13 +796,10 @@ are accepted in place of
 Sets the root directory for the program, using the
 .BR chroot (2)
 system call.  You must be the superuser for this option to work.  The
 Sets the root directory for the program, using the
 .BR chroot (2)
 system call.  You must be the superuser for this option to work.  The
-default is not to set a root directory.  The synonyms
-.BR cd ,
-.B chdir
-and
-.B cwd
-are accepted in place of
-.B dir .
+default is not to set a root directory.  The synonym
+.B chroot
+is accepted in place of
+.BR root .
 .OE
 .OS "Exec options"
 .B exec.user
 .OE
 .OS "Exec options"
 .B exec.user
@@ -910,7 +915,7 @@ The syntax for socket sources and targets is:
 .br
 .I socket-source
 ::=
 .br
 .I socket-source
 ::=
-.RB [ socket [ . ]]
+.RB [ socket [ .\& ]]
 .RB [[ : ] \c
 .IR addr-type \c
 .RB [ : ]]
 .RB [[ : ] \c
 .IR addr-type \c
 .RB [ : ]]
@@ -918,7 +923,7 @@ The syntax for socket sources and targets is:
 .br
 .I socket-target
 ::=
 .br
 .I socket-target
 ::=
-.RB [ socket [ . ]]
+.RB [ socket [ .\& ]]
 .RB [[ : ] \c
 .IR addr-type \c
 .RB [ : ]]
 .RB [[ : ] \c
 .IR addr-type \c
 .RB [ : ]]
@@ -955,6 +960,16 @@ the
 option is not recommended.
 .OE
 .OS "Socket options"
 option is not recommended.
 .OE
 .OS "Socket options"
+.B socket.listen
+.RB [ = ]
+.I number
+.OD
+Sets the maximum of the kernel incoming connection queue for this socket
+source.  This is the number given to the
+.BR listen (2)
+system call.  The default is 5.
+.OE
+.OS "Socket options"
 .B socket.logging
 .RB [ = ]
 .BR yes | no
 .B socket.logging
 .RB [ = ]
 .BR yes | no
@@ -997,7 +1012,7 @@ source and target addresses have the following syntax:
 .br
 .I addr-elt
 ::=
 .br
 .I addr-elt
 ::=
-.B .
+.B .\&
 |
 .I word
 .GE
 |
 .I word
 .GE
@@ -1013,11 +1028,23 @@ The
 .B inet
 source address accepts the following options:
 .OS "Socket options"
 .B inet
 source address accepts the following options:
 .OS "Socket options"
-.BR socket.inet. [ allow | deny ]
-.RB [ from ]
-.I address
+.B socket.inet.source.addr
+.RB [ = ]
+.RR any | \c
+.I addr
+.OD
+Specify the IP address on which to listen for incoming connections.  The
+default is
+.BR any ,
+which means to listen on all addresses, though it may be useful to
+specify this explicitly, if the global setting is different.
+.OE
+.OS "Socket options"
+.BR socket.inet.source. [ allow | deny ]
+.RB [ host ]
+.I addr
 .RB [ /
 .RB [ /
-.IR address ]
+.IR addr ]
 .OD
 Adds an entry to the source's access control list.  If only one
 .I address
 .OD
 Adds an entry to the source's access control list.  If only one
 .I address
@@ -1030,6 +1057,56 @@ and
 mean the same), and the entry applies to any address which, when masked
 by the netmask, is equal to the masked network address.
 .OE
 mean the same), and the entry applies to any address which, when masked
 by the netmask, is equal to the masked network address.
 .OE
+.OS "Socket options"
+.BR socket.inet.source. [ allow | deny ]
+.B priv-port
+.OD
+Accept or reject connections from low-numbered `privileged' ports, in
+the range 0--1023.
+.OE
+.OS "Socket options"
+.B socket.inet.dest.addr
+.RB [ = ]
+.RR any | \c
+.I addr
+.OD
+Specify the IP address to bind the local socket to when making an
+outbound connection.  The default is
+.BR any ,
+which means to use whichever address the kernel thinks is most
+convenient.  This option is useful if the destination is doing
+host-based access control and your server is multi-homed.
+.OE
+.OS "Socket options"
+.B socket.inet.dest.priv-port
+.RB [=]
+.BR yes | no
+.OD
+Make a privileged connection (i.e., from a low-numbered port) to the
+target.  This only works if
+.B fw
+was started with root privileges.  However, it still works if
+.B fw
+has
+.I dropped
+privileges after initialization (the
+.B \-s
+option).  Before dropping privileges, 
+.B fw
+forks off a separate process which continues to run with root
+privileges, and on demand passes sockets bound to privileged ports and
+connected to the appropriate peer back to the main program.  The
+privileged child only passes back sockets connected to peer addresses
+named in the configuration; even if the
+.B fw
+process is compromised, it can't make privileged connections to other
+addresses.  Note that because of this privilege separation, it's also
+not possible to reconfigure
+.B fw
+to make privileged connections to different peer addresses later by
+changing configuration files and sending the daemon a
+.BR SIGHUP .
+.OE
 .PP
 The access control rules are examined in the order: local entries first,
 then global ones, each in the order given in the configuration file.
 .PP
 The access control rules are examined in the order: local entries first,
 then global ones, each in the order given in the configuration file.
@@ -1070,7 +1147,9 @@ options to control the attributes of the socket file created.
 Sockets are removed if
 .B fw
 exits normally (which it will do if it runs out of sources or
 Sockets are removed if
 .B fw
 exits normally (which it will do if it runs out of sources or
-connections, or if killed by SIGINT or SIGTERM).
+connections, or if
+.B fw
+shuts down in a clean way).
 .SH "EXAMPLES"
 To forward the local port 25 to a main mail server:
 .VS
 .SH "EXAMPLES"
 To forward the local port 25 to a main mail server:
 .VS
@@ -1088,8 +1167,51 @@ from file stdin, stdout to unix:/tmp/fortunes
 To emulate
 .BR cat (1):
 .VS
 To emulate
 .BR cat (1):
 .VS
-from stdin, null to null, stdout
+from file stdin, null to file null, stdout
 .VE
 .VE
+.sp -1 \" undo final space
+.
+.\"--------------------------------------------------------------------------
+.SH "SIGNAL HANDLING"
+.
+The
+.B fw
+program responds to various signals when it's running.  If it receives
+.B SIGTERM
+or
+.BR SIGINT ,
+.B fw
+performs a
+.I graceful
+shutdown: it removes all of its sources, and will exit when no more
+connections are running.  (Note that if the disposition
+.B SIGINT
+was to ignore it,
+.B fw
+does not re-enable the signal.  You'll have to send
+.B SIGTERM
+in that case.)  If
+.B fw
+receives
+.BR SIGQUIT ,
+it performs an
+.I abrupt
+shutdown: it removes all sources and extant connections and closes down
+more-or-less immediately.
+.PP
+Finally, if any configuration files (other than standard input) were
+provided to
+.B fw
+on its command line using the
+.B \-f
+option, a
+.B SIGHUP
+signal may be sent to instruct
+.B fw
+to reload its configuration.  Any existing connections are allowed to
+run their course.  If no such configuration files are available,
+.B fw
+just logs a message about the signal and continues.
 .
 .\"--------------------------------------------------------------------------
 .SH "GRAMMAR SUMMARY"
 .
 .\"--------------------------------------------------------------------------
 .SH "GRAMMAR SUMMARY"
@@ -1143,7 +1265,7 @@ from stdin, null to null, stdout
 .br
        |
 .I prefix
 .br
        |
 .I prefix
-.B .
+.B .\&
 .I q-option
 .br
        |
 .I q-option
 .br
        |
@@ -1168,7 +1290,7 @@ from stdin, null to null, stdout
 .I file
 ::=
 .B file
 .I file
 ::=
 .B file
-.RB  [ . ]
+.RB  [ .\& ]
 .I fspec
 .RB [ ,
 .IR fspec ]
 .I fspec
 .RB [ ,
 .IR fspec ]
@@ -1189,7 +1311,7 @@ from stdin, null to null, stdout
 .br
 .I name-spec
 ::=
 .br
 .I name-spec
 ::=
-.RB [[ : ] file [ : ]]
+.RB [[ : ] name [ : ]]
 .I file-name
 .br
 .I file-name
 .I file-name
 .br
 .I file-name
@@ -1229,7 +1351,7 @@ exec
 .I exec
 ::=
 .BR exec
 .I exec
 ::=
 .BR exec
-.RB [ . ]
+.RB [ .\& ]
 .I cmd-spec
 .br
 .I cmd-spec
 .I cmd-spec
 .br
 .I cmd-spec
@@ -1269,7 +1391,7 @@ exec
 .br
 .I socket-source
 ::=
 .br
 .I socket-source
 ::=
-.RB [ socket [ . ]]
+.RB [ socket [ .\& ]]
 .RB [[ : ] \c
 .IR addr-type \c
 .RB [ : ]]
 .RB [[ : ] \c
 .IR addr-type \c
 .RB [ : ]]
@@ -1277,7 +1399,7 @@ exec
 .br
 .I socket-target
 ::=
 .br
 .I socket-target
 ::=
-.RB [ socket [ . ]]
+.RB [ socket [ .\& ]]
 .RB [[ : ] \c
 .IR addr-type \c
 .RB [ : ]]
 .RB [[ : ] \c
 .IR addr-type \c
 .RB [ : ]]
@@ -1304,7 +1426,7 @@ exec
 .br
 .I addr-elt
 ::=
 .br
 .I addr-elt
 ::=
-.B .
+.B .\&
 |
 .I word
 .PP
 |
 .I word
 .PP
@@ -1385,15 +1507,36 @@ exec
 .IR number | \c
 .BR unlimited | one-shot
 .br
 .IR number | \c
 .BR unlimited | one-shot
 .br
+.B socket.listen
+.RB [ = ]
+.I number
+.br
 .B socket.logging
 .RB [ = ]
 .BR yes | no
 .PP
 .B socket.logging
 .RB [ = ]
 .BR yes | no
 .PP
-.BR socket.inet. [ allow | deny ]
-.RB [ from ]
-.I address
+.BR socket.inet.source. [ allow | deny ]
+.RB [ host ]
+.I addr
 .RB [ /
 .RB [ /
-.IR address ]
+.IR addr ]
+.br
+.BR socket.inet.source. [ allow | deny ]
+.B priv-port
+.br
+.B socket.inet.source.addr
+.RB [ = ]
+.BR any | \c
+.I addr
+.br
+.B socket.inet.dest.addr
+.RB [ = ]
+.BR any | \c
+.I addr
+.br
+.B socket.inet.dest.priv-port
+.RB [=]
+.BR yes | no
 .PP
 .BR socket.unix.fattr. *
 .
 .PP
 .BR socket.unix.fattr. *
 .
@@ -1412,6 +1555,8 @@ this program.  I take security very seriously, and I will fix security
 holes as a matter of priority when I find out about them.  I will be
 annoyed if I have to read about problems on Bugtraq because they weren't
 mailed to me first.
 holes as a matter of priority when I find out about them.  I will be
 annoyed if I have to read about problems on Bugtraq because they weren't
 mailed to me first.
+.PP
+The program is too complicated, and this manual page is too long.
 .
 .\"--------------------------------------------------------------------------
 .SH "AUTHOR"
 .
 .\"--------------------------------------------------------------------------
 .SH "AUTHOR"