From 10cca4767b7479df01f74a3f36bb3d835a149827 Mon Sep 17 00:00:00 2001 From: Martijn Dekker Date: Sat, 12 Sep 2020 18:28:10 +0200 Subject: [PATCH] libast: update /usr/tmp fallback to /var/tmp To find the temporary files directory to use, the pathtemp() function (generate a unique path to a temporary file) first checks $TMPDIR and $TMPPATH, then falls back to /tmp, then to /usr/tmp as a last resort. But all systems replaced /usr/tmp by /var/tmp decades ago to allow mounting /usr as read-only, and a /usr/tmp compatibility symlink is no longer commonly provided. src/lib/libast/path/pathtemp.c: - Change TMP2 definition from "/usr/tmp" to "/var/tmp". src/lib/libast/features/mmap, src/lib/libast/features/stdio: - Change "/usr/tmp" to "/var/tmp" in feature tests. --- src/lib/libast/features/mmap | 2 +- src/lib/libast/features/stdio | 2 +- src/lib/libast/path/pathtemp.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/libast/features/mmap b/src/lib/libast/features/mmap index 41ac44e7e..efd695996 100644 --- a/src/lib/libast/features/mmap +++ b/src/lib/libast/features/mmap @@ -35,7 +35,7 @@ tst lib_mmap note{ standard mmap interface that works }end execute{ /* create data file in a local fs if possible */ t = file; if (access(f = "/tmp", 0) == 0 || - access(f = "/usr/tmp", 0) == 0) + access(f = "/var/tmp", 0) == 0) { while (*t = *f++) t++; diff --git a/src/lib/libast/features/stdio b/src/lib/libast/features/stdio index b32389399..b563f5bbe 100644 --- a/src/lib/libast/features/stdio +++ b/src/lib/libast/features/stdio @@ -336,7 +336,7 @@ macro{ <<"#endif">> <<"#ifndef P_tmpdir">> #ifndef P_tmpdir - #define P_tmpdir "/usr/tmp/" + #define P_tmpdir "/var/tmp/" #endif <<"#define P_tmpdir">> P_tmpdir <<"/*NOCATLITERAL*/">> <<"#endif">> diff --git a/src/lib/libast/path/pathtemp.c b/src/lib/libast/path/pathtemp.c index 844c86ae5..9ace96189 100644 --- a/src/lib/libast/path/pathtemp.c +++ b/src/lib/libast/path/pathtemp.c @@ -79,7 +79,7 @@ #define TMP_ENV "TMPDIR" #define TMP_PATH_ENV "TMPPATH" #define TMP1 "/tmp" -#define TMP2 "/usr/tmp" +#define TMP2 "/var/tmp" #define VALID(d) (*(d)&&!eaccess(d,W_OK|X_OK))