提交 9cddabcb 编写于 作者: O openeuler-ci-bot 提交者: Gitee

!63 input: Ensure sockets are accessible from within the container & code style

Merge pull request !63 from Night/master
......@@ -38,6 +38,10 @@ std::shared_ptr<Device> Device::create(
sp->connector_ = std::make_shared<network::PublishedSocketConnector>(
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;
}
......
......@@ -26,7 +26,12 @@
namespace anbox {
namespace input {
Manager::Manager(const std::shared_ptr<Runtime> &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() {}
......
......@@ -33,6 +33,8 @@ namespace anbox {
namespace platform {
NullPlatform::NullPlatform() {}
NullPlatform::~NullPlatform() {}
std::shared_ptr<wm::Window> 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);
......
......@@ -25,6 +25,7 @@ namespace platform {
class NullPlatform : public BasePlatform {
public:
NullPlatform();
~NullPlatform();
std::shared_ptr<wm::Window> create_window(
const anbox::wm::Task::Id &task,
const anbox::graphics::Rect &frame,
......
......@@ -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<struct sockaddr *>(&socket_addr), sizeof(socket_addr));
......
......@@ -38,12 +38,20 @@ constexpr const int button_padding{0};
namespace anbox {
namespace platform {
namespace sdl {
Window::Id Window::Invalid{-1};
const std::map<std::string, Window::window_property> 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<std::string, std::uint32_t> Window::property_map = {
{"喜马拉雅", HIDE_MAXIMIZE},
{"i深圳", HIDE_MAXIMIZE}
};
Window::Id Window::Invalid{-1};
Window::Observer::~Observer() {}
Window::Window(const std::shared_ptr<Renderer> &renderer,
......@@ -56,7 +64,8 @@ Window::Window(const std::shared_ptr<Renderer> &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> &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(),
......
......@@ -42,15 +42,7 @@ class Window : public std::enable_shared_from_this<Window>, 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<std::string, window_property> property_map;
static const std::map<std::string, std::uint32_t> property_map;
class Observer {
public:
......@@ -82,7 +74,7 @@ class Window : public std::enable_shared_from_this<Window>, 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<Window>, 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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册