logout.cpp 537 B

12345678910111213141516171819202122
  1. /*
  2. * Copyright (c) 2021, Peter Elliott <pelliott@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <LibCore/SessionManagement.h>
  7. #include <LibCore/System.h>
  8. #include <LibMain/Main.h>
  9. #include <signal.h>
  10. ErrorOr<int> serenity_main(Main::Arguments)
  11. {
  12. TRY(Core::System::pledge("stdio proc rpath"));
  13. TRY(Core::System::unveil("/proc/all", "r"));
  14. TRY(Core::System::unveil("/etc/passwd", "r"));
  15. TRY(Core::System::unveil(nullptr, nullptr));
  16. TRY(Core::SessionManagement::logout());
  17. return 0;
  18. }