Utilities: Add nologin application

This adds the `nologin` application to the system. This application
will look for `/etc/nologin`. If it is present, it will display the
message in the file. Otherwise, it will display an error about the
current account being unavailable.
This commit is contained in:
Beckett Normington 2022-10-29 20:13:30 -04:00 committed by Linus Groh
parent 429bd32016
commit 30189186e9
2 changed files with 25 additions and 0 deletions

View file

@ -165,6 +165,7 @@ target_link_libraries(mount LibMain)
target_link_libraries(nc LibMain)
target_link_libraries(netstat LibMain)
target_link_libraries(nl LibMain)
target_link_libraries(nologin LibMain)
target_link_libraries(notify LibGUI LibMain)
target_link_libraries(nproc LibMain)
target_link_libraries(ntpquery LibMain)

View file

@ -0,0 +1,24 @@
/*
* Copyright (c) 2022, Beckett Normington <beckett@b0ba.dev>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibCore/Stream.h>
#include <LibCore/System.h>
#include <LibMain/Main.h>
ErrorOr<int> serenity_main(Main::Arguments)
{
TRY(Core::System::pledge("stdio rpath"sv));
auto file_or_error = Core::Stream::File::open("/etc/nologin"sv, Core::Stream::OpenMode::Read);
if (file_or_error.is_error()) {
outln("This account is currently not available."sv);
} else {
auto message_from_file = TRY(file_or_error.value()->read_all());
out(message_from_file);
}
return 1;
}