Problem using gnupg from PHP

Daniel Kahn Gillmor dkg at fifthhorseman.net
Sun Jun 27 19:26:32 CEST 2010


On 06/24/2010 10:46 AM, Patrick Hanna wrote:
> I am using exec() calls to run pgp from within a php script.  I can decrypt
> a file without any problem but when I try to encrypt, I get a return code of
I'> 2 from pgp.

I'm assuming you mean gpg here.  a common problem people have when
invoking gpg (or other commands) from a script invoke by a webserver
(i'm assuming your php is run from a web server) is that the web server
is run as a different user than their personal account.

For example, the web server might run as the user "www-data" instead of
"pchanna1".  In that case, the web server will not have access to your
gpg keyring, so it won't be able to find (for example) the recipient's
keys that you want to target.  You may want to try explicitly indicating
the path to the desired keyring on the commandline (and ensuring that
the ownership/permissions on the keyring you want the script to use are
functional for the web server's user account)

> I am using gnupg version 1.2.3

this is a rather old version.  I encourage you to upgrade to the 1.4.x
series at least (I use 1.4.10)

	--dkg

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 892 bytes
Desc: OpenPGP digital signature
URL: </pipermail/attachments/20100627/895e5c54/attachment.pgp>


More information about the Gnupg-devel mailing list