can't proc_open() gpg;

This is a discussion on can't proc_open() gpg; within the PHP Language forums, part of the PHP Programming Forums category; Hi, I've been trying to run gpg through proc_open() and have failed all weekend. I keep getting this error ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-25-2005
razorfold@gmail.com
 
Posts: n/a
Default can't proc_open() gpg;

Hi,

I've been trying to run gpg through proc_open() and have failed all
weekend. I keep getting this error from stderr:

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

Im running php 4.3.11 on fedora 3. Here is the method i've been
debugging. It should just run '/usr/bin/gpg --version' and display the
output.

Thanks in advance
-r

///
/// This method produces the output below...
///


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") // STDERR is a pipe that GnuPG
will write to);
);

$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("resource not available", E_USER_ERROR);
die();

}

}

return true;

}


///
/// output
///

pipe[1] =

pipe[2] =

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

$processExitStatus:

127

Fatal error: gpg executable is not GnuPG. in
/home/test/public_html/SafeHaven2.0/EfmDebug.php on line 167

Reply With Quote
  #2 (permalink)  
Old 04-27-2005
Bent Stigsen
 
Posts: n/a
Default Re: can't proc_open() gpg;

razorfold@gmail.com wrote:
> Hi,
>
> I've been trying to run gpg through proc_open() and have failed all
> weekend. I keep getting this error from stderr:
>
> "/usr/bin/gpg: error while loading shared libraries: cannot restore
> segment prot after reloc: Permission denied"
>
> Im running php 4.3.11 on fedora 3. Here is the method i've been
> debugging. It should just run '/usr/bin/gpg --version' and display the
> output.


It is SELinux blocking the access. If you look in /var/log/messages,
you'll notice the security messages.

I dont know diddely squat about how to configure selinux, but I reckon
you can find what you seek in below link.
http://www.nsa.gov/selinux/papers/policy2-abs.cfm

I the meantime, just to see your script work, you can (temporarily)
disable the security enforcements by :

# echo 0 > /selinux/enforce


/Bent
Reply With Quote
  #3 (permalink)  
Old 04-29-2005
razorfold@gmail.com
 
Posts: n/a
Default Re: can't proc_open() gpg;

Thank you! That was very helpful. Im looking into SELinux now.

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 11:01 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0