diff --git a/CHANGELOG.md b/CHANGELOG.md index 0eac391d..a8e18253 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 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 ### Added diff --git a/README.md b/README.md index 7fdc1a0f..499b1bca 100644 --- a/README.md +++ b/README.md @@ -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 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 - 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 diff --git a/src/common/utils.cpp b/src/common/utils.cpp index 7ea49807..37e937ff 100644 --- a/src/common/utils.cpp +++ b/src/common/utils.cpp @@ -32,9 +32,18 @@ using namespace std::literals::string_view_literals; */ 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() { 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(); } else { return fs::temp_directory_path();