Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

*: fix a pile of directory and/or state retention related issues #15243

Merged
merged 19 commits into from
Jan 28, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ MODULE_LDFLAGS = \
$(SAN_FLAGS) \
# end

DEFS = @DEFS@ -DSYSCONFDIR=\"$(sysconfdir)/\" -DCONFDATE=$(CONFDATE)
DEFS = @DEFS@ -DSYSCONFDIR=\"$(CFG_SYSCONF)/\" -DCONFDATE=$(CONFDATE)

AR_FLAGS = @AR_FLAGS@
ARFLAGS = @ARFLAGS@
Expand Down
6 changes: 2 additions & 4 deletions alpine/APKBUILD.in
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,18 @@ source="$pkgname-$pkgver.tar.gz"
builddir="$srcdir"/$pkgname-$pkgver

_sbindir=/usr/lib/frr
_sysconfdir=/etc/frr
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lots of developers probably have custom scripts to set this up for themselves. Do we need to have them change anything?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_libdir=/usr/lib
_localstatedir=/var/run/frr
_user=frr

build() {
cd "$builddir"

./configure \
--prefix=/usr \
--sysconfdir=/etc \
--localstatedir=/var \
--sbindir=$_sbindir \
--sysconfdir=$_sysconfdir \
--libdir=$_libdir \
--localstatedir=$_localstatedir \
--enable-rpki \
--enable-vtysh \
--enable-multipath=64 \
Expand Down
2 changes: 1 addition & 1 deletion buildtest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# builds some git commit of FRR in some different configurations
# usage: buildtest.sh [commit [configurations...]]

basecfg="--prefix=/usr --enable-user=frr --enable-group=frr --enable-vty-group=frr --enable-configfile-mask=0660 --enable-logfile-mask=0640 --enable-vtysh --sysconfdir=/etc/frr --localstatedir=/var/run/frr --libdir=/usr/lib64/frr --enable-rtadv --disable-static --enable-isisd --enable-multipath=0 --enable-pimd --enable-werror"
basecfg="--prefix=/usr --enable-user=frr --enable-group=frr --enable-vty-group=frr --enable-configfile-mask=0660 --enable-logfile-mask=0640 --enable-vtysh --sysconfdir=/etc --localstatedir=/var --libdir=/usr/lib64/frr --enable-rtadv --disable-static --enable-isisd --enable-multipath=0 --enable-pimd --enable-werror"

configs_base="gcc|$basecfg"

Expand Down
178 changes: 105 additions & 73 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,77 @@ AC_CONFIG_SRCDIR([lib/zebra.h])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_AUX_DIR([m4/ac])

dnl ------------------------------
dnl system paths
dnl ------------------------------
dnl Versions of FRR (or Quagga, or Zebra) before ca. 9.2 used sysconfdir and
dnl localstatedir as-is, without appending /frr. The /frr was expected to be
dnl given on ./configure invocations.
dnl
dnl This does not match standard behavior by other packages and makes FRR
dnl specific packaging changes necessary to add these options. localstatedir
dnl was also misused to include the /run part (it normally is only /var),
dnl leaving no path configuration option that references /var itself. This
dnl is because runstatedir did not exist in ancient autoconf.
dnl
dnl The path options have been changed to expect plain / system prefix
dnl directories. As a temporary workaround to not break packaging, eventual
dnl /frr suffixes are stripped and a warning is printed.

path_warn_banner=false

AC_MSG_CHECKING([whether --sysconfdir option is FRR-specific])
case "$sysconfdir" in
*/frr)
AC_MSG_RESULT([yes, ends in /frr - removing suffix])
AC_MSG_WARN([Please remove /frr suffix from --sysconfdir="${sysconfdir}" (it should be /etc in 99% of cases)])
sysconfdir="${sysconfdir%/frr}"
path_warn_banner=true
;;
*)
AC_MSG_RESULT([no, as expected])
;;
esac

frr_sysconfdir="\${sysconfdir}/frr"

