From 52ff7ba04cb15785126dce0a69209b6684179fc0 Mon Sep 17 00:00:00 2001 From: Bryan Roe Date: Wed, 30 Jan 2019 23:17:39 -0800 Subject: [PATCH] 1. Updated user-sessions.consoleUid() to not try to parse 'from'. It just returns the uid of any user listed in 'who'. This fixes Fedora, but should still work with all the other distros. 2. Updated, so if it can't find an Xauthority, it propagates an error, asking if the user configured DM to use X. This makes it, so on something like Fedora, it pops up a more intuitive error, that the user can fix, rather than just a generic, XOpenDisplay() error. --- meshcore/agentcore.c | 19 +++++++++++++++++++ modules/user-sessions.js | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/meshcore/agentcore.c b/meshcore/agentcore.c index 8e70807..8c4e528 100644 --- a/meshcore/agentcore.c +++ b/meshcore/agentcore.c @@ -1305,6 +1305,19 @@ duk_ret_t ILibDuktape_MeshAgent_getRemoteDesktop_DomainIPC_Sink(duk_context *ctx } #endif +#if defined(_LINKVM) && defined(_POSIX) && !defined(__APPLE__) +void ILibDuktape_MeshAgent_RemoteDesktop_SendError(RemoteDesktop_Ptrs* ptrs, char *msg) +{ + int msgLen = strnlen_s(msg, 255); + char buffer[512]; + + ((unsigned short*)buffer)[0] = (unsigned short)htons((unsigned short)MNG_ERROR); // Write the type + ((unsigned short*)buffer)[1] = (unsigned short)htons((unsigned short)(msgLen + 4)); // Write the size + memcpy_s(buffer + 4, 512 - 4, msg, msgLen); + ILibDuktape_MeshAgent_RemoteDesktop_KVM_WriteSink(buffer, msgLen + 4, ptrs); +} +#endif + duk_ret_t ILibDuktape_MeshAgent_getRemoteDesktop(duk_context *ctx) { #ifndef _LINKVM @@ -1415,6 +1428,12 @@ duk_ret_t ILibDuktape_MeshAgent_getRemoteDesktop(duk_context *ctx) })();") == 0) { updateXAuth = (char*)duk_get_string(ctx, -1); + if (console_uid != 0 && updateXAuth == NULL) + { + ILibDuktape_MeshAgent_RemoteDesktop_SendError(ptrs, "Xauthority not found! Is you DM configured to use X?"); + duk_pop(ctx); + return(1); + } } needPop = 1; } diff --git a/modules/user-sessions.js b/modules/user-sessions.js index 730949b..1e245df 100644 --- a/modules/user-sessions.js +++ b/modules/user-sessions.js @@ -692,7 +692,7 @@ function UserSessions() tokens = lines[i].split(' '); for (j = 1; j < tokens.length; ++j) { - if (tokens[j].length > 0 && (tokens[j] == checkstr || tokens[j] == ('(' + checkstr + ')'))) + if (tokens[j].length > 0) { return (parseInt(this._users()[tokens[0]])); }