1
0
mirror of https://github.com/Ylianst/MeshAgent synced 2025-12-16 00:03:45 +00:00

1. added 'slaveKvmLog' flag to msh, to enable Linux Child KVM logging

2. added support for child process core dumps in Linux (Note: core location must be writable by the process)
This commit is contained in:
Bryan Roe
2019-10-25 13:42:07 -07:00
parent 15fdb323e1
commit 5476ad8b5f
4 changed files with 30 additions and 1 deletions

View File

@@ -29,12 +29,17 @@ limitations under the License.
#include <X11/keysym.h> #include <X11/keysym.h>
#include <dlfcn.h> #include <dlfcn.h>
#if !defined(_FREEBSD)
#include <sys/prctl.h>
#endif
#include "linux_events.h" #include "linux_events.h"
#include "linux_compression.h" #include "linux_compression.h"
#define EXIT_SUCCESS 0 #define EXIT_SUCCESS 0
#define EXIT_FAILURE 1 #define EXIT_FAILURE 1
extern uint32_t crc32c(uint32_t crc, const unsigned char* buf, uint32_t len); extern uint32_t crc32c(uint32_t crc, const unsigned char* buf, uint32_t len);
extern char* g_ILibCrashDump_path;
typedef enum KVM_MouseCursors typedef enum KVM_MouseCursors
{ {
@@ -617,7 +622,6 @@ void* kvm_server_mainloop(void* parm)
} }
} }
} }
g_messageQ = ILibQueue_Create(); g_messageQ = ILibQueue_Create();
// Init the kvm // Init the kvm
@@ -1010,6 +1014,19 @@ void* kvm_relay_restart(int paused, void *processPipeMgr, ILibKVM_WriteHandler w
if (SLAVELOG != 0) { logFile = fopen("/tmp/slave", "w"); } if (SLAVELOG != 0) { logFile = fopen("/tmp/slave", "w"); }
if (uid != 0) { ignore_result(setuid(uid)); } if (uid != 0) { ignore_result(setuid(uid)); }
if (g_ILibCrashDump_path != NULL)
{
#if !defined(_FREEBSD)
prctl(PR_SET_DUMPABLE, 1);
if (logFile) { fprintf(logFile, "SLAVE/KVM DUMPABLE: %s\n", prctl(PR_GET_DUMPABLE, 0)?"YES":"NO"); fflush(logFile); }
#endif
}
else
{
if (logFile) { fprintf(logFile, "SLAVE/KVM CoreDumps DISABLED\n"); fflush(logFile); }
}
//fprintf(logFile, "Starting kvm_server_mainloop\n"); //fprintf(logFile, "Starting kvm_server_mainloop\n");
if (authToken != NULL) { setenv("XAUTHORITY", authToken, 1); } if (authToken != NULL) { setenv("XAUTHORITY", authToken, 1); }
if (dispid != NULL) { setenv("DISPLAY", dispid, 1); } if (dispid != NULL) { setenv("DISPLAY", dispid, 1); }

View File

@@ -3389,6 +3389,10 @@ void MeshServer_Connect(MeshAgentHostContainer *agent)
agent->logUpdate = ILibSimpleDataStore_Get(agent->masterDb, "logUpdate", NULL, 0); agent->logUpdate = ILibSimpleDataStore_Get(agent->masterDb, "logUpdate", NULL, 0);
agent->fakeUpdate = ILibSimpleDataStore_Get(agent->masterDb, "fakeUpdate", NULL, 0); agent->fakeUpdate = ILibSimpleDataStore_Get(agent->masterDb, "fakeUpdate", NULL, 0);
agent->controlChannelDebug = ILibSimpleDataStore_Get(agent->masterDb, "controlChannelDebug", NULL, 0); agent->controlChannelDebug = ILibSimpleDataStore_Get(agent->masterDb, "controlChannelDebug", NULL, 0);
#if defined(_LINKVM) && defined(_POSIX) && !defined(__APPLE__)
SLAVELOG = ILibSimpleDataStore_Get(agent->masterDb, "slaveKvmLog", NULL, 0);
#endif
if (agent->logUpdate != 0) { ILIBLOGMESSAGEX("PLATFORM_TYPE: %d\n", agent->platformType); } if (agent->logUpdate != 0) { ILIBLOGMESSAGEX("PLATFORM_TYPE: %d\n", agent->platformType); }
if (agent->logUpdate != 0) { ILIBLOGMESSAGEX("Running as Service: %d\n", agent->JSRunningAsService); } if (agent->logUpdate != 0) { ILIBLOGMESSAGEX("Running as Service: %d\n", agent->JSRunningAsService); }

View File

@@ -258,6 +258,7 @@ forceUpdate: If set, will cause the agent to perform a self-update on next st
ignoreProxyFile: If set, will cause the agent to ignore any proxy settings ignoreProxyFile: If set, will cause the agent to ignore any proxy settings
logUpdate: If set, will cause the agent to log self-update status logUpdate: If set, will cause the agent to log self-update status
jsDebugPort: Specify a JS Debugger Port jsDebugPort: Specify a JS Debugger Port
slaveKvmLog: [Linux] If set, will enable logging inside the Child KVM Process.
WebProxy: Manually specify proxy configuration WebProxy: Manually specify proxy configuration
webSocketMaskOverride: If set, will disable the optimzation to skip WebSocket Masking for TLS protected Web Sockets webSocketMaskOverride: If set, will disable the optimzation to skip WebSocket Masking for TLS protected Web Sockets
* *

View File

@@ -35,6 +35,10 @@ limitations under the License.
#include <sys/utsname.h> #include <sys/utsname.h>
#endif #endif
#if defined(_POSIX) && !defined(__APPLE__) && !defined(_FREEBSD)
#include <sys/prctl.h>
#endif
#include "duktape.h" #include "duktape.h"
#if defined(WIN32) && !defined(_WIN32_WCE) && !defined(_MINCORE) #if defined(WIN32) && !defined(_WIN32_WCE) && !defined(_MINCORE)
@@ -1021,6 +1025,9 @@ duk_ret_t ILibDuktape_ScriptContainer_Process_coreDumpLocation_setter(duk_contex
duk_put_prop_string(ctx, -2, ILibDuktape_ScriptContainer_Process_CoreDumpPath); // [process] duk_put_prop_string(ctx, -2, ILibDuktape_ScriptContainer_Process_CoreDumpPath); // [process]
duk_pop(ctx); // ... duk_pop(ctx); // ...
#ifndef WIN32 #ifndef WIN32
#if defined(_POSIX) && !defined(__APPLE__) && !defined(_FREEBSD)
prctl(PR_SET_DUMPABLE, 1);
#endif
duk_eval_string_noresult(ctx, "process.rlimit.set(process.RLIMITS.CORE, {soft: -1, hard: -1});"); duk_eval_string_noresult(ctx, "process.rlimit.set(process.RLIMITS.CORE, {soft: -1, hard: -1});");
#endif #endif
} }