AC_MSG_CHECKING([whether --localstatedir option is FRR-specific])
case "$localstatedir" in
*/run/frr)
AC_MSG_RESULT([yes, ends in /run/frr - removing suffix])
AC_MSG_WARN([Please remove /run/frr suffix from --localstatedir=${localstatedir} (it should be /var in 99% of cases)])
localstatedir="${localstatedir%/run/frr}"
path_warn_banner=true
;;
*/frr)
AC_MSG_RESULT([yes, ends in /frr - removing suffix])
AC_MSG_WARN([The --localstatedir=${localstatedir} option seems to include /frr but not /run, this is unexpected. Please check for consistency.)])
localstatedir="${localstatedir%/frr}"
path_warn_banner=true
;;
*)
AC_MSG_RESULT([no, as expected])
;;
esac

dnl runstatedir is either ${localstatedir}/run or plain /run
dnl the change of localstatedir above may impact this
dnl
dnl note runstatedir was never used with /frr as the other two above, so does
dnl not need the same cleanup hack
: "${runstatedir:=\${localstatedir\}/run}"
frr_runstatedir="\${runstatedir}/frr"

if $path_warn_banner; then
AC_MSG_WARN([^])
AC_MSG_WARN([^])
AC_MSG_WARN([^ warnings regarding system path configuration were printed above])
AC_MSG_WARN([^ paths have been adjusted by temporary workarounds])
AC_MSG_WARN([^ please fix your ./configure invocation (remove /frr) so it will work without the workarounds])
AC_MSG_WARN([^])
AC_MSG_WARN([^])
fi

