From 9fd40751b20b1c3055025c639c11725d3444ade1 Mon Sep 17 00:00:00 2001 From: si458 Date: Sun, 9 Feb 2025 21:41:08 +0000 Subject: [PATCH] fix remote desktop consent for rdp sessions #6710 Signed-off-by: si458 --- agents/meshcore.js | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/agents/meshcore.js b/agents/meshcore.js index 13d73476..37253156 100644 --- a/agents/meshcore.js +++ b/agents/meshcore.js @@ -2318,9 +2318,10 @@ function terminal_consent_ask(ws) { ipr.consentTimeout = ws.httprequest.consentTimeout; ipr.consentAutoAccept = ws.httprequest.consentAutoAccept; ipr.username = ws.httprequest.realname; + ipr.tsid = ws.tsid; ipr.translations = { Allow: currentTranslation['allow'], Deny: currentTranslation['deny'], Auto: currentTranslation['autoAllowForFive'], Caption: consentMessage }; ws.httprequest.tpromise._consent = ipr.then(function (img) { - this.consent = require('win-userconsent').create(this.consentTitle, this.consentMessage, this.username, { b64Image: img.split(',').pop(), timeout: this.consentTimeout * 1000, timeoutAutoAccept: this.consentAutoAccept, translations: this.translations, background: color_options.background, foreground: color_options.foreground }); + this.consent = require('win-userconsent').create(this.consentTitle, this.consentMessage, this.username, { b64Image: img.split(',').pop(), uid: this.tsid, timeout: this.consentTimeout * 1000, timeoutAutoAccept: this.consentAutoAccept, translations: this.translations, background: color_options.background, foreground: color_options.foreground }); this.__childPromise.close = this.consent.close.bind(this.consent); return (this.consent); }); @@ -2736,7 +2737,7 @@ function kvm_consent_ask(ws){ ipr.consentMessage = consentMessage; ipr.consentTimeout = ws.httprequest.consentTimeout; ipr.consentAutoAccept = ws.httprequest.consentAutoAccept; - ipr.tsid = this.tsid; + ipr.tsid = ws.tsid; ipr.username = ws.httprequest.realname; ipr.translation = { Allow: currentTranslation['allow'], Deny: currentTranslation['deny'], Auto: currentTranslation['autoAllowForFive'], Caption: consentMessage }; pr = ipr.then(function (img) { @@ -2877,9 +2878,10 @@ function files_consent_ask(ws){ ipr.consentTimeout = ws.httprequest.consentTimeout; ipr.consentAutoAccept = ws.httprequest.consentAutoAccept; ipr.username = ws.httprequest.realname; + ipr.tsid = ws.tsid; ipr.translations = { Allow: currentTranslation['allow'], Deny: currentTranslation['deny'], Auto: currentTranslation['autoAllowForFive'], Caption: consentMessage }; pr = ipr.then(function (img) { - this.consent = require('win-userconsent').create(this.consentTitle, this.consentMessage, this.username, { b64Image: img.split(',').pop(), timeout: this.consentTimeout * 1000, timeoutAutoAccept: this.consentAutoAccept, translations: this.translations, background: color_options.background, foreground: color_options.foreground }); + this.consent = require('win-userconsent').create(this.consentTitle, this.consentMessage, this.username, { b64Image: img.split(',').pop(), uid: this.tsid, timeout: this.consentTimeout * 1000, timeoutAutoAccept: this.consentAutoAccept, translations: this.translations, background: color_options.background, foreground: color_options.foreground }); this.__childPromise.close = this.consent.close.bind(this.consent); return (this.consent); }); @@ -3009,6 +3011,12 @@ function onTunnelData(data) this.descriptorMetadata = "Remote Terminal"; + // Look for a TSID + var tsid = null; + if ((this.httprequest.xoptions != null) && (typeof this.httprequest.xoptions.tsid == 'number')) { tsid = this.httprequest.xoptions.tsid; } + require('MeshAgent')._tsid = tsid; + this.tsid = tsid; + if (process.platform == 'win32') { if (!require('win-terminal').PowerShellCapable() && (this.httprequest.protocol == 6 || this.httprequest.protocol == 9)) { @@ -3193,6 +3201,12 @@ function onTunnelData(data) this.descriptorMetadata = "Remote Files"; + // Look for a TSID + var tsid = null; + if ((this.httprequest.xoptions != null) && (typeof this.httprequest.xoptions.tsid == 'number')) { tsid = this.httprequest.xoptions.tsid; } + require('MeshAgent')._tsid = tsid; + this.tsid = tsid; + // Add the files session to the count to update the server if (this.httprequest.userid != null) { var userid = getUserIdAndGuestNameFromHttpRequest(this.httprequest);