diff options
-rw-r--r-- | Makefile.am | 2 | ||||
-rw-r--r-- | configure.ac | 54 | ||||
-rw-r--r-- | lib/.gitignore | 1 | ||||
-rw-r--r-- | lib/command.c | 2 | ||||
-rw-r--r-- | lib/config_paths.h.in | 24 | ||||
-rw-r--r-- | lib/libfrr.c | 2 | ||||
-rw-r--r-- | lib/vty.c | 2 | ||||
-rw-r--r-- | lib/yang.c | 2 | ||||
-rw-r--r-- | pkgsrc/bgpd.sh.in | 2 | ||||
-rw-r--r-- | pkgsrc/eigrpd.sh.in | 2 | ||||
-rw-r--r-- | pkgsrc/mgmtd.sh.in | 2 | ||||
-rw-r--r-- | pkgsrc/ospf6d.sh.in | 2 | ||||
-rw-r--r-- | pkgsrc/ospfd.sh.in | 2 | ||||
-rw-r--r-- | pkgsrc/ripd.sh.in | 2 | ||||
-rw-r--r-- | pkgsrc/ripngd.sh.in | 2 | ||||
-rw-r--r-- | pkgsrc/zebra.sh.in | 2 | ||||
-rwxr-xr-x | tools/frr.in | 10 | ||||
-rw-r--r-- | tools/frr.service.in | 8 | ||||
-rw-r--r-- | tools/frr@.service.in | 8 | ||||
-rwxr-xr-x | tools/frrcommon.sh.in | 12 | ||||
-rw-r--r-- | tools/frrinit.sh.in | 2 | ||||
-rw-r--r-- | tools/watchfrr.sh.in | 4 | ||||
-rw-r--r-- | watchfrr/watchfrr.c | 2 | ||||
-rw-r--r-- | watchfrr/watchfrr_vty.c | 2 |
24 files changed, 93 insertions, 60 deletions
diff --git a/Makefile.am b/Makefile.am index 6ad8e8dfa..0ce716e34 100644 --- a/Makefile.am +++ b/Makefile.am @@ -56,7 +56,7 @@ MODULE_LDFLAGS = \ $(SAN_FLAGS) \ # end -DEFS = @DEFS@ -DSYSCONFDIR=\"$(CFG_SYSCONF)/\" -DCONFDATE=$(CONFDATE) +DEFS = @DEFS@ -DCONFDATE=$(CONFDATE) AR_FLAGS = @AR_FLAGS@ ARFLAGS = @ARFLAGS@ diff --git a/configure.ac b/configure.ac index 440131941..d902f23d7 100644 --- a/configure.ac +++ b/configure.ac @@ -2715,31 +2715,26 @@ fi AC_SUBST([CONFDATE]) dnl get the full path, recursing through variables... -AX_RECURSIVE_EVAL([$bindir/vtysh], [vtysh_bin]) -AX_RECURSIVE_EVAL([$frr_sysconfdir], [CFG_SYSCONF]) -AX_RECURSIVE_EVAL([$sbindir], [CFG_SBIN]) -AX_RECURSIVE_EVAL([$bindir], [CFG_BIN]) -AX_RECURSIVE_EVAL([$frr_runstatedir], [CFG_STATE]) -AX_RECURSIVE_EVAL([$frr_libstatedir], [CFG_LIBSTATE]) -AX_RECURSIVE_EVAL([$moduledir], [CFG_MODULE]) -AX_RECURSIVE_EVAL([$yangmodelsdir], [CFG_YANGMODELS]) -AX_RECURSIVE_EVAL([$scriptdir], [CFG_SCRIPT]) -AC_SUBST([vtysh_bin]) -AC_SUBST([CFG_SYSCONF]) -AC_SUBST([CFG_SBIN]) -AC_SUBST([CFG_BIN]) -AC_SUBST([CFG_STATE]) -dnl AC_SUBST([CFG_LIBSTATE]) -- not currently used -AC_SUBST([CFG_MODULE]) -AC_SUBST([CFG_SCRIPT]) -AC_SUBST([CFG_YANGMODELS]) -AC_DEFINE_UNQUOTED([VTYSH_BIN_PATH], ["$vtysh_bin"], [path to vtysh binary]) -AC_DEFINE_UNQUOTED([MODULE_PATH], ["$CFG_MODULE"], [path to modules]) -AC_DEFINE_UNQUOTED([SCRIPT_PATH], ["$CFG_SCRIPT"], [path to scripts]) -AC_DEFINE_UNQUOTED([FRR_RUNSTATE_PATH], ["$CFG_STATE"], [/run/frr equivalent]) -AC_DEFINE_UNQUOTED([FRR_LIBSTATE_PATH], ["$CFG_LIBSTATE"], [/var/lib/frr equivalent]) -AC_DEFINE_UNQUOTED([YANG_MODELS_PATH], ["$CFG_YANGMODELS"], [path to YANG data models]) -AC_DEFINE_UNQUOTED([WATCHFRR_SH_PATH], ["${CFG_SBIN%/}/watchfrr.sh"], [path to watchfrr.sh]) +AC_DEFUN([AX_SUBST_EXPANDED], [ + AX_RECURSIVE_EVAL([[$]$1], [e_$1]) + AC_SUBST([e_$1]) +]) + +AX_SUBST_EXPANDED([bindir]) +AX_SUBST_EXPANDED([sbindir]) +AX_SUBST_EXPANDED([frr_sysconfdir]) +AX_SUBST_EXPANDED([frr_runstatedir]) +AX_SUBST_EXPANDED([frr_libstatedir]) +AX_SUBST_EXPANDED([moduledir]) +AX_SUBST_EXPANDED([yangmodelsdir]) +AX_SUBST_EXPANDED([scriptdir]) + +dnl strip duplicate trailing slashes if necessary +dnl note this uses e_bindir / e_sbindir created above +watchfrr_sh="\${e_sbindir%/}/watchfrr.sh" +AX_SUBST_EXPANDED([watchfrr_sh]) +vtysh_bin="\${e_bindir%/}/vtysh" +AX_SUBST_EXPANDED([vtysh_bin]) dnl various features AM_CONDITIONAL([SUPPORT_REALMS], [test "$enable_realms" = "yes"]) @@ -2811,6 +2806,7 @@ AC_CONFIG_FILES([ alpine/APKBUILD snapcraft/snapcraft.yaml lib/version.h + lib/config_paths.h tests/lib/cli/test_cli.refout pkgsrc/mgmtd.sh pkgsrc/bgpd.sh pkgsrc/ospf6d.sh pkgsrc/ospfd.sh pkgsrc/ripd.sh pkgsrc/ripngd.sh pkgsrc/zebra.sh @@ -2898,10 +2894,10 @@ compiler : ${CC} compiler flags : ${CFLAGS} ${WERROR} ${AC_CFLAGS} ${SAN_FLAGS} make : ${MAKE-make} linker flags : ${LDFLAGS} ${SAN_FLAGS} ${LIBS} ${LIBCAP} ${LIBREADLINE} ${LIBM} -state file directory : ${CFG_STATE} -config file directory : ${CFG_SYSCONF} -module directory : ${CFG_MODULE} -script directory : ${CFG_SCRIPT} +state file directory : ${e_frr_runstatedir} +config file directory : ${e_sysconfdir} +module directory : ${e_moduledir} +script directory : ${e_scriptdir} user to run as : ${enable_user} group to run as : ${enable_group} group for vty sockets : ${enable_vty_group} diff --git a/lib/.gitignore b/lib/.gitignore index 5d38469ca..1c9314bf0 100644 --- a/lib/.gitignore +++ b/lib/.gitignore @@ -1,3 +1,4 @@ +/config_paths.h /version.c /version.h /gitversion.h diff --git a/lib/command.c b/lib/command.c index 244bf86e8..fa260721d 100644 --- a/lib/command.c +++ b/lib/command.c @@ -43,6 +43,8 @@ #include "frrscript.h" +#include "lib/config_paths.h" + DEFINE_MTYPE_STATIC(LIB, HOST, "Host config"); DEFINE_MTYPE(LIB, COMPLETION, "Completion item"); diff --git a/lib/config_paths.h.in b/lib/config_paths.h.in new file mode 100644 index 000000000..cc4090563 --- /dev/null +++ b/lib/config_paths.h.in @@ -0,0 +1,24 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* autogenerated by configure / config.status */ + +/* IF YOU ARE INCLUDING THIS FILE FROM A DAEMON OR ZEBRA, YOU ARE PROBABLY + * DOING SOMETHING WRONG. Check for / add a library function that retrieves + * the path you need. + * + * Only libfrr and watchfrr should be including this file. + */ + +/* the replacements for these are emitted by AX_SUBST_EXPANDED, which also + * adds the e_ prefix + */ +#define FRR_RUNSTATE_PATH "@e_frr_runstatedir@" +#define FRR_LIBSTATE_PATH "@e_frr_libstatedir@" +#define YANG_MODELS_PATH "@e_yangmodelsdir@" +#define MODULE_PATH "@e_moduledir@" +#define SCRIPT_PATH "@e_scriptdir@" + +/* for extra footgunning, this one has a trailing slash */ +#define SYSCONFDIR "@e_frr_sysconfdir@/" + +#define VTYSH_BIN_PATH "@e_vtysh_bin@" +#define WATCHFRR_SH_PATH "@e_watchfrr_sh@" diff --git a/lib/libfrr.c b/lib/libfrr.c index fe2c8fa82..d904f6f8b 100644 --- a/lib/libfrr.c +++ b/lib/libfrr.c @@ -37,6 +37,8 @@ #include "frrscript.h" #include "systemd.h" +#include "lib/config_paths.h" + DEFINE_HOOK(frr_early_init, (struct event_loop * tm), (tm)); DEFINE_HOOK(frr_late_init, (struct event_loop * tm), (tm)); DEFINE_HOOK(frr_config_pre, (struct event_loop * tm), (tm)); @@ -46,6 +46,8 @@ #include <arpa/telnet.h> #include <termios.h> +#include "lib/config_paths.h" + #include "lib/vty_clippy.c" DEFINE_MTYPE_STATIC(LIB, VTY, "VTY"); diff --git a/lib/yang.c b/lib/yang.c index ed855c849..b6884619d 100644 --- a/lib/yang.c +++ b/lib/yang.c @@ -13,6 +13,8 @@ #include "yang_translator.h" #include "northbound.h" +#include "lib/config_paths.h" + DEFINE_MTYPE_STATIC(LIB, YANG_MODULE, "YANG module"); DEFINE_MTYPE_STATIC(LIB, YANG_DATA, "YANG data structure"); diff --git a/pkgsrc/bgpd.sh.in b/pkgsrc/bgpd.sh.in index bd6aba4f1..a8ba7c68f 100644 --- a/pkgsrc/bgpd.sh.in +++ b/pkgsrc/bgpd.sh.in @@ -16,7 +16,7 @@ fi name="bgpd" rcvar=$name -required_files="@CFG_SYSCONF@/${name}.conf" +required_files="@e_sysconfdir@/${name}.conf" command="@prefix@/sbin/${name}" command_args="-d" diff --git a/pkgsrc/eigrpd.sh.in b/pkgsrc/eigrpd.sh.in index e6b6b3c21..dd8caf87f 100644 --- a/pkgsrc/eigrpd.sh.in +++ b/pkgsrc/eigrpd.sh.in @@ -16,7 +16,7 @@ fi name="eigrpd" rcvar=$name -required_files="@CFG_SYSCONF@/${name}.conf" +required_files="@e_sysconfdir@/${name}.conf" command="@prefix@/sbin/${name}" command_args="-d" diff --git a/pkgsrc/mgmtd.sh.in b/pkgsrc/mgmtd.sh.in index 91a45f2e9..313633a78 100644 --- a/pkgsrc/mgmtd.sh.in +++ b/pkgsrc/mgmtd.sh.in @@ -16,7 +16,7 @@ fi name="mgmtd" rcvar=$name -required_files="@CFG_SYSCONF@/${name}.conf" +required_files="@e_sysconfdir@/${name}.conf" command="@prefix@/sbin/${name}" command_args="-d" diff --git a/pkgsrc/ospf6d.sh.in b/pkgsrc/ospf6d.sh.in index bdd348ee7..c9854ed79 100644 --- a/pkgsrc/ospf6d.sh.in +++ b/pkgsrc/ospf6d.sh.in @@ -16,7 +16,7 @@ fi name="ospf6d" rcvar=$name -required_files="@CFG_SYSCONF@/${name}.conf" +required_files="@e_sysconfdir@/${name}.conf" command="@prefix@/sbin/${name}" command_args="-d" diff --git a/pkgsrc/ospfd.sh.in b/pkgsrc/ospfd.sh.in index 508b8af47..07dee5557 100644 --- a/pkgsrc/ospfd.sh.in +++ b/pkgsrc/ospfd.sh.in @@ -16,7 +16,7 @@ fi name="ospfd" rcvar=$name -required_files="@CFG_SYSCONF@/${name}.conf" +required_files="@e_sysconfdir@/${name}.conf" command="@prefix@/sbin/${name}" command_args="-d" diff --git a/pkgsrc/ripd.sh.in b/pkgsrc/ripd.sh.in index ca915ad9d..6c9b580a3 100644 --- a/pkgsrc/ripd.sh.in +++ b/pkgsrc/ripd.sh.in @@ -16,7 +16,7 @@ fi name="ripd" rcvar=$name -required_files="@CFG_SYSCONF@/${name}.conf" +required_files="@e_sysconfdir@/${name}.conf" command="@prefix@/sbin/${name}" command_args="-d" diff --git a/pkgsrc/ripngd.sh.in b/pkgsrc/ripngd.sh.in index 18d6cd4d3..d316d4601 100644 --- a/pkgsrc/ripngd.sh.in +++ b/pkgsrc/ripngd.sh.in @@ -16,7 +16,7 @@ fi name="ripngd" rcvar=$name -required_files="@CFG_SYSCONF@/${name}.conf" +required_files="@e_sysconfdir@/${name}.conf" command="@prefix@/sbin/${name}" command_args="-d" diff --git a/pkgsrc/zebra.sh.in b/pkgsrc/zebra.sh.in index dc5016cd1..7a2410678 100644 --- a/pkgsrc/zebra.sh.in +++ b/pkgsrc/zebra.sh.in @@ -16,7 +16,7 @@ fi name="zebra" rcvar=$name -required_files="@CFG_SYSCONF@/${name}.conf" +required_files="@e_sysconfdir@/${name}.conf" command="@prefix@/sbin/${name}" command_args="-d" diff --git a/tools/frr.in b/tools/frr.in index cd24a9605..94c15d5de 100755 --- a/tools/frr.in +++ b/tools/frr.in @@ -14,11 +14,11 @@ # PATH=/bin:/usr/bin:/sbin:/usr/sbin -D_PATH="@CFG_SBIN@" # /usr/lib/frr -C_PATH="@CFG_SYSCONF@" # /etc/frr -V_PATH="@CFG_STATE@" # /var/run/frr -B_PATH="@CFG_BIN@" -VTYSH="@vtysh_bin@" # /usr/bin/vtysh +D_PATH="@e_sbindir@" # /usr/lib/frr +C_PATH="@e_frr_sysconfdir@" # /etc/frr +V_PATH="@e_frr_runstatedir@" # /var/run/frr +B_PATH="@e_bindir@" +VTYSH="@e_vtysh_bin@" # /usr/bin/vtysh FRR_USER="@enable_user@" # frr FRR_GROUP="@enable_group@" # frr FRR_VTY_GROUP="@enable_vty_group@" # frrvty diff --git a/tools/frr.service.in b/tools/frr.service.in index 1e958dd93..b52ee3f42 100644 --- a/tools/frr.service.in +++ b/tools/frr.service.in @@ -17,10 +17,10 @@ WatchdogSec=60s RestartSec=5 Restart=always LimitNOFILE=1024 -PIDFile=@CFG_STATE@/watchfrr.pid -ExecStart=@CFG_SBIN@/frrinit.sh start -ExecStop=@CFG_SBIN@/frrinit.sh stop -ExecReload=@CFG_SBIN@/frrinit.sh reload +PIDFile=@e_frr_runstatedir@/watchfrr.pid +ExecStart=@e_sbindir@/frrinit.sh start +ExecStop=@e_sbindir@/frrinit.sh stop +ExecReload=@e_sbindir@/frrinit.sh reload [Install] WantedBy=multi-user.target diff --git a/tools/frr@.service.in b/tools/frr@.service.in index 85408a0cc..c8a2d3ba8 100644 --- a/tools/frr@.service.in +++ b/tools/frr@.service.in @@ -17,10 +17,10 @@ WatchdogSec=60s RestartSec=5 Restart=always LimitNOFILE=1024 -PIDFile=@CFG_STATE@/%I/watchfrr.pid -ExecStart=@CFG_SBIN@/frrinit.sh start %I -ExecStop=@CFG_SBIN@/frrinit.sh stop %I -ExecReload=@CFG_SBIN@/frrinit.sh reload %I +PIDFile=@e_frr_runstatedir@/%I/watchfrr.pid +ExecStart=@e_sbindir@/frrinit.sh start %I +ExecStop=@e_sbindir@/frrinit.sh stop %I +ExecReload=@e_sbindir@/frrinit.sh reload %I [Install] WantedBy=multi-user.target diff --git a/tools/frrcommon.sh.in b/tools/frrcommon.sh.in index 00b63a78e..44d41956b 100755 --- a/tools/frrcommon.sh.in +++ b/tools/frrcommon.sh.in @@ -14,18 +14,18 @@ # not perform any action. Note there is an "exit 1" if the main config # file does not exist. # -# This script should be installed in @CFG_SBIN@/frrcommon.sh +# This script should be installed in @e_sbindir@/frrcommon.sh # FRR_PATHSPACE is passed in from watchfrr suffix="${FRR_PATHSPACE:+/${FRR_PATHSPACE}}" nsopt="${FRR_PATHSPACE:+-N ${FRR_PATHSPACE}}" PATH=/bin:/usr/bin:/sbin:/usr/sbin -D_PATH="@CFG_SBIN@" # /usr/lib/frr -C_PATH="@CFG_SYSCONF@${suffix}" # /etc/frr -V_PATH="@CFG_STATE@${suffix}" # /var/run/frr -B_PATH="@CFG_BIN@" -VTYSH="@vtysh_bin@" # /usr/bin/vtysh +D_PATH="@e_sbindir@" # /usr/lib/frr +C_PATH="@e_frr_sysconfdir@${suffix}" # /etc/frr +V_PATH="@e_frr_runstatedir@${suffix}" # /var/run/frr +B_PATH="@e_bindir@" +VTYSH="@e_vtysh_bin@" # /usr/bin/vtysh FRR_USER="@enable_user@" # frr FRR_GROUP="@enable_group@" # frr FRR_VTY_GROUP="@enable_vty_group@" # frrvty diff --git a/tools/frrinit.sh.in b/tools/frrinit.sh.in index 428d57c55..178d18d43 100644 --- a/tools/frrinit.sh.in +++ b/tools/frrinit.sh.in @@ -37,7 +37,7 @@ self="`dirname $0`" if [ -r "$self/frrcommon.sh" ]; then . "$self/frrcommon.sh" else - . "@CFG_SBIN@/frrcommon.sh" + . "@e_sbindir@/frrcommon.sh" fi case "$1" in diff --git a/tools/watchfrr.sh.in b/tools/watchfrr.sh.in index 712f962a0..31279f6db 100644 --- a/tools/watchfrr.sh.in +++ b/tools/watchfrr.sh.in @@ -5,7 +5,7 @@ # internally by watchfrr to start the protocol daemons with the appropriate # options. # -# This script should be installed in @CFG_SBIN@/watchfrr.sh +# This script should be installed in @e_sbindir@/watchfrr.sh log_success_msg() { : @@ -27,7 +27,7 @@ self="`dirname $0`" if [ -r "$self/frrcommon.sh" ]; then . "$self/frrcommon.sh" else - . "@CFG_SBIN@/frrcommon.sh" + . "@e_sbindir@/frrcommon.sh" fi frrcommon_main "$@" diff --git a/watchfrr/watchfrr.c b/watchfrr/watchfrr.c index c22f21ed1..acc612c0a 100644 --- a/watchfrr/watchfrr.c +++ b/watchfrr/watchfrr.c @@ -32,6 +32,8 @@ #include "watchfrr.h" #include "watchfrr_errors.h" +#include "lib/config_paths.h" + #ifndef MIN #define MIN(X,Y) (((X) <= (Y)) ? (X) : (Y)) #endif diff --git a/watchfrr/watchfrr_vty.c b/watchfrr/watchfrr_vty.c index 0547c1e8b..95a7962ec 100644 --- a/watchfrr/watchfrr_vty.c +++ b/watchfrr/watchfrr_vty.c @@ -18,6 +18,8 @@ #include "watchfrr.h" +#include "lib/config_paths.h" + pid_t integrated_write_pid; static int integrated_result_fd; |