Re: PGP --> PHP

From: Date: Sat, 22 Dec 2001 18:21:16 +0000
Subject: Re: PGP --> PHP
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-78579@lists.php.net to get a copy of this message
* J.Mueller, pro.vider.de GmbH (j.mueller@pro.vider.de) [Dec 22. 2001 10:03]: > Hello Everybody, Hiya. > we have a problem to implement a PGP-function into > a PHP-Script. PHP 4.0.6 as CGI, Apache 1.3.11, FeeBSD 4.2 > a) > PGP from the command line works: > % pgps -ato test.sig test.txt -z passphrase > b) > Calling a little PHP Script > $kommando = "/usr/local/bin/pgps -ato test.sig test.txt -z passphrase"; > exec("$kommando",$antwort); > to do so, also everything works fine: > % virtual /usr/local/bin/php /etc/test-pgp.php > Creating output file test.sig > X-Powered-By: PHP/4.0.6 > Content-type: text/html > c) > But when we use this very same PHP-code within a script, and call this > script through the web, it's not working anymore and the error_log > says > Cannot open configuration file pgp.cfg > Cannot open secret keyring "secring.skr" > Cannot open public keyring "pubring.pkr" > Why is that and can this problem be solved ? This happens because when you run this from the shell, it's picking up your environment. Apache has a completely different environment. You need to create a dummy keyring for Apache's user in the location this may provide: <?php $effective_user = posix_getpwuid(posix_geteuid()); print 'Apache is: ' . $effective_user['name']; print '<br>Home is: ' . $effective_user['dir']; ?> Or you can use putenv() to make apache temporarily use another $HOME that has the correct keyrings. YMMV -- Brian Clark | Avoiding the general public since 1805! Fingerprint: 07CE FA37 8DF6 A109 8119 076B B5A2 E5FB E4D0 C7C8 I think you need to flash your brain's firmware.

« previous php.general (#78579) next »