Re: invoke tempdir() failed
by Anonymous Monk on Sep 30, 2011 at 08:13 UTC
|
| [reply] |
|
|
Thru the programme running, there was no error prompt after calling tempdir() fucntion. But when it comes to copy a file to temporary directory, the error showed.
| [reply] |
Re: invoke tempdir() failed
by locked_user sundialsvc4 (Abbot) on Sep 30, 2011 at 12:20 UTC
|
You don’t tell us the context in which the request is being attempted. Is this e.g. a web-server process running as nobody? Where is the process attempting to create the file, and what are the effective-user’s permissions there?
| |
|
|
Sure, it is the apache web server who is invoking a section of code to create a temporary directory and copy some zip files into it. The apache server uses the same account as the zip file owner.
| [reply] |
|
|
The web server account is the same as the one who creates temporary directory in Solaris command line directly. It is weird that the same programme works by running 'perl test.pl',however, when the same code section is invoked in a web-based procedure, I can't find the temporary directory by 'ls -l /tmp/temp_dir_created_by_File_Temp'.
#!/usr/bin/perl
use strict;
use warnings;
use File::Temp qw/ tempfile tempdir /;
my $temp_dir = tempdir();
$temp_dir =~ /\/tmp\/(.*)/;
my $temp_dir_name = $1;
my $grep_str = "ls -l /tmp | grep $1";
my $res2 = `$grep_str`;
print "[$grep_str]grep result [$res2]\n";
| [reply] [d/l] |
|
|
#!/usr/bin/perl --
use strict;
use warnings;
use Cwd;
use File::Temp qw/ tempfile tempdir /;
print cwd(), "\n";
my $temp_dir = tempdir();
chdir $temp_dir or die "Cannot chdir to '$temp_dir': $!";
print cwd(), "\n";
__END__
| [reply] [d/l] |
|
|
Re: invoke tempdir() failed
by choroba (Cardinal) on Oct 08, 2011 at 10:00 UTC
|
Quoting the documentation of File::Temp:For maximum security, endeavour always to avoid ever looking at, touching, or even imputing the existence of the filename. You do not know that that filename is connected to the same file as the handle you have, and attempts to check this can only trigger more race conditions. It's far more secure to use the filehandle alone and dispense with the filename altogether.
Does the handle not work, or is it just the file name? | [reply] |
|
|
Hi Choroba,
The file handle works, in fact, it is the temporary directory that being created. Will try to specify to another directory instead of /tmp. Thanks for the advice !
| [reply] |
Re: invoke tempdir() failed
by Anonymous Monk on Sep 30, 2011 at 08:17 UTC
|
After I invoke $temp_dir = tempdir();, the corresponding temporary directory can not be found inside /tmp
What do you mean by that?
Apart from that, the invocation of `mkdir testDir` also failed.
Failed how?
Have you run into this issue before ?
Ever heard of chroot jail?
| [reply] |
|
|
Ideally, when the tempdir() is called, a temporary directory like /tmp/vIpIrMQg5r would be created. The question is that I can't find the /tmp/vIpIrMQg5r after calling tempdir(). Generally, user would invoke the function to create a directory from Microsoft IE. Is there any privilege issue regarding to the apache ?
| [reply] |
|
|
Lets try again :)
When you say After I invoke $temp_dir = tempdir();, the corresponding temporary directory can not be found inside /tmp
How do you know the corresponding temporary can not be found inside /tmp?
| [reply] |
|
|
|
|
Guys, I guess the problem would be how to keep the directory, which is created by tempdir(), instead of automatically cleaning it up.
| [reply] |
|
|
Guys, I guess the problem would be how to keep the directory, which is created by tempdir(), instead of automatically cleaning it up.
Since the tempdir function does not automatically clean up temporary directories it creates, the problem isn't with tempdir
Maybe you want to specify an alternate directory to tempdir, like File::HomeDir
| [reply] |
|
|