Skip to content

Commit

Permalink
Make lock dir configurable
Browse files Browse the repository at this point in the history
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: 66a8c74 ("Let ./configure control the paths for pppd")
Fixes: #419
Signed-off-by: Dominique Martinet <[email protected]>
  • Loading branch information
martinetd committed Aug 3, 2023
1 parent 091e69b commit 70ad859
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 29 deletions.
25 changes: 16 additions & 9 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}
Expand Down
2 changes: 1 addition & 1 deletion pppd/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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 =

Expand Down
48 changes: 29 additions & 19 deletions pppd/pathnames.h
Original file line number Diff line number Diff line change
Expand Up @@ -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=<dir>
* - PPPD_LOGFILE_DIR, set by --with-logfile-dir=<dir>
* - PPPD_PLUGIN_DIR, set by --with-plugin-dir=<dir>
* In addition, there are explicit variables that have overrides via configure:
* - SYSCONFDIR, set by --sysconfdir=<dir> or its platform default
* - LOCALSATEDIR, set by --localstatedir=<dir> or its platform default
* - PPPD_RUNTIME_DIR, set by --with-runtime-dir=<dir> or undef
* - PPPD_LOCK_DIR, set by --with-lock-dir=<dir> or undef
* - PPPD_LOGFILE_DIR, set by --with-logfile-dir=<dir> or undef
* If pppd is built with plugins, additionally:
* - PPPD_PLUGIN_DIR, set by --with-plugin-dir=<dir> or its platform default
*/
#ifndef PPP_PATHNAMES_H
#define PPP_PATHNAMES_H
Expand All @@ -59,22 +63,39 @@

/*
* PPPD_RUNTIME_DIR is set by passing --with-runtime-dir=<path> 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=<path> 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=<path> 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

/*
Expand Down Expand Up @@ -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 */
9 changes: 9 additions & 0 deletions pppd/pppdconf.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 70ad859

Please sign in to comment.