new: [diagnostic] Show installed GnuPG version

pull/6588/head
Jakub Onderka 2020-11-16 09:22:03 +01:00
parent a306784844
commit 73b63e2ccd
2 changed files with 26 additions and 20 deletions

View File

@ -5258,43 +5258,49 @@ class Server extends AppModel
return $result;
}
/**
* @param int $diagnostic_errors
* @return array
*/
public function gpgDiagnostics(&$diagnostic_errors)
{
$gpgStatus = 0;
$output = ['status' => 0, 'version' => null];
if (Configure::read('GnuPG.email') && Configure::read('GnuPG.homedir')) {
$continue = true;
try {
$gpg = GpgTool::initializeGpg();
} catch (Exception $e) {
$this->logException("Error during initializing GPG.", $e, LOG_NOTICE);
$gpgStatus = 2;
$continue = false;
$output['status'] = 2;
}
if ($continue) {
if ($output['status'] === 0) {
try {
$key = $gpg->addSignKey(Configure::read('GnuPG.email'), Configure::read('GnuPG.password'));
$output['version'] = $gpg->getVersion();
} catch (Exception $e) {
// ingore
}
try {
$gpg->addSignKey(Configure::read('GnuPG.email'), Configure::read('GnuPG.password'));
} catch (Exception $e) {
$this->logException("Error during adding GPG signing key.", $e, LOG_NOTICE);
$gpgStatus = 3;
$continue = false;
$output['status'] = 3;
}
}
if ($continue) {
if ($output['status'] === 0) {
try {
$gpgStatus = 0;
$signed = $gpg->sign('test', Crypt_GPG::SIGN_MODE_CLEAR);
$gpg->sign('test', Crypt_GPG::SIGN_MODE_CLEAR);
} catch (Exception $e) {
$this->logException("Error during GPG signing.", $e, LOG_NOTICE);
$gpgStatus = 4;
$output['status'] = 4;
}
}
} else {
$gpgStatus = 1;
$output['status'] = 1;
}
if ($gpgStatus != 0) {
if ($output['status'] !== 0) {
$diagnostic_errors++;
}
return $gpgStatus;
return $output;
}
public function zmqDiagnostics(&$diagnostic_errors)

View File

@ -351,12 +351,12 @@
<p><?php echo __('This tool tests whether your GnuPG is set up correctly or not.');?></p>
<div style="background-color:#f7f7f9;width:400px;">
<?php
$colour = 'green';
$message = $gpgErrors[$gpgStatus];
if ($gpgStatus > 0) {
$colour = 'red';
$message = $gpgErrors[$gpgStatus['status']];
$color = $gpgStatus['status'] === 0 ? 'green' : 'red';
echo __('GnuPG installation and settings') . '…<span style="color:' . $color . '">' . $message . '</span><br>';
if ($gpgStatus['version']) {
echo __('GnuPG version: %s', $gpgStatus['version'] ?: __('N/A'));
}
echo __('GnuPG installation and settings') . '…<span style="color:' . $colour . ';">' . $message . '</span>';
?>
</div>
<h3><?php echo __('ZeroMQ');?></h3>