fix remote desktop consent for rdp sessions #6710

Signed-off-by: si458 <simonsmith5521@gmail.com>

si458 committed Feb 9, 2025 at 21:41 UTC 9fd40751b20b1c3055025c639c11725d3444ade1
1 file changed +17 -3
agents/meshcore.js
+17 -3
@@ -2318,9 +2318,10 @@ function terminal_consent_ask(ws) {
2318 ipr.consentTimeout = ws.httprequest.consentTimeout;
2319 ipr.consentAutoAccept = ws.httprequest.consentAutoAccept;
2320 ipr.username = ws.httprequest.realname;
2321 + ipr.tsid = ws.tsid;
2322 ipr.translations = { Allow: currentTranslation['allow'], Deny: currentTranslation['deny'], Auto: currentTranslation['autoAllowForFive'], Caption: consentMessage };
2323 ws.httprequest.tpromise._consent = ipr.then(function (img) {
2323 - 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 });
2324 + 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 });
2325 this.__childPromise.close = this.consent.close.bind(this.consent);
2326 return (this.consent);
2327 });
@@ -2736,7 +2737,7 @@ function kvm_consent_ask(ws){
2737 ipr.consentMessage = consentMessage;
2738 ipr.consentTimeout = ws.httprequest.consentTimeout;
2739 ipr.consentAutoAccept = ws.httprequest.consentAutoAccept;
2739 - ipr.tsid = this.tsid;
2740 + ipr.tsid = ws.tsid;
2741 ipr.username = ws.httprequest.realname;
2742 ipr.translation = { Allow: currentTranslation['allow'], Deny: currentTranslation['deny'], Auto: currentTranslation['autoAllowForFive'], Caption: consentMessage };
2743 pr = ipr.then(function (img) {
@@ -2877,9 +2878,10 @@ function files_consent_ask(ws){
2878 ipr.consentTimeout = ws.httprequest.consentTimeout;
2879 ipr.consentAutoAccept = ws.httprequest.consentAutoAccept;
2880 ipr.username = ws.httprequest.realname;
2881 + ipr.tsid = ws.tsid;
2882 ipr.translations = { Allow: currentTranslation['allow'], Deny: currentTranslation['deny'], Auto: currentTranslation['autoAllowForFive'], Caption: consentMessage };
2883 pr = ipr.then(function (img) {
2882 - 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 });
2884 + 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 });
2885 this.__childPromise.close = this.consent.close.bind(this.consent);
2886 return (this.consent);
2887 });
@@ -3009,6 +3011,12 @@ function onTunnelData(data)
3011
3012 this.descriptorMetadata = "Remote Terminal";
3013
3014 + // Look for a TSID
3015 + var tsid = null;
3016 + if ((this.httprequest.xoptions != null) && (typeof this.httprequest.xoptions.tsid == 'number')) { tsid = this.httprequest.xoptions.tsid; }
3017 + require('MeshAgent')._tsid = tsid;
3018 + this.tsid = tsid;
3019 +
3020 if (process.platform == 'win32')
3021 {
3022 if (!require('win-terminal').PowerShellCapable() && (this.httprequest.protocol == 6 || this.httprequest.protocol == 9)) {
@@ -3193,6 +3201,12 @@ function onTunnelData(data)
3201
3202 this.descriptorMetadata = "Remote Files";
3203
3204 + // Look for a TSID
3205 + var tsid = null;
3206 + if ((this.httprequest.xoptions != null) && (typeof this.httprequest.xoptions.tsid == 'number')) { tsid = this.httprequest.xoptions.tsid; }
3207 + require('MeshAgent')._tsid = tsid;
3208 + this.tsid = tsid;
3209 +
3210 // Add the files session to the count to update the server
3211 if (this.httprequest.userid != null) {
3212 var userid = getUserIdAndGuestNameFromHttpRequest(this.httprequest);