From 6ebadf1d23eb9f945cbd6774badda807e7075778 Mon Sep 17 00:00:00 2001 From: augustin64 Date: Tue, 28 Nov 2023 10:00:29 +0100 Subject: [PATCH] Add a config.h parameter for base TMPDIR --- src/main/include/config.h | 4 +++- src/main/utils.c | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/include/config.h b/src/main/include/config.h index 9b9f1f6..2f5731b 100644 --- a/src/main/include/config.h +++ b/src/main/include/config.h @@ -1,9 +1,11 @@ #ifndef DEF_CONFIG_H #define DEF_CONFIG_H -#define VERSION "1.3.4" +#define VERSION "1.3.5" #define MAX_TASK_ID 10000 // max is set to MAX_TASK_ID-1 #define NEW_TASK_ID_MAX_RETRIES 10000 // number of retries before giving up +#define TMPDIR "/tmp" // Some Unix systems don't use /tmp as tmp dir (eg Android) + #endif \ No newline at end of file diff --git a/src/main/utils.c b/src/main/utils.c index 6b470af..7b4e324 100644 --- a/src/main/utils.c +++ b/src/main/utils.c @@ -19,9 +19,12 @@ char* get_socket_path() { return socket_path; } else { - char* base_path = "/tmp/takl"; + char* base_path = TMPDIR "/takl"; char* username = getenv("USER"); + if (!username) + username = getenv("USERNAME"); + assert(username != NULL); char* socket_path = malloc(sizeof(char)*(strlen(base_path)+strlen(username)+1));