Repository: vcl
Updated Branches:
  refs/heads/VCL-1080_RDP_file_port [created] cf8c88d62


VCL-1080 - Wrong port can be delivered in RDP file

requests.php: modified AJconnectRequest: added cmid to data saved in
continuation for sendRDPfile

utils.php: modified sendRDPfile: get $cmid from continuation; no longer
loop through connect methods to guess which connect method to use; just
use the one referenced by $cmid and get port information from it


Project: http://git-wip-us.apache.org/repos/asf/vcl/repo
Commit: http://git-wip-us.apache.org/repos/asf/vcl/commit/c5413288
Tree: http://git-wip-us.apache.org/repos/asf/vcl/tree/c5413288
Diff: http://git-wip-us.apache.org/repos/asf/vcl/diff/c5413288

Branch: refs/heads/VCL-1080_RDP_file_port
Commit: c54132882f05c427c7a165de561005e60c17d37b
Parents: f62627f
Author: Josh Thompson <[email protected]>
Authored: Wed May 9 15:10:39 2018 -0400
Committer: Josh Thompson <[email protected]>
Committed: Wed May 9 15:10:39 2018 -0400

----------------------------------------------------------------------
 web/.ht-inc/requests.php |  3 ++-
 web/.ht-inc/utils.php    | 34 ++++++++++++++++++----------------
 2 files changed, 20 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/vcl/blob/c5413288/web/.ht-inc/requests.php
----------------------------------------------------------------------
diff --git a/web/.ht-inc/requests.php b/web/.ht-inc/requests.php
index 9d8d8ce..a497ba4 100644
--- a/web/.ht-inc/requests.php
+++ b/web/.ht-inc/requests.php
@@ -4421,7 +4421,8 @@ function AJconnectRequest() {
                                #$h .= "<div id=\"connectdiv\">\n";
                                $h .= "<FORM action=\"" . BASEURL . SCRIPT . 
"\" method=post>\n";
                                $cdata = array('requestid' => $requestid,
-                                              'resid' => 
$res['reservationid']);
+                                              'resid' => $res['reservationid'],
+                                              'cmid' => $cmid);
                                $expire = datetimeToUnix($requestData['end']) - 
$now + 1800; # remaining reservation time plus 30 min
                                $cont = addContinuationsEntry('sendRDPfile', 
$cdata, $expire);
                                $h .= "<INPUT type=hidden name=continuation 
value=\"$cont\">\n";

http://git-wip-us.apache.org/repos/asf/vcl/blob/c5413288/web/.ht-inc/utils.php
----------------------------------------------------------------------
diff --git a/web/.ht-inc/utils.php b/web/.ht-inc/utils.php
index feaabef..f7ca371 100644
--- a/web/.ht-inc/utils.php
+++ b/web/.ht-inc/utils.php
@@ -10468,13 +10468,16 @@ function unset_by_val($needle, &$haystack) {
 
////////////////////////////////////////////////////////////////////////////////
 function sendRDPfile() {
        global $user;
-       # for more info on this file, see 
+       # for more info on this file, see
        # http://dev.remotenetworktechnology.com/ts/rdpfile.htm
        $requestid = getContinuationVar("requestid");
        $resid = getContinuationVar("resid");
+
+       $cmid = getContinuationVar('cmid');
+
        $request = getRequestInfo("$requestid");
        if($request['stateid'] == 11 || $request['stateid'] == 12 ||
-          ($request['stateid'] == 14 && 
+          ($request['stateid'] == 14 &&
           ($request['laststateid'] == 11 || $request['laststateid'] == 12))) {
                $cont = addContinuationsEntry('viewRequests');
                header("Location: " . BASEURL . SCRIPT . "?continuation=$cont");
@@ -10494,20 +10497,19 @@ function sendRDPfile() {
                                                  $res['imagerevisionid']);
        $natports = getNATports($resid);
        $port = '';
-       foreach($connectData as $cmid => $method) {
-               if(preg_match('/remote desktop/i', $method['description']) ||
-                  preg_match('/RDP/i', $method['description'])) {
-                       # assume index 0 of ports for nat
-                       if(! empty($natports) && 
array_key_exists($method['ports'][0]['key'], $natports[$cmid]))
-                               $port = ':' . 
$natports[$cmid][$method['ports'][0]['key']]['publicport'];
-                       else {
-                               if($method['ports'][0]['key'] == 
'#Port-TCP-3389#' &&
-                                  $user['rdpport'] != 3389)
-                                       $port = ':' . $user['rdpport'];
-                               else
-                                       $port = ':' . 
$method['ports'][0]['port'];
-                       }
-                       break;
+
+       $method = $connectData[$cmid];
+       if(preg_match('/remote desktop/i', $method['description']) ||
+          preg_match('/RDP/i', $method['description'])) {
+               # assume index 0 of ports for nat
+               if(! empty($natports) && 
array_key_exists($method['ports'][0]['key'], $natports[$cmid]))
+                       $port = ':' . 
$natports[$cmid][$method['ports'][0]['key']]['publicport'];
+               else {
+                       if($method['ports'][0]['key'] == '#Port-TCP-3389#' &&
+                          $user['rdpport'] != 3389)
+                               $port = ':' . $user['rdpport'];
+                       else
+                               $port = ':' . $method['ports'][0]['port'];
                }
        }
 

Reply via email to