follow up to mantis bug #814
[cacert.git] / www / gpg.php
index f97966f..526bcad 100644 (file)
@@ -83,7 +83,15 @@ function verifyEmail($email)
        if($oldid == "0" && $CSR != "")
        {
                $debugkey = $gpgkey = clean_gpgcsr($CSR);
-               $debugpg = $gpg = trim(`echo "$gpgkey"|gpg --with-colons --homedir /tmp 2>&1`);
+               #$debugpg = $gpg = trim(`echo "$gpgkey"|gpg --with-colons --homedir /tmp 2>&1`);
+
+                $tnam = tempnam('/tmp/', '__gpg');
+                $fp = fopen($tnam, 'w');
+                fwrite($fp, $gpgkey);
+                fclose($fp);
+                $debugpg = $gpg = trim(`gpg --with-colons --homedir /tmp 2>&1 < $tnam`);
+                unlink($tnam);
+
                $lines = "";
                $gpgarr = explode("\n", $gpg);
                foreach($gpgarr as $line)
@@ -104,11 +112,25 @@ function verifyEmail($email)
                $resulttable=_("The following UIDs were found in your key:")."<br/><table border='1'><tr><td>#</td><td>"._("Name")."</td><td>"._("Email")."</td><td>Result</td>";
                $i=0;
                $lastvalidemail="";
+                $npubs=0;
                foreach(explode("\n", $gpg) as $line)
                {
                        $bits = explode(":", $line);
                        $resulttable.="<tr><td>".++$i."</td>";
                        $name = $comment = "";
+                       if($bits[0] == "pub")
+                       {
+                               $npubs++;
+                       }
+                       if($npubs>1)
+                       {
+                               showheader(_("Welcome to CAcert.org"));
+                               echo "<font color='#ff0000'>"._("Please upload only one key at a time.")."</font>";
+                               unset($_REQUEST['process']);
+                               $id = $oldid;
+                               unset($oldid);
+                               exit();
+                       }
                        if($bits[0] == "pub" && (!$keyid || !$when))
                        {
                                $keyid = $bits[4];