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 } diff --git a/snapcraft.yaml b/snapcraft.yaml index 0bd0319..a9f4f7a 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 @@ -104,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 diff --git a/src/anbox/application/launcher_storage.cpp b/src/anbox/application/launcher_storage.cpp index 988281a..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 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(); + 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")); + } - f = std::ofstream(item_icon_path.string()); - f.write(item.icon.data(), item.icon.size()); - f.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 diff --git a/src/anbox/cmds/run.cpp b/src/anbox/cmds/run.cpp index 870cd50..dc701db 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 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.