base+gui: Move autologin configuration to /etc/loginui.conf
All checks were successful
Build and test / build (push) Successful in 1m45s
All checks were successful
Build and test / build (push) Successful in 1m45s
This commit is contained in:
parent
bbe1eca711
commit
4cf39c14a1
@ -44,7 +44,7 @@ If you have no toolchain set up, `run.sh` will build it automatically, which mea
|
||||
|
||||
For development convenience, the system automatically starts a GUI session as the default user, without prompting for a password.
|
||||
|
||||
Despite this, Luna does have a login window built-in. If you'd like to try this feature out or start a GUI session as a different user, you'll need to edit [base/etc/init/99-login](base/etc/init/99-login) and change the line that says `Command=/usr/bin/loginui --autologin=selene` to `Command=/usr/bin/loginui`.
|
||||
Despite this, Luna does have a login window built-in. If you'd like to try this feature out or start a GUI session as a different user, you'll need to edit [base/etc/loginui.conf](base/etc/loginui.conf) and change the line that says `Autologin=true` to `Autologin=false`.
|
||||
|
||||
## Prebuilt images
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
Name=login
|
||||
Description=Start a graphical user session.
|
||||
Command=/usr/bin/loginui --autologin=selene
|
||||
Command=/usr/bin/loginui
|
||||
StandardOutput=/dev/uart0
|
||||
StandardError=/dev/uart0
|
||||
Restart=true
|
||||
|
2
base/etc/loginui.conf
Normal file
2
base/etc/loginui.conf
Normal file
@ -0,0 +1,2 @@
|
||||
Autologin=true
|
||||
AutologinUser=selene
|
@ -9,6 +9,7 @@
|
||||
|
||||
#include <luna/String.h>
|
||||
#include <os/ArgumentParser.h>
|
||||
#include <os/Config.h>
|
||||
#include <os/File.h>
|
||||
#include <os/FileSystem.h>
|
||||
#include <os/IPC.h>
|
||||
@ -33,16 +34,9 @@ static constexpr ui::Color BACKGROUND_COLOR = ui::Color::from_rgb(89, 89, 89);
|
||||
|
||||
Result<int> luna_main(int argc, char** argv)
|
||||
{
|
||||
StringView username;
|
||||
|
||||
os::ArgumentParser parser;
|
||||
parser.add_description("Login prompt for a graphical UI session.");
|
||||
parser.add_system_program_info("loginui"_sv);
|
||||
// FIXME: Make this a config option instead of a switch.
|
||||
// Also, calling "loginui --autologin=user" is functionally identical to calling "startui --user=user", the only
|
||||
// difference is that it makes the init config easier to change (only adding or removing the autologin flag, instead
|
||||
// of changing the program to use)
|
||||
parser.add_value_argument(username, ' ', "autologin", "login as a specific user without prompting");
|
||||
parser.parse(argc, argv);
|
||||
|
||||
if (geteuid() != 0)
|
||||
@ -66,13 +60,20 @@ Result<int> luna_main(int argc, char** argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!username.is_empty())
|
||||
{
|
||||
auto flag = String::format("--user=%s"_sv, username.chars()).release_value();
|
||||
auto config = TRY(os::ConfigFile::open("/etc/loginui.conf"));
|
||||
|
||||
StringView startui_command[] = { "/usr/bin/startui", flag.view() };
|
||||
os::Process::exec(startui_command[0], Slice<StringView>(startui_command, 2));
|
||||
unreachable();
|
||||
if (config->read_boolean_or("Autologin", false))
|
||||
{
|
||||
StringView username = config->read_string_or("AutologinUser", "");
|
||||
|
||||
if (!username.is_empty())
|
||||
{
|
||||
auto flag = String::format("--user=%s"_sv, username.chars()).release_value();
|
||||
|
||||
StringView startui_command[] = { "/usr/bin/startui", flag.view() };
|
||||
os::Process::exec(startui_command[0], Slice<StringView>(startui_command, 2));
|
||||
unreachable();
|
||||
}
|
||||
}
|
||||
|
||||
ui::App app;
|
||||
|
Loading…
Reference in New Issue
Block a user