TMPDIR is taken over, but weird permissions are used
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- perl
- Domain
- testing-qa, tooling
Research direction
Start with Test::Harness::Runner::Job's tmp_dir setup and the code that assigns TMPDIR for spawned jobs. Review how File::Temp creates the runner and job directories, then check the Path::Tiny->tempfile scenario under a lower-privilege subprocess; done requires an agreed, tested directory-permission design, but the issue names no target file or test.
Written by the indexing model from the issue text.
Description
Test::Harness::Runner::Job sets up environment variables for the jobs it will run. Among these, it sets TMPDIR to $self->tmp_dir. That's computed from this:
File::Temp::tempdir("XXXXXX", DIR => $self->runner->tmp_dir);
File::Temp::tempdir boils down to calling its internal _gettemp, which will do this:
} elsif ($options{"mkdir"}) {
# Open the temp directory
if (mkdir( $path, 0700)) {
# in case of odd umask
chmod(0700, $path);
return undef, $path;
So, the TMPDIR we set is set 0700, but a normal unix TMPDIR is usually 1777. Also, the job's tmp_dir is under the runner's tmp_dir, which is another 0700 directory.
The net result is that processes spawned by tests can't be guaranteed that they can read and write in the TMPDIR.
For a more concrete example: I have a set of tests that runs as root and then forks a subprocess, which switches to a lower-privilege user. The subprocess then wants to create a lockfile using Path::Tiny->tempfile, but:
- TMPDIR is 0700, owned by root, so the subprocess may not write there
- a parent of TMPDIR (the runner's tmp_dir) is also 0700, so chmoding TMPDIR before dropping privileges won't help
I'm not sure what I actually suggest here, but I'm going to start by saying that my current thinking is that either the job's tmp_dir is for the job's use and shouldn't take over TMPDIR or if it's meant to create a localized TMPDIR-like space, it should make sure that it's 1777 and that every parent of it have all of the bits in 0555 set.
- Dominant language
- Perl
- Stars
- 28
- Forks
- 30
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Test-More/Test2-Harness
-
Difficulty 3/5 1-2 days Newbie friendliness 68/100
Test-More/Test2-Harness#457 · 1 comment ·
-
Difficulty 3/5 1-2 days Newbie friendliness 52/100
Test-More/Test2-Harness#450 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 42/100
Test-More/Test2-Harness#429 · 8 comments ·
-
Difficulty 3/5 1-2 days Newbie friendliness 48/100
Test-More/Test2-Harness#296 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 42/100
Test-More/Test2-Harness#290 · 3 comments · 2 reactions ·
All issues in Test-More/Test2-Harness
Similar issues
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
stfc/cloud-image-builders#218 ·
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
0.kind: bug
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
Role::Serializer: class-method deserialize failure raises Class::XSAccessor, masking the real error OpenBug
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
PerlDancer/Dancer2#1837 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100