Compare commits

...

16 commits

Author SHA1 Message Date
c4aa189a0f Merge pull request 'Add a contribution guide' (!32) from add-a-contribution-guide into main
Reviewed-on: #32
Reviewed-by: Brian Mc Cullough <bmccullough@cacert.org>
Reviewed-by: Dirk Astrath <dirk@cacert.org>
2024-10-17 22:45:50 +00:00
d6baac39d6 Add a section explaining the OpenID connect link 2024-10-08 09:02:20 +02:00
afcf1b5d37 Add missing closing quote 2024-10-08 08:58:19 +02:00
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
fae023e712 Add a contribution guide
This commit adds an initial version of a contribution guide to help new
contributors.
2024-10-05 18:25:39 +02: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
efe24df995 Merge pull request 'Add policy/CCA mail script for 2024-09-25 mailing' (!28) from send-policy-cca-script-202409 into main
Reviewed-on: #28
Reviewed-by: Dirk Astrath <dirk@cacert.org>
2024-10-01 09:17:03 +00:00
6c40447437 Merge pull request 'Ignore generated files' (!27) from ignore-generated-files into main
Reviewed-on: #27
Reviewed-by: Dirk Astrath <dirk@cacert.org>
2024-10-01 09:12:09 +00:00
bb4d099ea1 Add policy/CCA mail script for 2024-09-25 mailing
Signed-off-by: Jan Dittberner <jandd@cacert.org>
2024-10-01 10:56:43 +02:00
685ff8f2b8 Ignore generated files
- ignore multiple files from production (CommModule logs and debug
  output), tarballs, lastid files from scripts
- ignore files that are left over by patch, vim and JetBrains IDEs
  during development
2024-10-01 10:51:42 +02:00
7d0cb00de2 Merge pull request 'Fix user deletion' (!26) from fix-user-deletion into main
Reviewed-on: #26
Reviewed-by: Dirk Astrath <dirk@cacert.org>
2024-09-30 18:54:35 +00:00
07b1cd75fc Merge pull request 'Fix cats_import' (!25) from fix-cats-importer into main
Reviewed-on: #25
Reviewed-by: Dirk Astrath <dirk@cacert.org>
2024-09-30 18:54:16 +00:00
56c3a8a391 Fix user deletion
Fixes #1544
2024-09-30 08:32:38 +02:00
bba0b479d5 Fix cats_import
- compare the client certificate email address directly instead of
  trying to match DN parts
- improve handling of IP addresses
2024-09-21 10:27:54 +02:00
6 changed files with 433 additions and 26 deletions

9
.gitignore vendored
View file

