From 68dae7776caaf910a171f8b18c9480ed762ec73e Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Fri, 15 Oct 2021 09:49:57 +0200 Subject: [PATCH 1/3] do not use SHARE_DATADIR on Android There is no absolute install path that an app can expect data files on Android. Everything is expected to be a path inside of the app, and those paths depend on the Application ID of the app. /data/local/tmp is guaranteed to exist, but will only be usable by the 'shell' and 'root' users, so this fallback is for debugging only. This fixes a reproducible issue where the tor-android build harness ended up including build paths for SHARE_DATADIR. https://gitlab.torproject.org/tpo/core/tor/-/merge_requests/460 --- src/app/config/config.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/app/config/config.c b/src/app/config/config.c index 15b4585954..aca172cbe7 100644 --- a/src/app/config/config.c +++ b/src/app/config/config.c @@ -473,6 +473,13 @@ static const config_var_t option_vars_[] = { #ifdef _WIN32 V(GeoIPFile, FILENAME, ""), V(GeoIPv6File, FILENAME, ""), +#elif defined(__ANDROID__) + /* Android apps use paths that are configured at runtime. + * /data/local/tmp is guaranteed to exist, but will only be + * usable by the 'shell' and 'root' users, so this fallback is + * for debugging only. */ + V(GeoIPFile, FILENAME, "/data/local/tmp/geoip"), + V(GeoIPv6File, FILENAME, "/data/local/tmp/geoip6"), #else V(GeoIPFile, FILENAME, SHARE_DATADIR PATH_SEPARATOR "tor" PATH_SEPARATOR "geoip"), From ccdae2f753ea7125962f65fc50478753e40cc76b Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Fri, 15 Oct 2021 10:18:31 +0200 Subject: [PATCH 2/3] On Android, get_data_directory() should not use LOCALSTATEDIR closes https://gitlab.torproject.org/tpo/core/tor/-/issues/40487 --- src/app/config/config.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/app/config/config.c b/src/app/config/config.c index 8df5275cc6..3c3499696b 100644 --- a/src/app/config/config.c +++ b/src/app/config/config.c @@ -6883,6 +6883,15 @@ get_data_directory(const char *val) } else { return tor_strdup(get_windows_conf_root()); } +#elif defined(__ANDROID__) + /* Android apps can only use paths that are configured at runtime. + * /data/local/tmp is guaranteed to exist, but is only usable by the + * 'shell' and 'root' users, so this fallback is for debugging only. */ + if (val) { + return tor_strdup(val); + } else { + return tor_strdup("/data/local/tmp"); + } #else /* !defined(_WIN32) */ const char *d = val; if (!d) From a8b573a322542f882cd2d51fad12847d458c3480 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20F=C3=A6r=C3=B8y?= Date: Wed, 13 Sep 2023 18:39:55 +0200 Subject: [PATCH 3/3] Add changes file for tpo/core/tor#40487 (and its MR's). --- changes/ticket40487 | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 changes/ticket40487 diff --git a/changes/ticket40487 b/changes/ticket40487 new file mode 100644 index 0000000000..bd64d475b8 --- /dev/null +++ b/changes/ticket40487 @@ -0,0 +1,3 @@ + o Minor features (portability, android): + - Use /data/local/tmp for data storage on Android by default. Closes ticket + 40487. Patch from Hans-Christoph Steiner.