From 718e3744195351130f4ce7dbe0613f4b3e23df93 Mon Sep 17 00:00:00 2001 From: paul Date: Fri, 13 Dec 2002 20:15:29 +0000 Subject: Initial revision --- ripd/rip_main.c | 270 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 270 insertions(+) create mode 100644 ripd/rip_main.c (limited to 'ripd/rip_main.c') diff --git a/ripd/rip_main.c b/ripd/rip_main.c new file mode 100644 index 00000000..1070fb45 --- /dev/null +++ b/ripd/rip_main.c @@ -0,0 +1,270 @@ +/* RIPd main routine. + * Copyright (C) 1997, 98 Kunihiro Ishiguro + * + * This file is part of GNU Zebra. + * + * GNU Zebra is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2, or (at your option) any + * later version. + * + * GNU Zebra is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Zebra; see the file COPYING. If not, write to the Free + * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +#include + +#include "version.h" +#include "getopt.h" +#include "thread.h" +#include "command.h" +#include "memory.h" +#include "prefix.h" +#include "filter.h" +#include "keychain.h" +#include "log.h" + +#include "ripd/ripd.h" + +/* ripd options. */ +static struct option longopts[] = +{ + { "daemon", no_argument, NULL, 'd'}, + { "config_file", required_argument, NULL, 'f'}, + { "pid_file", required_argument, NULL, 'i'}, + { "help", no_argument, NULL, 'h'}, + { "vty_addr", required_argument, NULL, 'A'}, + { "vty_port", required_argument, NULL, 'P'}, + { "retain", no_argument, NULL, 'r'}, + { "version", no_argument, NULL, 'v'}, + { 0 } +}; + +/* Configuration file and directory. */ +char config_current[] = RIPD_DEFAULT_CONFIG; +char config_default[] = SYSCONFDIR RIPD_DEFAULT_CONFIG; +char *config_file = NULL; + +/* ripd program name */ + +/* Route retain mode flag. */ +int retain_mode = 0; + +/* RIP VTY bind address. */ +char *vty_addr = NULL; + +/* RIP VTY connection port. */ +int vty_port = RIP_VTY_PORT; + +/* Master of threads. */ +struct thread_master *master; + +/* Process ID saved for use by init system */ +char *pid_file = PATH_RIPD_PID; + +/* Help information display. */ +static void +usage (char *progname, int status) +{ + if (status != 0) + fprintf (stderr, "Try `%s --help' for more information.\n", progname); + else + { + printf ("Usage : %s [OPTION...]\n\ +Daemon which manages RIP version 1 and 2.\n\n\ +-d, --daemon Runs in daemon mode\n\ +-f, --config_file Set configuration file name\n\ +-i, --pid_file Set process identifier file name\n\ +-A, --vty_addr Set vty's bind address\n\ +-P, --vty_port Set vty's port number\n\ +-r, --retain When program terminates, retain added route by ripd.\n\ +-v, --version Print program version\n\ +-h, --help Display this help and exit\n\ +\n\ +Report bugs to %s\n", progname, ZEBRA_BUG_ADDRESS); + } + + exit (status); +} + +/* Signale wrapper. */ +RETSIGTYPE * +signal_set (int signo, void (*func)(int)) +{ + int ret; + struct sigaction sig; + struct sigaction osig; + + sig.sa_handler = func; + sigemptyset (&sig.sa_mask); + sig.sa_flags = 0; +#ifdef SA_RESTART + sig.sa_flags |= SA_RESTART; +#endif /* SA_RESTART */ + + ret = sigaction (signo, &sig, &osig); + + if (ret < 0) + return (SIG_ERR); + else + return (osig.sa_handler); +} + +/* SIGHUP handler. */ +void +sighup (int sig) +{ + zlog_info ("SIGHUP received"); + rip_clean (); + rip_reset (); + zlog_info ("ripd restarting!"); + + /* Reload config file. */ + vty_read_config (config_file, config_current, config_default); + + /* Create VTY's socket */ + vty_serv_sock (vty_addr, vty_port, RIP_VTYSH_PATH); + + /* Try to return to normal operation. */ +} + +/* SIGINT handler. */ +void +sigint (int sig) +{ + zlog (NULL, LOG_INFO, "Terminating on signal"); + + if (! retain_mode) + rip_clean (); + + exit (0); +} + +/* SIGUSR1 handler. */ +void +sigusr1 (int sig) +{ + zlog_rotate (NULL); +} + +/* Initialization of signal handles. */ +void +signal_init () +{ + signal_set (SIGHUP, sighup); + signal_set (SIGINT, sigint); + signal_set (SIGTERM, sigint); + signal_set (SIGPIPE, SIG_IGN); + signal_set (SIGUSR1, sigusr1); +} + +/* Main routine of ripd. */ +int +main (int argc, char **argv) +{ + char *p; + int daemon_mode = 0; + char *progname; + struct thread thread; + + /* Set umask before anything for security */ + umask (0027); + + /* Get program name. */ + progname = ((p = strrchr (argv[0], '/')) ? ++p : argv[0]); + + /* First of all we need logging init. */ + zlog_default = openzlog (progname, ZLOG_NOLOG, ZLOG_RIP, + LOG_CONS|LOG_NDELAY|LOG_PID, LOG_DAEMON); + + /* Command line option parse. */ + while (1) + { + int opt; + + opt = getopt_long (argc, argv, "df:hA:P:rv", longopts, 0); + + if (opt == EOF) + break; + + switch (opt) + { + case 0: + break; + case 'd': + daemon_mode = 1; + break; + case 'f': + config_file = optarg; + break; + case 'A': + vty_addr = optarg; + break; + case 'i': + pid_file = optarg; + break; + case 'P': + vty_port = atoi (optarg); + break; + case 'r': + retain_mode = 1; + break; + case 'v': + print_version (progname); + exit (0); + break; + case 'h': + usage (progname, 0); + break; + default: + usage (progname, 1); + break; + } + } + + /* Prepare master thread. */ + master = thread_master_create (); + + /* Library initialization. */ + signal_init (); + cmd_init (1); + vty_init (); + memory_init (); + keychain_init (); + + /* RIP related initialization. */ + rip_init (); + rip_if_init (); + rip_zclient_init (); + rip_peer_init (); + + /* Sort all installed commands. */ + sort_node (); + + /* Get configuration file. */ + vty_read_config (config_file, config_current, config_default); + + /* Change to the daemon program. */ + if (daemon_mode) + daemon (0, 0); + + /* Pid file create. */ + pid_output (pid_file); + + /* Create VTY's socket */ + vty_serv_sock (vty_addr, vty_port, RIP_VTYSH_PATH); + + /* Execute each thread. */ + while (thread_fetch (master, &thread)) + thread_call (&thread); + + /* Not reached. */ + exit (0); +} -- cgit v1.2.3 From 4fc4e7ab47fef3295d0ae40e064fc99478c24e23 Mon Sep 17 00:00:00 2001 From: paul Date: Wed, 22 Jan 2003 19:47:09 +0000 Subject: Matthew Grant [zebra 17290] [PATCHES] - Fixes for problems in 0.93b portfix patch --- ripd/rip_main.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'ripd/rip_main.c') diff --git a/ripd/rip_main.c b/ripd/rip_main.c index 1070fb45..5e560524 100644 --- a/ripd/rip_main.c +++ b/ripd/rip_main.c @@ -211,7 +211,15 @@ main (int argc, char **argv) pid_file = optarg; break; case 'P': - vty_port = atoi (optarg); + /* Deal with atoi() returning 0 on failure, and ripd not + listening on rip port... */ + if (strcmp(optarg, "0") == 0) + { + vty_port = 0; + break; + } + vty_port = atoi (optarg); + vty_port = (vty_port ? vty_port : RIP_VTY_PORT); break; case 'r': retain_mode = 1; -- cgit v1.2.3 From edd7c245d3a77012abf801da00d5664ebaa5f749 Mon Sep 17 00:00:00 2001 From: paul Date: Wed, 4 Jun 2003 13:59:38 +0000 Subject: 2003-06-04 Paul Jakma * Merge of zebra privileges --- ripd/rip_main.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'ripd/rip_main.c') diff --git a/ripd/rip_main.c b/ripd/rip_main.c index 5e560524..9526d7ae 100644 --- a/ripd/rip_main.c +++ b/ripd/rip_main.c @@ -30,6 +30,7 @@ #include "filter.h" #include "keychain.h" #include "log.h" +#include "privs.h" #include "ripd/ripd.h" @@ -43,10 +44,31 @@ static struct option longopts[] = { "vty_addr", required_argument, NULL, 'A'}, { "vty_port", required_argument, NULL, 'P'}, { "retain", no_argument, NULL, 'r'}, + { "user", required_argument, NULL, 'u'}, { "version", no_argument, NULL, 'v'}, { 0 } }; +/* ripd privileges */ +zebra_capabilities_t _caps_p [] = +{ + ZCAP_RAW, + ZCAP_BIND +}; + +struct zebra_privs_t ripd_privs = +{ +#if defined(ZEBRA_USER) + .user = ZEBRA_USER, +#endif +#if defined ZEBRA_GROUP + .group = ZEBRA_GROUP, +#endif + .caps_p = _caps_p, + .cap_num_p = 2, + .cap_num_i = 0 +}; + /* Configuration file and directory. */ char config_current[] = RIPD_DEFAULT_CONFIG; char config_default[] = SYSCONFDIR RIPD_DEFAULT_CONFIG; @@ -85,6 +107,7 @@ Daemon which manages RIP version 1 and 2.\n\n\ -A, --vty_addr Set vty's bind address\n\ -P, --vty_port Set vty's port number\n\ -r, --retain When program terminates, retain added route by ripd.\n\ +-u, --user User and group to run as\n\ -v, --version Print program version\n\ -h, --help Display this help and exit\n\ \n\ @@ -189,7 +212,7 @@ main (int argc, char **argv) { int opt; - opt = getopt_long (argc, argv, "df:hA:P:rv", longopts, 0); + opt = getopt_long (argc, argv, "df:hA:P:u:rv", longopts, 0); if (opt == EOF) break; @@ -224,6 +247,9 @@ main (int argc, char **argv) case 'r': retain_mode = 1; break; + case 'u': + ripd_privs.group = ripd_privs.user = optarg; + break; case 'v': print_version (progname); exit (0); @@ -241,6 +267,7 @@ main (int argc, char **argv) master = thread_master_create (); /* Library initialization. */ + zprivs_init (&ripd_privs); signal_init (); cmd_init (1); vty_init (); -- cgit v1.2.3 From b21b19c5785487f2ff4a6ce38f45c2e6c35f4363 Mon Sep 17 00:00:00 2001 From: paul Date: Sun, 15 Jun 2003 01:28:29 +0000 Subject: 2003-06-15 Paul Jakma * lib/vty.{c,h}: Remove vty layer depending on a 'master' global, pass the thread master in explicitly to vty_init. Sort out some header dependency problems with lib/command.h * zebra/: Move globals to struct zebrad. Update vty_init(). * (.*)/\1_main.c: update call to vty_init(). --- ripd/rip_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ripd/rip_main.c') diff --git a/ripd/rip_main.c b/ripd/rip_main.c index 9526d7ae..84ea75c5 100644 --- a/ripd/rip_main.c +++ b/ripd/rip_main.c @@ -270,7 +270,7 @@ main (int argc, char **argv) zprivs_init (&ripd_privs); signal_init (); cmd_init (1); - vty_init (); + vty_init (master); memory_init (); keychain_init (); -- cgit v1.2.3 From 96735eeafe4713b60700915dd2fb6dcbd0f09c8f Mon Sep 17 00:00:00 2001 From: paul Date: Sun, 10 Aug 2003 02:51:22 +0000 Subject: 2003-08-10 amir * Add missing 'i' to getopts, short form of --pid_file. see http://bugzilla.quagga.net/show_bug.cgi?id=25 --- ripd/rip_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ripd/rip_main.c') diff --git a/ripd/rip_main.c b/ripd/rip_main.c index 84ea75c5..d5713208 100644 --- a/ripd/rip_main.c +++ b/ripd/rip_main.c @@ -212,7 +212,7 @@ main (int argc, char **argv) { int opt; - opt = getopt_long (argc, argv, "df:hA:P:u:rv", longopts, 0); + opt = getopt_long (argc, argv, "df:i:hA:P:u:rv", longopts, 0); if (opt == EOF) break; -- cgit v1.2.3 From d81fadfd889aa7bc657fa19752344a585e8c274a Mon Sep 17 00:00:00 2001 From: paul Date: Thu, 14 Aug 2003 05:32:12 +0000 Subject: 2003-08-14 Paul Jakma * zebra/main.c: Fixup ZEBRA_{GROUP,USER} defines -> QUAGGA_{USER,GROUP} * bgpd/bgp_main.c: ditto * ospf6d/ospf6_main.c: ditto * ospfd/ospf_main.c: ditto * ripd/rip_main.c: ditto * ripngd/ripng_main.c: ditto * zebra/main.c: ditto --- ripd/rip_main.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'ripd/rip_main.c') diff --git a/ripd/rip_main.c b/ripd/rip_main.c index d5713208..a87e3b7e 100644 --- a/ripd/rip_main.c +++ b/ripd/rip_main.c @@ -58,11 +58,14 @@ zebra_capabilities_t _caps_p [] = struct zebra_privs_t ripd_privs = { -#if defined(ZEBRA_USER) - .user = ZEBRA_USER, +#if defined(QUAGGA_USER) + .user = QUAGGA_USER, #endif -#if defined ZEBRA_GROUP - .group = ZEBRA_GROUP, +#if defined QUAGGA_GROUP + .group = QUAGGA_GROUP, +#endif +#ifdef VTY_GROUP + .vty_group = VTY_GROUP, #endif .caps_p = _caps_p, .cap_num_p = 2, -- cgit v1.2.3 From 2d75d05218b76230bbd608cab8d08a5f47d77056 Mon Sep 17 00:00:00 2001 From: paul Date: Mon, 19 Jan 2004 21:31:15 +0000 Subject: 2004-01-19 Paul Jakma * tests/test-sig.c: New file, regression test for sigevents. * lib/Makefile.am: add sigevent.{c,h} * (isis|rip|ripng|ospf|ospf6|bgp)d/\1_main.c: modify for sigevents. * zebra/main.c: ditto. --- ripd/rip_main.c | 55 +++++++++++++++++++------------------------------------ 1 file changed, 19 insertions(+), 36 deletions(-) (limited to 'ripd/rip_main.c') diff --git a/ripd/rip_main.c b/ripd/rip_main.c index a87e3b7e..8b0d2162 100644 --- a/ripd/rip_main.c +++ b/ripd/rip_main.c @@ -31,6 +31,7 @@ #include "keychain.h" #include "log.h" #include "privs.h" +#include "sigevent.h" #include "ripd/ripd.h" @@ -120,32 +121,9 @@ Report bugs to %s\n", progname, ZEBRA_BUG_ADDRESS); exit (status); } -/* Signale wrapper. */ -RETSIGTYPE * -signal_set (int signo, void (*func)(int)) -{ - int ret; - struct sigaction sig; - struct sigaction osig; - - sig.sa_handler = func; - sigemptyset (&sig.sa_mask); - sig.sa_flags = 0; -#ifdef SA_RESTART - sig.sa_flags |= SA_RESTART; -#endif /* SA_RESTART */ - - ret = sigaction (signo, &sig, &osig); - - if (ret < 0) - return (SIG_ERR); - else - return (osig.sa_handler); -} - /* SIGHUP handler. */ void -sighup (int sig) +sighup (void) { zlog_info ("SIGHUP received"); rip_clean (); @@ -163,7 +141,7 @@ sighup (int sig) /* SIGINT handler. */ void -sigint (int sig) +sigint (void) { zlog (NULL, LOG_INFO, "Terminating on signal"); @@ -175,21 +153,26 @@ sigint (int sig) /* SIGUSR1 handler. */ void -sigusr1 (int sig) +sigusr1 (void) { zlog_rotate (NULL); } -/* Initialization of signal handles. */ -void -signal_init () +struct quagga_signal_t ripd_signals[] = { - signal_set (SIGHUP, sighup); - signal_set (SIGINT, sigint); - signal_set (SIGTERM, sigint); - signal_set (SIGPIPE, SIG_IGN); - signal_set (SIGUSR1, sigusr1); -} + { + .signal = SIGHUP, + .handler = &sighup, + }, + { + .signal = SIGUSR1, + .handler = &sigusr1, + }, + { + .signal = SIGINT, + .handler = &sigusr1, + }, +}; /* Main routine of ripd. */ int @@ -271,7 +254,7 @@ main (int argc, char **argv) /* Library initialization. */ zprivs_init (&ripd_privs); - signal_init (); + signal_init (master, Q_SIGC(ripd_signals), ripd_signals); cmd_init (1); vty_init (master); memory_init (); -- cgit v1.2.3 From 5e4fa1646cafe9e6f8dd78501bea0d2fe1eafdb4 Mon Sep 17 00:00:00 2001 From: gdt Date: Tue, 16 Mar 2004 14:38:36 +0000 Subject: 2004-03-16 David Young * (many) reference rather than "version.h", because version.h is a generated file and not present in the source tree when using objdir builds. (committed by gdt) works fine with normal builds; didn't try objdir --- ripd/rip_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ripd/rip_main.c') diff --git a/ripd/rip_main.c b/ripd/rip_main.c index 8b0d2162..5d6b0ad4 100644 --- a/ripd/rip_main.c +++ b/ripd/rip_main.c @@ -21,7 +21,7 @@ #include -#include "version.h" +#include #include "getopt.h" #include "thread.h" #include "command.h" -- cgit v1.2.3 From 8c903fbb11e5eed5bcf08d26c2b984d07a82e109 Mon Sep 17 00:00:00 2001 From: hasso Date: Wed, 17 Mar 2004 20:39:18 +0000 Subject: Fix bugzilla #82. --- ripd/rip_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ripd/rip_main.c') diff --git a/ripd/rip_main.c b/ripd/rip_main.c index 5d6b0ad4..abe61067 100644 --- a/ripd/rip_main.c +++ b/ripd/rip_main.c @@ -170,7 +170,7 @@ struct quagga_signal_t ripd_signals[] = }, { .signal = SIGINT, - .handler = &sigusr1, + .handler = &sigint, }, }; -- cgit v1.2.3 From f571dab0c677ca4f3328ea944cc59ab2269c9a5d Mon Sep 17 00:00:00 2001 From: hasso Date: Mon, 22 Mar 2004 08:55:25 +0000 Subject: Readded SIGTERM handling into sigevent stuff. Fixes bugzilla #85. --- ripd/rip_main.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'ripd/rip_main.c') diff --git a/ripd/rip_main.c b/ripd/rip_main.c index abe61067..530b13c9 100644 --- a/ripd/rip_main.c +++ b/ripd/rip_main.c @@ -172,6 +172,10 @@ struct quagga_signal_t ripd_signals[] = .signal = SIGINT, .handler = &sigint, }, + { + .signal = SIGTERM, + .handler = &sigint, + }, }; /* Main routine of ripd. */ -- cgit v1.2.3 From 320ec10a24d8dd81d0aa011dc92e07877e4e02f8 Mon Sep 17 00:00:00 2001 From: hasso Date: Sun, 20 Jun 2004 19:54:37 +0000 Subject: Removing code which looked at current dir for config file before attempting to read system one. --- ripd/rip_main.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'ripd/rip_main.c') diff --git a/ripd/rip_main.c b/ripd/rip_main.c index 530b13c9..c2128e46 100644 --- a/ripd/rip_main.c +++ b/ripd/rip_main.c @@ -74,7 +74,6 @@ struct zebra_privs_t ripd_privs = }; /* Configuration file and directory. */ -char config_current[] = RIPD_DEFAULT_CONFIG; char config_default[] = SYSCONFDIR RIPD_DEFAULT_CONFIG; char *config_file = NULL; @@ -131,7 +130,7 @@ sighup (void) zlog_info ("ripd restarting!"); /* Reload config file. */ - vty_read_config (config_file, config_current, config_default); + vty_read_config (config_file, config_default); /* Create VTY's socket */ vty_serv_sock (vty_addr, vty_port, RIP_VTYSH_PATH); @@ -274,7 +273,7 @@ main (int argc, char **argv) sort_node (); /* Get configuration file. */ - vty_read_config (config_file, config_current, config_default); + vty_read_config (config_file, config_default); /* Change to the daemon program. */ if (daemon_mode) -- cgit v1.2.3 From 8a676be30c275bcbe1a3de08c0c942a606caef2e Mon Sep 17 00:00:00 2001 From: hasso Date: Fri, 8 Oct 2004 06:36:38 +0000 Subject: There is no warnings here any more. --- ripd/rip_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ripd/rip_main.c') diff --git a/ripd/rip_main.c b/ripd/rip_main.c index c2128e46..bc251599 100644 --- a/ripd/rip_main.c +++ b/ripd/rip_main.c @@ -92,7 +92,7 @@ int vty_port = RIP_VTY_PORT; struct thread_master *master; /* Process ID saved for use by init system */ -char *pid_file = PATH_RIPD_PID; +const char *pid_file = PATH_RIPD_PID; /* Help information display. */ static void -- cgit v1.2.3 From c065230a4c617a1cdf8813dd25384bcc9591f61a Mon Sep 17 00:00:00 2001 From: hasso Date: Thu, 25 Nov 2004 19:33:48 +0000 Subject: Make group to run daemon as configurable. Fixes #2 from Bugzilla #64. --- ripd/rip_main.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'ripd/rip_main.c') diff --git a/ripd/rip_main.c b/ripd/rip_main.c index bc251599..d545a8ec 100644 --- a/ripd/rip_main.c +++ b/ripd/rip_main.c @@ -46,6 +46,7 @@ static struct option longopts[] = { "vty_port", required_argument, NULL, 'P'}, { "retain", no_argument, NULL, 'r'}, { "user", required_argument, NULL, 'u'}, + { "group", required_argument, NULL, 'g'}, { "version", no_argument, NULL, 'v'}, { 0 } }; @@ -110,7 +111,8 @@ Daemon which manages RIP version 1 and 2.\n\n\ -A, --vty_addr Set vty's bind address\n\ -P, --vty_port Set vty's port number\n\ -r, --retain When program terminates, retain added route by ripd.\n\ --u, --user User and group to run as\n\ +-u, --user User to run as\n\ +-g, --group Group to run as\n\ -v, --version Print program version\n\ -h, --help Display this help and exit\n\ \n\ @@ -201,7 +203,7 @@ main (int argc, char **argv) { int opt; - opt = getopt_long (argc, argv, "df:i:hA:P:u:rv", longopts, 0); + opt = getopt_long (argc, argv, "df:i:hA:P:u:g:rv", longopts, 0); if (opt == EOF) break; @@ -236,9 +238,12 @@ main (int argc, char **argv) case 'r': retain_mode = 1; break; - case 'u': - ripd_privs.group = ripd_privs.user = optarg; - break; + case 'u': + ripd_privs.user = optarg; + break; + case 'g': + ripd_privs.group = optarg; + break; case 'v': print_version (progname); exit (0); -- cgit v1.2.3 From 887c44a4f3d8219dc5b1c52b5dcde1f31d52b73d Mon Sep 17 00:00:00 2001 From: ajs Date: Fri, 3 Dec 2004 16:36:46 +0000 Subject: 2004-12-03 Andrew J. Schorr * bgp_main.c: (sigint) Use zlog_notice for termination message. (main) Use zlog_notice for startup announcement. * isis_main.c: (sigint,sigterm) Use zlog_notice for termination message. (terminate) This function should be static, not global. (main) Use zlog_notice for startup announcement, and remove ifdef ZEBRA_VERSION. * version.h.in: Remove declaration for pid_output_lock, this function is now static, not global. * pid_output.c: (pid_output_lock) This function should be static, not global. And remove "old umask" error message, since it was really an unimportant debug message, not an error. (pid_output) Need to declare static function pid_output_lock. * ospf6_main.c: (sigint,sigterm) Use zlog_notice for termination message. (main) Remove commented-out call to pid_output_lock (which should never be called other than from inside pid_output). And use zlog_notice to print the startup message, which now includes the vty port. * ospf_main.c: (sigint) Use zlog_notice for termination message. (main) Issue a startup announcement using zlog_notice. * rip_main.c: (sigint) Use zlog_notice for termination message. (main) Add a startup announcement using zlog_notice. * ripng_main.c: (sighup) Remove spurious terminating message. (sigint) Use zlog_notice for termination message. (main) Issue a startup announcement using zlog_notice. * main.c: (sigint) Use zlog_notice for termination message. (main) Add a startup announcement using zlog_notice. --- ripd/rip_main.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'ripd/rip_main.c') diff --git a/ripd/rip_main.c b/ripd/rip_main.c index d545a8ec..2b2939dd 100644 --- a/ripd/rip_main.c +++ b/ripd/rip_main.c @@ -144,7 +144,7 @@ sighup (void) void sigint (void) { - zlog (NULL, LOG_INFO, "Terminating on signal"); + zlog_notice ("Terminating on signal"); if (! retain_mode) rip_clean (); @@ -290,6 +290,9 @@ main (int argc, char **argv) /* Create VTY's socket */ vty_serv_sock (vty_addr, vty_port, RIP_VTYSH_PATH); + /* Print banner. */ + zlog_notice ("RIPd %s starting: vty@%d", QUAGGA_VERSION, vty_port); + /* Execute each thread. */ while (thread_fetch (master, &thread)) thread_call (&thread); -- cgit v1.2.3 From 274a4a4447b13f89f8237156a887d05a24a73cc6 Mon Sep 17 00:00:00 2001 From: ajs Date: Tue, 7 Dec 2004 15:39:31 +0000 Subject: 2004-12-07 Andrew J. Schorr * bgp_main.c: (main) The 2nd argument to openzlog has been removed. * isis_main.c: (main) The 2nd argument to openzlog has been removed. * ospf6_main.c: (main) The 2nd argument to openzlog has been removed. Note that stdout logging will no longer be enabled by default when not running as a daemon. * ospf_main.c: (main) The 2nd argument to openzlog has been removed. * rip_main.c: (main) The 2nd argument to openzlog has been removed. * ripng_main.c: (main) The 2nd argument to openzlog has been removed. * main.c: (main) The 2nd argument to openzlog has been removed. So stdout logging will no longer be enabled by default. * irdp_main.c: (irdp_finish) Reduce severity of shutdown message from LOG_WARNING to LOG_INFO. * vtysh.c: Make several functions static instead of global. Added several commands to support destination-specific logging levels. (vtysh_completion) This function is unused, so comment it out. * basic.texi: Document new logging features. Separate basic config commands from basic VTY commands. * log.h: Replace struct zlog flags and maskpri fields with maxlvl array to support individual logging levels for each destination. Remove the 2nd argument to openzlog since the default logging config should be standardized inside the library. Replaced the zlog_set_flag and zlog_reset_flag functions with zlog_set_level. And zlog_set_file now requires an additional log_level argument. Declare zlog_proto_names for use inside command.c in the "show logging" command. Added defines useful for command construction. * log.c: (vzlog) Decide where to send the message based on the individual logging levels configured for each destination. Remove support for ZLOG_STDERR since it was never actually used. Support record-priority for terminal monitors. (zlog_signal,zlog_backtrace_sigsafe) Support destination-specific logging levels. Remove stderr support (was never used). Added support for terminal monitor logging. (_zlog_assert_failed) Increase message severity to LOG_EMERG. (openzlog) Remove 2nd argument since default config should be standardized in library. By default, terminal monitoring is set to debug, and all other logging is disabled. (zlog_set_flag,zlog_reset_flag) Removed. (zlog_set_level) New function to replace zlog_set_flag and zlog_reset_flag. Supports destination-specific logging levels. (zlog_set_file,zlog_reset_file) Support file-specific logging level. (zlog_rotate) Log an error message if fopen fails, and support new file-specific logging level. * command.h: Change DEFUN_CMD_FUNC_DECL and DEFUN_CMD_FUNC_TEXT so that command functions will be static instead of global. Remove declarations for config_exit and config_help. Define new macros DEFUNSH_ATTR, DEFUNSH_HIDDEN, and DEFUNSH_DEPRECATED so we can have deprecated commands in vtysh. Similarly, for completeness, define macros ALIAS_SH, ALIAS_SH_HIDDEN, and ALIAS_SH_DEPRECATED. Also, fix bug in ALIAS_ATTR macro (didn't matter because it was never used). * command.c: Make many functions static instead of global. (facility_name,facility_match,level_match) New functions to support enhanced destination-specific logging levels. (config_write_host) Support new destination-specific logging levels. (config_logmsg) Added new "logmsg" command to help test logging system. (show_logging) Added "show logging" command to show the current configuration of the logging system. (config_log_stdout_level) Support explicit stdout logging level. (no_config_log_stdout) Now takes optional LEVEL arg. (config_log_monitor,config_log_monitor_level,no_config_log_monitor) New commands creating new "log monitor" commands to set terminal monitoring log level. (config_log_file_level) Support explicit file logging level. (config_log_syslog_level) Support explicit syslog logging level. (config_log_facility,no_config_log_facility) Implement new "log facility" command. (cmd_init) Add hooks for new commands: "show logging", "logmsg", "log stdout ", "log monitor", "log monitor ", "no log monitor", "log file ", "no log file ", "log syslog ", "log facility", and "no log facility". * vty.h: Added a "level" argument to vty_log so it can support "log record-priority". Declare new function vty_log_fixed for use in signal handlers. * vty.c: (vty_log,vty_log_out) Added a "level" argument to support "log record-priority" for vty terminal monitors. (vty_down_level) Use config_exit_cmd.func instead of calling config_exit directly (since command functions will now be static instead of global). (vty_log_fixed) New function to send terminal monitor messages from inside a signal handler. --- ripd/rip_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ripd/rip_main.c') diff --git a/ripd/rip_main.c b/ripd/rip_main.c index 2b2939dd..ba60b36f 100644 --- a/ripd/rip_main.c +++ b/ripd/rip_main.c @@ -195,7 +195,7 @@ main (int argc, char **argv) progname = ((p = strrchr (argv[0], '/')) ? ++p : argv[0]); /* First of all we need logging init. */ - zlog_default = openzlog (progname, ZLOG_NOLOG, ZLOG_RIP, + zlog_default = openzlog (progname, ZLOG_RIP, LOG_CONS|LOG_NDELAY|LOG_PID, LOG_DAEMON); /* Command line option parse. */ -- cgit v1.2.3 From ceacedba227e77156f92f7676b274c48a2817e8f Mon Sep 17 00:00:00 2001 From: paul Date: Thu, 29 Sep 2005 14:39:32 +0000 Subject: 2005-09-29 Paul Jakma * configure.ac: Add the test for Solaris least-privileges. Set defines for whether capabilities are supported and whether of the linux or solaris variety. Add missing-prototypes, missing-declarations, char-subscripts and cast-qual warnings to default cflags, cause Hasso enjoys warnings, and we really should clean the remaining ones up. (ie isisd..). * (*/*main.c) Update the zebra_capabilities_t arrays in the various daemons to match the changes made in lib/privs.h. * zebra.h: Solaris capabilities requires priv.h to be included. * privs.{c,h}: Add support for Solaris Least-Privileges. privs.h: Reduce some of the abstract capabilities, which do not have rough equivalents on both systems. Rename the net related caps to _NET, as they should have been in first place. (zprivs_terminate) should take the zebra_privs_t as argument so that it can update change pointer. Add an additional privilege state, ZPRIVS_UNKNOWN. * privs.c: (various capability functions) Add Solaris privileges variants. (zprivs_state) Use privs.c specific generic types to represent various capability/privilege related types, so that each can be typedef'd as appropriate on each platform. (zprivs_null_state) static added, to hold the state the null method should report (should be raised by default, and LOWERED if zprivs_terminate has been called) (zprivs_state_null) Report back the zprivs_null_state. (cap_map) Make it able to map abstract capability to multiple system capabilities. (zcaps2sys) Map to abstract capabilities to multiple system privileges/capabilities. (zprivs_init) move capability related init to seperate function, zprivs_caps_init. (zprivs_terminate) ditto, moved to zprivs_caps_terminate. Set the change_state callback to the NULL state, so the user can continue to run and use the callbacks. --- ripd/rip_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ripd/rip_main.c') diff --git a/ripd/rip_main.c b/ripd/rip_main.c index ba60b36f..c9b45e8b 100644 --- a/ripd/rip_main.c +++ b/ripd/rip_main.c @@ -54,7 +54,7 @@ static struct option longopts[] = /* ripd privileges */ zebra_capabilities_t _caps_p [] = { - ZCAP_RAW, + ZCAP_NET_RAW, ZCAP_BIND }; -- cgit v1.2.3 From dc63bfd49513b7ca157c3992c8bc9da9d736fc39 Mon Sep 17 00:00:00 2001 From: paul Date: Tue, 25 Oct 2005 23:31:05 +0000 Subject: 2005-10-26 Paul Jakma * (general) static/extern functions and definitions. * rip_interface.h: new file, export the public functions from rip_interface.c --- ripd/rip_main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'ripd/rip_main.c') diff --git a/ripd/rip_main.c b/ripd/rip_main.c index c9b45e8b..88e63678 100644 --- a/ripd/rip_main.c +++ b/ripd/rip_main.c @@ -123,7 +123,7 @@ Report bugs to %s\n", progname, ZEBRA_BUG_ADDRESS); } /* SIGHUP handler. */ -void +static void sighup (void) { zlog_info ("SIGHUP received"); @@ -141,7 +141,7 @@ sighup (void) } /* SIGINT handler. */ -void +static void sigint (void) { zlog_notice ("Terminating on signal"); @@ -153,13 +153,13 @@ sigint (void) } /* SIGUSR1 handler. */ -void +static void sigusr1 (void) { zlog_rotate (NULL); } -struct quagga_signal_t ripd_signals[] = +static struct quagga_signal_t ripd_signals[] = { { .signal = SIGHUP, -- cgit v1.2.3 From e8e1946edf6ba87ef53832cdceccc39d7f0c3f26 Mon Sep 17 00:00:00 2001 From: paul Date: Thu, 19 Jan 2006 20:16:55 +0000 Subject: [compiler] miscellaneous trivial compiler warning fixes 2006-01-19 Paul Jakma * (general) various miscellaneous compiler warning fixes. Remove redundant break statements from switch clauses which return. return from main, not exit, cause it annoys SOS. Remove stray semi-colons which cause empty-statement warnings. * zebra/main.c: (sighup) remove private declaration of external function. --- ripd/rip_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ripd/rip_main.c') diff --git a/ripd/rip_main.c b/ripd/rip_main.c index 88e63678..c9d564b7 100644 --- a/ripd/rip_main.c +++ b/ripd/rip_main.c @@ -298,5 +298,5 @@ main (int argc, char **argv) thread_call (&thread); /* Not reached. */ - exit (0); + return (0); } -- cgit v1.2.3 From 70ad2da67e6edee613c6eefae9480c9e9955c2fc Mon Sep 17 00:00:00 2001 From: paul 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 --- ripd/rip_main.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'ripd/rip_main.c') diff --git a/ripd/rip_main.c b/ripd/rip_main.c index c9d564b7..dfcd6c26 100644 --- a/ripd/rip_main.c +++ b/ripd/rip_main.c @@ -42,6 +42,7 @@ static struct option longopts[] = { "config_file", required_argument, NULL, 'f'}, { "pid_file", required_argument, NULL, 'i'}, { "help", no_argument, NULL, 'h'}, + { "dryrun", no_argument, NULL, 'C'}, { "vty_addr", required_argument, NULL, 'A'}, { "vty_port", required_argument, NULL, 'P'}, { "retain", no_argument, NULL, 'r'}, @@ -110,6 +111,7 @@ Daemon which manages RIP version 1 and 2.\n\n\ -i, --pid_file Set process identifier file name\n\ -A, --vty_addr Set vty's bind address\n\ -P, --vty_port Set vty's port number\n\ +-C, --dryrun Check configuration for validity and exit\n\ -r, --retain When program terminates, retain added route by ripd.\n\ -u, --user User to run as\n\ -g, --group Group to run as\n\ @@ -185,6 +187,7 @@ main (int argc, char **argv) { char *p; int daemon_mode = 0; + int dryrun = 0; char *progname; struct thread thread; @@ -203,7 +206,7 @@ main (int argc, char **argv) { int opt; - opt = getopt_long (argc, argv, "df:i:hA:P:u:g:rv", longopts, 0); + opt = getopt_long (argc, argv, "df:i:hA:P:u:g:rvC", longopts, 0); if (opt == EOF) break; @@ -238,6 +241,9 @@ main (int argc, char **argv) case 'r': retain_mode = 1; break; + case 'C': + dryrun = 1; + break; case 'u': ripd_privs.user = optarg; break; @@ -280,6 +286,10 @@ main (int argc, char **argv) /* Get configuration file. */ vty_read_config (config_file, config_default); + /* Start execution only if not in dry-run mode */ + if(dryrun) + return (0); + /* Change to the daemon program. */ if (daemon_mode) daemon (0, 0); -- cgit v1.2.3 From a73770abf4e87b073ca51ca0cd4171d712ca9bff Mon Sep 17 00:00:00 2001 From: paul 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. --- ripd/rip_main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'ripd/rip_main.c') diff --git a/ripd/rip_main.c b/ripd/rip_main.c index dfcd6c26..0b29107d 100644 --- a/ripd/rip_main.c +++ b/ripd/rip_main.c @@ -236,7 +236,8 @@ main (int argc, char **argv) break; } vty_port = atoi (optarg); - vty_port = (vty_port ? vty_port : RIP_VTY_PORT); + if (vty_port <= 0 || vty_port > 0xffff) + vty_port = RIP_VTY_PORT; break; case 'r': retain_mode = 1; -- cgit v1.2.3