]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
set up tmp dir for test suite to run on Android
authorHans-Christoph Steiner <hans@eds.org>
Wed, 16 Oct 2019 16:52:36 +0000 (18:52 +0200)
committerNick Mathewson <nickm@torproject.org>
Tue, 10 Dec 2019 20:55:40 +0000 (15:55 -0500)
There is no /tmp or mkdtemp on Android, there is /data/local/tmp for
root and the shell user. So this fakes mkdtemp.  Also, FYI, tor might
not like the default perms of /data/local/tmp, e.g. 0770.

https://trac.torproject.org/projects/tor/ticket/32172

src/test/testing_common.c

index c28d02be77c365e4eaa45f73e1b61c4a6de5cf78..378a6f1924b04fe14b1a8825485e8bea69de181a 100644 (file)
@@ -89,6 +89,17 @@ setup_directory(void)
                  (int)getpid(), rnd32);
     r = mkdir(temp_dir);
   }
+#elif defined(__ANDROID__)
+  /* tor might not like the default perms, so create a subdir */
+  tor_snprintf(temp_dir, sizeof(temp_dir),
+               "/data/local/tmp/tor_%d_%d_%s",
+               (int) getuid(), (int) getpid(), rnd32);
+  r = mkdir(temp_dir, 0700);
+  if (r) {
+    fprintf(stderr, "Can't create directory %s:", temp_dir);
+    perror("");
+    exit(1);
+  }
 #else /* !defined(_WIN32) */
   tor_snprintf(temp_dir, sizeof(temp_dir), "/tmp/tor_test_%d_%s",
                (int) getpid(), rnd32);