diff -urNp gpg.org/gpg.php gpg/gpg.php --- gpg.org/gpg.php 2007-07-07 23:03:42.000000000 +0300 +++ gpg/gpg.php 2007-12-19 21:41:57.000000000 +0200 @@ -25,6 +25,7 @@ define( 'GPGSTDOUT', 1 ); define( 'GPGSTDERR', 2 ); define( 'STATUS_FD', 5 ); define( 'PASSPHRASE_FD', 7 ); +define( 'PASSPHRASE_FD2', 8 ); define( 'CHECKPASSWORD_FD', 3 ); // from gnupg include/cipher.h @@ -444,6 +445,7 @@ class GnuPG GPGSTDERR => array( 'pipe', 'w' ), // stderr STATUS_FD => array( 'pipe', 'w' ), PASSPHRASE_FD => array( 'pipe', 'r' ) + PASSPHRASE_FD2 => array( 'pipe', 'r' ) ); //These variables control the environmental variables that we try to set before executing the gpg binary @@ -1512,6 +1514,7 @@ class GnuPG default: $this->printDebug("This action: " . $this->action . " isn't written to allow passing of the passphrase."); $this->closePipe(PASSPHRASE_FD); + $this->closePipe(PASSPHRASE_FD2); $this->setError("NOSTATUS","Couldn't handle the status"); break; } @@ -1770,6 +1773,7 @@ class GnuPG case "BEGIN ENCRYPTION": $this->printDebug("Encryption begun."); $this->closePipe( PASSPHRASE_FD ); + $this->closePipe( PASSPHRASE_FD2 ); break; } } //end [GNUPG]: if @@ -1795,7 +1799,7 @@ class GnuPG { if ($this->passphrase) { $this->printDebug( "Sending Passphrase" ); - $this->writeData( $this->passphrase."\n", PASSPHRASE_FD ); + $this->writeData( $this->passphrase."\n", PASSPHRASE_FD2 ); $this->printDebug( "Done Sending Passphrase" ); } else { $keyIndex = $this->getKeyIndexFromFingerprint( $fingerprint ); @@ -1803,12 +1807,12 @@ class GnuPG if( $keyIndex !== false && $this->keys[ $keyIndex ]->passphrase!='' ) { $this->printDebug( "Sending Passphrase" ); - $this->writeData( $this->keys[ $keyIndex]->passphrase."\n", PASSPHRASE_FD ); + $this->writeData( $this->keys[ $keyIndex]->passphrase."\n", PASSPHRASE_FD2 ); $this->printDebug( "Done Sending Passphrase" ); } else { $this->printDebug( "No Password: " . $this->keys[ $keyIndex ]->passphrase . '?' ); - $this->writeData("\n", PASSPHRASE_FD ); + $this->writeData("\n", PASSPHRASE_FD2 ); } } // $this->closePipe( PASSPHRASE_FD ); @@ -1827,8 +1831,8 @@ class GnuPG { if ($this->newpassphrase) { $this->printDebug("Writing new passphrase." ); - $this->writeData($this->newpassphrase."\n",PASSPHRASE_FD ); - $this->writeData($this->newpassphrase."\n",PASSPHRASE_FD ); + $this->writeData($this->newpassphrase."\n",PASSPHRASE_FD2 ); + $this->writeData($this->newpassphrase."\n",PASSPHRASE_FD2 ); } else { $this->printDebug("Failed to find new passphrase." ); } @@ -3072,7 +3076,7 @@ class GnuPG $lastSecondCommands=''; if( $usePassphrase ) - $lastSecondCommands .= ' --command-fd '.PASSPHRASE_FD; + $lastSecondCommands .= ' --batch --command-fd '.PASSPHRASE_FD . ' --passphrase-fd='.PASSPHRASE_FD2; else $lastSecondCommands .= ' --batch';