Re: Weird file permission problem with File::Temp
[prev]
[thread]
[next]
[Date index for 2004/11/23]
RobertCZ wrote:
> -------------8<---------- Start Bug Report ------------8<----------
> 1. Problem Description:
>
> I'm trying to create temp file in PerlFixupHandler using File::Temp,
> write to it, send it to the client and get the temp file automatically
> unlinked upon the end of the request.
> I keep getting file permission error.
>
> Relevant part of the handler
>
> use File::Temp ();
> $fh = new File::Temp( DIR => '/tmp/aimcache', UNLINK => 1 );
> chmod 0777, $fh;
don't forget to check the success of this operation.
> my @ll = split '\n', `ls -la /tmp/aimcache`;
> $r->log_error("$_") foreach @ll;
>
> print $fh "test";
>
> $tmpnam = $fh -> filename;
> $r -> filename ($tmpnam) ;
> return OK;
>
> Error log
>
> [Mon Nov 22 21:34:10 2004] [error] total 8
> [Mon Nov 22 21:34:10 2004] [error] drwxrwxrwx 2 apache apache 36
> Nov 22 21:34 .
> [Mon Nov 22 21:34:10 2004] [error] drwxrwxrwt 10 root root 4096
> Nov 22 20:48 ..
> [Mon Nov 22 21:34:10 2004] [error] -rwxrwxrwx 1 apache apache 0
> Nov 22 21:34 kGs2AahFrA
> [Mon Nov 22 21:34:10 2004] [error] Apache::ImageMagick: Write
> /tmp/aimcache/kGs2AahFrA ()
> [Mon Nov 22 21:34:10 2004] [error] [client 81.0.228.181] (2)No such file
> or directory: file permissions deny server access: /tmp/aimcache/kGs2AahFrA
1) make sure your httpd.conf is configured to serve from /tmp/aimcache
2) you said:
$fh = new File::Temp( DIR => '/tmp/aimcache', UNLINK => 1 );
so by the time the response phase comes, the file is not there anymore.
instead you could use the approach explained here:
http://perl.apache.org/docs/2.0/user/handlers/http.html#PerlCleanupHandler
or simply use the response phase and sendfile() to send the contents.
--
__________________________________________________________________
Stas Bekman JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide ---> http://perl.apache.org
mailto:stas@xxxxxx.xxx http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org http://ticketmaster.com
--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html
 |
 |
Re: Weird file permission problem with File::Temp
Stas Bekman 05:08 on 23 Nov 2004
|