/* -*-c-*-
*
- * $Id: fw.c,v 1.1 1999/07/01 08:56:23 mdw Exp $
+ * $Id: fw.c,v 1.2 1999/07/03 13:55:17 mdw Exp $
*
* Port forwarding thingy
*
/*----- Revision history --------------------------------------------------*
*
* $Log: fw.c,v $
- * Revision 1.1 1999/07/01 08:56:23 mdw
- * Initial revision
+ * Revision 1.2 1999/07/03 13:55:17 mdw
+ * Various changes. Add configuration grammar to help text. Change to
+ * root directory and open syslog when forking into background.
+ *
+ * Revision 1.1.1.1 1999/07/01 08:56:23 mdw
+ * Initial revision.
*
*/
#include "acl.h"
#include "bres.h"
#include "conf.h"
+#include "fw.h"
#include "listener.h"
#include "scan.h"
-/*----- Static variables --------------------------------------------------*/
+/*----- Global variables --------------------------------------------------*/
sel_state *sel; /* Multiplexor for nonblocking I/O */
+unsigned flags = 0; /* Global state flags */
/*----- Main code ---------------------------------------------------------*/
static void usage(FILE *fp)
{
- fprintf(stderr, "Usage: %s [-d] [-f file] [config statements...]\n",
+ fprintf(stderr, "Usage: %s [-db] [-f file] [config statements...]\n",
QUIS);
}
\n\
-f, --file=FILE Read configuration from a file.\n\
-d, --dump Dump the configuration to standard output.\n\
+-b, --background Fork into background after initializing.\n\
\n\
Configuration may be supplied in one or more configuration files, or on\n\
the command line (or both). If no `-f' option is present, and no\n\
read.\n\
\n\
Configuration is free-form. Comments begin with a `#' character and\n\
-continue to the end of the line. When reading from the command line,\n\
-each argument is considered a separate line. See the manual page for the\n\
-complete syntax.\n\
+continue to the end of the line. Each command line argument is considered\n\
+to be a separate line. The syntax is as follows:\n\
+\n\
+config : stmt...\n\
+stmt : fwd-stmt | acl-stmt\n\
+fwd-stmt : `forward' [`port'] port [`to'] addr [`:'] port [fwd-attr] [`;']\n\
+fwd-attr : `{' acl-stmt... `}'\n\
+acl-stmt : (`allow' | `deny') [`from'] addr [`/' mask] [`;']\n\
", fp);
}
_exit(0);
close(0); close(1); close(2);
+ chdir("/");
setsid();
kid = fork();
if (kid != 0)
_exit(0);
+
+ flags |= FW_SYSLOG;
+ openlog(QUIS, 0, LOG_DAEMON);
}
/* --- Let rip --- */
- openlog(QUIS, 0, LOG_DAEMON);
for (;;)
sel_select(sel);
return (0);