@ -6,13 +6,22 @@
# Ignore file with the account data
/password.dat
*.orig
*.rej
.*.swp
/.idea/
/CommModule/*-active
/CommModule/infogpg.txt
/CommModule/logfile*txt
/CommModule/nohup*
/CommModule/nohup.out
/CommModule/oldlogs/
/CommModule/serialserver.conf
/crt/
/csr/
/locale/cv
/pages/index/feed.rss
/scripts/*_lastid.txt
/tarballs
/www/*.crl
/www/*.crl.patch

196
CONTRIBUTING.md Normal file
View file

@ -0,0 +1,196 @@
# Contributing to the CAcert code base
This short guide will help you to get your contributions into the cacert-webdb
code base.
## Checking the bug tracker
CAcert tracks bugs in the bug tracker at https://bugs.cacert.org/. Please look
whether the change you want to contribute addresses any of the issues there.
The bug tracker is linked from the "Issues" link on
https://code.cacert.org/cacert/cacert-webdb.
## Clone the repository
You need a local working copy to contribute changes. Get a clone using a git
client of your choice. The following shell snippets use the official git
command line client that can be installed from common Linux distribution
repositories or can be downloaded or installed from [the Git project
website](https://git-scm.com/downloads).
```shell
# go to where you usually store your code or projects
cd ~/projects
# clone the repository
git clone https://code.cacert.org/cacert/cacert-webdb.git
```
## Create a local bugfix branch
Get the latest changes from the original repository before you start
```shell
# go to your local copy of the cacert-webdb repository
cd ~/projects/cacert-webdb
# fetch all recent changes (not needed if you just cloned the repository)
# -p removes local copies of branches that are no longer available in the
# main repository
git fetch --all -p
```
Create a new bugfix branch based on the origin/main branch. The main branch is
where all changes are merged before they are deployed in production.
```
# go to your local copy of the cacert-webdb repository
cd ~/projects/cacert-webdb
# create a new branch from the main branch
git checkout -b the-descriptive-name-for-your-change origin/main
```
## Edit code / documentation
Make sure that you do the minimal required changes to the code or documentation
files, this will make life of reviewers easier. Avoid whitespace changes and
code reformatting that are not related to the lines that you change. Code
reformatting should be performed in separate branches and pull requests that
contain no other changes.
Try to keep your changes small and isolated. A pull request (PR) should focus
on a single purpose.
Code comments should be used to explain the "Why" of code. It does not make
sense to comment things that are obvious from the code itself:
```php
// BAD EXAMPLE, don't do this
// print Hello
print("Hello");
```
## Commit your changes
Commit the changes that you made to your local branch. Please provide a
[meaningful commit message](https://chris.beams.io/posts/git-commit/) and
reference the bug number from the [Bug tracker](https://bugs.cacert.org/) when
you contribute to fix any of the issues.
```shell
git add .
git commit -m "Fix foo in bla subsystem
This commit does XYZ to address ABC.
Address #<number>"
```
You may add more commits but please make sure that you only do changes required
for the specific contribution. Please use new branches for other
features/bugfixes (see above).
## Contribute your changes
There are two ways to contribute changes. You can either push your branch to
https://code.cacert.org/cacert/cacert-webdb or you can upload a series of patches to
the bug tracker. Pushing the changes to https://code.cacert.org/ is the
preferred variant as it makes life of reviewers easier.
If it took a while to prepare your changes you should rebase your branch on the
latest changes in the CAcertOrg/cacert-devel release branch:
```shell
# go to your local copy of the cacert-webdb repository
cd ~/projects/cacert-webdb
git fetch --all -p
git rebase origin/main
```
You might need to fix merge conflicts in case you changed the same lines as
another contributor. A introduction to merge conflict handling can be found in
the [Git Book](https://git-scm.com/book/en/v2/Git-Branching-Basic-Branching-and-Merging#_basic_merge_conflicts).
Please be aware that all of us are volunteers. It might take a while until we
find the time to review and merge your changes.
### Create a pull request on code.cacert.org
You need a user account on code.cacert.org to contribute changes. If you don't
have an account yet send a mail to code-admin@cacert.org and include:
* your full name
* an email address
* a desired short username (up to 16 characters)
* a short introduction about you, if you are not yet known to other members of
the software team
An administrator will create an account for you and give you access to the
repositories. When you have received the welcome mail from the administrator
you should login to https://code.cacert.org/ and set your password.
Once you logged in using your password you may choose to add OpenID Connect
authentication to your account. Visit the
[Security](https://code.cacert.org/user/settings/security) settings of your
account and click on "Link account" and choose "cacert-oidc". You can then use
a CAcert client certificate and use the "Sign in with cacert-oidc" option for
future logins to the code.cacert.org application.
After this onboarding procedure you can push changes to the repository and
create pull requests.
```shell
# go to your local copy of the cacert-webdb repository
cd ~/projects/cacert-webdb
# push your changes
git push -u origin the-descriptive-name-for-your-change
```
The response to the push command will contain a short description and a link to
create a pull request. Please follow that link or go to
https://code.cacert.org/cacert/cacert-webdb/pulls to create a new pull request
from your branch to the main branch.
The code.cacert.org system will suggest a short description based on your
commit messages, you should add more information if you think that reviewers
will need some context to understand your pull requests' intent.
### Submit a series of patches for the bug tracker
If you have reasons not to use the pull request workflow you may create a
series of patches for your changes. Please be aware that this makes reviews
harder and may delay merging the changes.
To create a series of patches use the following:
```shell
# go to your local copy of the cacert-webdb repository
cd ~/projects/cacert-webdb
# fetch the latest changes if it has been a while
git fetch --all -p
# create a patch series and write the patches to the /tmp/ directory
git format-patch -o /tmp origin/main..the-descriptive-name-for-your-change
```
The git format-patch command will output the patch file names, similar to this:
```text
/tmp/0001-Change-the-files-for-me.patch
/tmp/0002-Update-the-documentation.patch
```
To submit this open the corresponding issue in [the bug
tracker](https://bugs.cacert.org/) and attach the patch files to the bug
report. Please add a descriptive comment to help reviewers understand what you
have changed.
## What next?
Once you have submitted your pull request or patch files you need to wait for
reviews. If your changes look ok they will be merged into the main branch.
Deployments to the production system are usually done close to the merges and
will be marked using git tags.
If reviewers ask you for changes to your pull requests please use your local
copy of the cacert-webdb code, add new commits to your branch and push them as
described above. The git format-patch workflow is a bit harder. You will need
to create a new patch series based on what you have submitted before and will
need to attach the new patch(es) to the bug tracker.

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

@ -1234,7 +1234,7 @@ function get_user_agreements($memid, $type=null, $active=null){
if (0==$cca) {
$query = "select 1 from `gpg` where `memid`='$uid' and `expire`>NOW()";
}else{
$query = "select 1 from `gpg` where `memid`='$uid' and `expire`>(NOW()-90*86400)";
$query = "select 1 from `gpg` where `memid`='$uid' and `expire`>( SUBDATE( NOW(), 90 ))";
}
$res = mysql_query($query);
return mysql_num_rows($res) > 0;
@ -1248,8 +1248,8 @@ function get_user_agreements($memid, $type=null, $active=null){
$query1 = "select 1 from `emailcerts` where `memid`='$uid' and `expire`>NOW() and `revoked`<`created`";
$query2 = "select 1 from `emailcerts` where `memid`='$uid' and `revoked`>NOW()";
}else{
$query1 = "select 1 from `emailcerts` where `memid`='$uid' and `expire`>(NOW()-90*86400) and `revoked`<`created`";
$query2 = "select 1 from `emailcerts` where `memid`='$uid' and `revoked`>(NOW()-90*86400)";
$query1 = "select 1 from `emailcerts` where `memid`='$uid' and `expire`>( SUBDATE( NOW(), 90 )) and `revoked`<`created`";
$query2 = "select 1 from `emailcerts` where `memid`='$uid' and `revoked`>( SUBDATE( NOW(), 90 ))";
}
$res = mysql_query($query1);
$r1 = mysql_num_rows($res)>0;
@ -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`>(NOW()-90*86400)
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`>(NOW()-90*86400)";
and `domaincerts`.`revoked` > ( SUBDATE( NOW(), 90 ))";
}
$res = mysql_query($query1);
$r1 = mysql_num_rows($res)>0;

View file

@ -0,0 +1,201 @@
#!/usr/bin/php -q
<?php
/*
LibreSSL - CAcert web application
Copyright (C) 2004-2009 CAcert Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
include_once("../includes/mysql.php");
// read texts
$lines_EN = <<<EOF
[German translation below / Deutsche Uebersetzung weiter unten]
We are writing to you as a member of CAcert. When you became a member of the CAcert community, you accepted the CCA (CAcert Community Agreement) as a basis for your membership. The Policy Group, as the legislative body of our community, has removed the reference to the location of the head office of CAcert Inc. (the association who operates the infrastructure on behalf of the community) from the CCA and a few Policies (RDL, Privacy Policy) as part of the relocation of the association from Australia (New South Wales) to Europe (Switzerland).
This does not change the meaning of the CCA, the policies or the relationship between you, the community and the association. The policies are still based on Common Law. You do not need to take any further action. However, if you do not agree with this change, you must cancel your agreement with the CCA, and, therefore, your membership in the CAcert community, by initiating the appropriate procedure as described in the policies and in the wiki.
While we are it, we would like to take this opportunity to briefly introduce you to some innovations:
The advantage of CAcert's certificates is the personal verification of those certificates by members of the Web of Trust. They can be used for identification, for signing documents or e-mails, for encryption, login, OpenID Connect, etc. In addition, we see good application possibilities in enterprises by means of Organisation Assurance (OrgA), which can also generate income and stabilise our finances.
Do you share our view that CAcert is still useful today? If so, then read on!
We have outlined above some areas where we see the future of CAcert. If you have any other ideas, please write to us. Your ideas are important to CAcert's teams. You may reach them directly using https://wiki.cacert.org/engagement
Apart from the new focus, a lot has happened in the operational area in recent months:
- renewed critical, acess admin and software team
- CAcert Inc. moved from Australia to Europe where most of its members live
- faster and more energy efficient hardware with recent software
- fail over
- OpenID Connect login with certificate [see below for details]
We all know the buttons with which we can log on to any website with our account with a large American Internet company. OpenID Connect is an extremely secure alternative for identity management. Websites and other Internet services can register with CAcert and then CAcert members can use one of their certificates, backed by our Web of Trust, to identify that member without needing to use a password. Password theft is impossible.
Of course, all this always takes time to be done, time required of our group of volunteers. And time is money, because day and night our servers continue to run, needing electric power... The cost for this, three thousand Euros per year, is actually very little.
- If you would like to support CAcert today: A donation of 5, 10, 20 or 50 Euro (francs, dollars) (if possible on a regular basis) already helps CAcert. We accept both cards and bank transfers. See https://wiki.cacert.org/engagement for more information.
- In addition, when you book your business trips and holidays please use our partner Booking.com https://www.booking.com/index.html?aid=346253
- Become a member of the CAcert Inc. association. Applications with postal address to: secretary@cacert.org (annual fee 10 Euro)
If you feel better at providing your skills than your money, read at https://wiki.cacert.org/engagement what you can do. You are more than welcome too! There are technical and non-technical areas, where even small contributions are a great help for running our operations, if they are made regularly and with a long term commitment in mind.
We would like to thank you very much for your participation, help and cooperation. If each of the thousands of CAcert members lifts only a little finger, we will be able to achieve great things!
Best regards
Brian McCullough Etienne Ruedin
President CAcert Inc. Secretary CAcert Inc.
PS: Answers to the most frequently asked questions about CAcert can be found at https://wiki.cacert.org/engagement
----
CAcert Inc.
Clos Belmont 2
1208 Geneva
Switzerland
Donations IBAN CH02 0077 4010 3947 4420 0
----
Wir schreiben Dir als Mitglied von CAcert. Als Du Mitglied der CAcert-Gemeinschaft wurdest, hast Du das CCA (CAcert Community Agreement) als Grundlage fuer Deine Mitgliedschaft akzeptiert. Die Policy Group als gesetzgebendes Organ unserer Gemeinschaft hat im Zuge des Umzugs des Vereins von Australien (Neusuedwales) nach Europa (Schweiz) den Hinweis auf den Sitz von CAcert Inc. (dem Verein, der die Infrastruktur im Auftrag der Gemeinschaft betreibt) aus dem CCA und einigen Policies (RDL, Privacy Policy) entfernt.
Dies aendert nichts an der Bedeutung des CCA, den Richtlinien (Policies) oder der Beziehung zwischen Dir, der Gemeinschaft und dem Verein. Die Richtlinien basieren nach wie vor auf dem Common Law. Du musst keine weiteren Schritte unternehmen. Wenn Du jedoch mit dieser Aenderung nicht einverstanden bist, musst Du Deine Zustimmung zur CCA und damit Deine Mitgliedschaft in der CAcert-Gemeinschaft kuendigen, indem Du das entsprechende Verfahren einleitest, wie in den Richtlinien und im Wiki beschrieben.
Bei dieser Gelegenheit moechten wir Dich kurz auf einige Neuerungen hinweisen:
Der Vorteil von CAcert-Zertifikaten ist die persoenliche Ueberpruefung dieser Zertifikate durch Mitglieder des Web of Trust. Sie koennen zur Identifikation, zum Signieren von Dokumenten oder E-Mails, zur Verschluesselung, zum Login, fuer OpenID Connect, etc. verwendet werden. Darueber hinaus sehen wir gute Anwendungsmoeglichkeiten in Unternehmen durch die Organisation Assurance (OrgA), die auch Einnahmen generieren und unsere Finanzen stabilisieren koennte.
Teilst Du unsere Ansicht, dass CAcert auch heute noch sinnvoll ist? Wenn ja, dann lies weiter!
Wir haben oben einige Bereiche skizziert, in denen wir die Zukunft von CAcert sehen. Wenn Du weitere Ideen hast, schreibe uns bitte. Deine Ideen sind den Teams von CAcert wichtig. Du kannst sie direkt ueber https://wiki.cacert.org/engagement erreichen.
Neben der neuen Ausrichtung hat sich in den letzten Monaten auch im operativen Bereich einiges getan:
- Erneuertes kritisches, Access-Admin- und Software-Team
- CAcert Inc. ist von Australien nach Europa umgezogen, wo die meisten seiner Mitglieder leben
- schnellere und energieeffizientere Hardware mit aktuellerer Software
- Failover
- OpenID Connect Anmeldung mit Zertifikat [Details siehe unten]
Wir alle kennen die Knoepfe, mit denen wir uns mit unserem Konto bei einer grossen amerikanischen Internetfirma auf jeder beliebigen Website anmelden koennen. OpenID Connect ist eine extrem sichere Alternative fuer das Identitaetsmanagement. Websites und andere Internetdienste koennen sich bei CAcert registrieren und dann koennen CAcert-Mitglieder eines ihrer Zertifikate, das durch unser Web of Trust gesichert ist, verwenden, um dieses Mitglied zu identifizieren, ohne ein Passwort verwenden zu muessen. Passwort-Diebstahl ist unmoeglich.
Natuerlich braucht all dies immer Zeit, Zeit, die unsere Gruppe von Freiwilligen benoetigt. Und Zeit ist Geld, denn unsere Server laufen Tag und Nacht weiter und brauchen Strom... Die Kosten dafuer, dreitausend Euro pro Jahr, sind eigentlich sehr gering.
- Wenn Du CAcert heute unterstuetzen moechtest: Eine Spende von 5, 10, 20 oder 50 Euro (Franken, Dollar) (moeglichst regelmaessig) hilft CAcert bereits. Wir akzeptieren sowohl Karten als auch Bankueberweisungen. Siehe https://wiki.cacert.org/engagement fuer weitere Informationen.
- Wenn Du Deine Geschaeftsreisen und Ferien buchst, nutze bitte auch unseren Partner Booking.com https://www.booking.com/index.html?aid=346253
- Werde Mitglied im Verein CAcert Inc. Anmeldungen mit Postanschrift an: secretary@cacert.org (Jahresbeitrag 10 Euro)
Wenn Du lieber Deine Faehigkeiten als Dein Geld zur Verfuegung stellen willst, lies unter https://wiki.cacert.org/engagement, was Du tun kannst. Auch da bist Du mehr als willkommen! Es gibt technische und nicht-technische Bereiche, in denen auch kleine Beitraege eine grosse Hilfe fuer den Betrieb sind, wenn sie regelmaessig und mit langfristigem Engagement geleistet werden.
Wir moechten Dir herzlich fuer Deine Teilnahme, Hilfe und Mitarbeit danken. Wenn jedes der Tausenden von CAcert-Mitgliedern nur einen kleinen Finger ruehrt, werden wir Grosses erreichen koennen!
Mit freundlichen Gruessen
Brian McCullough Etienne Ruedin
Praesident CAcert Inc. Sekretaer CAcert Inc.
PS: Antworten auf die am haeufigsten gestellten Fragen zu CAcert findest Du unter https://wiki.cacert.org/engagement
----
CAcert Inc.
Clos Belmont 2
1208 Geneva
Switzerland
Spendenkonto IBAN CH02 0077 4010 3947 4420 0
EOF;
$lines_EN = wordwrap($lines_EN, 75, "\n");
$lines_EN = mb_convert_encoding($lines_EN, "HTML-ENTITIES", "UTF-8");
// read last used id
$lastid = 0;
if (file_exists("send_policy_cca20240925_lastid.txt"))
{
$fp = fopen("send_policy_cca20240925_lastid.txt", "r");
$lastid = trim(fgets($fp, 4096));
fclose($fp);
}
echo "ID now: $lastid\n";
$count = 0;
$query = "
SELECT `id`, `fname`, `lname`, `email`
FROM `users`
WHERE `deleted` = '0000-00-00 00:00:00'
AND `modified` != '0000-00-00 00:00:00'
AND `verified` = '1'
AND `id` >= '$lastid'
AND email not like 'a20%cacert.org'
ORDER BY `id`";
/*
$query = "
SELECT `id`, `fname`, `lname`, `email`
FROM `users`
WHERE `deleted` = '0000-00-00 00:00:00'
AND `modified` != '0000-00-00 00:00:00'
AND `verified` = '1'
AND (`id` = '87908' or `id` = '12438')
ORDER BY `id`";
*/
$res = mysql_query($query);
while($row = mysql_fetch_assoc($res))
{
$mailtxt = "Dear ${row["fname"]} ${row["lname"]},\n".$lines_EN."\n\n";
sendmail($row['email'], "[CAcert.org] CAcert Inc. moved to Europe (legal information)", $mailtxt, "support@cacert.org", "", "", "CAcert", "returns@cacert.org", "");
$fp = fopen("send_policy_cca20240925_lastid.txt", "w");
fputs($fp, $row["id"]."\n");
fclose($fp);
$count++;
echo "Sent ${count}th mail. User ID: ${row["id"]}\n";
// if(0 == $count % 16) {
// sleep (1);
// }
if ($count >= 3000) {
// avoid memory exhaustion -- this script has a memory leak
echo "Continue\n";
exit(0);
}
}
echo "Stop\n";

View file

@ -1,6 +1,6 @@
<? /*
LibreSSL - CAcert web application
Copyright (C) 2004-2008 CAcert Inc.
Copyright (C) 2004-2024 CAcert Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -31,25 +31,19 @@ function sanitize_string($buffer) {
}
define ('UNDEFINED', 'nd');
define ('ALLOWED_IP', '213.154.225.243');
define ('ALLOWED_IP2', '172.16.2.27');
define ('CONFIG_FILEPATH', '/www/');
$expected_client_address = 'cats@cacert.org';
$allowed_ip_addresses = ['213.154.225.243', '172.16.2.27'];
$remote_addr = (isset($_SERVER['REMOTE_ADDR']))?$_SERVER['REMOTE_ADDR']:UNDEFINED;
$server_name = (isset($_SERVER['SERVER_NAME']))?$_SERVER['SERVER_NAME']:UNDEFINED;
$https = (isset($_SERVER['HTTPS']))?$_SERVER['HTTPS']:UNDEFINED;
$ssl_client_s_dn = (isset($_SERVER['SSL_CLIENT_S_DN']))?$_SERVER['SSL_CLIENT_S_DN']:UNDEFINED;
$ssl_client_email = (isset($_SERVER['SSL_CLIENT_S_DN_Email']))?$_SERVER['SSL_CLIENT_S_DN_Email']:UNDEFINED;
$access = FALSE;
// Access only from CATS.cacert.org with a client certificate for cats@cacert.org
if (
($remote_addr == ALLOWED_IP || $remote_addr == ALLOWED_IP2) &&
$https == 'on' &&
// Comment (to be romeved): better to use preg_match matching the end of the line (since this is on the end of the line right?)
// Ted: Is this specified? I don't think so, therefore I'd keep stristr
strlen(stristr($ssl_client_s_dn, '/emailAddress=cats@cacert.org')) > 0
) $access = TRUE;
// Access only from cats.cacert.org with a client certificate for cats@cacert.org
$access = in_array($remote_addr, $allowed_ip_addresses) && ($https == 'on') && ($ssl_client_email == $expected_client_address);
if ($access !== TRUE) {
echo 'UNAUTHORIZED ACCESS<br>'."\r\n";