dnl -----------------------------------
dnl Get hostname and other information.
dnl -----------------------------------
Expand Down Expand Up @@ -130,10 +201,10 @@ AC_ARG_WITH([moduledir], [AS_HELP_STRING([--with-moduledir=DIR], [module directo
])
AC_SUBST([moduledir], [$moduledir])

AC_ARG_WITH([scriptdir], [AS_HELP_STRING([--with-scriptdir=DIR], [script directory (${sysconfdir}/scripts)])], [
AC_ARG_WITH([scriptdir], [AS_HELP_STRING([--with-scriptdir=DIR], [script directory (${sysconfdir}/frr/scripts)])], [
scriptdir="$withval"
], [
scriptdir="\${sysconfdir}/scripts"
scriptdir="\${frr_sysconfdir}/scripts"
])
AC_SUBST([scriptdir], [$scriptdir])

Expand Down Expand Up @@ -2641,88 +2712,41 @@ else
fi
AC_SUBST([CONFDATE])

dnl ------------------------------
dnl set paths for state directory
dnl ------------------------------
AC_MSG_CHECKING([directory to use for state file])
if test "$prefix" = "NONE"; then
frr_statedir_prefix="";
else
frr_statedir_prefix=${prefix}
fi
if test "$localstatedir" = '${prefix}/var'; then
for FRR_STATE_DIR in ${frr_statedir_prefix}/var/run dnl
${frr_statedir_prefix}/var/adm dnl
${frr_statedir_prefix}/etc dnl
/var/run dnl
/var/adm dnl
/etc dnl
/dev/null;
do
test -d $FRR_STATE_DIR && break
done
frr_statedir=$FRR_STATE_DIR
else
frr_statedir=${localstatedir}
fi
if test "$frr_statedir" = "/dev/null"; then
AC_MSG_ERROR([STATE DIRECTORY NOT FOUND! FIX OR SPECIFY --localstatedir!])
fi
AC_MSG_RESULT([${frr_statedir}])
AC_SUBST([frr_statedir])

AC_DEFINE_UNQUOTED([LDPD_SOCKET], ["$frr_statedir%s%s/ldpd.sock"], [ldpd control socket])
AC_DEFINE_UNQUOTED([ZEBRA_SERV_PATH], ["$frr_statedir%s%s/zserv.api"], [zebra api socket])
AC_DEFINE_UNQUOTED([BFDD_CONTROL_SOCKET], ["$frr_statedir%s%s/bfdd.sock"], [bfdd control socket])
AC_DEFINE_UNQUOTED([OSPFD_GR_STATE], ["$frr_statedir%s/ospfd-gr.json"], [ospfd GR state information])
AC_DEFINE_UNQUOTED([MGMTD_FE_SERVER_PATH], ["$frr_statedir/mgmtd_fe.sock"], [mgmtd frontend server socket])
AC_DEFINE_UNQUOTED([MGMTD_BE_SERVER_PATH], ["$frr_statedir/mgmtd_be.sock"], [mgmtd backend server socket])
AC_DEFINE_UNQUOTED([OSPF6D_GR_STATE], ["$frr_statedir/ospf6d-gr.json"], [ospf6d GR state information])
AC_DEFINE_UNQUOTED([ISISD_RESTART], ["$frr_statedir%s/isid-restart.json"], [isisd restart information])
AC_DEFINE_UNQUOTED([OSPF6_AUTH_SEQ_NUM_FILE], ["$frr_statedir/ospf6d-at-seq-no.dat"], [ospf6d AT Sequence number information])
AC_DEFINE_UNQUOTED([DAEMON_VTY_DIR], ["$frr_statedir%s%s"], [daemon vty directory])
AC_DEFINE_UNQUOTED([DAEMON_DB_DIR], ["$frr_statedir"], [daemon database directory])

dnl autoconf does this, but it does it too late...
test "$prefix" = "NONE" && prefix=$ac_default_prefix
test "$exec_prefix" = "NONE" && exec_prefix='${prefix}'

dnl get the full path, recursing through variables...
vtysh_bin="$bindir/vtysh"
for I in 1 2 3 4 5 6 7 8 9 10; do
eval vtysh_bin="\"$vtysh_bin\""
done
AC_DEFINE_UNQUOTED([VTYSH_BIN_PATH], ["$vtysh_bin"], [path to vtysh binary])
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([$moduledir], [CFG_MODULE])
AX_RECURSIVE_EVAL([$yangmodelsdir], [CFG_YANGMODELS])
AX_RECURSIVE_EVAL([$scriptdir], [CFG_SCRIPT])
AC_SUBST([vtysh_bin])

CFG_SYSCONF="$sysconfdir"
CFG_SBIN="$sbindir"
CFG_BIN="$bindir"
CFG_STATE="$frr_statedir"
CFG_MODULE="$moduledir"
CFG_YANGMODELS="$yangmodelsdir"
CFG_SCRIPT="$scriptdir"
for I in 1 2 3 4 5 6 7 8 9 10; do
eval CFG_SYSCONF="\"$CFG_SYSCONF\""
eval CFG_SBIN="\"$CFG_SBIN\""
eval CFG_BIN="\"$CFG_BIN\""
eval CFG_STATE="\"$CFG_STATE\""
eval CFG_MODULE="\"$CFG_MODULE\""
eval CFG_YANGMODELS="\"$CFG_YANGMODELS\""
eval CFG_SCRIPT="\"$CFG_SCRIPT\""
done
AC_SUBST([CFG_SYSCONF])
AC_SUBST([CFG_SBIN])
AC_SUBST([CFG_BIN])
AC_SUBST([CFG_STATE])
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([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_DEFINE_UNQUOTED([LDPD_SOCKET], ["$CFG_STATE%s%s/ldpd.sock"], [ldpd control socket])
AC_DEFINE_UNQUOTED([ZEBRA_SERV_PATH], ["$CFG_STATE%s%s/zserv.api"], [zebra api socket])
AC_DEFINE_UNQUOTED([BFDD_CONTROL_SOCKET], ["$CFG_STATE%s%s/bfdd.sock"], [bfdd control socket])
AC_DEFINE_UNQUOTED([OSPFD_GR_STATE], ["$CFG_STATE%s/ospfd-gr.json"], [ospfd GR state information])
AC_DEFINE_UNQUOTED([MGMTD_FE_SERVER_PATH], ["$CFG_STATE/mgmtd_fe.sock"], [mgmtd frontend server socket])
AC_DEFINE_UNQUOTED([MGMTD_BE_SERVER_PATH], ["$CFG_STATE/mgmtd_be.sock"], [mgmtd backend server socket])
AC_DEFINE_UNQUOTED([OSPF6D_GR_STATE], ["$CFG_STATE/ospf6d-gr.json"], [ospf6d GR state information])
AC_DEFINE_UNQUOTED([ISISD_RESTART], ["$CFG_STATE%s/isid-restart.json"], [isisd restart information])
AC_DEFINE_UNQUOTED([OSPF6_AUTH_SEQ_NUM_FILE], ["$CFG_STATE/ospf6d-at-seq-no.dat"], [ospf6d AT Sequence number information])
AC_DEFINE_UNQUOTED([DAEMON_VTY_DIR], ["$CFG_STATE%s%s"], [daemon vty directory])
AC_DEFINE_UNQUOTED([DAEMON_DB_DIR], ["$CFG_STATE"], [daemon database directory])

dnl various features
AM_CONDITIONAL([SUPPORT_REALMS], [test "$enable_realms" = "yes"])
AM_CONDITIONAL([ENABLE_BGP_VNC], [test "$enable_bgp_vnc" != "no"])
Expand Down Expand Up @@ -2837,7 +2861,7 @@ fi
FRR_ALL_CCLS_FLAGS="$(echo ${LIBYANG_CFLAGS} ${LUA_INCLUDE} ${SQLITE3_CFLAGS} | sed -e 's/ */ /g')"
FRR_ALL_CCLS_CFLAGS="$(echo ${CFLAGS} ${WERROR} ${AC_CFLAGS} ${SAN_FLAGS} | sed -e 's/ */ /g')"
ac_frr_confdate="${CONFDATE}"
ac_frr_sysconfdir="${sysconfdir}/"
ac_frr_sysconfdir="${frr_sysconfdir}/"
])
])

Expand Down Expand Up @@ -2880,8 +2904,8 @@ 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 : ${frr_statedir}
config file directory : `eval echo \`echo ${sysconfdir}\``
state file directory : ${CFG_STATE}
config file directory : ${CFG_SYSCONF}
module directory : ${CFG_MODULE}
script directory : ${CFG_SCRIPT}
user to run as : ${enable_user}
Expand All @@ -2905,3 +2929,11 @@ fi
if test "$frr_py_mod_pytest" = "false"; then
AC_MSG_WARN([pytest is missing, unit tests cannot be performed])
fi

if $path_warn_banner; then
AC_MSG_WARN([^])
AC_MSG_WARN([^])
AC_MSG_WARN([^ warnings regarding system path configuration were printed at the very top of output])
AC_MSG_WARN([^ paths have been adjusted by temporary workarounds])
AC_MSG_WARN([^ please fix your ./configure invocation (remove /frr) so it will work without the workarounds])
fi
2 changes: 0 additions & 2 deletions debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@ export PYTHON=python3
override_dh_auto_configure:
$(shell dpkg-buildflags --export=sh); \
dh_auto_configure -- \
--localstatedir=/var/run/frr \
--sbindir=/usr/lib/frr \
--sysconfdir=/etc/frr \
--with-vtysh-pager=/usr/bin/pager \
--libdir=/usr/lib/$(DEB_HOST_MULTIARCH)/frr \
--with-moduledir=/usr/lib/$(DEB_HOST_MULTIARCH)/frr/modules \
Expand Down
2 changes: 0 additions & 2 deletions doc/developer/building-frr-for-centos6.rst
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,8 @@ an example.)
./configure \
--bindir=/usr/bin \
--sbindir=/usr/lib/frr \
--sysconfdir=/etc/frr \
--libdir=/usr/lib/frr \
--libexecdir=/usr/lib/frr \
--localstatedir=/var/run/frr \
--with-moduledir=/usr/lib/frr/modules \
--disable-pimd \
--enable-snmp=agentx \
Expand Down
2 changes: 0 additions & 2 deletions doc/developer/building-frr-for-centos7.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,8 @@ an example.)
./configure \
--bindir=/usr/bin \
--sbindir=/usr/lib/frr \
--sysconfdir=/etc/frr \
--libdir=/usr/lib/frr \
--libexecdir=/usr/lib/frr \
--localstatedir=/var/run/frr \
--with-moduledir=/usr/lib/frr/modules \
--enable-snmp=agentx \
--enable-multipath=64 \
Expand Down
2 changes: 0 additions & 2 deletions doc/developer/building-frr-for-centos8.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,8 @@ an example.)
./configure \
--bindir=/usr/bin \
--sbindir=/usr/lib/frr \
--sysconfdir=/etc/frr \
--libdir=/usr/lib/frr \
--libexecdir=/usr/lib/frr \
--localstatedir=/var/run/frr \
--with-moduledir=/usr/lib/frr/modules \
--enable-snmp=agentx \
--enable-multipath=64 \
Expand Down
4 changes: 2 additions & 2 deletions doc/developer/building-frr-for-debian12.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ an example.)
cd frr
./bootstrap.sh
./configure \
--localstatedir=/var/opt/frr \
--sysconfdir=/etc \
--localstatedir=/var \
--sbindir=/usr/lib/frr \
--sysconfdir=/etc/frr \
--enable-multipath=64 \
--enable-user=frr \
--enable-group=frr \
Expand Down
10 changes: 5 additions & 5 deletions doc/developer/building-frr-for-debian8.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ an example.)
cd frr
./bootstrap.sh
./configure \
--localstatedir=/var/run/frr \
--sysconfdir=/etc \
--localstatedir=/var \
--sbindir=/usr/lib/frr \
--sysconfdir=/etc/frr \
--enable-multipath=64 \
--enable-user=frr \
--enable-group=frr \
Expand Down Expand Up @@ -118,9 +118,9 @@ Troubleshooting

