mirror of
https://github.com/Ylianst/MeshAgent
synced 2025-12-16 00:03:45 +00:00
1. Updated linux to be able to KVM to login prompt
2. Fixed project file back 3. Added comments to makefile about gdm3
This commit is contained in:
10
makefile
10
makefile
@@ -38,10 +38,12 @@
|
||||
# NOTE: If you installed jpeg8 headers on your machine, you must specify --with-jpeg8 when building turbo jpeg, otherwise omit --with-jpeg8
|
||||
#
|
||||
#
|
||||
# Special Note about KVM Support on Linux:
|
||||
# If you get an error stating that an Xauthority cannot be found, and asking if your DM is configured to use X, you may need to:
|
||||
# 1. Open /etc/gdm/custom.conf and uncomment WaylandEnable=false.
|
||||
# 2. Add the following line to the [daemon] section:
|
||||
# Special Note about KVM Support on Linux:
|
||||
# If you get an error stating that an Xauthority cannot be found, and asking if your DM is configured to use X,
|
||||
# or if you get a black screen when connecting to the login screen, you may need to:
|
||||
# 1. Open /etc/gdm/custom.conf or /etc/gdm3/custom.conf
|
||||
# 2. Uncomment: WaylandEnable=false.
|
||||
# 3. Add the following line to the [daemon] section:
|
||||
# DefaultSession=gnome-xorg.desktop
|
||||
#
|
||||
#
|
||||
|
||||
@@ -297,7 +297,7 @@
|
||||
<PostBuildEventUseInBuild>false</PostBuildEventUseInBuild>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<OutDir>$(SolutionDir)$(Configuration)\愚蠢的\</OutDir>
|
||||
<OutDir>$(SolutionDir)$(Configuration)\</OutDir>
|
||||
<IntDir>$(SolutionDir)$(Configuration)\$(TargetName)\$(Platform)\OBJ\</IntDir>
|
||||
<TargetName>$(ProjectName)64</TargetName>
|
||||
</PropertyGroup>
|
||||
|
||||
@@ -91,6 +91,8 @@ char exeMeshPolicyGuid[] = { 0xB9, 0x96, 0x01, 0x58, 0x80, 0x54, 0x4A, 0x19, 0xB
|
||||
#define REMOTE_DESKTOP_STREAM "\xFF_RemoteDesktopStream"
|
||||
#define REMOTE_DESKTOP_ptrs "\xFF_RemoteDesktopPTRS"
|
||||
#define DEFAULT_IDLE_TIMEOUT 120
|
||||
#define MESH_USER_CHANGED_CB "\xFF_MeshAgent_UserChangedCallback"
|
||||
#define REMOTE_DESKTOP_UID "\xFF_RemoteDesktopUID"
|
||||
|
||||
#define KVM_IPC_SOCKET "\xFF_KVM_IPC_SOCKET"
|
||||
int ILibDuktape_HECI_Debug = 0;
|
||||
@@ -1282,6 +1284,48 @@ void ILibDuktape_MeshAgent_RemoteDesktop_SendError(RemoteDesktop_Ptrs* ptrs, cha
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef _POSIX
|
||||
extern void* kvm_relay_restart(int paused, void *processPipeMgr, ILibKVM_WriteHandler writeHandler, void *reserved, int uid, char* authToken, char *dispid);
|
||||
duk_ret_t ILibDuktape_MeshAgent_userChanged(duk_context *ctx)
|
||||
{
|
||||
char *d, *x;
|
||||
void *s;
|
||||
RemoteDesktop_Ptrs *ptrs;
|
||||
MeshAgentHostContainer *agent;
|
||||
|
||||
duk_eval_string(ctx, "require('MeshAgent')"); // [MeshAgent]
|
||||
agent = (MeshAgentHostContainer*)Duktape_GetPointerProperty(ctx, -1, MESH_AGENT_PTR);
|
||||
|
||||
if (!duk_has_prop_string(ctx, -1, REMOTE_DESKTOP_STREAM)) { return(0); }
|
||||
duk_get_prop_string(ctx, -1, REMOTE_DESKTOP_STREAM); // [MeshAgent][stream]
|
||||
s = duk_get_heapptr(ctx, -1);
|
||||
if (Duktape_GetIntPropertyValue(ctx, -1, REMOTE_DESKTOP_UID, -1) == 0) { return(0); }
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
return(0);
|
||||
}
|
||||
#endif
|
||||
|
||||
duk_ret_t ILibDuktape_MeshAgent_getRemoteDesktop(duk_context *ctx)
|
||||
{
|
||||
#ifndef _LINKVM
|
||||
@@ -1367,6 +1411,24 @@ duk_ret_t ILibDuktape_MeshAgent_getRemoteDesktop(duk_context *ctx)
|
||||
ptrs->kvmPipe = kvm_relay_setup(agent->exePath, agent->pipeManager, ILibDuktape_MeshAgent_RemoteDesktop_KVM_WriteSink, ptrs, console_uid);
|
||||
}
|
||||
#else
|
||||
duk_push_int(ctx, console_uid); duk_put_prop_string(ctx, -2, REMOTE_DESKTOP_UID);
|
||||
duk_push_this(ctx); // [MeshAgent]
|
||||
if (!duk_has_prop_string(ctx, -1, MESH_USER_CHANGED_CB))
|
||||
{
|
||||
duk_eval_string(ctx, "require('user-sessions')"); // [MeshAgent][usersessions]
|
||||
duk_get_prop_string(ctx, -1, "on"); // [MeshAgent][usersessions][on]
|
||||
duk_swap_top(ctx, -2); // [MeshAgent][on][this]
|
||||
duk_push_string(ctx, "changed"); // [MeshAgent][on][this][changed]
|
||||
duk_push_c_function(ctx, ILibDuktape_MeshAgent_userChanged, DUK_VARARGS); // [MeshAgent][on][this][changed][func]
|
||||
duk_dup(ctx, -5); // [MeshAgent][on][this][changed][func][MeshAgent]
|
||||
duk_dup(ctx, -2); // [MeshAgent][on][this][changed][func][MeshAgent][func]
|
||||
duk_put_prop_string(ctx, -2, MESH_USER_CHANGED_CB); // [MeshAgent][on][this][changed][func][MeshAgent]
|
||||
duk_pop(ctx); // [MeshAgent][on][this][changed][func]
|
||||
duk_call_method(ctx, 2); duk_pop(ctx); // [MeshAgent]
|
||||
}
|
||||
duk_pop(ctx); // ...
|
||||
|
||||
|
||||
// For Linux, we need to determine where the XAUTHORITY is:
|
||||
char *updateXAuth = NULL;
|
||||
char *updateDisplay = NULL;
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -410,6 +410,28 @@ function UserSessions()
|
||||
}
|
||||
else if(process.platform == 'linux' || process.platform == 'freebsd')
|
||||
{
|
||||
Object.defineProperty(this, "gdmUid", {
|
||||
get: function ()
|
||||
{
|
||||
var ret = null;
|
||||
var min = this.minUid();
|
||||
var child = require('child_process').execFile('/bin/sh', ['sh']);
|
||||
child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
|
||||
child.stderr.str = ''; child.stderr.on('data', function (c) { this.str += c.toString(); });
|
||||
child.stdin.write('getent passwd | grep "Gnome Display Manager" | ' + "tr '\\n' '`' | awk -F: '{ print $3 }'\nexit\n");
|
||||
child.waitExit();
|
||||
if (child.stdout.str.trim() != '' && (ret = parseInt(child.stdout.str.trim())) < min) { return (parseInt(child.stdout.str.trim())); }
|
||||
|
||||
child = require('child_process').execFile('/bin/sh', ['sh']);
|
||||
child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
|
||||
child.stderr.str = ''; child.stderr.on('data', function (c) { console.log(c.toString()); });
|
||||
child.stdin.write('getent passwd | grep gdm | ' + "tr '\\n' '`' | awk -F'`' '" + '{ for(i=1;i<NF;++i) { split($i, f, ":"); if(f[3]+0<' + min + '+0) { print f[3]; break; } } }' + "'\nexit\n");
|
||||
child.waitExit();
|
||||
if (child.stdout.str.trim() != '' && (ret = parseInt(child.stdout.str.trim())) < min) { return (parseInt(child.stdout.str.trim())); }
|
||||
|
||||
return (0);
|
||||
}
|
||||
});
|
||||
this.getUid = function getUid(username)
|
||||
{
|
||||
var child = require('child_process').execFile('/bin/sh', ['sh']);
|
||||
@@ -605,22 +627,32 @@ function UserSessions()
|
||||
var child = require('child_process').execFile('/bin/sh', ['sh']);
|
||||
child.stdout.str = ''; child.stdout.on('data', function (chunk) { this.str += chunk.toString(); });
|
||||
child.stderr.str = ''; child.stderr.on('data', function (chunk) { this.str += chunk.toString(); });
|
||||
child.stdin.write('who\nexit\n');
|
||||
child.stdin.write("who | tr '\\n' '\`' | awk '{ print $1 }'\nexit\n");
|
||||
child.waitExit();
|
||||
|
||||
if (child.stderr.str != '') { return (0); }
|
||||
|
||||
var lines = child.stdout.str.split('\n');
|
||||
var tokens, i, j;
|
||||
for (i in lines) {
|
||||
tokens = lines[i].split(' ');
|
||||
for (j = 1; j < tokens.length; ++j) {
|
||||
if (tokens[j].length > 0) {
|
||||
return (parseInt(this._users()[tokens[0]]));
|
||||
}
|
||||
if (child.stdout.str.trim() != '')
|
||||
{
|
||||
try
|
||||
{
|
||||
return (this.getUid(child.stdout.str.trim()));
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
}
|
||||
}
|
||||
throw ('nobody logged into console');
|
||||
|
||||
// Before we say nobody is logged on, let's check to see if there is a GDM session
|
||||
var gdm = this.gdmUid;
|
||||
var info = require('monitor-info').getXInfo(gdm);
|
||||
if (info == null || !info.xauthority || !info.display)
|
||||
{
|
||||
throw ('nobody logged into console');
|
||||
}
|
||||
else
|
||||
{
|
||||
return (gdm);
|
||||
}
|
||||
}
|
||||
|
||||
this.getHomeFolder = function getHomeFolder(id)
|
||||
|
||||
Reference in New Issue
Block a user