Add an environment variable for custom temp dirs

This would be useful if you need to do some elaborate namespacing setup
and want all sockets and other temporary files in a single directory
instead of in `${XDG_RUNTIME_DIR:/tmp}`.

This resolves #139.
This commit is contained in:
Robbert van der Helm
2021-10-16 01:41:48 +02:00
parent e79d1ec03a
commit 3257b9c32e
3 changed files with 22 additions and 2 deletions
+9
View File
@@ -6,6 +6,15 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic and this project adheres to [Semantic
Versioning](https://semver.org/spec/v2.0.0.html). Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
### Added
- Added an environment variable to choose a different directory for yabridge to
store its sockets and other temporary files in. This is only needed when
running the Wine process under a separate namespace. If you don't know that
you need this, then you probably don't need this!
## [3.6.0] - 2021-10-15 ## [3.6.0] - 2021-10-15
### Added ### Added
+3 -1
View File
@@ -668,7 +668,9 @@ the yabridge [Discord](https://discord.gg/pyNeweqadf).
- If you're using a `WINELOADER` that runs the Wine process under a separate - If you're using a `WINELOADER` that runs the Wine process under a separate
namespace while the host is not sandboxed, then you'll have to use the namespace while the host is not sandboxed, then you'll have to use the
`YABRIDGE_NO_WATCHDOG` environment variable to disable the watchdog timer. If `YABRIDGE_NO_WATCHDOG` environment variable to disable the watchdog timer. If
you know what this means then you probably know what you're doing. you know what this means then you probably know what you're doing. In that
case, you may also want to use `YABRIDGE_TEMP_PATH` to choose a different
directory for yabridge to store its sockets and other temporary files in.
## Performance tuning ## Performance tuning
+10 -1
View File
@@ -32,9 +32,18 @@ using namespace std::literals::string_view_literals;
*/ */
constexpr char disable_watchdog_timer_env_var[] = "YABRIDGE_NO_WATCHDOG"; constexpr char disable_watchdog_timer_env_var[] = "YABRIDGE_NO_WATCHDOG";
/**
* If this environment variable is set, yabridge will store its sockets and
* other temporary files here instead of in `$XDG_RUNTIME_DIR` or `/tmp`. This
* is only relevant when using some namespacing setup for sandboxing.
*/
constexpr char temp_dir_override_env_var[] = "YABRIDGE_TEMP_PATH";
fs::path get_temporary_directory() { fs::path get_temporary_directory() {
bp::environment env = boost::this_process::environment(); bp::environment env = boost::this_process::environment();
if (!env["XDG_RUNTIME_DIR"].empty()) { if (!env[temp_dir_override_env_var].empty()) {
return env[temp_dir_override_env_var].to_string();
} else if (!env["XDG_RUNTIME_DIR"].empty()) {
return env["XDG_RUNTIME_DIR"].to_string(); return env["XDG_RUNTIME_DIR"].to_string();
} else { } else {
return fs::temp_directory_path(); return fs::temp_directory_path();