From afd7451e40e07118103fcc81e3b635a164c545c4 Mon Sep 17 00:00:00 2001 From: mdw Date: Sat, 3 Jul 1999 13:55:17 +0000 Subject: [PATCH] Various changes. Add configuration grammar to help text. Change to root directory and open syslog when forking into background. --- fw.c | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/fw.c b/fw.c index ba4b565..04235d4 100644 --- a/fw.c +++ b/fw.c @@ -1,6 +1,6 @@ /* -*-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 * @@ -29,8 +29,12 @@ /*----- 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. * */ @@ -56,12 +60,14 @@ #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 ---------------------------------------------------------*/ @@ -74,7 +80,7 @@ static void version(FILE *fp) 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); } @@ -92,6 +98,7 @@ A fairly full-featured port-forwarder. Options available are:\n\ \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\ @@ -99,9 +106,14 @@ configuration is given on the command line, the standard input stream is\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); } @@ -244,16 +256,19 @@ int main(int argc, char *argv[]) _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); -- 2.11.0