Apache/PHP - 'loading shared library error'???

brett brett at eecs.tufts.edu
Tue Apr 26 15:27:20 CEST 2005


Hi,

I'm trying to get gpg to run from PHP and have run into a problem i can't
solve. I can use proc_open() to execute other commands, but not gpg.

It wont even run:

/usr/bin/gpg --version

Grrrr... When i do run that, the stderr pipe shows me the following
message:

/usr/bin/gpg: error while loading shared libraries: cannot restore segment
prot after reloc: Permission denied

Can anyone tell me what that means?

Also, the process exit status is '127'. I looked but can't find any
explanation of that either (though its a php code i imagine).

Thanks in advance,
-brett

Here's the php code i used:


   function gpgVerify()
   {

      $gpgPath = '/usr/bin/gpg';

      if(!is_executable($gpgPath))
      {
         trigger_error("gpgVerify::gpg is not executable", E_USER_ERROR);
         die();
      }
      else
      {

         // first we'll set up a pipe for gpg to write STDOUT to

         $descriptorSpec = array(
            1 => array("pipe", "w"),
            2 => array("pipe", "w")
         );

         $command = $gpgPath . " --version";

         $gpgProcess = proc_open( $command, $descriptorSpec, $pipes);

         if(is_resource($gpgProcess))
         {

            $gpgOutput = '';

            while(!feof($pipes[1]))
            {

               $gpgOutput .= fgets($pipes[1], 1024);

            }

            echo '<hr>pipe[1] = <p>'.$gpgOutput;

            fclose($pipes[1]);

            $stdErrOut = '';

            while(!feof($pipes[2]))
            {

               $stdErrOut .= fgets($pipes[2], 1024);

            }

            echo '<hr>pipe[2] = <p>'.$stdErrOut;

            fclose($pipes[2]);

            // close the $gpgProcess

            $processExitStatus = proc_close($gpgProcess);

           echo '<hr>$processExitStatus:<p>'.$processExitStatus;

           if(!ereg('^gpg ', $gpgOutput))
           {
              trigger_error("gpg executable is not GnuPG.", E_USER_ERROR);
                die();
           }

           unset(
               $gpgPath,
               $gpgOutput,
               $descriptorSpec,
               $command,
               $gpgProcess,
               $pipes,
               $processExitStatus,
               $gpgErrorMessage
           );

         }
         else
         {

            trigger_error("gpgVerify::proc_open failed.", E_USER_ERROR);
               die();

         }

      }

      return true;

   }






More information about the Gnupg-users mailing list