mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 06:27:45 +00:00
LibCore: Propagate errors from LibCore::Account::login()
This commit is contained in:
parent
08dcc40aa5
commit
8fabe9a3ad
4 changed files with 9 additions and 17 deletions
|
@ -157,18 +157,13 @@ ErrorOr<void> Account::create_user_temporary_directory_if_needed() const
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Account::login() const
|
ErrorOr<void> Account::login() const
|
||||||
{
|
{
|
||||||
if (setgroups(m_extra_gids.size(), m_extra_gids.data()) < 0)
|
TRY(Core::System::setgroups(m_extra_gids));
|
||||||
return false;
|
TRY(Core::System::setgid(m_gid));
|
||||||
|
TRY(Core::System::setuid(m_uid));
|
||||||
|
|
||||||
if (setgid(m_gid) < 0)
|
return {};
|
||||||
return false;
|
|
||||||
|
|
||||||
if (setuid(m_uid) < 0)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Account::set_password(SecretString const& password)
|
void Account::set_password(SecretString const& password)
|
||||||
|
|
|
@ -38,7 +38,7 @@ public:
|
||||||
static ErrorOr<Account> from_uid(uid_t uid, Read options = Read::All);
|
static ErrorOr<Account> from_uid(uid_t uid, Read options = Read::All);
|
||||||
|
|
||||||
bool authenticate(SecretString const& password) const;
|
bool authenticate(SecretString const& password) const;
|
||||||
bool login() const;
|
ErrorOr<void> login() const;
|
||||||
|
|
||||||
ErrorOr<void> create_user_temporary_directory_if_needed() const;
|
ErrorOr<void> create_user_temporary_directory_if_needed() const;
|
||||||
|
|
||||||
|
|
|
@ -23,8 +23,8 @@ static void child_process(Core::Account const& account)
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!account.login()) {
|
if (auto const result = account.login(); result.is_error()) {
|
||||||
dbgln("failed to switch users: {}", strerror(errno));
|
dbgln("failed to switch users: {}", result.error());
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,10 +51,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
|
|
||||||
TRY(Core::System::pledge("stdio rpath exec id"));
|
TRY(Core::System::pledge("stdio rpath exec id"));
|
||||||
|
|
||||||
if (!account.login()) {
|
TRY(account.login());
|
||||||
perror("Core::Account::login");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (simulate_login)
|
if (simulate_login)
|
||||||
TRY(Core::System::chdir(account.home_directory()));
|
TRY(Core::System::chdir(account.home_directory()));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue