1
0
mirror of https://github.com/Ylianst/MeshAgent synced 2025-12-21 02:33:24 +00:00

Disabled self-update if any of the following is true:

1. Agent running as service, but without admin rights
2. Agent running as console, in temporary mode
This commit is contained in:
Bryan Roe
2020-10-18 01:17:17 -07:00
parent 67e3b3c118
commit 0773585dfd
2 changed files with 7 additions and 1 deletions

View File

@@ -3671,7 +3671,7 @@ void MeshServer_Connect(MeshAgentHostContainer *agent)
gRemoteMouseRenderDefault = ILibSimpleDataStore_Get(agent->masterDb, "remoteMouseRender", NULL, 0);
ILibSimpleDataStore_ConfigCompact(agent->masterDb, ILibSimpleDataStore_GetInt(agent->masterDb, "compactDirtyMinimum", 0));
ILibSimpleDataStore_ConfigSizeLimit(agent->masterDb, ILibSimpleDataStore_GetInt(agent->masterDb, "dbWarningSizeThreshold", 0), MeshServer_DbWarning, agent);
agent->disableUpdate = ILibSimpleDataStore_Get(agent->masterDb, "disableUpdate", NULL, 0);
agent->disableUpdate = (agent->JSRunningAsService != 0 && agent->JSRunningWithAdmin == 0) | ILibSimpleDataStore_Get(agent->masterDb, "disableUpdate", NULL, 0) | (agent->JSRunningAsService == 0 && ((agent->capabilities & MeshCommand_AuthInfo_CapabilitiesMask_TEMPORARY) == MeshCommand_AuthInfo_CapabilitiesMask_TEMPORARY));
agent->forceUpdate = ILibSimpleDataStore_Get(agent->masterDb, "forceUpdate", NULL, 0);
agent->logUpdate = ILibSimpleDataStore_Get(agent->masterDb, "logUpdate", NULL, 0);
agent->fakeUpdate = ILibSimpleDataStore_Get(agent->masterDb, "fakeUpdate", NULL, 0);
@@ -4342,6 +4342,7 @@ int MeshAgent_AgentMode(MeshAgentHostContainer *agentHost, int paramLen, char **
agentHost->platformType = MeshAgent_Posix_PlatformTypes_UNKNOWN;
agentHost->JSRunningAsService = 0;
agentHost->JSRunningWithAdmin = 0;
if (duk_peval_string(tmpCtx, "(function foo() { var f = require('service-manager').manager.getServiceType(); switch(f){case 'procd': return(7); case 'windows': return(10); case 'launchd': return(3); case 'freebsd': return(5); case 'systemd': return(1); case 'init': return(2); case 'upstart': return(4); default: return(0);}})()") == 0)
{
@@ -4351,6 +4352,10 @@ int MeshAgent_AgentMode(MeshAgentHostContainer *agentHost, int paramLen, char **
{
agentHost->JSRunningAsService = duk_get_boolean(tmpCtx, -1);
}
if (duk_peval_string(tmpCtx, "require('user-sessions').isRoot();") == 0)
{
agentHost->JSRunningWithAdmin = duk_get_boolean(tmpCtx, -1);
}
#endif
#if !defined(MICROSTACK_NOTLS)