View Issue Details

IDProjectCategoryView StatusLast Update
0001171Main CAcert Websitemiscpublic2013-09-03 05:20
Reporterwytze Assigned To 
PriorityurgentSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version2013 Q2 
Target Version2013 Q2Fixed in Version2013 Q2 
Summary0001171: cron-driven warning.php script causes annoying warnings
DescriptionThe scripts/cron/warning.php script is causing annoying warnings after the upgrade to a newer version of PHP (5.3.3) which performs more stringent error checking.
The error is caused by a reference to an unitialized variable in the sendmail() function, which lives in includes/mysql.php (and which is derived from includes/mysql.php.sample). Note that the $_SERVER[] array only contains proper values when running in web server context; however this cron script runs as a standalone script.
The simple and adequate fix is to check for the existence of the referenced variable before actually referencing it, i.e. like this:

    if (array_key_exists("REMOTE_ADDR", $_SERVER))
        fputs($smtp, "X-OriginatingIP: ".$_SERVER["REMOTE_ADDR"]."\r\n");

Thus the X-OriginatingIP header will only be added to e-mails when there is actually a meaningful address to report.
Steps To Reproduce# cd /home/cacert/www/scripts/cron; ./warning.php
Additional InformationNote: to reduce the annoyance for system administrators, the attached patch has already been deployed on the production server on April 3, 2013. The patch has been included in the src tar ball on April 24, 2013.
TagsNo tags attached.
Reviewed byNEOatNHNG, BenBE
Test Instructions

Activities

wytze

2013-04-28 08:39

developer  

warning-patch.diff (724 bytes)   
===================================================================
RCS file: includes/mysql.php.sample,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- includes/mysql.php.sample	2012/10/13 13:53:53	1.14
+++ includes/mysql.php.sample	2013/04/24 13:13:06	1.15
@@ -64,7 +64,8 @@
 		fputs($smtp, "DATA\r\n");
 		$InputBuffer = fgets($smtp, 1024);
 		fputs($smtp, "X-Mailer: CAcert.org Website\r\n");
-		fputs($smtp, "X-OriginatingIP: ".$_SERVER["REMOTE_ADDR"]."\r\n");
+		if (array_key_exists("REMOTE_ADDR", $_SERVER))
+			fputs($smtp, "X-OriginatingIP: ".$_SERVER["REMOTE_ADDR"]."\r\n");
 		fputs($smtp, "Sender: $errorsto\r\n");
 		fputs($smtp, "Errors-To: $errorsto\r\n");
 		if($replyto != "")
warning-patch.diff (724 bytes)   

BenBE

2013-04-28 13:43

updater   ~0003924

Patch merged from attached diff and merged into testserver-stable.

Suggest skipping separate tests as production quality has been validated by critical when implementing the fix.

Second review missing.

NEOatNHNG

2013-04-30 22:36

administrator   ~0003934

Second review OK. Agree with BenBE about the tests.

BenBE

2013-05-13 19:26

updater   ~0003993

ACK for patch transferred to critical.

Issue History

Date Modified Username Field Change
2013-04-28 08:39 wytze New Issue
2013-04-28 08:39 wytze File Added: warning-patch.diff
2013-04-28 13:40 BenBE Source_changeset_attached => cacert-devel testserver-stable c90e7eef
2013-04-28 13:40 BenBE Source_changeset_attached => cacert-devel testserver-stable 473373dc
2013-04-28 13:43 BenBE Reviewed by => BenBE
2013-04-28 13:43 BenBE Note Added: 0003924
2013-04-28 13:43 BenBE Assigned To => NEOatNHNG
2013-04-28 13:43 BenBE Priority normal => urgent
2013-04-28 13:43 BenBE Severity major => minor
2013-04-28 13:43 BenBE Status new => needs review & testing
2013-04-28 13:43 BenBE Resolution open => fixed
2013-04-28 13:43 BenBE Fixed in Version => 2013 Q2
2013-04-28 13:43 BenBE Status needs review & testing => needs review
2013-04-30 22:36 NEOatNHNG Reviewed by BenBE => NEOatNHNG, BenBE
2013-04-30 22:36 NEOatNHNG Note Added: 0003934
2013-04-30 22:36 NEOatNHNG Status needs review => ready to deploy
2013-05-13 19:26 BenBE Note Added: 0003993
2013-05-13 19:26 BenBE Status ready to deploy => solved?
2013-05-13 20:00 BenBE Source_changeset_attached => cacert-devel release db0e084b
2013-09-03 05:20 INOPIAE Status solved? => closed
2013-09-03 05:20 INOPIAE Assigned To NEOatNHNG =>