Skip to contentSkip to conversation

Honor TMPDIR environment variable

PATCH In review Aurelien Jarno 1 participant 2 messages Jan 28, 2008 – Feb 18, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Honor TMPDIR environment variable

The patch below adds support for the -snapshot option to use the TMPDIR environment variable.

---
 block.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
block.c +5 -1
index 0f8ad7b..0730954 100644
@@ -191,8 +191,12 @@ void get_tmp_filename(char *filename, int size)
 void get_tmp_filename(char *filename, int size)
 {
     int fd;
+    char *tmpdir;
     /* XXX: race condition possible */
-    pstrcpy(filename, size, "/tmp/vl.XXXXXX");
+    tmpdir = getenv("TMPDIR");
+    if (!tmpdir)
+        tmpdir = "/tmp";
+    snprintf(filename, size, "%s/vl.XXXXXX", tmpdir);
     fd = mkstemp(filename);
     close(fd);
 }
Signature · 4 lines
  .''`.  Aurelien Jarno	            | GPG: 1024D/F1BCDB73
 : :' :  Debian developer           | Electrical Engineer
 `. `'   [email protected]         | [email protected]
   `-    people.debian.org/~aurel32 | www.aurel32.net
#1 lore raw

Any news about this patch?

Quoted 26 lines · Aurelien Jarno

The patch below adds support for the -snapshot option to use the TMPDIR environment variable.

---
 block.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
block.c +5 -1
index 0f8ad7b..0730954 100644
@@ -191,8 +191,12 @@ void get_tmp_filename(char *filename, int size)
 void get_tmp_filename(char *filename, int size)
 {
     int fd;
+    char *tmpdir;
     /* XXX: race condition possible */
-    pstrcpy(filename, size, "/tmp/vl.XXXXXX");
+    tmpdir = getenv("TMPDIR");
+    if (!tmpdir)
+        tmpdir = "/tmp";
+    snprintf(filename, size, "%s/vl.XXXXXX", tmpdir);
     fd = mkstemp(filename);
     close(fd);
 }
Signature · 4 lines
  .''`.  Aurelien Jarno	            | GPG: 1024D/F1BCDB73
 : :' :  Debian developer           | Electrical Engineer
 `. `'   [email protected]         | [email protected]
   `-    people.debian.org/~aurel32 | www.aurel32.net