I've got a bit of code that executes GPG in order to encrypt a file:
The entire command I want is:
/usr/bin/gpg -r DUMMYNAME --no-secmem-warning --encrypt "/fullpathhere/emailmessage.txt"
which runs just perfectly if I SSH and type it out manually.
However, my PHP seems to run into some problems:
$command = '
/usr/bin/gpg -r DUMMYNAME --no-secmem-warning --encrypt "/fullpathhere/emailmessage.txt"';
system($command . " &> /fullpath/error.txt ");
When I check the error.txt to see what happened, I get:
gpg: Warning: using insecure memory!
gpg: /fullpath/.gnupg/secring.gpg: can't create keyring: Permission denied
gpg: keyblock resource /fullpath/.gnupg/secring.gpg': file open error
gpg: /fullpath/.gnupg/pubring.gpg: can't create keyring: Permission denied
gpg: keyblock resource /fullpath/.gnupg/pubring.gpg': file open error
usage: gpg [options] [filename]
So, my question is, do I not have the permissions right for the files or something else? I saw something about system() would need permissions to execute, but I'm not sure how to set or check for that. Could I possible set up PHP to login as I do when I SSH and run it manually? And if so, how?
Thanx!