Skip to content

Tar uncompress can accomodate paths w/ symlinks.#118

Merged
selzoc merged 2 commits intodevelopfrom
fix/windows-tar-decompress-file-fails
Jun 25, 2025
Merged

Tar uncompress can accomodate paths w/ symlinks.#118
selzoc merged 2 commits intodevelopfrom
fix/windows-tar-decompress-file-fails

Conversation

@ragaskar
Copy link
Contributor

  • Windows recently changed such that System-user run processes receive C:\Windows\SystemTemp. In turn, the Windows 2019.x stemcell was updated such that C:\Windows\SystemTemp is a symlink to the boshTmpDir (\var\vcap\data\tmp\ via bosh-agent changes).
  • This behavior change subsequently caused bosh-utils tests to fail, since these tests attempt to extract tars to a path including a symlink, which tar does not permit.
  • There are at least two ways to fix this problem: the bosh-utils test environment can arbitarily configure a temp directory that it "knows" does not include a symlink (e.g., by hard-coding to C:\Windows\Temp, which is NOT symlinked). An advantage here is behavior changes are limited to Windows behavior. A disadvantage is this shifts the responsibility for that tar extract destination paths do NOT include symlinks downstream. To be fair, downstream consumers have ALWAYS had this responsibility, however, Windows behavior has changed such that it is almost certain that prior invocations of tar extraction with temp dirs that were previously successful will now fail. Alternatively, one can choose to change the tar uncompress behavior such that it will resolve the path prior to an extraction. This has a larger impact in terms of change as it will also affect linux users, HOWEVER, this should represent additive behavior to what consumers previously experienced. That is, current users of this method should be unaffected, including those users who would otherwise be impacted by the Windows stemcell changes. Further, I cannot currently imagine any previously valid invocations that would fail as a result of these changes, thus this latter change seems like a better choice, even given the behavior change.
  • As mentioned above, this commit should fix any tar extraction issues observed in the DecompressFileToDir function after upgrading to the Windows 2019.87 stemcell. This change should be backwards compatible.

- Windows recently changed such that System-user run processes receive
  C:\Windows\SystemTemp. In turn, the Windows 2019.x stemcell was
  updated such that C:\Windows\SystemTemp is a symlink to the boshTmpDir
  (`\var\vcap\data\tmp\` via bosh-agent changes).
- This behavior change subsequently caused bosh-utils tests to fail,
  since these tests attempt to extract tars to a path including a
  symlink, which tar does not permit.
- There are at least two ways to fix this problem: the bosh-utils test
  environment can arbitarily configure a temp directory that it "knows"
  does not include a symlink (e.g., by hard-coding to C:\Windows\Temp,
  which is NOT symlinked). An advantage here is behavior changes are
  limited to Windows behavior. A disadvantage is this shifts the
  responsibility for that tar extract destination paths do NOT include
  symlinks downstream. To be fair, downstream consumers have _ALWAYS_
  had this responsibility, _however_, Windows behavior has changed such
  that it is almost certain that prior invocations of tar extraction
  with temp dirs that were previously successful will now fail.
  Alternatively, one can choose to change the tar uncompress behavior
  such that it will resolve the path _prior_ to an extraction. This has
  a larger impact in terms of change as it will also affect linux users,
  HOWEVER, this _should_ represent additive behavior to what consumers
  previously experienced. That is, current users of this method should
  be unaffected, including those users who would otherwise be impacted
  by the Windows stemcell changes. Further, I cannot currently imagine
  any previously valid invocations that would fail as a result of these
  changes, thus this latter change seems like a better choice, even
  given the behavior change.
- As mentioned above, this commit should fix any tar extraction issues
  observed in the DecompressFileToDir function after upgrading to the
  Windows 2019.87 stemcell. This change should be backwards compatible.
@ragaskar ragaskar force-pushed the fix/windows-tar-decompress-file-fails branch 5 times, most recently from 93868c9 to 373c3ee Compare June 18, 2025 23:36
@ragaskar ragaskar changed the base branch from master to develop June 18, 2025 23:37
@ragaskar ragaskar force-pushed the fix/windows-tar-decompress-file-fails branch from 373c3ee to 217113a Compare June 19, 2025 00:07
- The "home dir" test was failing when the suite was run w/ Github
  Actions. We see these failures _begin_ with b6aa58b, which I believe
  was an attempt to address failures occuring as a knock-on effect on
  the changes in 5ec2200, which apparently did not sufficiently consider
  the various users which the test can be run as. It doesn't seem like
  those changes were correct for the Github Actions context, where
  user.Name does not seem to be set (it may be that the intended string
  _was_ user.Username, because I'm not sure the filepath.Base was needed
  for the Name case). In any circumstance, user.Username seems to work
  for both cases -- if possible it may be sensible to set a hardcoded
  expectation around the value of this string itself (e.g. as
  "runneradmin") to make these kind of cross-context failures easier to
  track down, although I suspect this kind of check would have to switch
  on environment.
- In any case, for now, this change appears to allow _both_ Github
  Actions and other CI pipeline test runners that may be in use to
  successfully pass, and also seems to reasonably represent the original
  intent of the test (the created homedir should contain the username).
@ragaskar ragaskar force-pushed the fix/windows-tar-decompress-file-fails branch from 217113a to dea3738 Compare June 19, 2025 00:20
@github-project-automation github-project-automation bot moved this from Inbox to Pending Merge | Prioritized in Foundational Infrastructure Working Group Jun 19, 2025
@selzoc selzoc merged commit ed331a9 into develop Jun 25, 2025
7 checks passed
@github-project-automation github-project-automation bot moved this from Pending Merge | Prioritized to Done in Foundational Infrastructure Working Group Jun 25, 2025
@selzoc selzoc deleted the fix/windows-tar-decompress-file-fails branch June 25, 2025 22:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

3 participants