Permission problem using php and gnupg on linux server

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I have been writing a script in php for secure email gunpg. The script
requires writing a file to the server for encryption. The problem
i am facing is the permissions. After php writes the file it becomes read
only so gpg can't encrypted it or rewrite it. I'm not sure
which..

this is the permissions i am getting from the file that is created on the
server.

 -rw-r--r--   1 nobody  nobody.

Since the file is created dynamicly, how does one set the permission using
php? Does anybody have
any suggestions or a code snippet that may help?

I have tried to change the permissions on the server and the user groups
using chmod and chgrp but that doesnt work. The tech at my hosting company
suggested a cgi script. Is their a workaround for this?

Thanks for the help,

zedleon

Here is the code I have presently.
<?

 $time = time();
 $msg = "Sender's Full Name:\t$sender_name\n";
 $msg .= "Sender's E-Mail:\t$sender_email\n";
 $msg .= "Secret Message?\t$secret_msg\n\n";

 putenv("GNUPGHOME=/home/path/.gnupg");

 $clear = "/home/path/temp/input/data";
 $clear .= "$time";

 $crypted = "/home/path/temp/output/data";
 $crypted .= "$time";

 $fp = fopen("$clear", "w+");
 fputs($fp, $msg);
 fclose($fp);

 system("/usr/bin/gpg -r my name <myemail@xxxxxxxxxxx>' -o $crypted -a
$clear");

 unlink("$clear");

 $fd = fopen($crypted, "r");
 $mail_cont = fread($fd, filesize($crypted));
 fclose($fd);

 unlink("$crypted");


 $recipient = "myemail@xxxxxxxxxxx";
 $subject = "GnuPG Test";

 $mailheaders = "From: www.mywebsite.com <\"\">\n";
 $mailheaders .= "Reply-To: $sender_email\n\n";

 mail("$recipient", "$subject", $mail_cont, $mailheaders);


 echo "<H1 align=center>Thank You, $sender_name</h1>";
 echo "<p align=center>Your message has been sent.</p>";

?>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux