mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:57:45 +00:00
WebServer: Tighten things up with pledge() and unveil()
This commit is contained in:
parent
6c752c15a2
commit
efb694ecad
1 changed files with 20 additions and 0 deletions
|
@ -1,12 +1,19 @@
|
||||||
#include "Client.h"
|
#include "Client.h"
|
||||||
#include <LibCore/EventLoop.h>
|
#include <LibCore/EventLoop.h>
|
||||||
#include <LibCore/TCPServer.h>
|
#include <LibCore/TCPServer.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
(void)argc;
|
(void)argc;
|
||||||
(void)argv;
|
(void)argv;
|
||||||
|
|
||||||
|
if (pledge("stdio accept rpath inet unix cpath fattr", nullptr) < 0) {
|
||||||
|
perror("pledge");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
Core::EventLoop loop;
|
Core::EventLoop loop;
|
||||||
|
|
||||||
auto server = Core::TCPServer::construct();
|
auto server = Core::TCPServer::construct();
|
||||||
|
@ -19,5 +26,18 @@ int main(int argc, char** argv)
|
||||||
};
|
};
|
||||||
|
|
||||||
server->listen({}, 8000);
|
server->listen({}, 8000);
|
||||||
|
|
||||||
|
if (unveil("/www", "r") < 0) {
|
||||||
|
perror("unveil");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
unveil(nullptr, nullptr);
|
||||||
|
|
||||||
|
if (pledge("stdio accept rpath", nullptr) < 0) {
|
||||||
|
perror("pledge");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
return loop.exec();
|
return loop.exec();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue