whoami: Port to LibMain :^)

This commit is contained in:
Andreas Kling 2021-11-29 21:16:35 +01:00
parent a93205199b
commit fbeebce4e3
Notes: sideshowbarker 2024-07-17 23:17:07 +09:00
2 changed files with 8 additions and 13 deletions

View file

@ -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)

View file

@ -1,25 +1,19 @@
/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibCore/System.h>
#include <LibMain/Main.h>
#include <stdio.h>
#include <unistd.h>
int main(int, char**)
ErrorOr<int> 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;