mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-04 05:20:30 +00:00
whoami: Port to LibMain :^)
This commit is contained in:
parent
a93205199b
commit
fbeebce4e3
Notes:
sideshowbarker
2024-07-17 23:17:07 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/fbeebce4e39
2 changed files with 8 additions and 13 deletions
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue