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:
parent
429bd32016
commit
30189186e9
Notes:
sideshowbarker
2024-07-17 18:08:55 +09:00
Author: https://github.com/tarob0ba Commit: https://github.com/SerenityOS/serenity/commit/30189186e9 Pull-request: https://github.com/SerenityOS/serenity/pull/15852 Reviewed-by: https://github.com/networkException ✅ Reviewed-by: https://github.com/timschumi ✅
2 changed files with 25 additions and 0 deletions
|
@ -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)
|
||||
|
|
24
Userland/Utilities/nologin.cpp
Normal file
24
Userland/Utilities/nologin.cpp
Normal 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;
|
||||
}
|
Loading…
Add table
Reference in a new issue