From 876b8be0ab24721e8f94d47dde022563f76db992 Mon Sep 17 00:00:00 2001 From: Paul Jakma Date: Sun, 15 Oct 2006 23:35:57 +0000 Subject: [daemon startup] Add --dry-run/-C argument to daemons, to check config file syntax 2006-10-04 Oliver Hookins * bgpd/bgp_main.c: Add configuration check option, with '-C' rather than '-c' for consistency between daemons. * isisd/isis_main.c: ditto * ospf6d/ospf6_main.c: ditto * ospfd/ospf_main.c: ditto * ripngd/ripng_main.c: ditto * vtysh/vtysh_main.c: ditto * ripd/rip_main.c: Change the config check option to '-C' and tidy up the code. * zebra/main.c: ditto 2006-10-04 Stergiakis Alexandros * ripd/rip_main.c: This trivial patch introduces a new command-line option '-c', which instructs zebra/ripd to check its configuration file for validity, print any error message, and then exit. This is useful when the configuration file is edited by hand or otherwise, and you simply want to validate it without any other effect. * zebra/main.c: ditto --- ospf6d/ospf6_main.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'ospf6d/ospf6_main.c') diff --git a/ospf6d/ospf6_main.c b/ospf6d/ospf6_main.c index c40b46ed..8380bc89 100644 --- a/ospf6d/ospf6_main.c +++ b/ospf6d/ospf6_main.c @@ -77,6 +77,7 @@ struct option longopts[] = { "user", required_argument, NULL, 'u'}, { "group", required_argument, NULL, 'g'}, { "version", no_argument, NULL, 'v'}, + { "dryrun", no_argument, NULL, 'C'}, { "help", no_argument, NULL, 'h'}, { 0 } }; @@ -114,6 +115,7 @@ Daemon which manages OSPF version 3.\n\n\ -u, --user User to run as\n\ -g, --group Group to run as\n\ -v, --version Print program version\n\ +-C, --dryrun Check configuration for validity and exit\n\ -h, --help Display this help and exit\n\ \n\ Report bugs to zebra@zebra.org\n", progname); @@ -184,6 +186,7 @@ main (int argc, char *argv[], char *envp[]) int vty_port = 0; char *config_file = NULL; struct thread thread; + int dryrun = 0; /* Set umask before anything for security */ umask (0027); @@ -194,7 +197,7 @@ main (int argc, char *argv[], char *envp[]) /* Command line argument treatment. */ while (1) { - opt = getopt_long (argc, argv, "df:i:hp:A:P:u:g:v", longopts, 0); + opt = getopt_long (argc, argv, "df:i:hp:A:P:u:g:vC", longopts, 0); if (opt == EOF) break; @@ -236,6 +239,9 @@ main (int argc, char *argv[], char *envp[]) print_version (progname); exit (0); break; + case 'C': + dryrun = 1; + break; case 'h': usage (progname, 0); break; @@ -271,6 +277,10 @@ main (int argc, char *argv[], char *envp[]) /* parse config file */ vty_read_config (config_file, config_default); + /* Start execution only if not in dry-run mode */ + if (dryrun) + return(0); + if (daemon_mode) daemon (0, 0); -- cgit v1.2.3 From 0d6b2ee249e9efba30da3236c413bf03c7b27ed9 Mon Sep 17 00:00:00 2001 From: Paul Jakma Date: Thu, 29 May 2008 18:29:16 +0000 Subject: [daemons] Sanity check port number arguments before use 2008-05-29 Martin Nagy * */*main.c: Sanity check port numbers before using. --- ospf6d/ospf6_main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'ospf6d/ospf6_main.c') diff --git a/ospf6d/ospf6_main.c b/ospf6d/ospf6_main.c index 8380bc89..680f4b7f 100644 --- a/ospf6d/ospf6_main.c +++ b/ospf6d/ospf6_main.c @@ -227,7 +227,8 @@ main (int argc, char *argv[], char *envp[]) break; } vty_port = atoi (optarg); - vty_port = (vty_port ? vty_port : OSPF6_VTY_PORT); + if (vty_port <= 0 || vty_port > 0xffff) + vty_port = OSPF6_VTY_PORT; break; case 'u': ospf6d_privs.user = optarg; -- cgit v1.2.3 From 6ac29a51075def99217a4ab1015635db3b3e83ed Mon Sep 17 00:00:00 2001 From: Paul Jakma Date: Fri, 15 Aug 2008 13:45:30 +0100 Subject: [trivia] finish off static'ification of ospf6d and ripngd 2008-08-15 Paul Jakma * {ospf6d,ripngd}/*: Finish job of marking functions as static, or exporting declarations for them, to quell warning noise with Quagga's GCC default high-level of warning flags. Thus allowing remaining, more useful warnings to be more easily seen. --- ospf6d/ospf6_main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'ospf6d/ospf6_main.c') diff --git a/ospf6d/ospf6_main.c b/ospf6d/ospf6_main.c index 680f4b7f..73d9150e 100644 --- a/ospf6d/ospf6_main.c +++ b/ospf6d/ospf6_main.c @@ -125,14 +125,14 @@ Report bugs to zebra@zebra.org\n", progname); } /* SIGHUP handler. */ -void +static void sighup (void) { zlog_info ("SIGHUP received"); } /* SIGINT handler. */ -void +static void sigint (void) { zlog_notice ("Terminating on signal SIGINT"); @@ -140,7 +140,7 @@ sigint (void) } /* SIGTERM handler. */ -void +static void sigterm (void) { zlog_notice ("Terminating on signal SIGTERM"); @@ -148,7 +148,7 @@ sigterm (void) } /* SIGUSR1 handler. */ -void +static void sigusr1 (void) { zlog_info ("SIGUSR1 received"); -- cgit v1.2.3