mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 14:07:45 +00:00
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
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(nc LibMain)
|
||||||
target_link_libraries(netstat LibMain)
|
target_link_libraries(netstat LibMain)
|
||||||
target_link_libraries(nl LibMain)
|
target_link_libraries(nl LibMain)
|
||||||
|
target_link_libraries(nologin LibMain)
|
||||||
target_link_libraries(notify LibGUI LibMain)
|
target_link_libraries(notify LibGUI LibMain)
|
||||||
target_link_libraries(nproc LibMain)
|
target_link_libraries(nproc LibMain)
|
||||||
target_link_libraries(ntpquery 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
Add a link
Reference in a new issue