The local state directory must exist and have the correct permissions
applied for the frrouting daemons to start. In the above ./configure
example the local state directory is set to /var/run/frr
(--localstatedir=/var/run/frr) Debian considers /var/run/frr to be
temporary and this is removed after a reboot.
example the local state directory is set to ``/var`` such that ``/var/run/frr``
is used. Debian considers ``/var/run/frr`` to be temporary and this is removed
after a reboot.

When using a different local state directory you need to create the new
directory and change the ownership to the frr user, for example:
Expand Down
4 changes: 2 additions & 2 deletions doc/developer/building-frr-for-debian9.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ an example.)
cd frr
./bootstrap.sh
./configure \
--localstatedir=/var/opt/frr \
--sysconfdir=/etc \
--localstatedir=/var \
--sbindir=/usr/lib/frr \
--sysconfdir=/etc/frr \
--enable-multipath=64 \
--enable-user=frr \
--enable-group=frr \
Expand Down
4 changes: 2 additions & 2 deletions doc/developer/building-frr-for-freebsd10.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ an example)
export LDFLAGS="-L/usr/local/lib"
export CPPFLAGS="-I/usr/local/include"
./configure \
--sysconfdir=/usr/local/etc/frr \
--sysconfdir=/usr/local/etc \
--localstatedir=/var \
--enable-pkgsrcrcdir=/usr/pkg/share/examples/rc.d \
--localstatedir=/var/run/frr \
--prefix=/usr/local \
--enable-multipath=64 \
--enable-user=frr \
Expand Down
4 changes: 2 additions & 2 deletions doc/developer/building-frr-for-freebsd11.rst
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ an example)
setenv CPPFLAGS -I/usr/local/include
ln -s /usr/local/bin/sphinx-build-3.6 /usr/local/bin/sphinx-build
./configure \
--sysconfdir=/usr/local/etc/frr \
--sysconfdir=/usr/local/etc \
--localstatedir=/var \
--enable-pkgsrcrcdir=/usr/pkg/share/examples/rc.d \
--localstatedir=/var/run/frr \
--prefix=/usr/local \
--enable-multipath=64 \
--enable-user=frr \
Expand Down
Loading