Skip Menu |
 

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

Report information
The Basics
Id: 122255
Status: open
Priority: 0/
Queue: File-Path

People
Owner: jkeenan [...] cpan.org
Requestors: SREZIC [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in:
  • 2.12_008
  • 2.13
  • 2.14
Fixed in: (no value)



Subject: "cannot chdir to child for ..." errors in some CPAN distributions
Download (untitled) / with headers
text/plain 509b
At least two CPAN distributions started to fail with newer File::Path releases, probably since 2.12_008: - Email-Fingerprint-0.48 - App-Module-Template-0.11 The failures look like this: cannot chdir to child for cant_read: Permission denied at t/process_dirs_abs.t line 39. For Email-Fingerprint I opened an RT ticket <https://rt.cpan.org/Ticket/Display.html?id=122241> but now I am not sure if this is an unwanted File-Path regression, so I think it's better to clarify the problem in this RT queue.
Download (untitled) / with headers
text/plain 703b
On Tue Jun 27 13:36:44 2017, SREZIC wrote: Show quoted text
> At least two CPAN distributions started to fail with newer File::Path > releases, probably since 2.12_008: > > - Email-Fingerprint-0.48
See https://rt.cpan.org/Ticket/Display.html?id=122241 for my response. Show quoted text
> - App-Module-Template-0.11
Investigating. Show quoted text
> > The failures look like this: > > cannot chdir to child for cant_read: Permission denied at > t/process_dirs_abs.t line 39. > > For Email-Fingerprint I opened an RT ticket > <https://rt.cpan.org/Ticket/Display.html?id=122241> but now I am not > sure if this is an unwanted File-Path regression, so I think it's > better to clarify the problem in this RT queue.
Thank you very much. Jim Keenan
Download (untitled) / with headers
text/plain 1.7k
On 2017-06-27 13:36:44, SREZIC wrote: Show quoted text
> At least two CPAN distributions started to fail with newer File::Path > releases, probably since 2.12_008: > > - Email-Fingerprint-0.48 > - App-Module-Template-0.11 > > The failures look like this: > > cannot chdir to child for cant_read: Permission denied at > t/process_dirs_abs.t line 39. > > For Email-Fingerprint I opened an RT ticket > <https://rt.cpan.org/Ticket/Display.html?id=122241> but now I am not > sure if this is an unwanted File-Path regression, so I think it's > better to clarify the problem in this RT queue.
The error message occurs in more test suites, but does not cause fails here: ./pass.Module-Path-More-0.33.x86_64-linux.3.16.0-4-amd64.1497995279.10062.rpt:cannot chdir to child for /var/tmp/cpansmoker-1023/2017062021/BnhiUwFgJN/3: Permission denied at /opt/perl-5.27.1/lib/5.27.1/File/Temp.pm line 784. ./pass.ack-2.18.x86_64-linux.3.16.0-4-amd64.1498084194.3756.rpt:cannot chdir to child for /tmp/I5fJLRuhUW/foo: Permission denied at /opt/perl-5.27.1/lib/5.27.1/File/Temp.pm line 1616. ./pass.File-MoreUtil-0.60.x86_64-linux.4.9.0-3-amd64.1498079189.31137.rpt:cannot chdir to child for /var/tmp/cpansmoker-1023/2017062118/KkrfGZwhrD/unreadable: Permission denied at /opt/perl-5.27.1/lib/5.27.1/File/Temp.pm line 784. ./pass.Archive-Tar-Builder-2.5002.x86_64-linux.3.16.0-4-amd64.1498088794.13009.rpt:cannot chdir to child for /var/tmp/cpansmoker-1023/2017062118/2OMt1kvtKp/foo: Permission denied at /opt/perl-5.27.1/lib/5.27.1/File/Temp.pm line 784. ./pass.Filesys-DiskUsage-0.10.x86_64-linux.3.16.0-4-amd64.1498255283.31090.rpt:cannot chdir to child for /var/tmp/cpansmoker-1023/2017062203/vfl2lFJVe8/sub: Permission denied at /opt/perl-5.27.1/lib/5.27.1/File/Temp.pm line 784.
Download (untitled) / with headers
text/plain 2.2k
On Tue Jun 27 15:17:10 2017, SREZIC wrote: Show quoted text
> On 2017-06-27 13:36:44, SREZIC wrote:
> > At least two CPAN distributions started to fail with newer File::Path > > releases, probably since 2.12_008: > > > > - Email-Fingerprint-0.48 > > - App-Module-Template-0.11 > > > > The failures look like this: > > > > cannot chdir to child for cant_read: Permission denied at > > t/process_dirs_abs.t line 39. > > > > For Email-Fingerprint I opened an RT ticket > > <https://rt.cpan.org/Ticket/Display.html?id=122241> but now I am not > > sure if this is an unwanted File-Path regression, so I think it's > > better to clarify the problem in this RT queue.
> > The error message occurs in more test suites, but does not cause fails > here: > > ./pass.Module-Path-More-0.33.x86_64-linux.3.16.0-4- > amd64.1497995279.10062.rpt:cannot chdir to child for > /var/tmp/cpansmoker-1023/2017062021/BnhiUwFgJN/3: Permission denied at > /opt/perl-5.27.1/lib/5.27.1/File/Temp.pm line 784. > ./pass.ack-2.18.x86_64-linux.3.16.0-4-amd64.1498084194.3756.rpt:cannot > chdir to child for /tmp/I5fJLRuhUW/foo: Permission denied at > /opt/perl-5.27.1/lib/5.27.1/File/Temp.pm line 1616. > ./pass.File-MoreUtil-0.60.x86_64-linux.4.9.0-3- > amd64.1498079189.31137.rpt:cannot chdir to child for > /var/tmp/cpansmoker-1023/2017062118/KkrfGZwhrD/unreadable: Permission > denied at /opt/perl-5.27.1/lib/5.27.1/File/Temp.pm line 784. > ./pass.Archive-Tar-Builder-2.5002.x86_64-linux.3.16.0-4- > amd64.1498088794.13009.rpt:cannot chdir to child for > /var/tmp/cpansmoker-1023/2017062118/2OMt1kvtKp/foo: Permission denied > at /opt/perl-5.27.1/lib/5.27.1/File/Temp.pm line 784. > ./pass.Filesys-DiskUsage-0.10.x86_64-linux.3.16.0-4- > amd64.1498255283.31090.rpt:cannot chdir to child for > /var/tmp/cpansmoker-1023/2017062203/vfl2lFJVe8/sub: Permission denied > at /opt/perl-5.27.1/lib/5.27.1/File/Temp.pm line 784.
Yes. Run attached program app.pl, first in perl-5.26.0, (File::Path v2.1201) then in blead (which has been updated to File::Path v2.14). Results attached. This is almost certainly a consequence of the changes we made in order to deal with https://rt.cpan.org/Ticket/Display.html?id=121951. We'll have to see whether we can avoid these problems without impacting the security changes. This will not be easy or quickly forthcoming. Thank you very much. Jim Keenan
Subject: app.pl
Download app.pl
text/x-perl 976b
use 5.12.0; use warnings; use File::Path qw( make_path remove_tree); use File::Temp qw( tempdir ); use File::Spec; use Fcntl qw(:mode); my $tdir = tempdir( CLEANUP => 1 ); chdir $tdir or die "Unable to chdir to $tdir: $!"; my $subdir = $$; say "subdir: $subdir"; my @created; @created = make_path($subdir); (scalar(@created) == 1) ? say "Created 1 subdirectory" : say "Problem creating subdirectory"; my $p = File::Spec->catdir($tdir, $subdir); (-d $p) ? say "$p exists" : say "$p does not exist"; my @perms = stat($p); printf("%04o\n" => S_IMODE($perms[2])); my $rv; $rv = chmod(oct(0400), $p); ($rv == 1) ? say "chmod 1 directory to 0400" : say "problem chmod to 0400: $rv"; @perms = stat($p); printf("%04o\n" => S_IMODE($perms[2])); my $removed_count; $removed_count = remove_tree($p); ($removed_count == 1) ? say "deleted 1 directory" : say "problem remove_tree: $removed_count"; (! -d $p) ? say "$p no longer exists" : say "$p still exists - WTF"; say "\nFinished";
Subject: output-5.26.0-versus-blead.txt
$ perl -v | head -2 | tail -1; perl -MFile::Path -E 'say $File::Path::VERSION;'; perl app.pl This is perl 5, version 26, subversion 0 (v5.26.0) built for x86_64-linux 2.1201 subdir: 17390 Created 1 subdirectory /tmp/o_ryFjSTLj/17390 exists 0775 chmod 1 directory to 0400 0256 deleted 1 directory /tmp/o_ryFjSTLj/17390 no longer exists Finished $ ~/testing/blead/bin/perl -v | head -2 | tail -1; ~/testing/blead/bin/perl -I~/testing/blead/lib -MFile::Path -E 'say $File::Path::VERSION;'; ~/testing/blead/bin/perl -I~/testing/blead/lib app.pl This is perl 5, version 27, subversion 2 (v5.27.2 (v5.27.1-77-g571ee10)) built for x86_64-linux 2.14 subdir: 17408 Created 1 subdirectory /tmp/0V0huqj44F/17408 exists 0775 chmod 1 directory to 0400 0256 cannot chdir to child for /tmp/0V0huqj44F/17408: Permission denied at app.pl line 28. problem remove_tree: 0 /tmp/0V0huqj44F/17408 still exists - WTF Finished cannot chdir to child for /tmp/0V0huqj44F/17408: Permission denied at /home/jkeenan/testing/blead/lib/perl5/5.27.2/File/Temp.pm line 795. cannot remove directory for /tmp/0V0huqj44F: Directory not empty at /home/jkeenan/testing/blead/lib/perl5/5.27.2/File/Temp.pm line 795.
Download (untitled) / with headers
text/plain 4.4k
On Tue Jun 27 16:16:42 2017, JKEENAN wrote: Show quoted text
> On Tue Jun 27 15:17:10 2017, SREZIC wrote:
> > On 2017-06-27 13:36:44, SREZIC wrote:
> > > At least two CPAN distributions started to fail with newer > > > File::Path > > > releases, probably since 2.12_008: > > > > > > - Email-Fingerprint-0.48 > > > - App-Module-Template-0.11 > > > > > > The failures look like this: > > > > > > cannot chdir to child for cant_read: Permission denied at > > > t/process_dirs_abs.t line 39. > > > > > > For Email-Fingerprint I opened an RT ticket > > > <https://rt.cpan.org/Ticket/Display.html?id=122241> but now I am > > > not > > > sure if this is an unwanted File-Path regression, so I think it's > > > better to clarify the problem in this RT queue.
> > > > The error message occurs in more test suites, but does not cause > > fails > > here: > > > > ./pass.Module-Path-More-0.33.x86_64-linux.3.16.0-4- > > amd64.1497995279.10062.rpt:cannot chdir to child for > > /var/tmp/cpansmoker-1023/2017062021/BnhiUwFgJN/3: Permission denied > > at > > /opt/perl-5.27.1/lib/5.27.1/File/Temp.pm line 784. > > ./pass.ack-2.18.x86_64-linux.3.16.0-4- > > amd64.1498084194.3756.rpt:cannot > > chdir to child for /tmp/I5fJLRuhUW/foo: Permission denied at > > /opt/perl-5.27.1/lib/5.27.1/File/Temp.pm line 1616. > > ./pass.File-MoreUtil-0.60.x86_64-linux.4.9.0-3- > > amd64.1498079189.31137.rpt:cannot chdir to child for > > /var/tmp/cpansmoker-1023/2017062118/KkrfGZwhrD/unreadable: Permission > > denied at /opt/perl-5.27.1/lib/5.27.1/File/Temp.pm line 784. > > ./pass.Archive-Tar-Builder-2.5002.x86_64-linux.3.16.0-4- > > amd64.1498088794.13009.rpt:cannot chdir to child for > > /var/tmp/cpansmoker-1023/2017062118/2OMt1kvtKp/foo: Permission denied > > at /opt/perl-5.27.1/lib/5.27.1/File/Temp.pm line 784. > > ./pass.Filesys-DiskUsage-0.10.x86_64-linux.3.16.0-4- > > amd64.1498255283.31090.rpt:cannot chdir to child for > > /var/tmp/cpansmoker-1023/2017062203/vfl2lFJVe8/sub: Permission denied > > at /opt/perl-5.27.1/lib/5.27.1/File/Temp.pm line 784.
> > Yes. Run attached program app.pl, first in perl-5.26.0, (File::Path > v2.1201) then in blead (which has been updated to File::Path v2.14). > Results attached. This is almost certainly a consequence of the > changes we made in order to deal with > https://rt.cpan.org/Ticket/Display.html?id=121951. We'll have to see > whether we can avoid these problems without impacting the security > changes. This will not be easy or quickly forthcoming. > > Thank you very much. > Jim Keenan
The file I attached yesterday, app.pl, was modeled after t/process_dirs_abs.t in the App::Module::Template module. I now believe that the code in that test file probably does not reflect the author's intent and that, as a consequence, some of the code in app.pl is a bit misleading. In t/process_dirs_abs.t, we have this code: ##### ok( make_path($cant_read), 'create cant_read' ); SKIP: { skip( 'Running under windows', 2 ) if $^O eq 'MSWin32'; ok( chmod(oct(0400), $cant_read), 'make cant_read unreadable' ); throws_ok{ _process_dirs($abs_tt2, $tmpl_vars, $abs_tmpl_path, $cant_read) } qr/\ACouldn't open directory/, '_process_dirs() fails on unreadable output path'; } ok( remove_tree($cant_read), 'removing cant_read path' ); ##### Note this statement: ##### chmod(oct(0400), $cant_read ##### The author intends to change the permissions on directory $cant_read (which commence as 0775). The author probably intends to change those permissions to 0400, i.e., directory owner has read-only permissions; no group or world permissions whatsoever. But the author's syntax for 'chmod' is almost certainly incorrect. The directory permissions end up being the rather bizarre 0256 (see second attachment from yesterday). Following the documentation in 'perldoc -f chmod', the author should have said: ##### chmod 0400, $cant_read ##### ... or the slightly less desirable: ##### chmod oct("0400"), $cant_read ##### I have attached a new program, chmod-impact.pl. When I run this with older and newer versions of File::Path (via perl-5.26.0 and blead), I get satisfactory results in both cases. That is, with File::Path 2.14 I get no warnings and all my tempdirs are removed as desired. This does not completely resolve this issue, but it does highlight the fact that File::Path::remove_tree() has never been intended to handle all possible cases of directory permissions. We'll have to start looking at the other CPAN distributions cited by Slaven. Thank you very much. Jim Keenan
Subject: better-output-5.26.0-versus-blead.txt
$ perl chmod-impact.pl Perl version: 5.026000 File::Path version: 2.1201 subdir name: 27579 Created 1 subdirectory /tmp/5G6ztsDHEr/27579 exists 0775 chmod 1 directory to 0400 0400 deleted 1 directory /tmp/5G6ztsDHEr/27579 no longer exists Finished $ ~/testing/blead/bin/perl -I~/testing/blead/lib chmod-impact.pl Perl version: 5.027002 File::Path version: 2.14 subdir name: 27588 Created 1 subdirectory /tmp/BMJXe5GWYf/27588 exists 0775 chmod 1 directory to 0400 0400 deleted 1 directory /tmp/BMJXe5GWYf/27588 no longer exists Finished
Subject: chmod-impact.pl
Download chmod-impact.pl
text/x-perl 1k
use 5.12.0; use warnings; use File::Path qw( make_path remove_tree); use File::Temp qw( tempdir ); use File::Spec; use Fcntl qw(:mode); say "Perl version: $]"; say "File::Path version: $File::Path::VERSION"; my $subdir = $$; say "subdir name: $subdir"; my $tdir = tempdir( CLEANUP => 1 ); chdir $tdir or die "Unable to chdir to $tdir: $!"; my @created; @created = make_path($subdir); (scalar(@created) == 1) ? say "Created 1 subdirectory" : say "Problem creating subdirectory"; my $p = File::Spec->catdir($tdir, $subdir); (-d $p) ? say "$p exists" : say "$p does not exist"; my @perms = stat($p); printf("%04o\n" => S_IMODE($perms[2])); my $rv; $rv = chmod(0400, $p); ($rv == 1) ? say "chmod 1 directory to 0400" : say "problem chmod to 0400: $rv"; @perms = stat($p); printf("%04o\n" => S_IMODE($perms[2])); my $removed_count; $removed_count = remove_tree($p); ($removed_count == 1) ? say "deleted 1 directory" : say "problem remove_tree: $removed_count"; (! -d $p) ? say "$p no longer exists" : say "$p still exists - WTF"; say "\nFinished";
Download (untitled) / with headers
text/plain 4.2k
On Tue Jun 27 15:17:10 2017, SREZIC wrote: Show quoted text
> On 2017-06-27 13:36:44, SREZIC wrote:
> > At least two CPAN distributions started to fail with newer File::Path > > releases, probably since 2.12_008: > > > > - Email-Fingerprint-0.48 > > - App-Module-Template-0.11 > > > > The failures look like this: > > > > cannot chdir to child for cant_read: Permission denied at > > t/process_dirs_abs.t line 39. > > > > For Email-Fingerprint I opened an RT ticket > > <https://rt.cpan.org/Ticket/Display.html?id=122241> but now I am not > > sure if this is an unwanted File-Path regression, so I think it's > > better to clarify the problem in this RT queue.
> > The error message occurs in more test suites, but does not cause fails > here: > > ./pass.Module-Path-More-0.33.x86_64-linux.3.16.0-4- > amd64.1497995279.10062.rpt:cannot chdir to child for > /var/tmp/cpansmoker-1023/2017062021/BnhiUwFgJN/3: Permission denied at > /opt/perl-5.27.1/lib/5.27.1/File/Temp.pm line 784. > ./pass.ack-2.18.x86_64-linux.3.16.0-4-amd64.1498084194.3756.rpt:cannot > chdir to child for /tmp/I5fJLRuhUW/foo: Permission denied at > /opt/perl-5.27.1/lib/5.27.1/File/Temp.pm line 1616. > ./pass.File-MoreUtil-0.60.x86_64-linux.4.9.0-3- > amd64.1498079189.31137.rpt:cannot chdir to child for > /var/tmp/cpansmoker-1023/2017062118/KkrfGZwhrD/unreadable: Permission > denied at /opt/perl-5.27.1/lib/5.27.1/File/Temp.pm line 784. > ./pass.Archive-Tar-Builder-2.5002.x86_64-linux.3.16.0-4- > amd64.1498088794.13009.rpt:cannot chdir to child for > /var/tmp/cpansmoker-1023/2017062118/2OMt1kvtKp/foo: Permission denied > at /opt/perl-5.27.1/lib/5.27.1/File/Temp.pm line 784. > ./pass.Filesys-DiskUsage-0.10.x86_64-linux.3.16.0-4- > amd64.1498255283.31090.rpt:cannot chdir to child for > /var/tmp/cpansmoker-1023/2017062203/vfl2lFJVe8/sub: Permission denied > at /opt/perl-5.27.1/lib/5.27.1/File/Temp.pm line 784.
Here we have a significant problem: File::Temp's dependence on File::Path::rmtree. If I run the program attached, filetemp.pl, under perl-5.26.0 and File::Path 2.1201, no warnings are emitted and all tempdirs are removed. If, I however, I run the program with Perl 5 blead and File::Path 2.14, then warnings are emitted after the code has run but at the point where 'CLEANUP => 1' is taking effect. The tempdirs are not removed, defeating the point of the 'CLEANUP => 1'. The tail of the output from the debugger is also attached. ##### $ ls -ltr /tmp | tail -5 -rw------- 1 jkeenan jkeenan 0 Jun 28 10:08 38eS2lsUa0 drwx------ 3 jkeenan jkeenan 4096 Jun 28 10:09 Y1Ko2x75Mv -rw------- 1 jkeenan jkeenan 0 Jun 28 10:10 RIoQN4x57v drwx------ 3 jkeenan jkeenan 4096 Jun 28 10:23 86wXLcdhTP drwx------ 3 jkeenan jkeenan 4096 Jun 28 10:24 9f9BWnRVYW $ ~/testing/blead/bin/perl -I~/testing/blead/lib filetemp.pl Perl version: 5.027002 File::Path version: 2.14 subdir name: 29081 Created 1 subdirectory /tmp/NSJxaEJaDH/29081 exists directory permissions: 0775 chmod 1 directory to 0 directory permissions: 0000 Finished cannot chdir to child for /tmp/NSJxaEJaDH/29081: Permission denied at /home/jkeenan/testing/blead/lib/perl5/5.27.2/File/Temp.pm line 784. cannot remove directory for /tmp/NSJxaEJaDH: Directory not empty at /home/jkeenan/testing/blead/lib/perl5/5.27.2/File/Temp.pm line 784. $ ls -ltr /tmp | tail -5 drwx------ 3 jkeenan jkeenan 4096 Jun 28 10:09 Y1Ko2x75Mv -rw------- 1 jkeenan jkeenan 0 Jun 28 10:10 RIoQN4x57v drwx------ 3 jkeenan jkeenan 4096 Jun 28 10:23 86wXLcdhTP drwx------ 3 jkeenan jkeenan 4096 Jun 28 10:24 9f9BWnRVYW drwx------ 3 jkeenan jkeenan 4096 Jun 28 10:33 NSJxaEJaDH ##### Relevant code from File::Temp 0.2304: ##### # Set up an end block to use these arrays END { local($., $@, $!, $^E, $?); cleanup(at_exit => 1); # <-- line 738 } # Cleanup function. Always triggered on END (with at_exit => 1) but # can be invoked manually. sub cleanup { ... foreach my $dir (@dirs) { if (-d $dir) { ... if ($at_exit) { $cwd = Cwd::abs_path(File::Spec->curdir) if not defined $cwd; my $abs = Cwd::abs_path($dir); if ($abs eq $cwd) { $cwd_to_remove = $dir; next; } } eval { rmtree($dir, $DEBUG, 0); }; # <-- line 784 warn $@ if ($@ && $^W); } } #####
Subject: file-temp-cleanup-failure.txt
Finished cannot chdir to child for /tmp/9f9BWnRVYW/28957: Permission denied at /home/jkeenan/testing/blead/lib/perl5/5.27.2/File/Temp.pm line 784. at /home/jkeenan/testing/blead/lib/perl5/5.27.2/File/Path.pm line 65. File::Path::_error(HASH(0x183e4d0), "cannot chdir to child", "/tmp/9f9BWnRVYW/28957") called at /home/jkeenan/testing/blead/lib/perl5/5.27.2/File/Path.pm line 429 File::Path::_rmtree(HASH(0x183e4d0), ARRAY(0x1671d48)) called at /home/jkeenan/testing/blead/lib/perl5/5.27.2/File/Path.pm line 500 File::Path::_rmtree(HASH(0x18362c0), ARRAY(0x16712f8)) called at /home/jkeenan/testing/blead/lib/perl5/5.27.2/File/Path.pm line 366 File::Path::rmtree("/tmp/9f9BWnRVYW", 0, 0) called at /home/jkeenan/testing/blead/lib/perl5/5.27.2/File/Temp.pm line 784 eval {...} called at /home/jkeenan/testing/blead/lib/perl5/5.27.2/File/Temp.pm line 784 File::Temp::cleanup("at_exit", 1) called at /home/jkeenan/testing/blead/lib/perl5/5.27.2/File/Temp.pm line 738 File::Temp::END() called at filetemp.pl line 0 eval {...} called at filetemp.pl line 0 cannot remove directory for /tmp/9f9BWnRVYW: Directory not empty at /home/jkeenan/testing/blead/lib/perl5/5.27.2/File/Temp.pm line 784. at /home/jkeenan/testing/blead/lib/perl5/5.27.2/File/Path.pm line 65. File::Path::_error(HASH(0x18362c0), "cannot remove directory", "/tmp/9f9BWnRVYW") called at /home/jkeenan/testing/blead/lib/perl5/5.27.2/File/Path.pm line 549 File::Path::_rmtree(HASH(0x18362c0), ARRAY(0x16712f8)) called at /home/jkeenan/testing/blead/lib/perl5/5.27.2/File/Path.pm line 366 File::Path::rmtree("/tmp/9f9BWnRVYW", 0, 0) called at /home/jkeenan/testing/blead/lib/perl5/5.27.2/File/Temp.pm line 784 eval {...} called at /home/jkeenan/testing/blead/lib/perl5/5.27.2/File/Temp.pm line 784 File::Temp::cleanup("at_exit", 1) called at /home/jkeenan/testing/blead/lib/perl5/5.27.2/File/Temp.pm line 738 File::Temp::END() called at filetemp.pl line 0 eval {...} called at filetemp.pl line 0 Debugged program terminated. Use q to quit or R to restart, use o inhibit_exit to avoid stopping after program termination, h q, h R or h o to get additional info.
Subject: filetemp.pl
Download filetemp.pl
text/x-perl 962b
use 5.12.0; use warnings; use File::Path qw( make_path rmtree ); use File::Temp qw( tempdir tempfile ); use File::Spec; use Fcntl qw(:mode); use Cwd; say "Perl version: $]"; say "File::Path version: $File::Path::VERSION"; my $subdir = $$; say "subdir name: $subdir"; my $cwd = cwd(); my $tdir = tempdir( CLEANUP => 1 ); chdir $tdir or die "Unable to chdir to $tdir: $!"; my @created; @created = make_path($subdir); (scalar(@created) == 1) ? say "Created 1 subdirectory" : say "Problem creating subdirectory"; my $p = File::Spec->catdir($tdir, $subdir); (-d $p) ? say "$p exists" : say "$p does not exist"; my @perms = stat($p); printf("directory permissions: %04o\n" => S_IMODE($perms[2])); my $rv; $rv = chmod(0, $p); ($rv == 1) ? say "chmod 1 directory to 0" : say "problem chmod to 0: $rv"; @perms = stat($p); printf("directory permissions: %04o\n" => S_IMODE($perms[2])); chdir $cwd or die "Unable to chdir to $cwd: $!"; say "\nFinished";
Download (untitled) / with headers
text/plain 4.5k
On Wed Jun 28 09:20:43 2017, JKEENAN wrote: Show quoted text
> On Tue Jun 27 16:16:42 2017, JKEENAN wrote:
> > On Tue Jun 27 15:17:10 2017, SREZIC wrote:
> > > On 2017-06-27 13:36:44, SREZIC wrote:
> > > > At least two CPAN distributions started to fail with newer > > > > File::Path > > > > releases, probably since 2.12_008: > > > > > > > > - Email-Fingerprint-0.48 > > > > - App-Module-Template-0.11 > > > > > > > > The failures look like this: > > > > > > > > cannot chdir to child for cant_read: Permission denied at > > > > t/process_dirs_abs.t line 39. > > > > > > > > For Email-Fingerprint I opened an RT ticket > > > > <https://rt.cpan.org/Ticket/Display.html?id=122241> but now I am > > > > not > > > > sure if this is an unwanted File-Path regression, so I think it's > > > > better to clarify the problem in this RT queue.
> > > > > > The error message occurs in more test suites, but does not cause > > > fails > > > here: > > > > > > ./pass.Module-Path-More-0.33.x86_64-linux.3.16.0-4- > > > amd64.1497995279.10062.rpt:cannot chdir to child for > > > /var/tmp/cpansmoker-1023/2017062021/BnhiUwFgJN/3: Permission denied > > > at > > > /opt/perl-5.27.1/lib/5.27.1/File/Temp.pm line 784. > > > ./pass.ack-2.18.x86_64-linux.3.16.0-4- > > > amd64.1498084194.3756.rpt:cannot > > > chdir to child for /tmp/I5fJLRuhUW/foo: Permission denied at > > > /opt/perl-5.27.1/lib/5.27.1/File/Temp.pm line 1616. > > > ./pass.File-MoreUtil-0.60.x86_64-linux.4.9.0-3- > > > amd64.1498079189.31137.rpt:cannot chdir to child for > > > /var/tmp/cpansmoker-1023/2017062118/KkrfGZwhrD/unreadable: > > > Permission > > > denied at /opt/perl-5.27.1/lib/5.27.1/File/Temp.pm line 784. > > > ./pass.Archive-Tar-Builder-2.5002.x86_64-linux.3.16.0-4- > > > amd64.1498088794.13009.rpt:cannot chdir to child for > > > /var/tmp/cpansmoker-1023/2017062118/2OMt1kvtKp/foo: Permission > > > denied > > > at /opt/perl-5.27.1/lib/5.27.1/File/Temp.pm line 784. > > > ./pass.Filesys-DiskUsage-0.10.x86_64-linux.3.16.0-4- > > > amd64.1498255283.31090.rpt:cannot chdir to child for > > > /var/tmp/cpansmoker-1023/2017062203/vfl2lFJVe8/sub: Permission > > > denied > > > at /opt/perl-5.27.1/lib/5.27.1/File/Temp.pm line 784.
> > > > Yes. Run attached program app.pl, first in perl-5.26.0, (File::Path > > v2.1201) then in blead (which has been updated to File::Path v2.14). > > Results attached. This is almost certainly a consequence of the > > changes we made in order to deal with > > https://rt.cpan.org/Ticket/Display.html?id=121951. We'll have to see > > whether we can avoid these problems without impacting the security > > changes. This will not be easy or quickly forthcoming. > > > > Thank you very much. > > Jim Keenan
> > The file I attached yesterday, app.pl, was modeled after > t/process_dirs_abs.t in the App::Module::Template module. I now > believe that the code in that test file probably does not reflect the > author's intent and that, as a consequence, some of the code in app.pl > is a bit misleading. > > In t/process_dirs_abs.t, we have this code: > > ##### > ok( make_path($cant_read), 'create cant_read' ); > > SKIP: { > skip( 'Running under windows', 2 ) if $^O eq 'MSWin32'; > > ok( chmod(oct(0400), $cant_read), 'make cant_read unreadable' ); > > throws_ok{ _process_dirs($abs_tt2, $tmpl_vars, $abs_tmpl_path, > $cant_read) } qr/\ACouldn't open directory/, '_process_dirs() fails on > unreadable output path'; > } > > ok( remove_tree($cant_read), 'removing cant_read path' ); > ##### > > Note this statement: > > ##### > chmod(oct(0400), $cant_read > ##### > > The author intends to change the permissions on directory $cant_read > (which commence as 0775). The author probably intends to change those > permissions to 0400, i.e., directory owner has read-only permissions; > no group or world permissions whatsoever. > > But the author's syntax for 'chmod' is almost certainly incorrect. > The directory permissions end up being the rather bizarre 0256 (see > second attachment from yesterday). Following the documentation in > 'perldoc -f chmod', the author should have said: > > ##### > chmod 0400, $cant_read > ##### > > ... or the slightly less desirable: > > ##### > chmod oct("0400"), $cant_read > ##### > > I have attached a new program, chmod-impact.pl. When I run this with > older and newer versions of File::Path (via perl-5.26.0 and blead), I > get satisfactory results in both cases. That is, with File::Path 2.14 > I get no warnings and all my tempdirs are removed as desired. >
I have commented to that effect here: https://rt.cpan.org/Ticket/Display.html?id=122635#txn-1743546


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.