From fbeebce4e39fbe8ef9a7f01fec28ccee44952d81 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Mon, 29 Nov 2021 21:16:35 +0100 Subject: [PATCH] whoami: Port to LibMain :^) --- Userland/Utilities/CMakeLists.txt | 1 + Userland/Utilities/whoami.cpp | 20 +++++++------------- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/Userland/Utilities/CMakeLists.txt b/Userland/Utilities/CMakeLists.txt index c32930dad9..958321f8e5 100644 --- a/Userland/Utilities/CMakeLists.txt +++ b/Userland/Utilities/CMakeLists.txt @@ -123,4 +123,5 @@ target_link_libraries(cpp-parser LibCpp LibGUI) target_link_libraries(cpp-preprocessor LibCpp LibGUI) target_link_libraries(w LibMain) target_link_libraries(wasm LibWasm LibLine) +target_link_libraries(whoami LibMain) target_link_libraries(wsctl LibGUI) diff --git a/Userland/Utilities/whoami.cpp b/Userland/Utilities/whoami.cpp index fb5a0901a9..08d4f7e15a 100644 --- a/Userland/Utilities/whoami.cpp +++ b/Userland/Utilities/whoami.cpp @@ -1,25 +1,19 @@ /* - * Copyright (c) 2018-2020, Andreas Kling + * Copyright (c) 2018-2021, Andreas Kling * * SPDX-License-Identifier: BSD-2-Clause */ +#include +#include #include #include -int main(int, char**) +ErrorOr serenity_main(Main::Arguments) { - if (pledge("stdio rpath", nullptr) < 0) { - perror("pledge"); - return 1; - } - - if (unveil("/etc/passwd", "r") < 0) { - perror("unveil"); - return 1; - } - - unveil(nullptr, nullptr); + TRY(Core::System::pledge("stdio rpath")); + TRY(Core::System::unveil("/etc/passwd", "r")); + TRY(Core::System::unveil(nullptr, nullptr)); puts(getlogin()); return 0;