[Popcon-commits] cvs commit to popularity-contest by pere

pere at cvs.alioth.debian.org pere at cvs.alioth.debian.org
Sun Jan 8 16:32:51 UTC 2006


Update of /cvsroot/popcon/popularity-contest
In directory haydn:/tmp/cvs-serv24871

Modified Files:
	popcon-submit.cgi 
Log Message:
Let popcon-submit.cgi pipe incoming reports through prepop.pl
instead of saving it directly to disk, to make sure the same
sanity checks are done for both HTTP and SMTP reports.  Thanks to
Bill Allombert for pointing out the risks of the old approach.


Index: popcon-submit.cgi
===================================================================
RCS file: /cvsroot/popcon/popularity-contest/popcon-submit.cgi,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- popcon-submit.cgi	20 Jul 2005 10:15:10 -0000	1.5
+++ popcon-submit.cgi	8 Jan 2006 16:32:46 -0000	1.6
@@ -19,7 +19,7 @@
 
 my $directsave = 0; # Enable to store on disk instead of sending an email
 my $basedir   = "/var/lib/popcon";
-my $uploaddir = "$basedir/popcon-data/";
+my $bindir    = "$basedir/bin";
 
 $ENV{PATH}="";
 
@@ -73,14 +73,10 @@
     @entry = <GZIP>;
 }
 
-my ($id1, $id2) =
-    $entry[0] =~ m/POPULARITY-CONTEST-0 .+ ID:(\S\S)(\S+) /;
-if ($id1) {
+my ($id) = $entry[0] =~ m/POPULARITY-CONTEST-0 .+ ID:(\S+) /;
+if ($id) {
     if ($directsave) {
-	-d $uploaddir || mkdir $uploaddir;
-	my $dir = "$uploaddir/$id1";
-	-d $dir || mkdir $dir;
-	open(POPCON, ">$dir/$id1$id2") || die "Unable to write to '$dir/$id1$id2'";
+	open(POPCON, "|$bindir/prepop.pl") or die "Unable to pipe to prepop.pl";
 	print POPCON @entry;
 	close POPCON;
     } else {
@@ -93,8 +89,7 @@
         print POPCON @entry;
 	close POPCON;
     }
-}
-if ($id1) {
+
     print "Thanks for your submission to Debian Popularity-Contest!\n";
     print "DEBIAN POPCON HTTP-POST OK\n";
 } else {




More information about the Popcon-commits mailing list