mirror of
https://github.com/Ylianst/MeshAgent
synced 2026-02-05 11:13:51 +00:00
Updated linux KVM, so when you logout, it doesn't display an error
This commit is contained in:
@@ -1330,20 +1330,25 @@ void kvm_relay_readSink(ILibProcessPipe_Pipe sender, char *buffer, size_t buffer
|
||||
|
||||
}
|
||||
|
||||
void kvm_relay_brokenPipeSink(ILibProcessPipe_Pipe sender)
|
||||
#include "../../../microstack/ILibParsers.h"
|
||||
|
||||
void kvm_relay_brokenPipeSink_2(void *sender)
|
||||
{
|
||||
ILibKVM_WriteHandler writeHandler = (ILibKVM_WriteHandler)((void**)ILibMemory_Extra(sender))[0];
|
||||
void *reserved = ((void**)ILibMemory_Extra(sender))[1];
|
||||
|
||||
char msg[] = "KVM Child process has unexpectedly exited";
|
||||
char buffer[4096];
|
||||
|
||||
((unsigned short*)buffer)[0] = (unsigned short)htons((unsigned short)MNG_ERROR); // Write the type
|
||||
((unsigned short*)buffer)[1] = (unsigned short)htons((unsigned short)(sizeof(msg) + 3));// Write the size
|
||||
memcpy_s(buffer + 4, sizeof(msg)-1, msg, sizeof(msg)-1);
|
||||
memcpy_s(buffer + 4, sizeof(msg) - 1, msg, sizeof(msg) - 1);
|
||||
|
||||
writeHandler(buffer, sizeof(msg) + 3, reserved);
|
||||
|
||||
}
|
||||
void kvm_relay_brokenPipeSink(ILibProcessPipe_Pipe sender)
|
||||
{
|
||||
void *chain = ((void**)ILibMemory_Extra(sender))[2];
|
||||
ILibLifeTime_AddEx(ILibGetBaseTimer(chain), sender, 1000, kvm_relay_brokenPipeSink_2, NULL);
|
||||
}
|
||||
|
||||
void* kvm_relay_restart(int paused, void *processPipeMgr, ILibKVM_WriteHandler writeHandler, void *reserved, int uid, char* authToken, char *dispid)
|
||||
@@ -1368,9 +1373,10 @@ void* kvm_relay_restart(int paused, void *processPipeMgr, ILibKVM_WriteHandler w
|
||||
fcntl(master2slave[0], F_SETFD, FD_CLOEXEC);
|
||||
fcntl(master2slave[1], F_SETFD, FD_CLOEXEC);
|
||||
|
||||
slave_out = ILibProcessPipe_Pipe_CreateFromExistingWithExtraMemory(processPipeMgr, slave2master[0], 2 * sizeof(void*));
|
||||
slave_out = ILibProcessPipe_Pipe_CreateFromExistingWithExtraMemory(processPipeMgr, slave2master[0], 3 * sizeof(void*));
|
||||
((void**)ILibMemory_Extra(slave_out))[0] = writeHandler;
|
||||
((void**)ILibMemory_Extra(slave_out))[1] = reserved;
|
||||
((void**)ILibMemory_Extra(slave_out))[2] = ((ILibChain_Link*)processPipeMgr)->ParentChain;
|
||||
|
||||
UNREFERENCED_PARAMETER(r);
|
||||
do
|
||||
|
||||
@@ -1103,25 +1103,30 @@ duk_ret_t ILibDuktape_MeshAgent_userChanged(duk_context *ctx)
|
||||
duk_get_prop_string(ctx, -1, REMOTE_DESKTOP_ptrs);
|
||||
ptrs = (RemoteDesktop_Ptrs*)Duktape_GetBuffer(ctx, -1, NULL); // [MeshAgent][stream][ptrs]
|
||||
|
||||
duk_peval_string(ctx, "require('user-sessions').consoleUid()");
|
||||
int id = duk_to_int(ctx, -1);
|
||||
duk_eval_string(ctx, "require('monitor-info')"); //[uid][monitor-info]
|
||||
duk_get_prop_string(ctx, -1, "getXInfo"); //[uid][monitor-info][getXInfo]
|
||||
duk_swap_top(ctx, -2); //[uid][getXInfo][this]
|
||||
duk_dup(ctx, -3); //[uid][getXInfo][this][uid]
|
||||
if (duk_pcall_method(ctx, 1) != 0) { duk_eval_string(ctx, "console.log('error');"); return(0); } //[uid][xinfo]
|
||||
x = Duktape_GetStringPropertyValue(ctx, -1, "xauthority", NULL);
|
||||
d = Duktape_GetStringPropertyValue(ctx, -1, "display", NULL);
|
||||
if (ptrs->kvmPipe != NULL)
|
||||
{
|
||||
ILibLifeTime_Remove(ILibGetBaseTimer(duk_ctx_chain(ctx)), ptrs->kvmPipe);
|
||||
ILibProcessPipe_Pipe_SetBrokenPipeHandler(ptrs->kvmPipe, NULL);
|
||||
kvm_cleanup();
|
||||
|
||||
duk_peval_string(ctx, "require('user-sessions').consoleUid()");
|
||||
int id = duk_to_int(ctx, -1);
|
||||
duk_eval_string(ctx, "require('monitor-info')"); //[uid][monitor-info]
|
||||
duk_get_prop_string(ctx, -1, "getXInfo"); //[uid][monitor-info][getXInfo]
|
||||
duk_swap_top(ctx, -2); //[uid][getXInfo][this]
|
||||
duk_dup(ctx, -3); //[uid][getXInfo][this][uid]
|
||||
if (duk_pcall_method(ctx, 1) != 0) { duk_eval_string(ctx, "console.log('error');"); return(0); } //[uid][xinfo]
|
||||
x = Duktape_GetStringPropertyValue(ctx, -1, "xauthority", NULL);
|
||||
d = Duktape_GetStringPropertyValue(ctx, -1, "display", NULL);
|
||||
|
||||
|
||||
duk_push_heapptr(ctx, s); // [stream]
|
||||
duk_push_int(ctx, id); // [stream][id]
|
||||
duk_put_prop_string(ctx, -2, REMOTE_DESKTOP_UID); // [stream]
|
||||
duk_pop(ctx); // ...
|
||||
|
||||
ILibProcessPipe_Pipe_SetBrokenPipeHandler(ptrs->kvmPipe, NULL);
|
||||
ptrs->kvmPipe = kvm_relay_restart(0, agent->pipeManager, ILibDuktape_MeshAgent_RemoteDesktop_KVM_WriteSink, ptrs, id, x, d);
|
||||
duk_push_heapptr(ctx, s); // [stream]
|
||||
duk_push_int(ctx, id); // [stream][id]
|
||||
duk_put_prop_string(ctx, -2, REMOTE_DESKTOP_UID); // [stream]
|
||||
duk_pop(ctx); // ...
|
||||
|
||||
ptrs->kvmPipe = kvm_relay_restart(0, agent->pipeManager, ILibDuktape_MeshAgent_RemoteDesktop_KVM_WriteSink, ptrs, id, x, d);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user