473,769 Members | 6,187 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_executab le($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($pi pes[1]))
{

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

}

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

fclose($pipes[1]);

$stdErrOut = '';

while(!feof($pi pes[2]))
{

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

}

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

fclose($pipes[2]);

// close the $gpgProcess

$processExitSta tus = proc_close($gpg Process);

echo '<hr>$processEx itStatus:<p>'.$ processExitStat us;

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

unset(
$gpgPath,
$gpgOutput,
$descriptorSpec ,
$command,
$gpgProcess,
$pipes,
$processExitSta tus,
$gpgErrorMessag e
);

}
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

$processExitSta tus:

127

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

Jul 17 '05 #1
2 2899
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
Thank you! That was very helpful. Im looking into SELinux now.

Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2528
by: Alan Little | last post by:
I'm struggling with proc_open(). What I'm trying to do is conduct an sftp session. The process appears to open fine, but anything I send to it with fwrite() is ignored, and any output from sftp is simply dumped to my script's stdout, rather than being captured by fread(). Could someone give me a quick rundown of how to do something like this? The examples in the manual don't seem to work for me. This is on a FreeBSD system. -- Alan...
0
5852
by: Bernhard Kuemel | last post by:
Hi! I want to read/write commands and program input to/from /bin/bash several times before I close the stdin pipe. However, reading from cat hangs unless I first close the stdin pipe. <?php $descriptorspec = array( 0 => array("pipe", "r"), // stdin is a pipe that the child
0
2294
by: Christian Hammers | last post by:
Hello I would like to call a unix shellscript from within a PHP script and - write data to its STDIN - read data from its STDOUT *and* STDERR - get its exit code afterwards proc_open seems to be the right thing to use but I have the problem that the called program gives >8kb data on both stdout/stderr back which causes my PHP script to simply hang in the fread call. To be precise the first 4096 "O" characters are read and displayed. ...
4
3154
by: FLEB | last post by:
I like PHP for its excellent inline integration into standard HTML files, but I like Perl for its quick-moving syntax and simpler data-processing. To resolve this deep-seated inner turmoil (oh, the drama) I've been trying to think of good ways to get Perl code to run inline in a PHP script. Here are a few of my ideas. If anyone has any further ideas, resources, or knows of someone else who's solved this already, please do tell... 1.) The...
0
2073
by: FrenKy | last post by:
Hi *. I get this error when trying to run proc_open() function: "Fatal error: Call to undefined function: proc_open() in /home/frantic/public_html/a/phpshell.pup on line 140" Does anybody knows what setting I have to change to fix this? Configuration:
1
2306
by: arielCo | last post by:
Hello, I'm attempting to use proc_open to launch, control and log CLI applications from my scripts, but my first tests are disheartening: <pre> <?php $descriptorspec = array( 0 => array("pipe", "r"),
2
6950
by: ¹é¿ø¼® | last post by:
Hello, everybody. I want to call any shell command from php script using shell_exec(). The problem is that the next line of the php script would not be run until a few minutes after running the shell command. I found the shell command couldn't be run at background mode. It seemed that the shell_exec() function waits a return from the command. Because the command doesn't return, the shell_exec() waits until timeout reached. Using the '&'...
2
4039
by: kimonp | last post by:
I am running on windows XP with a fresh install of wamp5 (1.7.2) and mediawiki. I am trying to call a perl function from within php using proc_open. The perl script is being executed and returns a successful exit value, and I can read the results it prints to STDOUT in PHP, but the perl script does not see STDIN from PHP. Since I want to use the perl script as a filter and I don't want to create an intermediary file, this is problematic....
1
6275
by: YasirHussain | last post by:
hi! i want to execute a python script from php through proc_open() function of php.. i read a fine tutorial at http://stackoverflow.com/questions/196771/what-is-the-best-way-to-escape-python-strings-in-php when i made following py script. print 'enter value' input = raw_input() print input
0
9423
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10211
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10045
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9994
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8872
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7409
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5299
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3562
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.