nixpkgs/pkgs/applications/networking/p2p/gnunet/tmpdir.patch
Ludovic Courtès eddce10d13 Add GNUnet, GNU's anonymous peer-to-peer communication framework.
svn path=/nixpkgs/trunk/; revision=12699
2008-08-24 18:48:09 +00:00

94 lines
2.7 KiB
Diff

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)
{