Skip to content

Execution will fail on Windows if TMPDIR, TEMP or TMP refer to an invalid directory #9394

@joshcooper

Description

@joshcooper

Describe the Bug

This is a follow up to the issue described in #9385

Puppet::FileSystem::Uniquefile creates files relative to the current temp directory. It searches these environment variables (in order) TMPDIR, TMP or TEMP. If any of those are set and refer to a non-existent directory, then Uniquefile.new will raise, never falling back to later variables. On Windows, we redirect the child process' stdout to a Uniquefile.new However, this bug means execution can fail due to an errant temp related environment variable.

Expected Behavior

Puppet::FileSystem::Uniquefile should not raise in this situation. Also the code should be updated to take advantage of other improvements made to Tempfile, since Uniquefile was created.

Steps to Reproduce

After #9385 is fixed:

C:\Users\Administrator\puppet>set TMPDIR=c:\doesntexist
C:\Users\Administrator\puppet>bundle exec puppet resource exec c:/windows/system32/whoami.exe logoutput=true
Error: No such file or directory @ rb_file_s_stat - c:\doesntexist
Error: /Exec[c:/windows/system32/whoami.exe]/returns: change from 'notrun' to ['0'] failed: No such file or directory @ rb_file_s_stat - c:\doesntexist

Environment

  • Version 7.31.0, 8.6.0
  • Platform Windows

The bug has existed for a long time.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtriagedJira issue has been created for this

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions