Skip Menu |

This queue is for tickets about the File-Temp CPAN distribution.

Report information
The Basics
Id: 60340
Status: resolved
Priority: 0/
Queue: File-Temp

People
Owner: Nobody in particular
Requestors: mmusgrove [...] cpan.org
perlmonk.athanasius [...] gmail.com
RIVY [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.22
Fixed in: (no value)



Subject: Fails under -T, Windows 7, Strawberry Perl 5.12.1
I was attempting to install Config::INI last night (following the dependency chain for Dist::Zilla actually). A few of the test cases failed: http://www.nntp.perl.org/group/perl.cpan.testers/2010/08/msg7663252.html See this line: Error in tempfile() using \XXXXXXXXXX: Could not create temp file \TemKaXr2rW: Permission denied at t/reader-err.t line 40 I've pulled out everything but this section of code from the test case and ran it with and without -T. (See attachment) Without -T, it completes successfully. With -T, I get the same error as above, "Error in tempfile() using \XXXXXXXXXX: Could not create temp file". If you need any further assistance with resolving this issue, please let me know. C:\Users\mmusgrove\Development\perl>perl -V Summary of my perl5 (revision 5 version 12 subversion 1) configuration: Platform: osname=MSWin32, osvers=6.1, archname=MSWin32-x64-multi-thread uname='Win32 strawberryperl 5.12.1.0 #1 Thu Jul 29 19:04:04 2010 x64' config_args='undef' hint=recommended, useposix=true, d_sigaction=undef useithreads=define, usemultiplicity=define useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef use64bitint=define, use64bitall=undef, uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='gcc', ccflags =' -s -O2 -DWIN32 -DHAVE_DES_FCRYPT -DWIN64 -DCONSERVATIVE -DUSE_SITECUSTOMIZE -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -fno-strict-al iasing -mms-bitfields -DPERL_MSVCRT_READFIX', optimize='-s -O2', cppflags='-DWIN32' ccversion='', gccversion='4.4.3', gccosandvers='' intsize=4, longsize=4, ptrsize=8, doublesize=8, byteorder=12345678 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12 ivtype='long long', ivsize=8, nvtype='double', nvsize=8, Off_t='long long', lseeksize=8 alignbytes=8, prototype=define Linker and Libraries: ld='g++', ldflags ='-s -L"C:\strawberry\perl\lib\CORE" -L"C:\strawberry\c\li b"' libpth=C:\strawberry\c\lib C:\strawberry\c\x86_64-w64-mingw32\lib libs=-lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr -lwinmm -lversion -lodbc32 -lodbccp32 -lcomctl32 perllibs=-lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladva pi32 -lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr -lwinmm -lver sion -lodbc32 -lodbccp32 -lcomctl32 libc=, so=dll, useshrplib=true, libperl=libperl512.a gnulibc_version='' Dynamic Linking: dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' ' cccdlflags=' ', lddlflags='-mdll -s -L"C:\strawberry\perl\lib\CORE" -L"C:\st rawberry\c\lib"' Characteristics of this binary (from libperl): Compile-time options: MULTIPLICITY PERL_DONT_CREATE_GVSV PERL_IMPLICIT_CONTEXT PERL_IMPLICIT_SYS PERL_MALLOC_WRAP PL_OP_SLAB_ALLOC USE_64_BIT_INT USE_ITHREADS USE_LARGE_FILES USE_PERLIO USE_PERL_ATOF USE_SITECUSTOMIZE Built under MSWin32 Compiled at Jul 29 2010 19:18:08 @INC: C:/strawberry/perl/site/lib C:/strawberry/perl/vendor/lib C:/strawberry/perl/lib .
Subject: ft.pl
#!perl -Tw use strict; use Test::More; SKIP: { eval "require File::Temp;" or skip "File::Temp not available", 1; # This could probably be limited to being required for Cygwin. eval "require filetest;" or skip "filetest.pm not available", 1; filetest->import('access'); my ($fh, $fn) = File::Temp::tempfile(UNLINK => 1); close $fh; chmod 0222, $fn; if (-r $fn) { chmod 0666, $fh; skip "chmoding file 0222 left it -r", 1; } eval { Config::INI::Reader->read_file($fn); }; like($@, qr/(?:couldn't|can't) read/, "can't read an unreadable file"); chmod 0666, $fh; }
Subject: Re: [rt.cpan.org #60340] Fails under -T, Windows 7, Strawberry Perl 5.12.1
Date: Sat, 14 Aug 2010 07:12:43 -1000
To: bug-File-Temp [...] rt.cpan.org
From: Tim Jenness <tjenness [...] cpan.org>
On Sat, Aug 14, 2010 at 4:34 AM, Matthew Musgrove via RT < bug-File-Temp@rt.cpan.org> wrote: Show quoted text
> Sat Aug 14 10:34:04 2010: Request 60340 was acted upon. > Transaction: Ticket created by MMUSGROVE > Queue: File-Temp > Subject: Fails under -T, Windows 7, Strawberry Perl 5.12.1 > Broken in: 0.22 > Severity: Important > Owner: Nobody > Requestors: mmusgrove@cpan.org > Status: new > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=60340 > > > > I was attempting to install Config::INI last night (following the > dependency chain for Dist::Zilla actually). A few of the test cases failed: > http://www.nntp.perl.org/group/perl.cpan.testers/2010/08/msg7663252.html > > See this line: > Error in tempfile() using \XXXXXXXXXX: Could not create temp file > \TemKaXr2rW: Permission denied at t/reader-err.t line 40 > > I've pulled out everything but this section of code from the test case > and ran it with and without -T. (See attachment) Without -T, it > completes successfully. With -T, I get the same error as above, "Error > in tempfile() using \XXXXXXXXXX: Could not create temp file". > > If you need any further assistance with resolving this issue, please let > me know. > >
I'm wondering if the problem is with File::Spec::Win32 and its tmpdir method. What do you get if you try the following: % perl -MFile::Spec -e 'print File::Spec->tmpdir' and then with taint % perl -T -MFile::Spec -e 'print File::Spec->tmpdir' File::Spec::Win32 indicates all the temp directories it will try and environment variables won't be read in taint mode. Do the directories listed in File::Spec::Win32 man page give you a clue? Tim
On Sat Aug 14 13:12:53 2010, TJENNESS wrote: Show quoted text
> On Sat, Aug 14, 2010 at 4:34 AM, Matthew Musgrove via RT < > bug-File-Temp@rt.cpan.org> wrote: >
> > Sat Aug 14 10:34:04 2010: Request 60340 was acted upon. > > Transaction: Ticket created by MMUSGROVE > > Queue: File-Temp > > Subject: Fails under -T, Windows 7, Strawberry Perl 5.12.1 > > Broken in: 0.22 > > Severity: Important > > Owner: Nobody > > Requestors: mmusgrove@cpan.org > > Status: new > > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=60340 > > > > > > > I was attempting to install Config::INI last night (following the > > dependency chain for Dist::Zilla actually). A few of the test cases
> failed:
> >
> http://www.nntp.perl.org/group/perl.cpan.testers/2010/08/msg7663252.html
> > > > See this line: > > Error in tempfile() using \XXXXXXXXXX: Could not create temp file > > \TemKaXr2rW: Permission denied at t/reader-err.t line 40 > > > > I've pulled out everything but this section of code from the test
> case
> > and ran it with and without -T. (See attachment) Without -T, it > > completes successfully. With -T, I get the same error as above,
> "Error
> > in tempfile() using \XXXXXXXXXX: Could not create temp file". > > > > If you need any further assistance with resolving this issue, please
> let
> > me know. > > > >
> I'm wondering if the problem is with File::Spec::Win32 and its tmpdir > method. > > What do you get if you try the following: > > % perl -MFile::Spec -e 'print File::Spec->tmpdir' > > and then with taint > > % perl -T -MFile::Spec -e 'print File::Spec->tmpdir' > > File::Spec::Win32 indicates all the temp directories it will try and > environment variables won't be read in taint mode. Do the directories > listed > in File::Spec::Win32 man page give you a clue? > > Tim
Tim, I should have poked around a little more before submitting the bug report. C:\Users\mmusgrove\Documents>perl -MFile::Spec -e 'print File::Spec->tmpdir' Can't find string terminator "'" anywhere before EOF at -e line 1. C:\Users\mmusgrove\Documents>perl -MFile::Spec -e "print File::Spec->tmpdir" C:\Users\MMUSGR~1\AppData\Local\Temp C:\Users\mmusgrove\Documents>perl -T -MFile::Spec -e "print File::Spec->tmpdir" \ Looks like I will open a bug report against File::Spec because it should include at least one valid temp directory for Win32 systems for cases where the environment variables are not available such as when -T is in use.
Subject: Re: [rt.cpan.org #60340] Fails under -T, Windows 7, Strawberry Perl 5.12.1
Date: Sat, 14 Aug 2010 08:11:18 -1000
To: bug-File-Temp [...] rt.cpan.org
From: Tim Jenness <tjenness [...] cpan.org>
On Sat, Aug 14, 2010 at 8:04 AM, Matthew Musgrove via RT < bug-File-Temp@rt.cpan.org> wrote: Show quoted text
> > C:\Users\mmusgrove\Documents>perl -MFile::Spec -e "print > File::Spec->tmpdir" > C:\Users\MMUSGR~1\AppData\Local\Temp > C:\Users\mmusgrove\Documents>perl -T -MFile::Spec -e "print > File::Spec->tmpdir" > \ > > Looks like I will open a bug report against File::Spec because it should > include at least one valid temp directory for Win32 systems for cases > where the environment variables are not available such as when -T is in > use. > > >
File::Spec::Win32 does. That's why I suggested reading the man page for it. The implication is that on your system C:\TEMP or others listed there are not writeable or do not exist. "\" is the last resort. Tim
On Sat Aug 14 14:11:29 2010, TJENNESS wrote: Show quoted text
> On Sat, Aug 14, 2010 at 8:04 AM, Matthew Musgrove via RT < > bug-File-Temp@rt.cpan.org> wrote: >
> > > > C:\Users\mmusgrove\Documents>perl -MFile::Spec -e "print > > File::Spec->tmpdir" > > C:\Users\MMUSGR~1\AppData\Local\Temp > > C:\Users\mmusgrove\Documents>perl -T -MFile::Spec -e "print > > File::Spec->tmpdir" > > \ > > > > Looks like I will open a bug report against File::Spec because it should > > include at least one valid temp directory for Win32 systems for cases > > where the environment variables are not available such as when -T is in > > use. > > > > > >
> File::Spec::Win32 does. That's why I suggested reading the man page
for it. Show quoted text
> The implication is that on your system C:\TEMP or others listed there are > not writeable or do not exist. "\" is the last resort. > > Tim
You can close this bug report out. The culprit is else where.
Ticket 60406 opened against PathTools: https://rt.cpan.org/Ticket/Display.html?id=60406
RT-Send-CC: tjenness [...] cpan.org
On Mon Aug 16 19:37:34 2010, MMUSGROVE wrote: Show quoted text
> Ticket 60406 opened against PathTools: > > https://rt.cpan.org/Ticket/Display.html?id=60406
I reopened this ticket because this is a software defect in this module as well. As noted, the originating problem arises from File::Spec->tmpdir(), but, as currently written, this module fails installation tests (and therefore installation) on all versions of Perl v5.8.8+ on all normal/usual installations of Windows beyond XP (Vista, Windows 7, ...). And the installation tests fail with a particularly unhelpful error message: "t/reader-err.t .. 1/7 Error in tempfile() using \XXXXXXXXXX: Could not create temp file [...]: Permission denied at t/reader-err.t line 40". The only ways to install this module are using a "force install", create a world-read/write c:\temp directory, or change the root directory (\) of the drive that the installation scripts are run to world-read/write. None of these options are either obvious or desirable, especially to new users of Perl. Here are a couple of possible solutions: (1) remove the taint mode execution from the user installation tests (are they really needed for installation tests?) (2) Until File::Temp is taint fixed for Win32, SKIP the two failing tests by adding ----<cut> ${^O} ne "MSWin32" or skip "Taint issue with File::Temp for MSWin32", 3; ----<cut> before the ----<cut> eval "require File::Temp;" or skip "File::Temp not availabe", 3; ----<cut> lines in both the reader-err.t and writer.t test scripts. Thanks for you attention. - Roy
I've just realised that whilst the error message is coming from File::Temp the actual module that is failing its tests is Config::INI. Looking around on the internet I think the Config::INI problem was fixed in v0.017. Closing the File::Temp bug.
Subject: Please Reopen Bug #60340
Date: Sat, 11 Apr 2015 17:15:35 +1000
To: bug-File-Temp [...] rt.cpan.org
From: Athanasius <perlmonk.athanasius [...] gmail.com>
Re: Bug #60340 for File-Temp: Fails under -T, Windows 7, Strawberry Perl 5.12.1 I was about to report a new bug, when I found that the issue has been reported already as Bug #60340, which was marked "resolved" in 2010. But the issue persists. Distribution name and version: File-Temp-0.2304 Perl version: Strawberry Perl portable edition, perl 5, version 20, subversion 2 (v5.20.2) built for MSWin32-x64-multi-thread Operating System vendor and version: Windows 8.1 64-bit (windows32 XXX 2.6.2 9200 i686-pc Intel unknown MinGW) Code which demonstrates the bug and shows the exact error message: Show quoted text
>perl -MFile::Temp -wE "File::Temp::tempfile;"
Show quoted text
>perl -T -MFile::Temp -wE "File::Temp::tempfile;"
Error in tempfile() using template \XXXXXXXXXX: Could not create temp file \sLDCElXCmQ: Permission denied at -e line 1. Show quoted text
>
This issue is documented in the PerlMonks thread "File::Temp::tempfile() fails under taint mode" at http://perlmonks.pair.com/index.pl?node_id=1122816. Other users report that the problem does not appear in ActiveState Perl versions, only in Strawberry Perl. Versions known to exhibit the error: Perl 5.14.2 MSWin32-x86-multi-thread File::Temp 0.22 Perl 5.16.2 MSWin32-x64-multi-thread File::Temp 0.22 Perl 5.18.2 MSWin32-x64-multi-thread File::Temp 0.2304 Perl 5.20.0 MSWin32-x86-multi-thread-64int File::Temp 0.2304 This error currently causes installation failure for modules MooseX-App-Cmd-0.30, Dancer-1.3134, and probably others. I understand that the underlying bug occurs in another module: "Bug #96863 for PathTools: [Bug] File::Spec::Win32 - user temporary directory not found if taint mode". But until that bug is fixed, File::Temp continues to fail for Strawberry Perl running under taint mode. So I propose that Bug #60340 be reopened, and the fixes previously detailed in the post https://rt.cpan.org/Public/Bug/Display.html?id=60340#txn-853480 be reconsidered. Thank you, Athanasius
As noted in https://rt.cpan.org/Ticket/Display.html?id=103452, this problem persists. File::Temp should do something smarter if File::Spec reports a non-writable directory as the temporary directory. Warn and write to "." instead?
Reopened.
Proposed resolution: That File::Temp fall back to the following if it can't create a temporary directory in the directory that is the result of File::Spec->tmpdir: File::Spec->catdir(Win32::GetFolderPath(Win32::CSIDL_LOCAL_APPDATA),q{Temp}) Discussion here: http://www.nntp.perl.org/group/perl.cpan.workers/2015/05/msg1280.html
Possible fix here (but not yet tested): https://github.com/Perl-Toolchain-Gang/File-Temp/pull/10
Tested. Resolving this issue. It will be available in the next release of File::Temp.
This is still an ongoing problem that crops up in lots of odd places in the development toolchain. For example, I'm trying to use Dist::Zilla::Plugin::Templates, which uses Test::DiagINC, which has installation tests using taint checks and Capture::Tiny, which, yep, uses File::Temp. So, it crumps without a forced install. I see the commit referenced by David which fixes the issue. But I don't see that it ever made it out into a published File::Temp version. Is there a planned release with the included fix?
This is fixed now in File-Temp-0.2305-TRIAL -- let me know if it works out, and I will make a stable release in a few days/weeks.
On Thu Apr 19 08:04:50 2018, ETHER wrote: Show quoted text
> This is fixed now in File-Temp-0.2305-TRIAL -- let me know if it works > out, and I will make a stable release in a few days/weeks.
The fix doesn't work, because default ACL on C:\ in Windows 7 and Windows 10 allow creating folders but disallow creating files there. So the check passes but then a file can't be created there. IMO the overall idea of checking if it's writable by writing something there is flawed, just like the idea that _sometimes_ writing to \ might be a good idea. \ is never good because it's a _relative_ path on Windows: it's the root of the current drive. So if current drive is changed we can't anymore delete our files by their old names. So I propose just to detect if a relative path is returned (whether in taint mode or not, it's always a bad idea), and if it is, fall back to AppData\Local\Temp, obtained via current CSIDL approach. I can provide a PR if you agree on the approach.