Blank encrypted messages
Fri May 2 18:15:02 2003
In the function below, I 'fopen' then 'fputs' to the file, but it's not
flushed until the file pointer goes out of scope at the end of the =
At the time of calling gpg, the file is created but empty. By adding an
'fclose' call on that pointer prior to calling gpg the problem is =
That's why when running it from the command line there was no problem, =
when using the same files.
Anyway, thanks everyone for your help, both on and off list!
> -----Original Message-----
> From: email@example.com=20
> [mailto:firstname.lastname@example.org] On Behalf Of Matthew Reeve
> Sent: 30 April 2003 08:26
> To: 'Joseph Bruni'
> Cc: email@example.com
> Subject: RE: Blank encrypted messages
> > Does the variable "$msg" exist in the subshell? If it's not=20
> > defined the=20
> > you would be just echoing nothing into the left-hand side=20
> of the pipe.
> It's an interesting thought - I rewrote the script to look=20
> like this, also
> addressing Adam's concerns about the security of echoing $msg.
> The file called $plainTxt is created and contains the correct=20
> data. The file
> called $crypted is also created and contains a PGP message. However,
> decrypting the contents of $crypted gives an empty string.
> The 'echo' shows the encryption command is the following.
> /usr/bin/gpg --encrypt -v -ao
> --always-trust -r
> If I copy and paste the encryption command into a shell running as the
> apache user (instead of calling it from PHP), an encrypted=20
> file is created
> containing a PGP message which contains the correct data when=20
> Is there any way to see what is going on with gpg while it's running?=20
> function _encrypt($msg)=20
> $oldhome =3D getEnv("HOME");=20
> $tmpToken =3D md5(uniqid(rand()));
> $plainTxt =3D "/var/www/tempFiles/" . $tmpToken . "data";
> $crypted =3D "/var/www/tempFiles/" . $tmpToken . "output";
> $fp =3D fopen($plainTxt, "w+");
> fputs($fp, $msg);
> echo "/usr/bin/gpg --encrypt -v -ao $crypted --always-trust -r
> firstname.lastname@example.org $plainTxt";
> passthru("/usr/bin/gpg --encrypt -v -ao $crypted=20
> --always-trust -r
> email@example.com $plainTxt");
> $fd =3D fopen($crypted, "r");
> $message =3D fread($fd, filesize($crypted));
> return $message;
> Thanks for the help!
> Matthew Reeve
> Gnupg-users mailing list