Unable to run GPG from PHP gpg: WARNING: unsafe ownership on homedir

Roberto rmartinez at netcontac.com
Thu Dec 20 20:32:50 CET 2012


Hi,
I made and script in PHP to encrypt information with GPG. It works fine  
until I move it from a Plesk server to a cPanel server. I adjusted paths,  
permissions and users but I get this errors:
gpg: keyblock resource `/home/USER/.gnupg/pubring.gpg': General error
gpg: failed to create temporary file  
`/home/USER/.gnupg/.#lk0x9b1b580.HOST.1614': Permission denied
gpg: keyblock resource `/home/USER/.gnupg/secring.gpg': General error
gpg: failed to create temporary file  
`/home/USER/.gnupg/.#lk0x9b1b580.HOST.1614': Permission denied
gpg: WARNING: unsafe ownership on homedir `/home/USER/.gnupg'

Where:
USER is the same user in Plesk (Where it works) than in cPanel.
HOST is the name of the host server.

Here is the PHP script:

$message = "Message";
$gnupg = "/usr/bin/gpg";
$gnupghome = "/home/USER/.gnupg";
$uid = "UID";

$command = "echo ". $message ." | ". $gnupg ." -a -t --batch  
--no-secmem-warning --homedir ". $gnupghome ." -e -r ". $uid ."  
--compress-algo 1 --cipher-algo cast5";

$messageCodified = shell_exec($command);


I am missing something obvious, but I can not tell. I tried a lot of  
configurations without success.

Please help.

Kind Regards,

Roberto



More information about the Gnupg-users mailing list