From f7185dfa912fa0e0dae555c2d1d7fc013b50aba5 Mon Sep 17 00:00:00 2001 From: Liav A Date: Sat, 20 May 2023 21:59:08 +0300 Subject: [PATCH] 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. --- Userland/Services/SystemServer/Service.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Userland/Services/SystemServer/Service.cpp b/Userland/Services/SystemServer/Service.cpp index eda136ce1f..bc3190c362 100644 --- a/Userland/Services/SystemServer/Service.cpp +++ b/Userland/Services/SystemServer/Service.cpp @@ -200,8 +200,8 @@ ErrorOr 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));