I'm trying to get Gnu Privacy Guard going with PHP4. I have it working in an identical setup on another system running PHP3.
The apache server runs as 'nobody'. I have a directory in the target account with all appropriate information for gpg set up. PHP opens gpg with:
popen("/usr/bin/gpg --homedir /home/tcdp/.gnupg -e -a -o $tempfile -r $keyid");
I then write a cleartext file and pclose().
This worked with PHP3, however under PHP4 gpg is apparently needing interactive input and can't get a fd or /dev/tty, so it complains and bombs and I can't find out what it needs. I can su to nobody and run the above with no problems (with appropriate manual substitutions and it works fine, which leaves me very much in the dark as to exactly what's going on.
I've tried --no-tty, specifying an alternate fd with --command-fd, but no help. Aparently popen provides a very restrictive set of resources for forked programs. I can capture stdout, and get crypting messages from gpg such as "gpg: cannot open /dev/tty: No such device or address". The odd thing is that I can run this manually and the entire gpg setup, which it took me some time to get working in the first place, works exactly as expected and dumps cyphertext into $tempfile.
I need some help setting up a debugging context. If I satisfy gpg's need for an input fd or device of some sort, even if it's not sending anything, at least I may be able to get gpg to at least tell me what kind of answer it's expecting and provide for this in the invocation.
The only other option I have is to use exec instead of popen, which would require me to dump cleartext to a temporary file, which is a security problem and I don't want to do it.
Any help would be appreciated.