Exit code 2 from PHP script

Vlad "SATtva" Miller sattva at pgpru.com
Tue Jan 22 18:28:34 CET 2008


Brent Hagany wrote on 22.01.2008 01:10:
> I have found and corrected the problem: it should be
> "--homedir=/home/daemon/.gnupg".  Also, for some reason, setting
> GNUPGHOME directly does not work.
> 
> Getting a useful error message was a great help.  Thanks again, Vlad.

Glad to help you. I'm using similar scheme in a couple of web
applications, and was unaware that not specifying a --homedir could lead
to such problems.

> -----Original Message-----
> From: gnupg-users-bounces+bhagany=gofox.com at gnupg.org
> [mailto:gnupg-users-bounces+bhagany=gofox.com at gnupg.org] On Behalf Of
> Brent Hagany
> Sent: Monday, January 21, 2008 10:02 AM
> To: Gnupg-users
> Subject: RE: Exit code 2 from PHP script
> 
> Apologies for the delay, it was a busy weekend.
> 
>> You don't have to specify full path to the executable if it's in your
>> system PATH.
> 
> I'm aware, I just thought it would head off the "make sure it's in your
> path" suggestions.
> 
> Anyway, I tried system(); it gave the same result, so I went about
> playing with proc_open() like so:
> 
> $message = "This is a test message";
> $process = proc_open("/usr/bin/gpg",
>                      array(0 => array("pipe","r"),
>                            1 => array("pipe","w"),
>                            2 => array("file","errors.log","a")),
>                      $pipes);
> 
> if(is_resource($process)) {
>   fwrite($pipes[0], "--list-keys --homedir=/home/daemon");
>   fclose($pipes[0]);
> 
>   echo stream_get_contents($pipes[1]);
>   fclose($pipes[1]);
> 
>   echo proc_close($process);
> }
> 
> This still doesn't work, but at least I get a somewhat helpful error
> message in the log file:
> 
> gpg: fatal: can't create directory `//.gnupg': Permission denied
> secmem usage: 0/0 bytes in 0/0 blocks of pool 0/32768
[snip]


-- 
SATtva | security & privacy consulting
www.vladmiller.info | www.pgpru.com


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 505 bytes
Desc: OpenPGP digital signature
URL: </pipermail/attachments/20080122/8bcca412/attachment.pgp>


More information about the Gnupg-users mailing list