SystemServer: Print useful information when failing to drop privileges

It occurred to me that when trying to running "pls pro SOME_URL" with a
subsequent failure (which will be fixed in a future patch), that a small
error message was printed to the debug log about "Failed to drop
privileges (GID=0, UID=0)".

To actually understand where it failed, I added the actual errno to
printed message which helped me with further debugging, but this could
easily help others in similar scenarios so let's print the actual error.
This commit is contained in:
Liav A 2023-05-20 21:59:08 +03:00 committed by Jelle Raaijmakers
parent 2a051738ca
commit f7185dfa91
Notes: sideshowbarker 2024-07-16 19:57:56 +09:00

View file

@ -200,8 +200,8 @@ ErrorOr<void> Service::spawn(int socket_fd)
if (m_account.has_value() && m_account.value().uid() != getuid()) {
auto& account = m_account.value();
if (account.login().is_error()) {
dbgln("Failed to drop privileges (GID={}, UID={})\n", account.gid(), account.uid());
if (auto error_or_void = account.login(); error_or_void.is_error()) {
dbgln("Failed to drop privileges (GID={}, UID={}), due to {}\n", account.gid(), account.uid(), error_or_void.error());
exit(1);
}
TRY(Core::System::setenv("HOME"sv, account.home_directory(), true));