aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLiam Mitchell <[email protected]>2026-01-15 17:13:53 -0800
committerLiam Mitchell <[email protected]>2026-01-15 17:13:53 -0800
commit566afb9f4a59c030d6f1235d1555fbe5968ea1b3 (patch)
tree97aa62edd1f09bb774880b7e5e268ac916efdb23
parentImplement final changes required for daemon mode on Mac (diff)
downloadzen-566afb9f4a59c030d6f1235d1555fbe5968ea1b3.tar.xz
zen-566afb9f4a59c030d6f1235d1555fbe5968ea1b3.zip
Rename IsElevated to RequiresElevation
-rw-r--r--src/zen/cmds/service_cmd.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/zen/cmds/service_cmd.cpp b/src/zen/cmds/service_cmd.cpp
index c7df6c640..aa6bfb436 100644
--- a/src/zen/cmds/service_cmd.cpp
+++ b/src/zen/cmds/service_cmd.cpp
@@ -37,9 +37,9 @@ namespace zen {
namespace {
#if ZEN_PLATFORM_WINDOWS
- BOOL IsElevated()
+ BOOL RequiresElevation()
{
- BOOL fRet = FALSE;
+ BOOL fRet = TRUE;
HANDLE hToken = NULL;
if (OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &hToken))
{
@@ -47,7 +47,7 @@ namespace {
DWORD cbSize = sizeof(TOKEN_ELEVATION);
if (GetTokenInformation(hToken, TokenElevation, &Elevation, sizeof(Elevation), &cbSize))
{
- fRet = Elevation.TokenIsElevated;
+ fRet = !Elevation.TokenIsElevated;
}
}
if (hToken)
@@ -104,11 +104,11 @@ namespace {
#elif ZEN_PLATFORM_MAC
- bool IsElevated() { return true; } // Mac service mode commands can run without elevation, so we lie a little bit here
+ bool RequiresElevation() { return false; } // Mac service mode commands can run without elevation
#else
- bool IsElevated() { return geteuid() == 0; }
+ bool RequiresElevation() { return geteuid() != 0; }
#endif // ZEN_PLATFORM_WINDOWS
@@ -348,7 +348,7 @@ ServiceCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv)
if (SubOption == &m_InstallOptions)
{
- if (!IsElevated())
+ if (RequiresElevation())
{
RunElevated(m_AllowElevation);
return;
@@ -557,7 +557,7 @@ ServiceCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv)
throw std::runtime_error(fmt::format("Service '{}' is running, stop before uninstalling", m_ServiceName));
}
- if (!IsElevated())
+ if (RequiresElevation())
{
RunElevated(m_AllowElevation);
return;
@@ -589,7 +589,7 @@ ServiceCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv)
return;
}
- if (!IsElevated())
+ if (RequiresElevation())
{
RunElevated(m_AllowElevation);
return;
@@ -621,7 +621,7 @@ ServiceCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv)
return;
}
- if (!IsElevated())
+ if (RequiresElevation())
{
RunElevated(m_AllowElevation);
return;