From 4d7aa678bd9a03a2e182b50f15d3fa7224875d7f Mon Sep 17 00:00:00 2001 From: Bryan Roe Date: Fri, 14 Feb 2020 09:14:17 -0800 Subject: [PATCH] Fixed build for No_OpenSSL build mode --- meshcore/agentcore.c | 46 +++++++++++++++++++---- microscript/ILibDuktape_ScriptContainer.c | 7 +++- 2 files changed, 44 insertions(+), 9 deletions(-) diff --git a/meshcore/agentcore.c b/meshcore/agentcore.c index a6f3a71..dcacbd9 100644 --- a/meshcore/agentcore.c +++ b/meshcore/agentcore.c @@ -1643,7 +1643,7 @@ duk_ret_t ILibDuktape_MeshAgent_ServerInfo(duk_context *ctx) return(1); } - +#ifndef MICROSTACK_NOTLS duk_ret_t ILibDuktape_MeshAgent_GenerateCertsForDiagnosticAgent(duk_context *ctx) { char tmp[UTIL_SHA384_HASHSIZE]; @@ -1736,6 +1736,7 @@ duk_ret_t ILibDuktape_MeshAgent_GenerateCertsForDiagnosticAgent(duk_context *ctx } #endif } +#endif duk_ret_t ILibDuktape_MeshAgent_forceExit(duk_context *ctx) { @@ -3820,6 +3821,7 @@ int MeshAgent_AgentMode(MeshAgentHostContainer *agentHost, int paramLen, char ** { agentHost->capabilities |= MeshCommand_AuthInfo_CapabilitiesMask_RECOVERY; parseCommands = 0; } +#ifndef MICROSTACK_NOTLS if (strcmp(param[ri], "-nocertstore") == 0) { parseCommands = 0; @@ -3828,6 +3830,7 @@ int MeshAgent_AgentMode(MeshAgentHostContainer *agentHost, int paramLen, char ** agentHost->noCertStore = 1; #endif } +#endif } @@ -3871,16 +3874,43 @@ int MeshAgent_AgentMode(MeshAgentHostContainer *agentHost, int paramLen, char ** } } paramLen -= ixr; - - switch (installFlag) + if (installFlag != 0) { - case 1: - break; - default: - break; - } + int bufLen = 0; + char *buf; + duk_context *ctxx = ILibDuktape_ScriptContainer_InitializeJavaScriptEngineEx(0, 0, agentHost->chain, NULL, NULL, agentHost->exePath, NULL, NULL, NULL); + duk_eval_string(ctxx, "require('user-sessions').isRoot();"); + if (!duk_get_boolean(ctxx, -1)) + { + printf(" Administrator permissions needed...\n"); + installFlag = 0; + } + switch (installFlag) + { + case 1: + + + + + + bufLen = ILibSimpleDataStore_Cached_GetJSONEx(agentHost->masterDb, NULL, 0); + buf = (char*)ILibMemory_SmartAllocate(bufLen); + bufLen = ILibSimpleDataStore_Cached_GetJSONEx(agentHost->masterDb, buf, bufLen); + + + + + ILibMemory_Free(buf); + break; + default: + break; + } + + duk_destroy_heap(ctxx); + } + agentHost->httpClientManager = ILibCreateWebClient(3, agentHost->chain); ILibRemoteLogging_printf(ILibChainGetLogger(agentHost->chain), ILibRemoteLogging_Modules_Microstack_Generic, ILibRemoteLogging_Flags_VerbosityLevel_1, "agentcore: argv[0] = %s", param[0]); diff --git a/microscript/ILibDuktape_ScriptContainer.c b/microscript/ILibDuktape_ScriptContainer.c index f077e5a..8a28556 100644 --- a/microscript/ILibDuktape_ScriptContainer.c +++ b/microscript/ILibDuktape_ScriptContainer.c @@ -1073,9 +1073,10 @@ void ILibDuktape_ScriptContainer_Process_Init(duk_context *ctx, char **argList) { int i = 0; ILibDuktape_EventEmitter *emitter; +#ifndef MICROSTACK_NOTLS char *sslv = (char*)SSLeay_version(SSLEAY_VERSION); char *sslvS = strstr(sslv, " ") + 1; - +#endif duk_push_global_object(ctx); // [g] duk_push_object(ctx); // [g][process] @@ -1127,6 +1128,8 @@ void ILibDuktape_ScriptContainer_Process_Init(duk_context *ctx, char **argList) duk_put_prop_string(ctx, -2, "SIGTABLE"); duk_push_object(ctx); + +#ifndef MICROSTACK_NOTLS if (sslvS != ((char*)NULL + 1)) { char *tmp = strstr(sslvS, " "); @@ -1136,6 +1139,8 @@ void ILibDuktape_ScriptContainer_Process_Init(duk_context *ctx, char **argList) duk_put_prop_string(ctx, -2, "openssl"); } } +#endif + duk_push_string(ctx, DUK_GIT_DESCRIBE); duk_put_prop_string(ctx, -2, "duktape"); if (SOURCE_COMMIT_DATE != NULL) {