浏览代码

Kernel+keymap+KeyboardMapper: New pledge for getkeymap

Ben Wiederhake 4 年之前
父节点
当前提交
cbee0c26e1
共有 4 个文件被更改,包括 11 次插入5 次删除
  1. 2 1
      Kernel/Process.h
  2. 1 1
      Kernel/Syscalls/keymap.cpp
  3. 7 2
      Userland/Applications/KeyboardMapper/main.cpp
  4. 1 1
      Userland/Utilities/keymap.cpp

+ 2 - 1
Kernel/Process.h

@@ -82,7 +82,8 @@ extern VirtualAddress g_return_to_ring3_from_signal_trampoline;
     __ENUMERATE_PLEDGE_PROMISE(settime)   \
     __ENUMERATE_PLEDGE_PROMISE(settime)   \
     __ENUMERATE_PLEDGE_PROMISE(sigaction) \
     __ENUMERATE_PLEDGE_PROMISE(sigaction) \
     __ENUMERATE_PLEDGE_PROMISE(setkeymap) \
     __ENUMERATE_PLEDGE_PROMISE(setkeymap) \
-    __ENUMERATE_PLEDGE_PROMISE(prot_exec)
+    __ENUMERATE_PLEDGE_PROMISE(prot_exec) \
+    __ENUMERATE_PLEDGE_PROMISE(getkeymap)
 
 
 enum class Pledge : u32 {
 enum class Pledge : u32 {
 #define __ENUMERATE_PLEDGE_PROMISE(x) x,
 #define __ENUMERATE_PLEDGE_PROMISE(x) x,

+ 1 - 1
Kernel/Syscalls/keymap.cpp

@@ -69,7 +69,7 @@ int Process::sys$setkeymap(Userspace<const Syscall::SC_setkeymap_params*> user_p
 
 
 int Process::sys$getkeymap(Userspace<const Syscall::SC_getkeymap_params*> user_params)
 int Process::sys$getkeymap(Userspace<const Syscall::SC_getkeymap_params*> user_params)
 {
 {
-    REQUIRE_PROMISE(stdio);
+    REQUIRE_PROMISE(getkeymap);
 
 
     Syscall::SC_getkeymap_params params;
     Syscall::SC_getkeymap_params params;
     if (!copy_from_user(&params, user_params))
     if (!copy_from_user(&params, user_params))

+ 7 - 2
Userland/Applications/KeyboardMapper/main.cpp

@@ -40,14 +40,14 @@ int main(int argc, char** argv)
     args_parser.add_positional_argument(path, "Keyboard character mapping file.", "file", Core::ArgsParser::Required::No);
     args_parser.add_positional_argument(path, "Keyboard character mapping file.", "file", Core::ArgsParser::Required::No);
     args_parser.parse(argc, argv);
     args_parser.parse(argc, argv);
 
 
-    if (pledge("stdio thread rpath accept cpath wpath recvfd sendfd unix fattr", nullptr) < 0) {
+    if (pledge("stdio getkeymap thread rpath accept cpath wpath recvfd sendfd unix fattr", nullptr) < 0) {
         perror("pledge");
         perror("pledge");
         return 1;
         return 1;
     }
     }
 
 
     auto app = GUI::Application::construct(argc, argv);
     auto app = GUI::Application::construct(argc, argv);
 
 
-    if (pledge("stdio thread rpath accept cpath wpath recvfd sendfd", nullptr) < 0) {
+    if (pledge("stdio getkeymap thread rpath accept cpath wpath recvfd sendfd", nullptr) < 0) {
         perror("pledge");
         perror("pledge");
         return 1;
         return 1;
     }
     }
@@ -69,6 +69,11 @@ int main(int argc, char** argv)
         keyboard_mapper_widget->load_from_system();
         keyboard_mapper_widget->load_from_system();
     }
     }
 
 
+    if (pledge("stdio thread rpath accept cpath wpath recvfd sendfd", nullptr) < 0) {
+        perror("pledge");
+        return 1;
+    }
+
     // Actions
     // Actions
     auto open_action = GUI::CommonActions::make_open_action(
     auto open_action = GUI::CommonActions::make_open_action(
         [&](auto&) {
         [&](auto&) {

+ 1 - 1
Userland/Utilities/keymap.cpp

@@ -32,7 +32,7 @@
 
 
 int main(int argc, char** argv)
 int main(int argc, char** argv)
 {
 {
-    if (pledge("stdio setkeymap rpath", nullptr) < 0) {
+    if (pledge("stdio setkeymap getkeymap rpath", nullptr) < 0) {
         perror("pledge");
         perror("pledge");
         return 1;
         return 1;
     }
     }