From 4863d25e2c76ff3c9dc031b5cd3e67572eeb3894 Mon Sep 17 00:00:00 2001 From: Simon Fels Date: Tue, 14 Mar 2017 08:06:58 +0100 Subject: [PATCH] Use correct path for the anbox binary when running from within a snap --- src/anbox/application/launcher_storage.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/anbox/application/launcher_storage.cpp b/src/anbox/application/launcher_storage.cpp index cb8f5f1..a94602d 100644 --- a/src/anbox/application/launcher_storage.cpp +++ b/src/anbox/application/launcher_storage.cpp @@ -25,6 +25,12 @@ namespace fs = boost::filesystem; +namespace { +// This will always point us to the right executable when we're running within +// a snap environment. +constexpr const char *snap_exe_path{"/snap/bin/anbox"}; +} + namespace anbox { namespace application { LauncherStorage::LauncherStorage(const fs::path &path, @@ -62,7 +68,11 @@ void LauncherStorage::add_or_update(const Item &item) { auto package_name = item.package; std::replace(package_name.begin(), package_name.end(), '.', '-'); - std::string exec = utils::string_format("%s launch ", utils::process_get_exe_path(getpid())); + auto exe_path = utils::process_get_exe_path(getpid()); + if (utils::get_env_value("SNAP").length() > 0) + exe_path = snap_exe_path; + + std::string exec = utils::string_format("%s launch ", exe_path); if (!item.launch_intent.action.empty()) exec += utils::string_format("--action=%s ", item.launch_intent.action);