1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 17:37:37 +00:00

SystemServer: Change user only when needed

This commit is contained in:
Lucas CHOLLET 2022-07-24 13:22:40 +02:00 committed by Linus Groh
parent a13ffffbec
commit a3b8a9a142

View file

@ -211,7 +211,7 @@ void Service::spawn(int socket_fd)
setenv("SOCKET_TAKEOVER", builder.to_string().characters(), true);
}
if (m_account.has_value()) {
if (m_account.has_value() && m_account.value().uid() != getuid()) {
auto& account = m_account.value();
if (setgid(account.gid()) < 0 || setgroups(account.extra_gids().size(), account.extra_gids().data()) < 0 || setuid(account.uid()) < 0) {
dbgln("Failed to drop privileges (GID={}, UID={})\n", account.gid(), account.uid());