commit 2211bb8f972a2313936baf3c0f699ccf2e85b296
parent 5ddfc2131c520a35c34d998bb58985b6fcba5b2a
Author: Daniel Fahlgren <daniel@fahlgren.se>
Date: Wed, 17 Aug 2022 13:16:25 +0200
Some platforms doesn't have a /tmp/ directory where temporary files can be
stored. Make it possible to override that location compile time.
Diffstat:
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/Makefile b/Makefile
@@ -13,6 +13,7 @@ MAN_DIR?=$(PREFIX)/share/man
SHARE_DIR=$(PREFIX)/share/kore
INCLUDE_DIR=$(PREFIX)/include/kore
TLS_BACKEND?=openssl
+KORE_TMPDIR?=/tmp
TOOLS= kore-serve
@@ -56,7 +57,7 @@ endif
endif
ifneq ("$(KORE_SINGLE_BINARY)", "")
- CFLAGS+=-DKORE_SINGLE_BINARY
+ CFLAGS+=-DKORE_SINGLE_BINARY -DKORE_TMPDIR='"$(KORE_TMPDIR)"'
FEATURES+=-DKORE_SINGLE_BINARY
endif
diff --git a/src/config.c b/src/config.c
@@ -761,7 +761,8 @@ config_file_write(void)
int fd, len;
char fpath[MAXPATHLEN];
- len = snprintf(fpath, sizeof(fpath), "/tmp/%s.XXXXXX", __progname);
+ len = snprintf(fpath, sizeof(fpath), "%s/%s.XXXXXX", KORE_TMPDIR,
+ __progname);
if (len == -1 || (size_t)len >= sizeof(fpath))
fatal("failed to create temporary path");