By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,256 Members | 914 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,256 IT Pros & Developers. It's quick & easy.

can't proc_open() gpg;

P: n/a
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

Jul 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
ra*******@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
Jul 17 '05 #2

P: n/a
Thank you! That was very helpful. Im looking into SELinux now.

Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.