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

Check for nil before closing Uniquefile #9393

Merged
merged 1 commit into from
Jun 13, 2024

Conversation

joshcooper
Copy link
Contributor

@joshcooper joshcooper commented Jun 13, 2024

On Windows, if squelch was false and Uniquefile.new raised, then we attempted to
close a nil stdout. This scenario can occur if TEMP or similar environment
variable is defined but refers to a non-existent directory.

So check for nil before closing. We don't have this issue on posix, because
it uses an IO pipe instead of Uniquefile.

Fixes #9385

@joshcooper joshcooper force-pushed the uniquefile_9385 branch 3 times, most recently from 319bef5 to a47b312 Compare June 13, 2024 04:07
@joshcooper joshcooper added the bug Something isn't working label Jun 13, 2024
@joshcooper joshcooper force-pushed the uniquefile_9385 branch 2 times, most recently from d879bf8 to db83e48 Compare June 13, 2024 04:26
On Windows, we by default assign stdout for the child process to a file:

    stdout = Puppet::FileSystem::Uniquefile.new('puppet')

However, if TMPDIR, TEMP or TMP env vars refer to a non-existent directory, then
`Uniquefile.new` will raise, leaving `stdout` set to nil, so the later call to
`stdout.close` raised NoMethodError.

So check for nil before closing. We don't have this issue on posix, because
it uses an IO pipe instead of Uniquefile.

Fixes puppetlabs#9385
@joshcooper joshcooper marked this pull request as ready for review June 13, 2024 06:01
@joshcooper joshcooper requested a review from a team as a code owner June 13, 2024 06:01
@mhashizume mhashizume merged commit ed4eee5 into puppetlabs:main Jun 13, 2024
9 checks passed
@joshcooper joshcooper deleted the uniquefile_9385 branch June 14, 2024 19:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

change from 'notrun' to ['0'] failed: undefined method `close!' for nil:NilClass (corrective)
2 participants