* J.Mueller, pro.vider.de GmbH ([EMAIL PROTECTED]) [Dec 22. 2001 10:03]:

> Hello Everybody,


> 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:

$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.


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.

PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to