Merge gpg verify function into newsportal.php for use in nocem.php and interBBS_mail.php.
This commit is contained in:
parent
c9fafb0f97
commit
6e50c0d53d
|
@ -1668,6 +1668,15 @@ function write_access_log() {
|
|||
file_put_contents($accessfile, "\n".format_log_date()." ".$currentPageUrl, FILE_APPEND);
|
||||
}
|
||||
|
||||
function verify_gpg_signature($res, $signed_text) {
|
||||
$result = gnupg_verify($res,$signed_text,false);
|
||||
if ((($result[0]['summary'] > 3)) || $result[0]['validity'] == 2){
|
||||
return false; // Bad signature
|
||||
} else {
|
||||
return true; // Good signature
|
||||
}
|
||||
}
|
||||
|
||||
function get_db_data_from_msgid($msgid, $group) {
|
||||
global $spooldir;
|
||||
$database = $spooldir.'/'.$group.'-articles.db3';
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
}
|
||||
|
||||
putenv("GNUPGHOME=".$rslight_gpg['gnupghome']);
|
||||
$res = gnupg_init();
|
||||
|
||||
$webserver_group=$CONFIG['webserver_user'];
|
||||
$logfile=$logdir.'/nocem.log';
|
||||
@mkdir($spooldir."/nocem/processed",0755,'recursive');
|
||||
|
@ -35,14 +37,14 @@
|
|||
continue;
|
||||
}
|
||||
$signed_text=file_get_contents($nocem_file);
|
||||
if(verify_signature($signed_text) == 1) {
|
||||
if(verify_gpg_signature($res, $signed_text) == 1) {
|
||||
file_put_contents($logfile, "\n".format_log_date()." ".$config_name." Good signature in: ".$message, FILE_APPEND);
|
||||
echo "Good signature in: ".$message."\r\n";
|
||||
} else {
|
||||
file_put_contents($logfile, "\n".format_log_date()." ".$config_name." Bad signature in: ".$message, FILE_APPEND);
|
||||
echo "Bad signature in: ".$message."\r\n";
|
||||
rename($nocem_file, $nocem_path."failed/".$message);
|
||||
continue;
|
||||
} else {
|
||||
file_put_contents($logfile, "\n".format_log_date()." ".$config_name." Good signature in: ".$message, FILE_APPEND);
|
||||
echo "Good signature in: ".$message."\r\n";
|
||||
}
|
||||
$nocem_list=file($nocem_file, FILE_IGNORE_NEW_LINES);
|
||||
$start=0;
|
||||
|
@ -67,18 +69,6 @@
|
|||
unlink($lockfile);
|
||||
exit;
|
||||
|
||||
function verify_signature($signed_text) {
|
||||
$plaintext = "";
|
||||
$res = gnupg_init();
|
||||
$info = gnupg_verify($res,$signed_text,false,$plaintext);
|
||||
|
||||
if($info[0]['status'] == 0 && $info[0]['summary'] == 0) {
|
||||
return 0;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
function delete_message($messageid, $group) {
|
||||
global $logfile,$config_dir,$spooldir, $CONFIG, $webserver_group;
|
||||
|
||||
|
|
Loading…
Reference in New Issue