From 6a1dd315a64962898016ac77ba58f6ad1d9266f1 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste VESLIN Date: Fri, 1 Jan 2021 07:47:30 +0100 Subject: [PATCH] build: improve tmpdir management (#15) Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> --- src/mapserverapi.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/mapserverapi.c b/src/mapserverapi.c index 88179d0..0cef6f5 100644 --- a/src/mapserverapi.c +++ b/src/mapserverapi.c @@ -21,15 +21,21 @@ void mapserverapi_init() { if (tmp != NULL) { __MAPSERVERAPI_TMPDIR = g_strdup(tmp); } - tmp = g_getenv("TMPDIR"); - if (tmp != NULL) { - __MAPSERVERAPI_TMPDIR = g_strdup(tmp); - } - tmp = g_getenv("TMP"); - if (tmp != NULL) { - __MAPSERVERAPI_TMPDIR = g_strdup(tmp); + else { + tmp = g_getenv("TMPDIR"); + if (tmp != NULL) { + __MAPSERVERAPI_TMPDIR = g_strdup(tmp); + } + else { + tmp = g_getenv("TMP"); + if (tmp != NULL) { + __MAPSERVERAPI_TMPDIR = g_strdup(tmp); + } + else { + __MAPSERVERAPI_TMPDIR = g_strdup("/tmp"); + } + } } - __MAPSERVERAPI_TMPDIR = g_strdup("/tmp"); if (__MAPSERVER_SETUP == FALSE) { msSetup(); __MAPSERVER_SETUP = TRUE;