1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 00:47:45 +00:00

LookupServer: Port to LibMain :^)

This commit is contained in:
Andreas Kling 2021-11-23 15:30:59 +01:00
parent ddd99b4594
commit d8482134b6
2 changed files with 10 additions and 30 deletions

View file

@ -21,4 +21,4 @@ set(SOURCES
) )
serenity_bin(LookupServer) serenity_bin(LookupServer)
target_link_libraries(LookupServer LibCore LibIPC) target_link_libraries(LookupServer LibCore LibIPC LibMain)

View file

@ -7,38 +7,18 @@
#include "LookupServer.h" #include "LookupServer.h"
#include <LibCore/EventLoop.h> #include <LibCore/EventLoop.h>
#include <LibCore/LocalServer.h> #include <LibCore/LocalServer.h>
#include <stdio.h> #include <LibCore/System.h>
#include <unistd.h> #include <LibMain/Main.h>
int main([[maybe_unused]] int argc, [[maybe_unused]] char** argv) ErrorOr<int> serenity_main(Main::Arguments)
{ {
if (pledge("stdio accept unix inet rpath", nullptr) < 0) { TRY(Core::System::pledge("stdio accept unix inet rpath", nullptr));
perror("pledge");
return 1;
}
Core::EventLoop event_loop; Core::EventLoop event_loop;
auto server = LookupServer::LookupServer::construct(); auto server = TRY(LookupServer::LookupServer::try_create());
if (pledge("stdio accept inet rpath", nullptr) < 0) {
perror("pledge");
return 1;
}
if (unveil("/proc/net/adapters", "r") < 0) {
perror("unveil");
return 1;
}
if (unveil("/etc/hosts", "r") < 0) {
perror("unveil");
return 1;
}
if (unveil(nullptr, nullptr) < 0) {
perror("unveil");
return 1;
}
TRY(Core::System::pledge("stdio accept inet rpath", nullptr));
TRY(Core::System::unveil("/proc/net/adapters", "r"));
TRY(Core::System::unveil("/etc/hosts", "r"));
TRY(Core::System::unveil(nullptr, nullptr));
return event_loop.exec(); return event_loop.exec();
} }