Skip to content

Commit

Permalink
Allow running on non modern root filesystems
Browse files Browse the repository at this point in the history
All modern Linux systems have the ephemeral local state directory
created at "/run" - however this is not universal even across just the
supported Linux systems.

Add a configure option to set the location of run dir that is compiled
into the binary.

(See PR n42n#48 and n42n#49)
  • Loading branch information
hamishcoleman committed Aug 2, 2024
1 parent a17cf2c commit 0847c26
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,14 @@ INSTALL_DOC=$(INSTALL) -m444
# DESTDIR set in debian make system
PREFIX=$(DESTDIR)/$(CONFIG_PREFIX)

# Note that both these install dirs are outside of the CONFIG_PREFIX.
# Note that these three install dirs are outside of the CONFIG_PREFIX.
# The ETCDIR is not configurable in the code, so no changes should be done
# without code changes.
# The systemd unit dir should default to /lib for most Debian packages (if
# CONFIG_PREFIX is /usr) otherwise it should be based on the prefix.
# The current autotools has hacks to apply this logic.
ETCDIR=$(DESTDIR)/etc/n3n
CONFIG_RUNDIR?=$(DESTDIR)/run
CONFIG_SYSTEMDDIR?=$(DESTDIR)/lib/systemd/system

CONFIG_BINDIR?=$(PREFIX)/bin
Expand All @@ -78,6 +79,8 @@ MAN7DIR=$(CONFIG_MANDIR)/man7
MAN8DIR=$(CONFIG_MANDIR)/man8
CONFIG_DOCDIR?=$(PREFIX)/share/doc/n3n

CFLAGS+=-DCONFIG_RUNDIR='"$(CONFIG_RUNDIR)"'

#######################################
# All the additiona needed for using the n3n library
#
Expand Down
7 changes: 4 additions & 3 deletions config.mak.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ CONFIG_HOST=@host@
CONFIG_HOST_OS=@host_os@

CONFIG_PREFIX=@CONFIG_PREFIX@
CONFIG_DOCDIR=$(DESTDIR)/@CONFIG_DOCDIR@
CONFIG_MANDIR=$(DESTDIR)/@CONFIG_MANDIR@
CONFIG_SYSTEMDDIR=$(DESTDIR)/@CONFIG_SYSTEMDDIR@
CONFIG_DOCDIR=$(DESTDIR)@CONFIG_DOCDIR@
CONFIG_MANDIR=$(DESTDIR)@CONFIG_MANDIR@
CONFIG_RUNDIR=$(DESTDIR)@CONFIG_RUNDIR@
CONFIG_SYSTEMDDIR=$(DESTDIR)@CONFIG_SYSTEMDDIR@

CONFIG_WITH_OPENSSL=@with_openssl@

Expand Down
6 changes: 6 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ AS_IF([test "x$prefix" = "xNONE" ],
prefix=/usr/local
)

AS_IF([test "x$runstatedir" = 'x${localstatedir}/run' ],
runstatedir=/run
)

# The systemd unit dir should be in a sane location (based on the prefix) but
# that is not always a dir underneath the prefix. Apply another hack
AS_IF([test "x$systemddir" = "x" ],
Expand All @@ -134,13 +138,15 @@ AS_IF([test "x$systemddir" = "x" ],
CONFIG_DOCDIR=$(eval echo $(eval echo $docdir))
CONFIG_MANDIR=$(eval echo $(eval echo $mandir))
CONFIG_PREFIX=$prefix
CONFIG_RUNDIR=$runstatedir
CONFIG_SYSTEMDDIR=$systemddir

configure_command=$0$ac_configure_args_raw

AC_SUBST(CONFIG_DOCDIR)
AC_SUBST(CONFIG_MANDIR)
AC_SUBST(CONFIG_PREFIX)
AC_SUBST(CONFIG_RUNDIR)
AC_SUBST(CONFIG_SYSTEMDDIR)

AC_SUBST(configure_command)
Expand Down
2 changes: 1 addition & 1 deletion src/conffile.c
Original file line number Diff line number Diff line change
Expand Up @@ -1383,7 +1383,7 @@ int n3n_config_setup_sessiondir (n2n_edge_conf_t *conf) {


#ifndef _WIN32
char *basedir = "/run/n3n";
char *basedir = CONFIG_RUNDIR "/n3n";
#endif
#ifdef _WIN32
char basedir[1024];
Expand Down

0 comments on commit 0847c26

Please sign in to comment.