diff options
author | David Lamparter <equinox@diac24.net> | 2009-10-14 18:13:29 +0200 |
---|---|---|
committer | David Lamparter <equinox@diac24.net> | 2010-02-04 02:53:48 +0100 |
commit | ac9ed56d887357049bae1bc901e80b58961d6380 (patch) | |
tree | a5cd31094ee55324fe6a57212c03c6f7828673c4 | |
parent | f99eea6053507e6dbd5ad22f4c7ba80c5a981651 (diff) | |
download | quagga-ac9ed56d887357049bae1bc901e80b58961d6380.tar.bz2 quagga-ac9ed56d887357049bae1bc901e80b58961d6380.tar.xz |
lib: fs namespacing 2/5: use path_state for vty paths
use the path_state helper functions for determining vty socket paths in
all quagga daemons. this allows for running multiple daemons if a
namespace name is set.
-rw-r--r-- | bgpd/Makefile.am | 1 | ||||
-rw-r--r-- | bgpd/bgp_main.c | 15 | ||||
-rw-r--r-- | bgpd/bgpd.h | 4 | ||||
-rwxr-xr-x | configure.ac | 14 | ||||
-rw-r--r-- | isisd/Makefile.am | 1 | ||||
-rw-r--r-- | isisd/isis_main.c | 18 | ||||
-rw-r--r-- | ospf6d/Makefile.am | 1 | ||||
-rw-r--r-- | ospf6d/ospf6_main.c | 17 | ||||
-rw-r--r-- | ospfd/Makefile.am | 2 | ||||
-rw-r--r-- | ospfd/ospf_main.c | 12 | ||||
-rw-r--r-- | ospfd/ospfd.h | 4 | ||||
-rw-r--r-- | ripd/Makefile.am | 1 | ||||
-rw-r--r-- | ripd/rip_main.c | 15 | ||||
-rw-r--r-- | ripd/ripd.h | 4 | ||||
-rw-r--r-- | ripngd/Makefile.am | 1 | ||||
-rw-r--r-- | ripngd/ripng_main.c | 14 | ||||
-rw-r--r-- | ripngd/ripngd.h | 4 | ||||
-rw-r--r-- | vtysh/Makefile.am | 1 | ||||
-rw-r--r-- | vtysh/vtysh.c | 33 | ||||
-rw-r--r-- | zebra/Makefile.am | 2 | ||||
-rw-r--r-- | zebra/main.c | 13 | ||||
-rw-r--r-- | zebra/test_main.c | 11 | ||||
-rw-r--r-- | zebra/zserv.h | 4 |
23 files changed, 122 insertions, 70 deletions
diff --git a/bgpd/Makefile.am b/bgpd/Makefile.am index 1b17d386..56a9fb8f 100644 --- a/bgpd/Makefile.am +++ b/bgpd/Makefile.am @@ -1,7 +1,6 @@ ## Process this file with automake to produce Makefile.in. INCLUDES = @INCLUDES@ -I.. -I$(top_srcdir) -I$(top_srcdir)/lib @SNMP_INCLUDES@ -DEFS = @DEFS@ -DSYSCONFDIR=\"$(sysconfdir)/\" INSTALL_SDATA=@INSTALL@ -m 600 AM_CFLAGS = $(PICFLAGS) diff --git a/bgpd/bgp_main.c b/bgpd/bgp_main.c index 9d14683c..f6dc1cae 100644 --- a/bgpd/bgp_main.c +++ b/bgpd/bgp_main.c @@ -35,6 +35,7 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA #include "routemap.h" #include "filter.h" #include "plist.h" +#include "paths.h" #include "bgpd/bgpd.h" #include "bgpd/bgp_attr.h" @@ -96,7 +97,7 @@ static struct quagga_signal_t bgp_signals[] = }; /* Configuration file and directory. */ -char config_default[] = SYSCONFDIR BGP_DEFAULT_CONFIG; +static char config_default[MAXPATHLEN]; /* Route retain mode flag. */ static int retain_mode = 0; @@ -107,8 +108,11 @@ struct thread_master *master; /* Manually specified configuration file name. */ char *config_file = NULL; +/* pid_file default value */ +static char pid_file_default[MAXPATHLEN]; + /* Process ID saved for use by init system */ -static const char *pid_file = PATH_BGPD_PID; +static const char *pid_file = pid_file_default; /* VTY port number and address. */ int vty_port = BGP_VTY_PORT; @@ -182,7 +186,7 @@ sighup (void) vty_read_config (config_file, config_default); /* Create VTY's socket */ - vty_serv_sock (vty_addr, vty_port, BGP_VTYSH_PATH); + vty_serv_sock (vty_addr, vty_port, path_state (BGP_VTY_NAME)); /* Try to return to normal operation. */ } @@ -398,6 +402,9 @@ main (int argc, char **argv) } } + strcpy (config_default, path_config (BGP_CONFIG_NAME)); + strcpy (pid_file_default, path_state (BGP_PID_NAME)); + /* Make thread master. */ master = bm->master; @@ -434,7 +441,7 @@ main (int argc, char **argv) pid_output (pid_file); /* Make bgp vty socket. */ - vty_serv_sock (vty_addr, vty_port, BGP_VTYSH_PATH); + vty_serv_sock (vty_addr, vty_port, path_state (BGP_VTY_NAME)); /* Print banner. */ zlog_notice ("BGPd %s starting: vty@%d, bgp@%s:%d", QUAGGA_VERSION, diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h index 49664030..77c26646 100644 --- a/bgpd/bgpd.h +++ b/bgpd/bgpd.h @@ -739,7 +739,9 @@ struct bgp_nlri /* Default configuration settings for bgpd. */ #define BGP_VTY_PORT 2605 -#define BGP_DEFAULT_CONFIG "bgpd.conf" +#define BGP_CONFIG_NAME "bgpd.conf" +#define BGP_PID_NAME "bgpd.pid" +#define BGP_VTY_NAME "bgpd.vty" /* Check AS path loop when we send NLRI. */ /* #define BGP_SEND_ASPATH_CHECK */ diff --git a/configure.ac b/configure.ac index 9ccefafa..1b60a93a 100755 --- a/configure.ac +++ b/configure.ac @@ -1493,22 +1493,8 @@ AC_MSG_RESULT(${quagga_statedir}) AC_SUBST(quagga_statedir) AC_DEFINE_UNQUOTED(PATH_STATE, "$quagga_statedir",zebra state path) -AC_DEFINE_UNQUOTED(PATH_ZEBRA_PID, "$quagga_statedir/zebra.pid",zebra PID) -AC_DEFINE_UNQUOTED(PATH_RIPD_PID, "$quagga_statedir/ripd.pid",ripd PID) -AC_DEFINE_UNQUOTED(PATH_RIPNGD_PID, "$quagga_statedir/ripngd.pid",ripngd PID) -AC_DEFINE_UNQUOTED(PATH_BGPD_PID, "$quagga_statedir/bgpd.pid",bgpd PID) -AC_DEFINE_UNQUOTED(PATH_OSPFD_PID, "$quagga_statedir/ospfd.pid",ospfd PID) -AC_DEFINE_UNQUOTED(PATH_OSPF6D_PID, "$quagga_statedir/ospf6d.pid",ospf6d PID) -AC_DEFINE_UNQUOTED(PATH_ISISD_PID, "$quagga_statedir/isisd.pid",isisd PID) AC_DEFINE_UNQUOTED(PATH_WATCHQUAGGA_PID, "$quagga_statedir/watchquagga.pid",watchquagga PID) AC_DEFINE_UNQUOTED(ZEBRA_SERV_PATH, "$quagga_statedir/zserv.api",zebra api socket) -AC_DEFINE_UNQUOTED(ZEBRA_VTYSH_PATH, "$quagga_statedir/zebra.vty",zebra vty socket) -AC_DEFINE_UNQUOTED(RIP_VTYSH_PATH, "$quagga_statedir/ripd.vty",rip vty socket) -AC_DEFINE_UNQUOTED(RIPNG_VTYSH_PATH, "$quagga_statedir/ripngd.vty",ripng vty socket) -AC_DEFINE_UNQUOTED(BGP_VTYSH_PATH, "$quagga_statedir/bgpd.vty",bgpd vty socket) -AC_DEFINE_UNQUOTED(OSPF_VTYSH_PATH, "$quagga_statedir/ospfd.vty",ospfd vty socket) -AC_DEFINE_UNQUOTED(OSPF6_VTYSH_PATH, "$quagga_statedir/ospf6d.vty",ospf6d vty socket) -AC_DEFINE_UNQUOTED(ISIS_VTYSH_PATH, "$quagga_statedir/isisd.vty",isisd vty socket) AC_DEFINE_UNQUOTED(DAEMON_VTY_DIR, "$quagga_statedir",daemon vty directory) dnl ------------------------------- diff --git a/isisd/Makefile.am b/isisd/Makefile.am index 9c303390..a7117fd6 100644 --- a/isisd/Makefile.am +++ b/isisd/Makefile.am @@ -2,7 +2,6 @@ INCLUDES = @INCLUDES@ -I.. -I$(top_srcdir) -I$(top_srcdir)/lib \ @ISIS_TOPOLOGY_INCLUDES@ -DEFS = @DEFS@ -DSYSCONFDIR=\"$(sysconfdir)/\" INSTALL_SDATA=@INSTALL@ -m 600 LIBS = @LIBS@ diff --git a/isisd/isis_main.c b/isisd/isis_main.c index c5e824c1..b924b77f 100644 --- a/isisd/isis_main.c +++ b/isisd/isis_main.c @@ -34,6 +34,7 @@ #include "privs.h" #include "sigevent.h" #include "filter.h" +#include "paths.h" #include "isisd/dict.h" #include "include-netbsd/iso.h" @@ -45,7 +46,10 @@ #include "isisd/isis_dynhn.h" /* Default configuration file name */ -#define ISISD_DEFAULT_CONFIG "isisd.conf" +#define ISISD_CONFIG_NAME "isisd.conf" +#define ISISD_PID_NAME "isisd.pid" +#define ISISD_VTY_NAME "isisd.vty" + /* Default vty port */ #define ISISD_VTY_PORT 2608 @@ -86,7 +90,7 @@ struct option longopts[] = { }; /* Configuration file and directory. */ -char config_default[] = SYSCONFDIR ISISD_DEFAULT_CONFIG; +char config_default[MAXPATHLEN]; char *config_file = NULL; /* isisd program name. */ @@ -97,8 +101,11 @@ int daemon_mode = 0; /* Master of threads. */ struct thread_master *master; +/* pid_file default value */ +static char pid_file_default[MAXPATHLEN]; + /* Process ID saved for use by init system */ -const char *pid_file = PATH_ISISD_PID; +const char *pid_file = pid_file_default; /* for reload */ char _cwd[MAXPATHLEN]; @@ -303,6 +310,9 @@ main (int argc, char **argv, char **envp) } } + strcpy (config_default, path_config (ISISD_CONFIG_NAME)); + strcpy (pid_file_default, path_state (ISISD_PID_NAME)); + /* thread master */ master = thread_master_create (); @@ -343,7 +353,7 @@ main (int argc, char **argv, char **envp) pid_output (pid_file); /* Make isis vty socket. */ - vty_serv_sock (vty_addr, vty_port, ISIS_VTYSH_PATH); + vty_serv_sock (vty_addr, vty_port, path_state (ISISD_VTY_NAME)); /* Print banner. */ zlog_notice ("Quagga-ISISd %s starting: vty@%d", QUAGGA_VERSION, vty_port); diff --git a/ospf6d/Makefile.am b/ospf6d/Makefile.am index 01bc6fe0..eeed1652 100644 --- a/ospf6d/Makefile.am +++ b/ospf6d/Makefile.am @@ -1,7 +1,6 @@ ## Process this file with automake to produce Makefile.in. INCLUDES = @INCLUDES@ -I.. -I$(top_srcdir) -I$(top_srcdir)/lib @SNMP_INCLUDES@ -DEFS = @DEFS@ -DSYSCONFDIR=\"$(sysconfdir)/\" INSTALL_SDATA=@INSTALL@ -m 600 AM_CFLAGS = $(PICFLAGS) diff --git a/ospf6d/ospf6_main.c b/ospf6d/ospf6_main.c index a7a96a1f..980cf794 100644 --- a/ospf6d/ospf6_main.c +++ b/ospf6d/ospf6_main.c @@ -34,11 +34,14 @@ #include "plist.h" #include "privs.h" #include "sigevent.h" +#include "paths.h" #include "ospf6d.h" /* Default configuration file name for ospf6d. */ -#define OSPF6_DEFAULT_CONFIG "ospf6d.conf" +#define OSPF6_CONFIG_NAME "ospf6d.conf" +#define OSPF6_PID_NAME "ospf6d.pid" +#define OSPF6_VTY_NAME "ospf6d.vty" /* Default port values. */ #define OSPF6_VTY_PORT 2606 @@ -83,7 +86,7 @@ struct option longopts[] = }; /* Configuration file and directory. */ -char config_default[] = SYSCONFDIR OSPF6_DEFAULT_CONFIG; +char config_default[MAXPATHLEN]; /* ospf6d program name. */ char *progname; @@ -94,8 +97,11 @@ int daemon_mode = 0; /* Master of threads. */ struct thread_master *master; +/* pid_file default value */ +static char pid_file_default[MAXPATHLEN]; + /* Process ID saved for use by init system */ -const char *pid_file = PATH_OSPF6D_PID; +const char *pid_file = pid_file_default; /* Help information display. */ static void @@ -252,6 +258,9 @@ main (int argc, char *argv[], char *envp[]) } } + strcpy (config_default, path_config (OSPF6_CONFIG_NAME)); + strcpy (pid_file_default, path_state (OSPF6_PID_NAME)); + /* thread master */ master = thread_master_create (); @@ -294,7 +303,7 @@ main (int argc, char *argv[], char *envp[]) /* Make ospf6 vty socket. */ if (!vty_port) vty_port = OSPF6_VTY_PORT; - vty_serv_sock (vty_addr, vty_port, OSPF6_VTYSH_PATH); + vty_serv_sock (vty_addr, vty_port, path_state (OSPF6_VTY_NAME)); /* Print start message */ zlog_notice ("OSPF6d (Quagga-%s ospf6d-%s) starts: vty@%d", diff --git a/ospfd/Makefile.am b/ospfd/Makefile.am index 2e4d5c8e..bed90d7b 100644 --- a/ospfd/Makefile.am +++ b/ospfd/Makefile.am @@ -1,7 +1,7 @@ ## Process this file with automake to produce Makefile.in. INCLUDES = @INCLUDES@ -I.. -I$(top_srcdir) -I$(top_srcdir)/lib @SNMP_INCLUDES@ -DEFS = @DEFS@ $(LOCAL_OPTS) -DSYSCONFDIR=\"$(sysconfdir)/\" +DEFS = @DEFS@ $(LOCAL_OPTS) INSTALL_SDATA=@INSTALL@ -m 600 lib_LTLIBRARIES = libospf.la diff --git a/ospfd/ospf_main.c b/ospfd/ospf_main.c index 8b9a3458..30993aa3 100644 --- a/ospfd/ospf_main.c +++ b/ospfd/ospf_main.c @@ -72,7 +72,7 @@ struct zebra_privs_t ospfd_privs = }; /* Configuration filename and directory. */ -char config_default[] = SYSCONFDIR OSPF_DEFAULT_CONFIG; +char config_default[MAXPATHLEN]; /* OSPFd options. */ struct option longopts[] = @@ -96,8 +96,11 @@ struct option longopts[] = /* Master of threads. */ struct thread_master *master; +/* pid_file default value */ +static char pid_file_default[MAXPATHLEN]; + /* Process ID saved for use by init system */ -const char *pid_file = PATH_OSPFD_PID; +const char *pid_file = pid_file_default; #ifdef SUPPORT_OSPF_API extern int ospf_apiserver_enable; @@ -274,6 +277,9 @@ main (int argc, char **argv) } } + strcpy (config_default, path_config (OSPF_CONFIG_NAME)); + strcpy (pid_file_default, path_state (OSPF_PID_NAME)); + /* Initializations. */ master = om->master; @@ -324,7 +330,7 @@ main (int argc, char **argv) pid_output (pid_file); /* Create VTY socket */ - vty_serv_sock (vty_addr, vty_port, OSPF_VTYSH_PATH); + vty_serv_sock (vty_addr, vty_port, path_state (OSPF_VTY_NAME)); /* Print banner. */ zlog_notice ("OSPFd %s starting: vty@%d", QUAGGA_VERSION, vty_port); diff --git a/ospfd/ospfd.h b/ospfd/ospfd.h index b24b3ced..64e91cef 100644 --- a/ospfd/ospfd.h +++ b/ospfd/ospfd.h @@ -48,7 +48,9 @@ #define OSPF_VL_IP_TTL 100 /* Default configuration file name for ospfd. */ -#define OSPF_DEFAULT_CONFIG "ospfd.conf" +#define OSPF_CONFIG_NAME "ospfd.conf" +#define OSPF_PID_NAME "ospfd.pid" +#define OSPF_VTY_NAME "ospfd.vty" /* Architectual Constants */ #ifdef DEBUG diff --git a/ripd/Makefile.am b/ripd/Makefile.am index 2fa26659..a6d3d398 100644 --- a/ripd/Makefile.am +++ b/ripd/Makefile.am @@ -1,7 +1,6 @@ ## Process this file with automake to produce Makefile.in. INCLUDES = @INCLUDES@ -I.. -I$(top_srcdir) -I$(top_srcdir)/lib @SNMP_INCLUDES@ -DEFS = @DEFS@ -DSYSCONFDIR=\"$(sysconfdir)/\" INSTALL_SDATA=@INSTALL@ -m 600 AM_CFLAGS = $(PICFLAGS) diff --git a/ripd/rip_main.c b/ripd/rip_main.c index 57b5f3af..d392baf8 100644 --- a/ripd/rip_main.c +++ b/ripd/rip_main.c @@ -32,6 +32,7 @@ #include "log.h" #include "privs.h" #include "sigevent.h" +#include "paths.h" #include "ripd/ripd.h" @@ -76,7 +77,7 @@ struct zebra_privs_t ripd_privs = }; /* Configuration file and directory. */ -char config_default[] = SYSCONFDIR RIPD_DEFAULT_CONFIG; +char config_default[MAXPATHLEN]; char *config_file = NULL; /* ripd program name */ @@ -93,8 +94,11 @@ int vty_port = RIP_VTY_PORT; /* Master of threads. */ struct thread_master *master; +/* pid_file default value */ +static char pid_file_default[MAXPATHLEN]; + /* Process ID saved for use by init system */ -const char *pid_file = PATH_RIPD_PID; +const char *pid_file = pid_file_default; /* Help information display. */ static void @@ -137,7 +141,7 @@ sighup (void) vty_read_config (config_file, config_default); /* Create VTY's socket */ - vty_serv_sock (vty_addr, vty_port, RIP_VTYSH_PATH); + vty_serv_sock (vty_addr, vty_port, path_state (RIPD_VTY_NAME)); /* Try to return to normal operation. */ } @@ -264,6 +268,9 @@ main (int argc, char **argv) } } + strcpy (config_default, path_config (RIPD_CONFIG_NAME)); + strcpy (pid_file_default, path_state (RIPD_PID_NAME)); + /* Prepare master thread. */ master = thread_master_create (); @@ -302,7 +309,7 @@ main (int argc, char **argv) pid_output (pid_file); /* Create VTY's socket */ - vty_serv_sock (vty_addr, vty_port, RIP_VTYSH_PATH); + vty_serv_sock (vty_addr, vty_port, path_state (RIPD_VTY_NAME)); /* Print banner. */ zlog_notice ("RIPd %s starting: vty@%d", QUAGGA_VERSION, vty_port); diff --git a/ripd/ripd.h b/ripd/ripd.h index 45b07b9c..01ca562e 100644 --- a/ripd/ripd.h +++ b/ripd/ripd.h @@ -69,7 +69,9 @@ #define RIP_VTY_PORT 2602 /* Default configuration file name. */ -#define RIPD_DEFAULT_CONFIG "ripd.conf" +#define RIPD_CONFIG_NAME "ripd.conf" +#define RIPD_PID_NAME "ripd.pid" +#define RIPD_VTY_NAME "ripd.vty" /* RIP route types. */ #define RIP_ROUTE_RTE 0 diff --git a/ripngd/Makefile.am b/ripngd/Makefile.am index c6bd4868..ba52dba7 100644 --- a/ripngd/Makefile.am +++ b/ripngd/Makefile.am @@ -1,7 +1,6 @@ ## Process this file with automake to produce Makefile.in. INCLUDES = @INCLUDES@ -I.. -I$(top_srcdir) -I$(top_srcdir)/lib @SNMP_INCLUDES@ -DEFS = @DEFS@ -DSYSCONFDIR=\"$(sysconfdir)/\" INSTALL_SDATA=@INSTALL@ -m 600 AM_CFLAGS = $(PICFLAGS) diff --git a/ripngd/ripng_main.c b/ripngd/ripng_main.c index 85209a15..54e3b69d 100644 --- a/ripngd/ripng_main.c +++ b/ripngd/ripng_main.c @@ -38,7 +38,7 @@ #include "ripngd/ripngd.h" /* Configuration filename and directory. */ -char config_default[] = SYSCONFDIR RIPNG_DEFAULT_CONFIG; +char config_default[MAXPATHLEN]; char *config_file = NULL; /* RIPngd options. */ @@ -96,8 +96,11 @@ int vty_port = RIPNG_VTY_PORT; /* Master of threads. */ struct thread_master *master; +/* pid_file default value */ +static char pid_file_default[MAXPATHLEN]; + /* Process ID saved for use by init system */ -const char *pid_file = PATH_RIPNGD_PID; +const char *pid_file = pid_file_default; /* Help information display. */ static void @@ -137,7 +140,7 @@ sighup (void) /* Reload config file. */ vty_read_config (config_file, config_default); /* Create VTY's socket */ - vty_serv_sock (vty_addr, vty_port, RIPNG_VTYSH_PATH); + vty_serv_sock (vty_addr, vty_port, path_state (RIPNG_VTY_NAME)); /* Try to return to normal operation. */ } @@ -263,6 +266,9 @@ main (int argc, char **argv) } } + strcpy (config_default, path_config (RIPNG_CONFIG_NAME)); + strcpy (pid_file_default, path_state (RIPNG_PID_NAME)); + master = thread_master_create (); /* Library inits. */ @@ -295,7 +301,7 @@ main (int argc, char **argv) } /* Create VTY socket */ - vty_serv_sock (vty_addr, vty_port, RIPNG_VTYSH_PATH); + vty_serv_sock (vty_addr, vty_port, path_state (RIPNG_VTY_NAME)); /* Process id file create. */ pid_output (pid_file); diff --git a/ripngd/ripngd.h b/ripngd/ripngd.h index ab06d81b..71615c3c 100644 --- a/ripngd/ripngd.h +++ b/ripngd/ripngd.h @@ -51,7 +51,9 @@ #define RIPNG_PEER_TIMER_DEFAULT 180 /* Default config file name. */ -#define RIPNG_DEFAULT_CONFIG "ripngd.conf" +#define RIPNG_CONFIG_NAME "ripngd.conf" +#define RIPNG_PID_NAME "ripngd.pid" +#define RIPNG_VTY_NAME "ripngd.vty" /* RIPng route types. */ #define RIPNG_ROUTE_RTE 0 diff --git a/vtysh/Makefile.am b/vtysh/Makefile.am index 791d95dd..59265060 100644 --- a/vtysh/Makefile.am +++ b/vtysh/Makefile.am @@ -1,7 +1,6 @@ ## Process this file with Automake to create Makefile.in INCLUDES = @INCLUDES@ -I$(top_srcdir) -I$(top_srcdir)/lib -DEFS = @DEFS@ -DSYSCONFDIR=\"$(sysconfdir)/\" LIBS = @LIBS@ @CURSES@ @LIBPAM@ diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c index 3f189adb..8df8dc17 100644 --- a/vtysh/vtysh.c +++ b/vtysh/vtysh.c @@ -34,6 +34,7 @@ #include "memory.h" #include "vtysh/vtysh.h" #include "log.h" +#include "paths.h" #include "bgpd/bgp_vty.h" /* Struct VTY. */ @@ -48,16 +49,15 @@ struct vtysh_client int fd; const char *name; int flag; - const char *path; } vtysh_client[] = { - { .fd = -1, .name = "zebra", .flag = VTYSH_ZEBRA, .path = ZEBRA_VTYSH_PATH}, - { .fd = -1, .name = "ripd", .flag = VTYSH_RIPD, .path = RIP_VTYSH_PATH}, - { .fd = -1, .name = "ripngd", .flag = VTYSH_RIPNGD, .path = RIPNG_VTYSH_PATH}, - { .fd = -1, .name = "ospfd", .flag = VTYSH_OSPFD, .path = OSPF_VTYSH_PATH}, - { .fd = -1, .name = "ospf6d", .flag = VTYSH_OSPF6D, .path = OSPF6_VTYSH_PATH}, - { .fd = -1, .name = "bgpd", .flag = VTYSH_BGPD, .path = BGP_VTYSH_PATH}, - { .fd = -1, .name = "isisd", .flag = VTYSH_ISISD, .path = ISIS_VTYSH_PATH}, + { .fd = -1, .name = "zebra", .flag = VTYSH_ZEBRA}, + { .fd = -1, .name = "ripd", .flag = VTYSH_RIPD}, + { .fd = -1, .name = "ripngd", .flag = VTYSH_RIPNGD}, + { .fd = -1, .name = "ospfd", .flag = VTYSH_OSPFD}, + { .fd = -1, .name = "ospf6d", .flag = VTYSH_OSPF6D}, + { .fd = -1, .name = "bgpd", .flag = VTYSH_BGPD}, + { .fd = -1, .name = "isisd", .flag = VTYSH_ISISD}, }; #define VTYSH_INDEX_MAX (sizeof(vtysh_client)/sizeof(vtysh_client[0])) @@ -2103,13 +2103,17 @@ vtysh_connect (struct vtysh_client *vclient) int sock, len; struct sockaddr_un addr; struct stat s_stat; + char path[MAXPATHLEN]; + + /* figure out path to daemon VTY socket */ + snprintf (path, sizeof(path), "%s.vty", path_state (vclient->name)); /* Stat socket to see if we have permission to access it. */ - ret = stat (vclient->path, &s_stat); + ret = stat (path, &s_stat); if (ret < 0 && errno != ENOENT) { fprintf (stderr, "vtysh_connect(%s): stat = %s\n", - vclient->path, safe_strerror(errno)); + path, safe_strerror(errno)); exit(1); } @@ -2117,8 +2121,7 @@ vtysh_connect (struct vtysh_client *vclient) { if (! S_ISSOCK(s_stat.st_mode)) { - fprintf (stderr, "vtysh_connect(%s): Not a socket\n", - vclient->path); + fprintf (stderr, "vtysh_connect(%s): Not a socket\n", path); exit (1); } @@ -2128,7 +2131,7 @@ vtysh_connect (struct vtysh_client *vclient) if (sock < 0) { #ifdef DEBUG - fprintf(stderr, "vtysh_connect(%s): socket = %s\n", vclient->path, + fprintf(stderr, "vtysh_connect(%s): socket = %s\n", path, safe_strerror(errno)); #endif /* DEBUG */ return -1; @@ -2136,7 +2139,7 @@ vtysh_connect (struct vtysh_client *vclient) memset (&addr, 0, sizeof (struct sockaddr_un)); addr.sun_family = AF_UNIX; - strncpy (addr.sun_path, vclient->path, strlen (vclient->path)); + strncpy (addr.sun_path, path, sizeof (addr.sun_path)); #ifdef HAVE_STRUCT_SOCKADDR_UN_SUN_LEN len = addr.sun_len = SUN_LEN(&addr); #else @@ -2147,7 +2150,7 @@ vtysh_connect (struct vtysh_client *vclient) if (ret < 0) { #ifdef DEBUG - fprintf(stderr, "vtysh_connect(%s): connect = %s\n", vclient->path, + fprintf(stderr, "vtysh_connect(%s): connect = %s\n", path, safe_strerror(errno)); #endif /* DEBUG */ close (sock); diff --git a/zebra/Makefile.am b/zebra/Makefile.am index 542f36f4..828e88ff 100644 --- a/zebra/Makefile.am +++ b/zebra/Makefile.am @@ -1,7 +1,7 @@ ## Process this file with automake to produce Makefile.in. INCLUDES = @INCLUDES@ -I.. -I$(top_srcdir) -I$(top_srcdir)/lib @SNMP_INCLUDES@ -DEFS = @DEFS@ -DSYSCONFDIR=\"$(sysconfdir)/\" -DMULTIPATH_NUM=@MULTIPATH_NUM@ +DEFS = @DEFS@ -DMULTIPATH_NUM=@MULTIPATH_NUM@ INSTALL_SDATA=@INSTALL@ -m 600 LIB_IPV6 = @LIB_IPV6@ diff --git a/zebra/main.c b/zebra/main.c index d829c046..293e22b8 100644 --- a/zebra/main.c +++ b/zebra/main.c @@ -32,6 +32,7 @@ #include "plist.h" #include "privs.h" #include "sigevent.h" +#include "paths.h" #include "zebra/rib.h" #include "zebra/zserv.h" @@ -108,10 +109,13 @@ struct zebra_privs_t zserv_privs = }; /* Default configuration file path. */ -char config_default[] = SYSCONFDIR DEFAULT_CONFIG_FILE; +char config_default[MAXPATHLEN]; + +/* pid_file default value */ +static char pid_file_default[MAXPATHLEN]; /* Process ID saved for use by init system */ -const char *pid_file = PATH_ZEBRA_PID; +const char *pid_file = pid_file_default; /* Help information display. */ static void @@ -300,6 +304,9 @@ main (int argc, char **argv) } } + strcpy (config_default, path_config (ZEBRA_CONFIG_NAME)); + strcpy (pid_file_default, path_state (ZEBRA_PID_NAME)); + /* Make master thread emulator. */ zebrad.master = thread_master_create (); @@ -389,7 +396,7 @@ main (int argc, char **argv) zebra_zserv_socket_init (); /* Make vty server socket. */ - vty_serv_sock (vty_addr, vty_port, ZEBRA_VTYSH_PATH); + vty_serv_sock (vty_addr, vty_port, path_state (ZEBRA_VTY_NAME)); /* Print banner. */ zlog_notice ("Zebra %s starting: vty@%d", QUAGGA_VERSION, vty_port); diff --git a/zebra/test_main.c b/zebra/test_main.c index 70a1a3a6..4e1002e8 100644 --- a/zebra/test_main.c +++ b/zebra/test_main.c @@ -29,6 +29,7 @@ #include "log.h" #include "privs.h" #include "sigevent.h" +#include "paths.h" #include "zebra/rib.h" #include "zebra/zserv.h" @@ -73,10 +74,13 @@ zebra_capabilities_t _caps_p [] = }; /* Default configuration file path. */ -char config_default[] = SYSCONFDIR DEFAULT_CONFIG_FILE; +char config_default[MAXPATHLEN]; + +/* pid_file default value */ +static char pid_file_default[MAXPATHLEN]; /* Process ID saved for use by init system */ -const char *pid_file = PATH_ZEBRA_PID; +const char *pid_file = pid_file_default; /* Help information display. */ static void @@ -276,6 +280,9 @@ main (int argc, char **argv) usage (progname, 1); } + strcpy (config_default, path_config (ZEBRA_CONFIG_NAME)); + strcpy (pid_file_default, path_state (ZEBRA_PID_NAME)); + /* Make master thread emulator. */ zebrad.master = thread_master_create (); diff --git a/zebra/zserv.h b/zebra/zserv.h index a7371830..cccd9be0 100644 --- a/zebra/zserv.h +++ b/zebra/zserv.h @@ -30,7 +30,9 @@ #define ZEBRA_VTY_PORT 2601 /* Default configuration filename. */ -#define DEFAULT_CONFIG_FILE "zebra.conf" +#define ZEBRA_CONFIG_NAME "zebra.conf" +#define ZEBRA_PID_NAME "zebra.pid" +#define ZEBRA_VTY_NAME "zebra.vty" /* Client structure. */ struct zserv |