mirror of
https://github.com/Ylianst/MeshAgent
synced 2025-12-17 08:43:21 +00:00
Updated slavelog so that it is off by default
This commit is contained in:
@@ -35,6 +35,8 @@ limitations under the License.
|
|||||||
#define EXIT_SUCCESS 0
|
#define EXIT_SUCCESS 0
|
||||||
#define EXIT_FAILURE 1
|
#define EXIT_FAILURE 1
|
||||||
|
|
||||||
|
int SLAVELOG = 0;
|
||||||
|
|
||||||
int SCREEN_NUM = 0;
|
int SCREEN_NUM = 0;
|
||||||
int SCREEN_WIDTH = 0;
|
int SCREEN_WIDTH = 0;
|
||||||
int SCREEN_HEIGHT = 0;
|
int SCREEN_HEIGHT = 0;
|
||||||
@@ -319,8 +321,8 @@ int kvm_init(int displayNo)
|
|||||||
if (count == 10) { return -1; }
|
if (count == 10) { return -1; }
|
||||||
count = 0;
|
count = 0;
|
||||||
eventdisplay = x11_exports->XOpenDisplay(displayString);
|
eventdisplay = x11_exports->XOpenDisplay(displayString);
|
||||||
fprintf(logFile, "XAUTHORITY is %s\n", getenv("XAUTHORITY")); fflush(logFile);
|
if (logFile) { fprintf(logFile, "XAUTHORITY is %s\n", getenv("XAUTHORITY")); fflush(logFile); }
|
||||||
fprintf(logFile, "DisplayString is %s\n", displayString); fflush(logFile);
|
if (logFile) { fprintf(logFile, "DisplayString is %s\n", displayString); fflush(logFile); }
|
||||||
|
|
||||||
if (eventdisplay == NULL)
|
if (eventdisplay == NULL)
|
||||||
{
|
{
|
||||||
@@ -533,7 +535,7 @@ void* kvm_server_mainloop(void* parm)
|
|||||||
default_JPEG_error_handler = kvm_server_jpegerror;
|
default_JPEG_error_handler = kvm_server_jpegerror;
|
||||||
|
|
||||||
|
|
||||||
fprintf(logFile, "Checking $DISPLAY\n");
|
if (logFile) { fprintf(logFile, "Checking $DISPLAY\n"); fflush(logFile); }
|
||||||
for (char **env = environ; *env; ++env)
|
for (char **env = environ; *env; ++env)
|
||||||
{
|
{
|
||||||
int envLen = (int)strnlen_s(*env, INT_MAX);
|
int envLen = (int)strnlen_s(*env, INT_MAX);
|
||||||
@@ -543,7 +545,7 @@ void* kvm_server_mainloop(void* parm)
|
|||||||
if (i == 7 && strncmp("DISPLAY", *env, 7) == 0)
|
if (i == 7 && strncmp("DISPLAY", *env, 7) == 0)
|
||||||
{
|
{
|
||||||
current_display = (unsigned short)atoi(*env + i + 2);
|
current_display = (unsigned short)atoi(*env + i + 2);
|
||||||
fprintf(logFile, "ENV[DISPLAY] = %s\n", *env + i + 2);
|
if (logFile) { fprintf(logFile, "ENV[DISPLAY] = %s\n", *env + i + 2); fflush(logFile); }
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -789,7 +791,7 @@ void* kvm_relay_restart(int paused, void *processPipeMgr, ILibKVM_WriteHandler w
|
|||||||
close(slave2master[0]);
|
close(slave2master[0]);
|
||||||
close(master2slave[1]);
|
close(master2slave[1]);
|
||||||
|
|
||||||
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)); }
|
||||||
|
|
||||||
//fprintf(logFile, "Starting kvm_server_mainloop\n");
|
//fprintf(logFile, "Starting kvm_server_mainloop\n");
|
||||||
@@ -799,7 +801,8 @@ void* kvm_relay_restart(int paused, void *processPipeMgr, ILibKVM_WriteHandler w
|
|||||||
kvm_server_mainloop((void*)0);
|
kvm_server_mainloop((void*)0);
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
else { //master
|
else
|
||||||
|
{ //master
|
||||||
close(slave2master[1]);
|
close(slave2master[1]);
|
||||||
close(master2slave[0]);
|
close(master2slave[0]);
|
||||||
logFile = fopen("/tmp/master", "w");
|
logFile = fopen("/tmp/master", "w");
|
||||||
|
|||||||
@@ -94,6 +94,9 @@ char exeMeshPolicyGuid[] = { 0xB9, 0x96, 0x01, 0x58, 0x80, 0x54, 0x4A, 0x19, 0xB
|
|||||||
|
|
||||||
#ifdef _POSIX
|
#ifdef _POSIX
|
||||||
extern char **environ;
|
extern char **environ;
|
||||||
|
#ifndef __APPLE__
|
||||||
|
extern int SLAVELOG;
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
char* MeshAgentHost_BatteryInfo_STRINGS[] = { "UNKNOWN", "HIGH_CHARGE", "LOW_CHARGE", "NO_BATTERY", "CRITICAL_CHARGE", "", "", "", "CHARGING" };
|
char* MeshAgentHost_BatteryInfo_STRINGS[] = { "UNKNOWN", "HIGH_CHARGE", "LOW_CHARGE", "NO_BATTERY", "CRITICAL_CHARGE", "", "", "", "CHARGING" };
|
||||||
@@ -1868,6 +1871,13 @@ duk_ret_t ILibDuktape_MeshAgent_hostname(duk_context *ctx)
|
|||||||
duk_push_string(ctx, agent->hostname);
|
duk_push_string(ctx, agent->hostname);
|
||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
|
#if defined(_LINKVM) && defined(_POSIX) && !defined(__APPLE__)
|
||||||
|
duk_ret_t ILibDuktape_MeshAgent_enableKvmSlaveLog(duk_context *ctx)
|
||||||
|
{
|
||||||
|
SLAVELOG = (int)duk_require_int(ctx, 0);
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
void ILibDuktape_MeshAgent_PUSH(duk_context *ctx, void *chain)
|
void ILibDuktape_MeshAgent_PUSH(duk_context *ctx, void *chain)
|
||||||
{
|
{
|
||||||
MeshAgentHostContainer *agent;
|
MeshAgentHostContainer *agent;
|
||||||
@@ -1941,6 +1951,9 @@ void ILibDuktape_MeshAgent_PUSH(duk_context *ctx, void *chain)
|
|||||||
#ifdef _LINKVM
|
#ifdef _LINKVM
|
||||||
ILibDuktape_CreateReadonlyProperty_int(ctx, "hasKVM", 1);
|
ILibDuktape_CreateReadonlyProperty_int(ctx, "hasKVM", 1);
|
||||||
ILibDuktape_EventEmitter_CreateEventEx(emitter, "kvmConnected");
|
ILibDuktape_EventEmitter_CreateEventEx(emitter, "kvmConnected");
|
||||||
|
#if defined(_POSIX) && !defined(__APPLE__)
|
||||||
|
ILibDuktape_CreateInstanceMethod(ctx, "enableKvmSlaveLog", ILibDuktape_MeshAgent_enableKvmSlaveLog, 1);
|
||||||
|
#endif
|
||||||
#else
|
#else
|
||||||
ILibDuktape_CreateReadonlyProperty_int(ctx, "hasKVM", 0);
|
ILibDuktape_CreateReadonlyProperty_int(ctx, "hasKVM", 0);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user