main.cpp 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. /*
  2. * Copyright (c) 2021, Dex♪ <dexes.ttp@gmail.com>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <LibCore/EventLoop.h>
  7. #include <LibCore/LocalServer.h>
  8. #include <LibCore/System.h>
  9. #include <LibIPC/SingleServer.h>
  10. #include <LibMain/Main.h>
  11. #include <LibTLS/Certificate.h>
  12. #include <WebSocket/ConnectionFromClient.h>
  13. ErrorOr<int> serenity_main(Main::Arguments)
  14. {
  15. TRY(Core::System::pledge("stdio inet unix rpath sendfd recvfd"));
  16. // Ensure the certificates are read out here.
  17. // FIXME: Allow specifying extra certificates on the command line, or in other configuration.
  18. [[maybe_unused]] auto& certs = DefaultRootCACertificates::the();
  19. Core::EventLoop event_loop;
  20. // FIXME: Establish a connection to LookupServer and then drop "unix"?
  21. TRY(Core::System::unveil("/tmp/portal/lookup", "rw"));
  22. TRY(Core::System::unveil("/etc/timezone", "r"));
  23. TRY(Core::System::unveil(nullptr, nullptr));
  24. auto client = TRY(IPC::take_over_accepted_client_from_system_server<WebSocket::ConnectionFromClient>());
  25. return event_loop.exec();
  26. }