Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dist::Zilla::Tester dies when run from a read-only working directory #698

Open
ppisar opened this issue Jul 12, 2021 · 0 comments
Open

Dist::Zilla::Tester dies when run from a read-only working directory #698

ppisar opened this issue Jul 12, 2021 · 0 comments

Comments

@ppisar
Copy link

ppisar commented Jul 12, 2021

An example of Dist::Zilla::Tester dying when a test of Dist-Zilla-Plugin-Git is run from read-only location:

$ perl -I. t/tag.t 
1..8
Error in tempdir() using tmp/XXXXXXXXXX: Parent directory (tmp) does not exist at /usr/share/perl5/vendor_perl/Dist/Zilla/Tester.pm line 142.
# Looks like your test exited with 2 before it could output anything.

The cause is that Dist::Zilla::Tester defaults to ./tmp and "mkdir $tempdir_root " failure is not handled:

  around from_config => sub {
    my ($orig, $self, $arg, $tester_arg) = @_;

    confess "dist_root required for from_config" unless $arg->{dist_root};

    my $source = $arg->{dist_root};

    my $tempdir_root = exists $tester_arg->{tempdir_root}
                     ? $tester_arg->{tempdir_root}
                     : 'tmp';

    mkdir $tempdir_root if defined $tempdir_root and not -d $tempdir_root;

→   my $tempdir_obj = File::Temp->newdir(
      CLEANUP => 1,
      (defined $tempdir_root ? (DIR => $tempdir_root) : ()),
    );
    [...]

I recommend stop using ./tmp and leave selecting the temporary directory on File::Temp->newdir(). It's much smarter when finding a place for the temporary object. ./tmp is also insecure because an attacker can implant symlink of that name.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant