mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 06:47:35 +00:00
KeyboardSettings: Call out to /bin/keymap to actually set the keymap
Now that KeyboardSettings is no longer setuid-root, we have to call out to a helper program to actually set the keymap. This is a very nice improvement to system security. :^)
This commit is contained in:
parent
6e78279614
commit
fe458f81ec
1 changed files with 35 additions and 6 deletions
|
@ -43,9 +43,34 @@
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
|
if (pledge("stdio rpath accept cpath wpath shared_buffer unix fattr proc exec", nullptr) < 0) {
|
||||||
|
perror("pledge");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
// If there is no command line parameter go for GUI.
|
// If there is no command line parameter go for GUI.
|
||||||
GUI::Application app(argc, argv);
|
GUI::Application app(argc, argv);
|
||||||
|
|
||||||
|
if (pledge("stdio rpath accept shared_buffer proc exec", nullptr) < 0) {
|
||||||
|
perror("pledge");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (unveil("/res", "r") < 0 ) {
|
||||||
|
perror("unveil");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (unveil("/bin/keymap", "x") < 0 ) {
|
||||||
|
perror("unveil");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (unveil(nullptr, nullptr)) {
|
||||||
|
perror("unveil");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
auto app_icon = GUI::Icon::default_icon("app-keyboard-settings");
|
auto app_icon = GUI::Icon::default_icon("app-keyboard-settings");
|
||||||
|
|
||||||
Vector<String> character_map_files;
|
Vector<String> character_map_files;
|
||||||
|
@ -99,13 +124,17 @@ int main(int argc, char** argv)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Keyboard::CharacterMap character_map(character_map_file);
|
pid_t child_pid = fork();
|
||||||
int rc = character_map.set_system_map();
|
if (child_pid < 0) {
|
||||||
if (rc != 0) {
|
perror("fork");
|
||||||
GUI::MessageBox::show(strerror(-rc), "Keyboard settings", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK, window);
|
exit(1);
|
||||||
return;
|
}
|
||||||
|
if (child_pid == 0) {
|
||||||
|
if (execl("/bin/keymap", "/bin/keymap", character_map_file.characters(), nullptr) < 0) {
|
||||||
|
perror("execl");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (quit)
|
if (quit)
|
||||||
app.quit();
|
app.quit();
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue