1
0
mirror of https://github.com/Yubico/yubikey-val.git synced 2025-02-08 03:54:20 +01:00

Cosmetic changes.

- remove last remaining tabs,
	so now the whole file is using the same indentation convention.
This commit is contained in:
Jean Paul Galea 2015-07-15 17:52:26 +02:00
parent 2cc0f50257
commit 514b943945

View File

@ -353,95 +353,104 @@ class SyncLib
$ch = curl_init(); $ch = curl_init();
while ($entry=$this->db->fetchArray($res)) { while ($entry=$this->db->fetchArray($res)) {
$this->log(LOG_INFO, "server=" . $entry['server'] . ", server_nonce=" . $entry['server_nonce'] . ", info=" . $entry['info']); $this->log(LOG_INFO, "server=" . $entry['server'] . ", server_nonce=" . $entry['server_nonce'] . ", info=" . $entry['info']);
$url=$entry['server'] . $url=$entry['server'] .
"?otp=" . $entry['otp'] . "?otp=" . $entry['otp'] .
"&modified=" . $entry['modified'] . "&modified=" . $entry['modified'] .
"&" . $this->otpPartFromInfoString($entry['info']); "&" . $this->otpPartFromInfoString($entry['info']);
/* Send out sync request */ /* Send out sync request */
curl_settings($this, "YK-VAL resync", $ch, $url, $timeout, $this->curlopts); curl_settings($this, "YK-VAL resync", $ch, $url, $timeout, $this->curlopts);
$response = curl_exec($ch); $response = curl_exec($ch);
if ($response==False) { if ($response==False) {
$this->log(LOG_NOTICE, 'Timeout. Stopping queue resync for server ' . $entry['server']); $this->log(LOG_NOTICE, 'Timeout. Stopping queue resync for server ' . $entry['server']);
break; break;
} }
if (preg_match("/status=OK/", $response)) { if (preg_match("/status=OK/", $response)) {
$resParams=$this->parseParamsFromMultiLineString($response); $resParams=$this->parseParamsFromMultiLineString($response);
$this->log(LOG_DEBUG, "response contains ", $resParams); $this->log(LOG_DEBUG, "response contains ", $resParams);
/* Update database counters */ /* Update database counters */
$this->updateDbCounters($resParams); $this->updateDbCounters($resParams);
/* Retrieve info from entry info string */ /* Retrieve info from entry info string */
/* This is the counter values we had in our database *before* processing the current OTP. */ /* This is the counter values we had in our database *before* processing the current OTP. */
$validationParams=$this->localParamsFromInfoString($entry['info']); $validationParams=$this->localParamsFromInfoString($entry['info']);
/* This is the data from the current OTP. */ /* This is the data from the current OTP. */
$otpParams=$this->otpParamsFromInfoString($entry['info']); $otpParams=$this->otpParamsFromInfoString($entry['info']);
/* Fetch current information from our database */ /* Fetch current information from our database */
$localParams=$this->getLocalParams($otpParams['yk_publicname']); $localParams=$this->getLocalParams($otpParams['yk_publicname']);
$this->log(LOG_DEBUG, "validation params: ", $validationParams); $this->log(LOG_DEBUG, "validation params: ", $validationParams);
$this->log(LOG_DEBUG, "OTP params: ", $otpParams); $this->log(LOG_DEBUG, "OTP params: ", $otpParams);
/* Check for warnings */ /* Check for warnings */
if ($this->countersHigherThan($validationParams, $resParams)) { if ($this->countersHigherThan($validationParams, $resParams)) {
$this->log(LOG_NOTICE, "Remote server out of sync compared to counters at validation request time. "); $this->log(LOG_NOTICE, "Remote server out of sync compared to counters at validation request time. ");
} }
if ($this->countersHigherThan($resParams, $validationParams)) { if ($this->countersHigherThan($resParams, $validationParams)) {
if ($this->countersEqual($resParams, $otpParams)) { if ($this->countersEqual($resParams, $otpParams)) {
$this->log(LOG_INFO, "Remote server had received the current counter values already. "); $this->log(LOG_INFO, "Remote server had received the current counter values already. ");
} else { } else {
$this->log(LOG_NOTICE, "Local server out of sync compared to counters at validation request time. "); $this->log(LOG_NOTICE, "Local server out of sync compared to counters at validation request time. ");
} }
} }
if ($this->countersHigherThan($localParams, $resParams)) { if ($this->countersHigherThan($localParams, $resParams)) {
$this->log(LOG_WARNING, "Remote server out of sync compared to current local counters. "); $this->log(LOG_WARNING, "Remote server out of sync compared to current local counters. ");
} }
if ($this->countersHigherThan($resParams, $localParams)) { if ($this->countersHigherThan($resParams, $localParams)) {
$this->log(LOG_WARNING, "Local server out of sync compared to current local counters. Local server updated. "); $this->log(LOG_WARNING, "Local server out of sync compared to current local counters. Local server updated. ");
} }
if ($this->countersHigherThan($resParams, $otpParams)) { if ($this->countersHigherThan($resParams, $otpParams)) {
$this->log(LOG_ERR, "Remote server has higher counters than OTP. This response would have marked the OTP as invalid. "); $this->log(LOG_ERR, "Remote server has higher counters than OTP. This response would have marked the OTP as invalid. ");
} }
elseif ($this->countersEqual($resParams, $otpParams) && elseif ($this->countersEqual($resParams, $otpParams)
$resParams['nonce']!=$otpParams['nonce']) { && $resParams['nonce']!=$otpParams['nonce']) {
$this->log(LOG_ERR, "Remote server has equal counters as OTP and nonce differs. This response would have marked the OTP as invalid."); $this->log(LOG_ERR, "Remote server has equal counters as OTP and nonce differs. This response would have marked the OTP as invalid.");
} }
/* Deletion */ /* Deletion */
$this->log(LOG_DEBUG, 'deleting queue entry with modified=' . $entry['modified'] . $this->log(LOG_DEBUG, 'deleting queue entry with modified=' . $entry['modified'] .
' server_nonce=' . $entry['server_nonce'] . ' server_nonce=' . $entry['server_nonce'] .
' server=' . $entry['server']); ' server=' . $entry['server']);
$this->db->deleteByMultiple('queue',
array("modified"=>$entry['modified'], $this->db->deleteByMultiple('queue', array(
"server_nonce"=>$entry['server_nonce'], 'modified' => $entry['modified'],
'server'=>$entry['server'])); 'server_nonce' => $entry['server_nonce'],
} else if (preg_match("/status=BAD_OTP/", $response)) { 'server' => $entry['server']
$this->log(LOG_WARNING, "Remote server says BAD_OTP, pointless to try again, removing from queue."); ));
$this->db->deleteByMultiple('queue',
array("modified"=>$entry['modified'], }
"server_nonce"=>$entry['server_nonce'], else if (preg_match("/status=BAD_OTP/", $response)) {
'server'=>$entry['server'])); $this->log(LOG_WARNING, "Remote server says BAD_OTP, pointless to try again, removing from queue.");
} else { $this->db->deleteByMultiple('queue', array(
$this->log(LOG_ERR, "Remote server refused our sync request. Check remote server logs."); 'modified' => $entry['modified'],
} 'server_nonce' => $entry['server_nonce'],
'server' => $entry['server']
));
}
else {
$this->log(LOG_ERR, "Remote server refused our sync request. Check remote server logs.");
}
} /* End of loop over each queue entry for a server */ } /* End of loop over each queue entry for a server */
curl_close($ch); curl_close($ch);
$this->db->closeCursor($res); $this->db->closeCursor($res);
} /* End of loop over each distinct server in queue */ } /* End of loop over each distinct server in queue */
$this->db->closeCursor($server_res); $this->db->closeCursor($server_res);
return true; return true;
} }