Can't run GPG through php on linux (works fine through telnet)

Andy Freeman news@symbad.co.uk
Mon May 20 20:58:01 2002


This is a multi-part message in MIME format.

------=_NextPart_000_0072_01C20038.DAA10730
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi everyone...

I'm trying to use gpg with php to encrypt a string on a linux server
and decrypt it at the other side using delphi on a NT box.

I've got the decryption working on the NT side,
but can't for the life of me get gpg to run through php.

I don't really understand linux,
and was wondering if anyone could help ?

i figured it was easier to use files for i/o than strings since, again,=20
i don't really understand linux redirects & pipes.

my php code is this :

passthru( " gpg --status-fd 5 5>>$status_file --no-default-keyring =
--keyring $keyring_file --always-trust -r $key_name -o $out_file -e =
$in_file ");


when i run the exec string (with substituted file names, obviously) =
through telnet,
logged in as my user (not root, for what it's worth)
the whole thing works fine, including the creation of the status file.

when i run it through php, the following happens :

1) status file is not created
2) there is no output file created

I believe that the problem is something to do with the user context.

i.e.
In NT, there is a special user (IUSR_blah) which is the userid=20
when web requests are being processed.

I believe that the same is true in linux ("nobody" ?)

Could anyone help me ?

I created a folder (and chmod 777),
and can create and delete files in this folder using my php script,
but gpg is not creating files in this folder.


1) How can i get gpg to return its status output to my php script,
   so that i can at least see what errors are being reported.

2) How can i get it to work ? Any ideas ?


Any help would be greatly appreciated.


Kind Regards



Andy Freeman


------=_NextPart_000_0072_01C20038.DAA10730
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2600.0" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#00ffff>
<DIV><FONT face=3DArial size=3D2>Hi everyone...</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I'm trying to use gpg with php to =
encrypt a string=20
on a linux server<BR>and decrypt it at the other side using delphi on a =
NT=20
box.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I've got the decryption working on the =
NT=20
side,<BR>but can't for the life of me get gpg to run through =
php.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I don't really understand linux,<BR>and =
was=20
wondering if anyone could help ?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>i figured it was easier to use files =
for i/o than=20
strings since, again, <BR>i don't really understand linux redirects =
&amp;=20
pipes.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>my php code is this :</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>passthru( " gpg --status-fd 5 =
5&gt;&gt;$status_file=20
--no-default-keyring --keyring $keyring_file --always-trust -r $key_name =
-o=20
$out_file -e $in_file ");</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV><FONT face=3DArial =
size=3D2>
<DIV><BR>when i run the exec string (with substituted file names, =
obviously)=20
through telnet,<BR>logged in as my user (not root, for what it's =
worth)<BR>the=20
whole thing works fine, including the creation of the status file.</DIV>
<DIV>&nbsp;</DIV>
<DIV>when i run it through php, the following happens :</DIV>
<DIV>&nbsp;</DIV>
<DIV>1) status file is not created<BR>2) there is no output file =
created</DIV>
<DIV>&nbsp;</DIV>
<DIV>I believe that the problem is something to do with the user =
context.</DIV>
<DIV>&nbsp;</DIV>
<DIV>i.e.<BR>In NT, there is a special user (IUSR_blah) which is the =
userid=20
<BR>when web requests are being processed.</DIV>
<DIV>&nbsp;</DIV>
<DIV>I believe that the same is true in linux ("nobody" ?)</DIV>
<DIV>&nbsp;</DIV>
<DIV>Could anyone help me ?</DIV>
<DIV>&nbsp;</DIV>
<DIV>I created a folder (and chmod 777),<BR>and can create and delete =
files in=20
this folder using my php script,<BR>but gpg is not creating files in =
this=20
folder.</DIV>
<DIV>&nbsp;</DIV>
<DIV><BR>1) How can i get gpg to return its status output to my php=20
script,<BR>&nbsp;&nbsp; so that i can at least see what errors are being =

reported.</DIV>
<DIV>&nbsp;</DIV>
<DIV>2) How can i get it to work ? Any ideas ?</DIV>
<DIV>&nbsp;</DIV>
<DIV><BR>Any help would be greatly appreciated.</DIV>
<DIV>&nbsp;</DIV>
<DIV><BR>Kind Regards</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>Andy Freeman<BR></FONT></DIV></BODY></HTML>

------=_NextPart_000_0072_01C20038.DAA10730--