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/ClientConnection.h>
  10. #include <LibMain/Main.h>
  11. #include <LibTLS/Certificate.h>
  12. #include <WebSocket/ClientConnection.h>
  13. ErrorOr<int> serenity_main(Main::Arguments)
  14. {
  15. TRY(Core::System::pledge("stdio inet unix rpath sendfd recvfd", nullptr));
  16. // Ensure the certificates are read out here.
  17. [[maybe_unused]] auto& certs = DefaultRootCACertificates::the();
  18. Core::EventLoop event_loop;
  19. // FIXME: Establish a connection to LookupServer and then drop "unix"?
  20. TRY(Core::System::pledge("stdio inet unix sendfd recvfd", nullptr));
  21. TRY(Core::System::unveil("/tmp/portal/lookup", "rw"));
  22. TRY(Core::System::unveil(nullptr, nullptr));
  23. auto socket = Core::LocalSocket::take_over_accepted_socket_from_system_server();
  24. VERIFY(socket);
  25. IPC::new_client_connection<WebSocket::ClientConnection>(socket.release_nonnull(), 1);
  26. return event_loop.exec();
  27. }