[hal] UidSetter: Don't revert euid if its already current value (#3566)

When running from admin account, this hangs for 5-10 seconds.

Co-authored-by: Tyler Veness <calcmogul@gmail.com>
This commit is contained in:
Thad House
2021-09-13 21:08:39 -07:00
committed by GitHub
parent 27951442b8
commit 95a12e0ee8

View File

@@ -31,7 +31,7 @@ class UidSetter {
}
~UidSetter() noexcept(false) {
if (seteuid(m_uid) == -1) {
if (geteuid() != m_uid && seteuid(m_uid) == -1) {
throw std::system_error(errno, std::generic_category(),
fmt::format("seteuid({}) failed", m_uid));
}