summary refs log tree commit diff
path: root/pkgs/applications/networking/p2p/gnunet/tmpdir.patch
blob: e47a253e0f0ff932806b11706d8c02242982dd23 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
Make sure the core libraries used by the tests honor $TMPDIR.

diff --git a/src/applications/dstore_sqlite/dstore.c b/src/applications/dstore_sqlite/dstore.c
index cdcae81..4bb45a3 100644
--- a/src/applications/dstore_sqlite/dstore.c
+++ b/src/applications/dstore_sqlite/dstore.c
@@ -129,6 +129,7 @@ db_reset ()
   int fd;
   sqlite3 *dbh;
   char *tmpl;
+  const char *tmpdir;
 
   if (fn != NULL)
     {
@@ -136,7 +137,15 @@ db_reset ()
       GNUNET_free (fn);
     }
   payload = 0;
-  tmpl = "/tmp/dstoreXXXXXX";
+
+  tmpdir = getenv ("TMPDIR");
+  tmpdir = tmpdir ? tmpdir : "/tmp";
+
+#define TEMPLATE "/gnunet-dstoreXXXXXX"
+  tmpl = alloca (strlen (tmpdir) + sizeof (TEMPLATE) + 1);
+  strcpy (tmpl, tmpdir);
+  strcat (tmpl, TEMPLATE);
+#undef TEMPLATE
 
 #ifdef MINGW
   fn = (char *) GNUNET_malloc (MAX_PATH + 1);
diff --git a/src/applications/fs/collection/collection.c b/src/applications/fs/collection/collection.c
index 5671cb3..da2b605 100644
--- a/src/applications/fs/collection/collection.c
+++ b/src/applications/fs/collection/collection.c
@@ -487,6 +487,7 @@ GNUNET_CO_collection_publish_now ()
   char *dirData;
   char this_revision_string[128];
   char next_revision_string[128];
+  const char *tmpdir;
 
   GNUNET_mutex_lock (lock);
   if ((collectionData == NULL) ||
@@ -495,7 +496,17 @@ GNUNET_CO_collection_publish_now ()
       GNUNET_mutex_unlock (lock);
       return;
     }
-  tmpName = GNUNET_strdup ("/tmp/gnunet-collectionXXXXXX");
+
+  tmpdir = getenv ("TMPDIR");
+  tmpdir = tmpdir ? tmpdir : "/tmp";
+
+#define TEMPLATE "/gnunet-collectionXXXXXX"
+  tmpName = alloca (strlen (tmpdir) + sizeof (TEMPLATE) + 1);
+  strcpy (tmpName, tmpdir);
+  strcat (tmpName, TEMPLATE);
+#undef TEMPLATE
+
+  tmpName = GNUNET_strdup (tmpName);
   fd = mkstemp (tmpName);
   if (fd == -1)
     {
diff --git a/src/applications/fs/fsui/upload.c b/src/applications/fs/fsui/upload.c
index dc683a5..46a04af 100644
--- a/src/applications/fs/fsui/upload.c
+++ b/src/applications/fs/fsui/upload.c
@@ -159,6 +159,7 @@ createDirectoryHelper (struct GNUNET_GE_Context *ectx,
   int handle;
   struct GNUNET_GE_Memory *mem;
   struct GNUNET_GE_Context *ee;
+  const char *tmpdir;
 
   fis = NULL;
   size = 0;
@@ -208,7 +209,17 @@ createDirectoryHelper (struct GNUNET_GE_Context *ectx,
       pos = pos->next;
     }
   GNUNET_GE_memory_reset (mem);
-  tempName = GNUNET_strdup ("/tmp/gnunet-upload-dir.XXXXXX");
+
+  tmpdir = getenv ("TMPDIR");
+  tmpdir = tmpdir ? tmpdir : "/tmp";
+
+#define TEMPLATE "/gnunet-upload-dirXXXXXX"
+  tempName = alloca (strlen (tmpdir) + sizeof (TEMPLATE) + 1);
+  strcpy (tempName, tmpdir);
+  strcat (tempName, TEMPLATE);
+#undef TEMPLATE
+
+  tempName = GNUNET_strdup (tempName);
   handle = mkstemp (tempName);
   if (handle == -1)
     {