mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 21:07:35 +00:00
keymap: Add back a tiny utility for setting the system keyboard layout
This patch removes the setuid-root flag from the KeyboardSettings GUI application and adds back the old "keymap" program. It doesn't feel very safe and sound to have a GUI program runnable as setuid-root, so in the next patch I'll be making KeyboardSettings call out to the "keymap" program to do its bidding.
This commit is contained in:
parent
0609eefd57
commit
6e78279614
4 changed files with 40 additions and 20 deletions
35
Userland/keymap.cpp
Normal file
35
Userland/keymap.cpp
Normal file
|
@ -0,0 +1,35 @@
|
|||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibKeyboard/CharacterMap.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
if (pledge("stdio setkeymap rpath", nullptr) < 0) {
|
||||
perror("pledge");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (unveil("/res/keymaps", "r") < 0) {
|
||||
perror("unveil");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (unveil(nullptr, nullptr) < 0) {
|
||||
perror("unveil");
|
||||
return 1;
|
||||
}
|
||||
|
||||
const char* path = nullptr;
|
||||
Core::ArgsParser args_parser;
|
||||
args_parser.add_positional_argument(path, "The mapping file to be used", "file");
|
||||
args_parser.parse(argc, argv);
|
||||
|
||||
Keyboard::CharacterMap character_map(path);
|
||||
int rc = character_map.set_system_map();
|
||||
if (rc != 0)
|
||||
fprintf(stderr, "%s\n", strerror(-rc));
|
||||
|
||||
return rc;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue