GnuPG in PHP Problems

Hi there,

I'm very sorry to have to everyone but I've exhausted all options to
get this to work. The gpg command is working fine on an apache server
through the command prompt - I've added a key and successfully
encrypted. However, I cannot get it working in PHP. The strange thing
is it did previously work but now I just get "gpg: command not found"
- I've no idea why this has stopped working.

My path is /usr/local/bin/gpg
The .gnupg folder contains:
666 trustdb.gpg
604 secring.gpg
604 random_seed
644 pubring.gpg
644 options

I'm using the following code (using same command as I would in SSH)
where the test.txt file contains some example text and user [at] domain
would be my email user in the key ring:

$gpg = '/usr/local/bin/gpg';
$oldhome = getEnv("HOME");
putenv("HOME=$gpg");
echo shell_exec("gpg -a --always-trust --batch --no-secmem-warning -e -
r user [at] domain.com test.txt");
putenv("HOME=$oldhome");

Has anybody got any suggestions?

Robin.
r_irwin_rabc [ Do, 08 März 2007 01:21 ] [ ID #1651666 ]

Re: GnuPG in PHP Problems

On 8 Mar, 00:21, r_irwin_r... [at] yahoo.com wrote:
> Hi there,
>
> I'm very sorry to have to everyone but I've exhausted all options to
> get this to work. The gpg command is working fine on an apache server
> through the command prompt - I've added a key and successfully
> encrypted. However, I cannot get it working in PHP. The strange thing
> is it did previously work but now I just get "gpg: command not found"
> - I've no idea why this has stopped working.
>
> My path is /usr/local/bin/gpg
> The .gnupg folder contains:
> 666 trustdb.gpg
> 604 secring.gpg
> 604 random_seed
> 644 pubring.gpg
> 644 options
>
> I'm using the following code (using same command as I would in SSH)
> where the test.txt file contains some example text and user [at] domain
> would be my email user in the key ring:
>
> $gpg = '/usr/local/bin/gpg';
> $oldhome = getEnv("HOME");
> putenv("HOME=$gpg");
> echo shell_exec("gpg -a --always-trust --batch --no-secmem-warning -e -
> r u... [at] domain.com test.txt");
> putenv("HOME=$oldhome");
>
> Has anybody got any suggestions?
>
> Robin.


Are you are changing a path ($HOME) that is probably needed for the
correct running of other programs when you don't have to?
"gpg command cannot be found"
instead of changing the HOME env var, why not change working
directory, using
chdir()

example:
// current directory
echo getcwd() . "\n";

chdir('public_html');

// current directory
echo getcwd() . "\n";

output:
/home/vincent
/home/vincent/public_html

failing that - use absolute paths.

and issue exec( 'ls ); if you don't know where you are, just to check.
shimmyshack [ Fr, 09 März 2007 01:50 ] [ ID #1652897 ]
PHP » alt.php » GnuPG in PHP Problems

Vorheriges Thema: Bookmark and/or URL Manipulation
Nächstes Thema: Newbie question: Bigger variables