From 07fe3c7bace803bb545db43cf922e81eb4f49f89 Mon Sep 17 00:00:00 2001 From: Simon Fels Date: Fri, 18 May 2018 17:27:39 +0200 Subject: [PATCH] Move runtime sockets etc. into SNAP_USER_COMMON / SNAP_COMMON --- src/anbox/system_configuration.cpp | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/anbox/system_configuration.cpp b/src/anbox/system_configuration.cpp index 675c9e5..0d3d8ed 100644 --- a/src/anbox/system_configuration.cpp +++ b/src/anbox/system_configuration.cpp @@ -30,9 +30,14 @@ namespace { static std::string runtime_dir() { static std::string path; if (path.empty()) { - path = anbox::utils::get_env_value("XDG_RUNTIME_DIR", ""); - if (path.empty()) - BOOST_THROW_EXCEPTION(std::runtime_error("No runtime directory specified")); + const auto snap_user_common = anbox::utils::get_env_value("SNAP_USER_COMMON"); + if (!snap_user_common.empty()) + path = (fs::path(snap_user_common) / "runtime").string(); + else { + path = anbox::utils::get_env_value("XDG_RUNTIME_DIR"); + if (path.empty()) + BOOST_THROW_EXCEPTION(std::runtime_error("No runtime directory specified")); + } } return path; } @@ -59,7 +64,15 @@ std::string anbox::SystemConfiguration::container_config_dir() const { } std::string anbox::SystemConfiguration::container_socket_path() const { - return "/run/anbox-container.socket"; + static std::string path; + if (path.empty()) { + const auto snap_common = anbox::utils::get_env_value("SNAP_COMMON"); + if (!snap_common.empty()) + path = (fs::path(snap_common) / "sockets" / "anbox-container.socket").string(); + else + path = "/run/anbox-container.socket"; + } + return path; } std::string anbox::SystemConfiguration::socket_dir() const {