Forum Moderators: coopster

Message Too Old, No Replies

PGP Encryption - Error 2

pgp command generates an error 2

         

jpmadmin

8:48 pm on Nov 11, 2011 (gmt 0)

10+ Year Member



In PHP 5.3, I'm using exec() to run this command:

echo "Text that will be encrypted" | gpg -a --yes --always-trust --batch --no-secmem-warning -e -u "Me <me@test.com>" -r "Client <client@abc.com>"

It seems to work fine at the Command line & encrypts the text.

The PGP configuration files are under: /root/.gnupg "root" is the User

# chmod 700 /root/.gnupg
# chown -R root:root /root/.gnupg
# cd /root/.gnupg
# chmod 600 *

When I run it within PHP (apache User), it produces an Error 2 ?

What am I missing ?

Thanks, in advance, for your help.

eelixduppy

9:25 pm on Nov 11, 2011 (gmt 0)



First, do you have PHP's safe mode enabled? If so, try disabling it to see if it fixes the problem.

jpmadmin

9:48 pm on Nov 11, 2011 (gmt 0)

10+ Year Member



Hi eelixduppy,

Thanks for the reply.

Safe mode is Off.

jpmadmin

9:50 pm on Nov 11, 2011 (gmt 0)

10+ Year Member



What should my "HOME" or "GNUPGHOME" be set to ?

Right now:

putenv("GNUPGHOME=/root");
putenv("HOME=/root");

eelixduppy

3:54 pm on Nov 12, 2011 (gmt 0)



I am not quite sure, here. It appears this error is coming from GPG itself, and not from PHP.

From what I can tell, things should be working. With a little Googling, some people suggest that setting GNUPGHOME does not work, and have instead used the --homedir option as part of the command.

jpmadmin

11:52 pm on Nov 12, 2011 (gmt 0)

10+ Year Member



When I created a CRONJOB and stipulated the --homedir /root/.gnupg , that did it !

Thank you !