Compare commits

...

4 commits

Author SHA1 Message Date
12fdf40cda Merge pull request 'Implement warning thresholds for OpenPGP' (!31) from unify-behaviour-of-x509-and-gpg-retries into main
Reviewed-on: #31
Reviewed-by: Brian Mc Cullough <bmccullough@cacert.org>
Reviewed-by: Dirk Astrath <dirk@cacert.org>
2024-10-07 20:59:40 +00:00
3a3dae868e Merge pull request 'Fix server cert expiry queries' (!29) from fix-user-deletion-sql into main
Reviewed-on: #29
Reviewed-by: Dirk Astrath <dirk@cacert.org>
2024-10-05 19:26:37 +00:00
de3cf38c5d Implement warning thresholds for OpenPGP
This patch fixes https://bugs.cacert.org/view.php?id=1530 by adding the same
warning threshold behaviour for OpenPGP signing requests that exists for
X.509 signing requests.

The warning threshold has been moved to a variable. The SQL statements are
created using an sprintf statement to avoid potential SQL injections that may
get introduced by setting the warning_threshold variable to an invalid valid.

Fixes #1530
2024-10-05 17:24:49 +02:00
18ffb1b781 Fix server cert expiry queries
Addresses #1544
2024-10-05 09:55:10 +02:00
2 changed files with 16 additions and 9 deletions

View file

@ -40,6 +40,9 @@ my $paranoid=1;
my $debug=0;
# number of attempts before giving up
my $warn_threshold = 3;
#my $serialport="/dev/ttyS0";
my $serialport="/dev/ttyUSB0";
@ -734,7 +737,9 @@ sub HandleCerts($$)
SysLog "HandleCerts $table\n";
my $sth = $dbh->prepare("select * from $table where crt_name='' and csr_name!='' and warning<3");
my $sth = $dbh->prepare(sprintf(
"select * from %s where crt_name='' and csr_name!='' and warning<%d", $table, $warn_threshold
));
$sth->execute();
#$rowdata;
while ( my $rowdata = $sth->fetchrow_hashref() )
@ -904,7 +909,7 @@ sub HandleCerts($$)
else
{
SysLog("Could not find the issued certificate. $crtname ".$row{"id"}."\n");
$dbh->do("update `$table` set warning=warning+1 where `id`='".$row{'id'}."'");
$dbh->do(sprintf("update %s set warning=warning+1 where id=%d", $table, $row{'id'}));
}
}
}
@ -1078,7 +1083,9 @@ sub sendRevokeMail()
sub HandleGPG()
{
my $sth = $dbh->prepare("select * from gpg where crt='' and csr!='' ");
my $sth = $dbh->prepare(sprintf(
"select * from gpg where crt='' and csr!='' and warning<%d", $warn_threshold
));
$sth->execute();
my $rowdata;
while ( $rowdata = $sth->fetchrow_hashref() )
@ -1144,7 +1151,7 @@ sub HandleGPG()
sendmail($user{email}, "[CAcert.org] Your GPG/PGP Key", $body, "support\@cacert.org", "", "", "CAcert Support");
} else {
SysLog("Could not find the issued gpg key. ".$row{"id"}."\n");
#$dbh->do("delete from `gpg` where `id`='".$row{'id'}."'");
$dbh->do(sprintf("update gpg set warning=warning+1 where id=%d", $row{'id'}));
}
}
}

View file

@ -1273,19 +1273,19 @@ function get_user_agreements($memid, $type=null, $active=null){
select 1 from `domaincerts` join `domains`
on `domaincerts`.`domid` = `domains`.`id`
where `domains`.`memid` = '$uid'
and `revoked`>NOW()";
}else{
and `domaincerts`.`revoked` > NOW()";
} else {
$query1 = "
select 1 from `domaincerts` join `domains`
on `domaincerts`.`domid` = `domains`.`id`
where `domains`.`memid` = '$uid'
and `expire`>( SUBDATE( NOW(), 90 ))
and `revoked`<`created`";
and `domaincerts`.`expire` > ( SUBDATE( NOW(), 90 ))
and `domaincerts`.`revoked` < `domaincerts`.`created`";
$query2 = "
select 1 from `domaincerts` join `domains`
on `domaincerts`.`domid` = `domains`.`id`
where `domains`.`memid` = '$uid'
and `revoked`>( SUBDATE( NOW(), 90 ))";
and `domaincerts`.`revoked` > ( SUBDATE( NOW(), 90 ))";
}
$res = mysql_query($query1);
$r1 = mysql_num_rows($res)>0;