mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-11 13:36:13 +03:00
pgrep: Port to LibMain
Use unveil to allow access only to required paths. Switch to new pledge format.
This commit is contained in:
parent
5c63537ae9
commit
a9b387a1bf
Notes:
sideshowbarker
2024-07-17 19:03:00 +09:00
Author: https://github.com/hjeldin Commit: https://github.com/SerenityOS/serenity/commit/a9b387a1bf Pull-request: https://github.com/SerenityOS/serenity/pull/12367 Reviewed-by: https://github.com/kennethmyhra
@ -146,7 +146,7 @@ target_link_libraries(open LibDesktop LibMain)
|
||||
target_link_libraries(pape LibGUI LibMain)
|
||||
target_link_libraries(passwd LibCrypt LibMain)
|
||||
target_link_libraries(paste LibGUI)
|
||||
target_link_libraries(pgrep LibRegex)
|
||||
target_link_libraries(pgrep LibRegex LibMain)
|
||||
target_link_libraries(pidof LibMain)
|
||||
target_link_libraries(ping LibMain)
|
||||
target_link_libraries(pls LibCrypt LibMain)
|
||||
|
@ -8,14 +8,16 @@
|
||||
#include <AK/Vector.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/ProcessStatisticsReader.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <LibMain/Main.h>
|
||||
#include <LibRegex/Regex.h>
|
||||
|
||||
int main(int argc, char** argv)
|
||||
ErrorOr<int> serenity_main(Main::Arguments args)
|
||||
{
|
||||
if (pledge("stdio rpath", nullptr) < 0) {
|
||||
perror("pledge");
|
||||
return 1;
|
||||
}
|
||||
TRY(Core::System::pledge("stdio rpath"));
|
||||
TRY(Core::System::unveil("/proc/all", "r"));
|
||||
TRY(Core::System::unveil("/etc/passwd", "r"));
|
||||
TRY(Core::System::unveil(nullptr, nullptr));
|
||||
|
||||
bool case_insensitive = false;
|
||||
bool invert_match = false;
|
||||
@ -25,7 +27,7 @@ int main(int argc, char** argv)
|
||||
args_parser.add_option(case_insensitive, "Make matches case-insensitive", nullptr, 'i');
|
||||
args_parser.add_option(invert_match, "Select non-matching lines", "invert-match", 'v');
|
||||
args_parser.add_positional_argument(pattern, "Process name to search for", "process-name");
|
||||
args_parser.parse(argc, argv);
|
||||
args_parser.parse(args);
|
||||
|
||||
PosixOptions options {};
|
||||
if (case_insensitive)
|
||||
|
Loading…
Reference in New Issue
Block a user