From b7937afc3c4e9a217f9666a2d6cf6ec9605f796d Mon Sep 17 00:00:00 2001 From: Simon Fels Date: Thu, 26 Jan 2017 07:27:13 +0100 Subject: [PATCH 1/7] Only warn when FUSE support for user namespaces couldn't be enabled --- scripts/container-manager.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/container-manager.sh b/scripts/container-manager.sh index e8b831d..ba708eb 100755 --- a/scripts/container-manager.sh +++ b/scripts/container-manager.sh @@ -95,7 +95,7 @@ start() { fi # Ensure FUSE support for user namespaces is enabled - echo Y > /sys/module/fuse/parameters/userns_mounts + echo Y | sudo tee /sys/module/fuse/parameters/userns_mounts || echo "WARNING: kernel doesn't support fuse in user namespaces" exec $SNAP/usr/sbin/aa-exec -p unconfined -- $SNAP/bin/anbox-wrapper.sh container-manager } From f9d95172c44cfe8c87339d7b3594a3ca4aa86d89 Mon Sep 17 00:00:00 2001 From: Simon Fels Date: Thu, 26 Jan 2017 07:28:13 +0100 Subject: [PATCH 2/7] Adjust indentation of launcher storage --- src/anbox/application/launcher_storage.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/anbox/application/launcher_storage.cpp b/src/anbox/application/launcher_storage.cpp index 988281a..9aab375 100644 --- a/src/anbox/application/launcher_storage.cpp +++ b/src/anbox/application/launcher_storage.cpp @@ -71,18 +71,18 @@ void LauncherStorage::add(const Item &item) { exec += utils::string_format("--component=%s ", item.launch_intent.component); - std::ofstream f(item_path.string()); - f << "[Desktop Entry]" << std::endl - << "Name=" << item.package << std::endl - << "Exec=" << exec << std::endl - << "Terminal=false" << std::endl - << "Type=Application" << std::endl - << "Icon=" << item_icon_path.string() << std::endl; - f.close(); + std::ofstream desktop_item(item_path.string()); + desktop_item << "[Desktop Entry]" << std::endl + << "Name=" << item.package << std::endl + << "Exec=" << exec << std::endl + << "Terminal=false" << std::endl + << "Type=Application" << std::endl + << "Icon=" << item_icon_path.string() << std::endl; + desktop_item.close(); - f = std::ofstream(item_icon_path.string()); - f.write(item.icon.data(), item.icon.size()); - f.close(); + std::ofstream icon(item_icon_path.string()); + icon.write(item.icon.data(), item.icon.size()); + icon.close(); } } // namespace application } // namespace anbox From 1459488bd3da377008456d43946e0dfbb18d91f7 Mon Sep 17 00:00:00 2001 From: Simon Fels Date: Thu, 26 Jan 2017 07:33:19 +0100 Subject: [PATCH 3/7] Drop old and unneeded icon flag for run command --- src/anbox/cmds/run.cpp | 3 --- src/anbox/cmds/run.h | 1 - 2 files changed, 4 deletions(-) diff --git a/src/anbox/cmds/run.cpp b/src/anbox/cmds/run.cpp index aa03481..596c6f9 100644 --- a/src/anbox/cmds/run.cpp +++ b/src/anbox/cmds/run.cpp @@ -81,9 +81,6 @@ anbox::cmds::Run::Run(const BusFactory &bus_factory) flag(cli::make_flag(cli::Name{"desktop_file_hint"}, cli::Description{"Desktop file hint for QtMir/Unity8"}, desktop_file_hint_)); - flag(cli::make_flag(cli::Name{"icon"}, - cli::Description{"Icon of the application to run"}, - icon_)); action([this](const cli::Command::Context &) { auto trap = core::posix::trap_signals_for_process( diff --git a/src/anbox/cmds/run.h b/src/anbox/cmds/run.h index 7e14a18..d0b3ec3 100644 --- a/src/anbox/cmds/run.h +++ b/src/anbox/cmds/run.h @@ -39,7 +39,6 @@ class Run : public cli::CommandWithFlagsAndAction { private: BusFactory bus_factory_; std::string desktop_file_hint_; - std::string icon_; }; } // namespace cmds } // namespace anbox From 51489edbfccb7b41b804f557a78d51a0d629775c Mon Sep 17 00:00:00 2001 From: Simon Fels Date: Thu, 26 Jan 2017 07:38:39 +0100 Subject: [PATCH 4/7] Don't build snap in debug mode anymore --- snapcraft.yaml | 3 --- 1 file changed, 3 deletions(-) diff --git a/snapcraft.yaml b/snapcraft.yaml index 0bd0319..c7b6c4e 100644 --- a/snapcraft.yaml +++ b/snapcraft.yaml @@ -88,9 +88,6 @@ parts: # FIXME: Anbox currently has some paths with hard coded prefixes. Once # that is fixed we can avoid using a prefix here. - -DCMAKE_INSTALL_PREFIX:PATH=/usr - # FIXME: When building in release mode we get a lot of error which cause - # the build to fail. - - -DCMAKE_BUILD_TYPE=debug build-packages: - build-essential - cmake From fba0b8215d47b4923a4340d86cfe6d463f8ce945 Mon Sep 17 00:00:00 2001 From: Simon Fels Date: Thu, 26 Jan 2017 07:38:52 +0100 Subject: [PATCH 5/7] Add missing dependency on boost-test --- snapcraft.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/snapcraft.yaml b/snapcraft.yaml index c7b6c4e..a9f4f7a 100644 --- a/snapcraft.yaml +++ b/snapcraft.yaml @@ -101,6 +101,7 @@ parts: - libboost-iostreams-dev - libboost-program-options-dev - libboost-system-dev + - libboost-test-dev - libboost-thread-dev - libcap-dev - libdbus-1-dev From 4b5613a02369f412dd4ef6d482d310f7aafd5096 Mon Sep 17 00:00:00 2001 From: Simon Fels Date: Thu, 26 Jan 2017 07:37:40 +0100 Subject: [PATCH 6/7] Use correct type for buffer size to avoid compiler time errors --- tests/anbox/graphics/buffered_io_stream_tests.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/anbox/graphics/buffered_io_stream_tests.cpp b/tests/anbox/graphics/buffered_io_stream_tests.cpp index 1a37986..4008586 100644 --- a/tests/anbox/graphics/buffered_io_stream_tests.cpp +++ b/tests/anbox/graphics/buffered_io_stream_tests.cpp @@ -51,7 +51,7 @@ TEST(BufferedIOStream, CommitBufferWritesOutToMessenger) { auto messenger = std::make_shared(); BufferedIOStream stream(messenger); - const auto buffer_size{1000}; + const size_t buffer_size{1000}; // We will write out the data we get in two junks of half the size // the original buffer has. EXPECT_CALL(*messenger, send_raw(_, buffer_size)) @@ -75,8 +75,8 @@ TEST(BufferedIOStream, WriterContinuesWhenSocketIsBusy) { auto messenger = std::make_shared(); BufferedIOStream stream(messenger); - const auto buffer_size{1000}; - const auto first_chunk_size{100}; + const size_t buffer_size{1000}; + const size_t first_chunk_size{100}; // The writer will check the error code of the send function // and will retry writing the next chunk when it doesn't get // EAGAIN anymore from the sender. From e2f51b80a1aa7a9a97214e5b061cac99158f0755 Mon Sep 17 00:00:00 2001 From: Simon Fels Date: Thu, 2 Feb 2017 12:37:49 +0100 Subject: [PATCH 7/7] Rework stream usage for desktop/icon file creation --- src/anbox/application/launcher_storage.cpp | 34 +++++++++++----------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/anbox/application/launcher_storage.cpp b/src/anbox/application/launcher_storage.cpp index 9aab375..ae036ef 100644 --- a/src/anbox/application/launcher_storage.cpp +++ b/src/anbox/application/launcher_storage.cpp @@ -48,10 +48,8 @@ void LauncherStorage::add(const Item &item) { auto package_name = item.package; std::replace(package_name.begin(), package_name.end(), '.', '-'); - const auto item_path = - path_ / utils::string_format("anbox-%s.desktop", package_name); - const auto item_icon_path = - icon_path_ / utils::string_format("anbox-%s.png", package_name); + const auto item_path = path_ / utils::string_format("anbox-%s.desktop", package_name); + const auto item_icon_path = icon_path_ / utils::string_format("anbox-%s.png", package_name); std::string exec = utils::string_format("%s launch ", utils::process_get_exe_path(getpid())); @@ -68,21 +66,23 @@ void LauncherStorage::add(const Item &item) { exec += utils::string_format("--package=%s ", item.launch_intent.package); if (!item.launch_intent.component.empty()) - exec += - utils::string_format("--component=%s ", item.launch_intent.component); + exec += utils::string_format("--component=%s ", item.launch_intent.component); - std::ofstream desktop_item(item_path.string()); - desktop_item << "[Desktop Entry]" << std::endl - << "Name=" << item.package << std::endl - << "Exec=" << exec << std::endl - << "Terminal=false" << std::endl - << "Type=Application" << std::endl - << "Icon=" << item_icon_path.string() << std::endl; - desktop_item.close(); + if (auto desktop_item = std::ofstream(item_path.string())) { + desktop_item << "[Desktop Entry]" << std::endl + << "Name=" << item.package << std::endl + << "Exec=" << exec << std::endl + << "Terminal=false" << std::endl + << "Type=Application" << std::endl + << "Icon=" << item_icon_path.string() << std::endl; + } else { + BOOST_THROW_EXCEPTION(std::runtime_error("Failed to create desktop item")); + } - std::ofstream icon(item_icon_path.string()); - icon.write(item.icon.data(), item.icon.size()); - icon.close(); + if (auto icon = std::ofstream(item_icon_path.string())) + icon.write(item.icon.data(), item.icon.size()); + else + BOOST_THROW_EXCEPTION(std::runtime_error("Failed to write icon")); } } // namespace application } // namespace anbox