-
Improvement
-
Resolution: Deferred
-
Minor
-
None
-
3.7.1
-
None
-
MOODLE_37_STABLE
this has been used for a very long time to secure the key comparison in mnet exchanges, specially when mixing Windows and Linux underlyig servers.
Code is in /admin/mnet/peers.php
// editing a host - load up the review form
if (!empty($hostid)) {
// TODO print a nice little heading
$mnet_peer->set_id($hostid);
echo $OUTPUT->header();
$currenttab = 'mnetdetails';
require_once($CFG->dirroot . '/' . $CFG->admin . '/mnet/tabs.php');
if ($hostid != $CFG->mnet_all_hosts_id) {
$mnet_peer->currentkey = mnet_get_public_key($mnet_peer->wwwroot, $mnet_peer->application);
// PATCH+ : Secures the comparison.
$mnet_peer->currentkey = str_replace("\r", '', trim($mnet_peer->currentkey));
$mnet_peer->public_key = str_replace("\r", '', trim($mnet_peer->public_key));
// PATCH-.
if ($mnet_peer->currentkey == $mnet_peer->public_key)
else
{ error_log($mnet_peer->currentkey); error_log($mnet_peer->public_key); error_log(md5($mnet_peer->currentkey)); error_log(md5($mnet_peer->public_key)); } $credentials = $mnet_peer->check_credentials($mnet_peer->public_key);
$reviewform = new mnet_review_host_form(null, array('peer' => $mnet_peer)); // the second step (also the edit host form)
$mnet_peer->oldpublickey = $mnet_peer->public_key; // set this so we can confirm on form post without having to recreate the mnet_peer object
$reviewform->set_data((object)$mnet_peer);
echo $OUTPUT->box_start();
$reviewform->display();
echo $OUTPUT->box_end();
} else
echo $OUTPUT->footer();
exit;
}
This addresses a very odd situation in which moodle reports that the key do NOT match, although display tells the opposite (same visible key).
the patch secures the key endlines to be sure they match Linux standards.