From 8c5cc17bf0da5719f10ce0fccad88c8dd2a681f5 Mon Sep 17 00:00:00 2001 From: Dominique Martinet Date: Thu, 3 Aug 2023 16:20:11 +0900 Subject: [PATCH] Make lock dir configurable lock dir changed on linux from /var/log to /run/pppd/lock with pppd-2.5.0, which makes pppd fail to start if the distribution does not pre-create the directory. In the line of configurability, also make the lock dir configurable through ./configure --with-lock-dir for distributions that prefer /run/pppd/lock, but change the default for linux back to /var/lock This commit is bigger than it should be, because the current configure mechanism for PPPD_RUNTIME_DIR and others is inconditional: pathnames.h has #else cases for when the variable is not defined but that is not possible. This does not work for lock dir, because on non-linux platform the path is different, and reproducing this logic at configure time is not trivial. Instead of the current method, only set the the PPPD_X_DIR variables in pppdconf.h if it was explicitly set in configure, and otherwise leave it to the else case. Note: - the else cases were incorrect for runtime dir and log dirs, and have been fixed - PPPD_PLUGIN_DIR has been kept as is because it is used for rpath in makefiles and needs to be set inconditionnaly at configure time Fixes: 66a8c74c3f73 ("Let ./configure control the paths for pppd") Fixes: #419 Signed-off-by: Dominique Martinet --- configure.ac | 25 +++++++++++++++--------- pppd/Makefile.am | 6 +++--- pppd/pathnames.h | 48 ++++++++++++++++++++++++++++------------------ pppd/pppdconf.h.in | 9 +++++++++ 4 files changed, 57 insertions(+), 31 deletions(-) diff --git a/configure.ac b/configure.ac index 7ee06d3b5..4e6f97d14 100644 --- a/configure.ac +++ b/configure.ac @@ -209,18 +209,24 @@ AC_SUBST(PPPD_PLUGIN_DIR, "$PPPD_PLUGIN_DIR", [The pppd plugin directory]) AC_ARG_WITH([runtime-dir], AS_HELP_STRING([--with-runtime-dir=DIR],[Specify the runtime directory for pppd])) AS_IF([test -n "$with_runtime_dir"], - [PPPD_RUNTIME_DIR="$with_runtime_dir"], - [PPPD_RUNTIME_DIR="${runstatedir}/pppd"]) -AC_SUBST(PPPD_RUNTIME_DIR) + [PPPD_RUNTIME_DIR="$with_runtime_dir"; + AC_DEFINE_UNQUOTED(PPPD_RUNTIME_DIR, "$PPPD_RUNTIME_DIR", [The pppd runtime directory])]) # -# Specify runtime directory +# Specify lock directory +AC_ARG_WITH([lock-dir], + AS_HELP_STRING([--with-lock-dir=DIR],[Specify the lock directory for pppd])) +AS_IF([test -n "$with_lock_dir"], + [PPPD_LOCK_DIR="$with_lock_dir"; + AC_DEFINE_UNQUOTED(PPPD_LOCK_DIR, "$PPPD_LOCK_DIR", [The pppd lock directory])]) + +# +# Specify logfile directory AC_ARG_WITH([logfile-dir], AS_HELP_STRING([--with-logfile-dir=DIR],[Specify the log directory for pppd])) AS_IF([test -n "$with_logfile_dir"], - [PPPD_LOGFILE_DIR="$with_logfile_dir"], - [PPPD_LOGFILE_DIR="${localstatedir}/log/ppp"]) -AC_SUBST(PPPD_LOGFILE_DIR) + [PPPD_LOGFILE_DIR="$with_logfile_dir"]; + AC_DEFINE_UNQUOTED(PPPD_LOGFILE_DIR, "$PPPD_LOGFILE_DIR", [The pppd logfile directory])]) # # System CA certificates path @@ -410,8 +416,9 @@ Setting up SunOS kernel module(s)" echo " $PACKAGE_NAME version $PACKAGE_VERSION Prefix...............: $prefix - Runtime Dir..........: $PPPD_RUNTIME_DIR - Logfile Dir..........: $PPPD_LOGFILE_DIR + Runtime Dir..........: ${PPPD_RUNTIME_DIR:-system default} + Lock Dir.............: ${PPPD_LOCK_DIR:-system default} + Logfile Dir..........: ${PPPD_LOGFILE_DIR:-system default} Plugin Dir...........: $PPPD_PLUGIN_DIR System CA Path ......: ${SYSTEM_CA_PATH:-not set} With OpenSSL.........: ${with_openssl:-yes} diff --git a/pppd/Makefile.am b/pppd/Makefile.am index e5bedf26a..626042bcd 100644 --- a/pppd/Makefile.am +++ b/pppd/Makefile.am @@ -3,11 +3,11 @@ dist_man8_MANS = pppd.8 check_PROGRAMS = utest_chap_SOURCES = chap_ms.c utils.c crypto_ms.c -utest_chap_CPPFLAGS = -DUNIT_TEST +utest_chap_CPPFLAGS = -DUNIT_TEST -DLOCALSTATEDIR=\"${localstatedir}\" utest_chap_LDFLAGS = utest_peap_SOURCES = peap.c utils.c mppe.c -utest_peap_CPPFLAGS = -DUNIT_TEST +utest_peap_CPPFLAGS = -DUNIT_TEST -DLOCALSTATEDIR=\"${localstatedir}\" utest_peap_LDFLAGS = utest_crypto_SOURCES = crypto.c @@ -83,7 +83,7 @@ pppd_SOURCES = \ upap.c \ utils.c -pppd_CPPFLAGS = -DSYSCONFDIR=\"${sysconfdir}\" -DLOCALSTATEDIR=\"${localstatedir}\" -DPPPD_RUNTIME_DIR='"@PPPD_RUNTIME_DIR@"' -DPPPD_LOGFILE_DIR='"@PPPD_LOGFILE_DIR@"' +pppd_CPPFLAGS = -DSYSCONFDIR=\"${sysconfdir}\" -DLOCALSTATEDIR=\"${localstatedir}\" pppd_LDFLAGS = pppd_LIBS = diff --git a/pppd/pathnames.h b/pppd/pathnames.h index de2fb6889..7dcc2978b 100644 --- a/pppd/pathnames.h +++ b/pppd/pathnames.h @@ -37,10 +37,14 @@ * sysconfdir is ${prefix}/etc. Setting prefix to /usr, you'll have to override * sysconfdir with /etc to avoid installing config files into /usr/etc. * - * In addition, there are three explicit variables that has overrides via configure: - * - PPPD_RUNTIME_DIR, set by --with-runtime-dir= - * - PPPD_LOGFILE_DIR, set by --with-logfile-dir= - * - PPPD_PLUGIN_DIR, set by --with-plugin-dir= + * In addition, there are explicit variables that have overrides via configure: + * - SYSCONFDIR, set by --sysconfdir= or its platform default + * - LOCALSATEDIR, set by --localstatedir= or its platform default + * - PPPD_RUNTIME_DIR, set by --with-runtime-dir= or undef + * - PPPD_LOCK_DIR, set by --with-lock-dir= or undef + * - PPPD_LOGFILE_DIR, set by --with-logfile-dir= or undef + * If pppd is built with plugins, additionally: + * - PPPD_PLUGIN_DIR, set by --with-plugin-dir= or its platform default */ #ifndef PPP_PATHNAMES_H #define PPP_PATHNAMES_H @@ -59,22 +63,39 @@ /* * PPPD_RUNTIME_DIR is set by passing --with-runtime-dir= via configure - * the default value set by configure when option is absent is ${localstatedir}/run/pppd */ #ifdef PPPD_RUNTIME_DIR #define PPP_PATH_VARRUN PPPD_RUNTIME_DIR #else -#define PPP_PATH_VARRUN _PATH_VARRUN +#define PPP_PATH_VARRUN _PATH_VARRUN "/pppd" +#endif + +/* + * PPPD_LOCK_DIR is set by passing --with-lock-dir= via configure + */ +#ifdef PPPD_LOCK_DIR +#define PPP_PATH_LOCKDIR PPPD_LOCK_DIR +#else +#ifdef __linux__ +#define PPP_PATH_LOCKDIR LOCALSTATEDIR "/lock" +#else +#ifdef SVR4 +#define PPP_PATH_LOCKDIR LOCALSTATEDIR "/spool/locks" +#else +#define PPP_PATH_LOCKDIR LOCALSTATEDIR "/spool/lock" +#endif +#endif + + #endif /* * PPPD_LOGFILE_DIR is set by passing --with-logfile-dir= via configure - * the default value set by configure when option is absent is ${localstatedir}/log/ppp */ #ifdef PPPD_LOGFILE_DIR #define PPP_PATH_VARLOG PPPD_LOGFILE_DIR #else -#define PPP_PATH_VARLOG _PATH_VARRUN "/log/ppp" +#define PPP_PATH_VARLOG LOCALSTATEDIR "log/ppp" #endif /* @@ -119,15 +140,4 @@ #define PPP_PATH_PPPDB PPP_PATH_VARRUN "/pppd2.tdb" -#ifdef __linux__ -#define PPP_PATH_LOCKDIR PPP_PATH_VARRUN "/lock" -#else -#ifdef SVR4 -#define PPP_PATH_LOCKDIR LOCALSTATEDIR "/spool/locks" -#else -#define PPP_PATH_LOCKDIR LOCALSTATEDIR "/spool/lock" -#endif -#endif - - #endif /* PPP_PATHNAMES_H */ diff --git a/pppd/pppdconf.h.in b/pppd/pppdconf.h.in index 9fb6f4b0f..a98d2d8d3 100644 --- a/pppd/pppdconf.h.in +++ b/pppd/pppdconf.h.in @@ -76,4 +76,13 @@ /* The pppd version */ #undef PPPD_VERSION +/* runtime dir as per configure's --with-runtime-dir */ +#undef PPPD_RUNTIME_DIR + +/* lock dir as per configure's --with-lock-dir */ +#undef PPPD_LOCK_DIR + +/* logfile dir as per configure's --with-logfile-dir */ +#undef PPPD_LOGFILE_DIR + #endif