diff --git a/src/anbox/input/device.cpp b/src/anbox/input/device.cpp index 0364296ae5bddd66b45b3ca06892658b3eb0daee..64637bd2cf7e13230be28f2e676a0e18bda0eeaf 100644 --- a/src/anbox/input/device.cpp +++ b/src/anbox/input/device.cpp @@ -38,6 +38,10 @@ std::shared_ptr Device::create( sp->connector_ = std::make_shared( path, runtime, delegate_connector); + // The socket is created with user permissions (e.g. rwx------), + // which prevents the container from accessing it. Make sure it is writable. + ::chmod(path.c_str(), S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH); + return sp; } diff --git a/src/anbox/input/manager.cpp b/src/anbox/input/manager.cpp index eacdd8baf48dd2677c9a2076bed5ec9d4983b900..fb32f559784388f7e8f52289fb30bbabe767aa4c 100644 --- a/src/anbox/input/manager.cpp +++ b/src/anbox/input/manager.cpp @@ -26,7 +26,12 @@ namespace anbox { namespace input { Manager::Manager(const std::shared_ptr &runtime) : runtime_(runtime) { - utils::ensure_paths({SystemConfiguration::instance().input_device_dir()}); + const auto dir = SystemConfiguration::instance().input_device_dir(); + utils::ensure_paths({dir}); + + // The directory is bind-mounted into the container but might have user + // permissions only (rwx------). Make sure it is accessible. + ::chmod(dir.c_str(), S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH); } Manager::~Manager() {} diff --git a/src/anbox/platform/null/platform.cpp b/src/anbox/platform/null/platform.cpp index 9d2a339ba1be05cda18f54f6180be9321ba9976a..b7d7badb7875945c7319911300a07930202be362 100644 --- a/src/anbox/platform/null/platform.cpp +++ b/src/anbox/platform/null/platform.cpp @@ -33,6 +33,8 @@ namespace anbox { namespace platform { NullPlatform::NullPlatform() {} +NullPlatform::~NullPlatform() {} + std::shared_ptr NullPlatform::create_window( const anbox::wm::Task::Id &task, const anbox::graphics::Rect &frame, const std::string &title) { return std::make_shared<::NullWindow>(task, frame, title); diff --git a/src/anbox/platform/null/platform.h b/src/anbox/platform/null/platform.h index beb53aea6c3e9904a6b3d28002290da0ae9c52f2..c80ed90b82adec1f2ba243b441000805f039edc6 100644 --- a/src/anbox/platform/null/platform.h +++ b/src/anbox/platform/null/platform.h @@ -25,6 +25,7 @@ namespace platform { class NullPlatform : public BasePlatform { public: NullPlatform(); + ~NullPlatform(); std::shared_ptr create_window( const anbox::wm::Task::Id &task, const anbox::graphics::Rect &frame, diff --git a/src/anbox/platform/sdl/platform.cpp b/src/anbox/platform/sdl/platform.cpp index 3e27218733af68bffb0bf37457990131c865959f..20197c052e6125348cd8a82b56ca909ff7f5e363 100644 --- a/src/anbox/platform/sdl/platform.cpp +++ b/src/anbox/platform/sdl/platform.cpp @@ -174,6 +174,10 @@ void Platform::create_ime_socket() { return; } socket_addr.sun_family = AF_UNIX; + if (ime_socket_file_.length() >= strlen(socket_addr.sun_path) - 1) { + ERROR("Create ime failed, socket path too long"); + return; + } strcpy(socket_addr.sun_path, ime_socket_file_.c_str()); unlink(ime_socket_file_.c_str()); rc = bind(ime_socket, reinterpret_cast(&socket_addr), sizeof(socket_addr)); diff --git a/src/anbox/platform/sdl/window.cpp b/src/anbox/platform/sdl/window.cpp index c5bf61e32e6667508d0166657d90c7bdfe75e892..24b4c7973469aff4d1c7206b0048fc5ad5d07811 100755 --- a/src/anbox/platform/sdl/window.cpp +++ b/src/anbox/platform/sdl/window.cpp @@ -38,12 +38,20 @@ constexpr const int button_padding{0}; namespace anbox { namespace platform { namespace sdl { -Window::Id Window::Invalid{-1}; -const std::map Window::property_map = { - {"喜马拉雅", Window::HIDE_MAXIMIZE}, - {"i深圳", Window::HIDE_MAXIMIZE} + +static const std::uint32_t HIDE_BACK = 0x01; +static const std::uint32_t HIDE_MINIMIZE = 0x02; +static const std::uint32_t HIDE_MAXIMIZE = 0x04; +static const std::uint32_t HIDE_CLOSE = 0x08; +static const std::uint32_t SHOW_ALL = 0x00; + +const std::map Window::property_map = { + {"喜马拉雅", HIDE_MAXIMIZE}, + {"i深圳", HIDE_MAXIMIZE} }; +Window::Id Window::Invalid{-1}; + Window::Observer::~Observer() {} Window::Window(const std::shared_ptr &renderer, @@ -56,7 +64,8 @@ Window::Window(const std::shared_ptr &renderer, id_(id), lastClickTime(0), observer_(observer), - native_display_(0){ + native_display_(0), + visible_property(SHOW_ALL) { SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 1); // NOTE: We don't furce GL initialization of the window as this will @@ -68,12 +77,11 @@ Window::Window(const std::shared_ptr &renderer, auto property_itr = property_map.find(title); if (property_itr != property_map.end()) { visible_property = property_itr->second; - if (!(visible_property & HIDE_MAXIMIZE) && resizable) { - flags |= SDL_WINDOW_RESIZABLE; - } - } else if (resizable) { + } + if (!(visible_property & HIDE_MAXIMIZE) && resizable) { flags |= SDL_WINDOW_RESIZABLE; } + window_ = SDL_CreateWindow(title.c_str(), frame.left(), frame.top(), frame.width(), frame.height(), diff --git a/src/anbox/platform/sdl/window.h b/src/anbox/platform/sdl/window.h index 41884af2e70d8a30c20ba20739a39243347d47bb..0afdf2338fdc6ac1fa4bf94ac6fac17ea7856763 100755 --- a/src/anbox/platform/sdl/window.h +++ b/src/anbox/platform/sdl/window.h @@ -42,15 +42,7 @@ class Window : public std::enable_shared_from_this, public wm::Window { static const long long APP_START_MAX_TIME = 15 * USEC_PER_SEC; static const long long timespan_db_click = 500000; - enum window_property{ - HIDE_BACK = 0x01, - HIDE_MINIMIZE = 0x02, - HIDE_MAXIMIZE = 0x04, - HIDE_CLOSE = 0x08, - SHOW_ALL = 0x00 - }; - - static const std::map property_map; + static const std::map property_map; class Observer { public: @@ -82,7 +74,7 @@ class Window : public std::enable_shared_from_this, public wm::Window { Id id() const; std::uint32_t window_id() const; Uint32 GetWindowFlags(){return SDL_GetWindowFlags(window_);} - inline window_property get_property() { + inline std::uint32_t get_property() { return visible_property; } @@ -102,7 +94,7 @@ class Window : public std::enable_shared_from_this, public wm::Window { int last_point_y{ 0 }; int last_wnd_x{ 0 }; int last_wnd_y{ 0 }; - window_property visible_property{ SHOW_ALL }; + std::uint32_t visible_property; }; } // namespace sdl } // namespace platform