mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:07:35 +00: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
2 changed files with 9 additions and 7 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue