Skip to content

Prevent chdir race condition in hasAccessibleHomeDir#61634

Merged
espadolini merged 1 commit intomasterfrom
espadolini/chdir-lock
Nov 21, 2025
Merged

Prevent chdir race condition in hasAccessibleHomeDir#61634
espadolini merged 1 commit intomasterfrom
espadolini/chdir-lock

Conversation

@espadolini
Copy link
Copy Markdown
Contributor

srv.hasAccessibleHomeDir can end up being called, even concurrently, by virtue of homeDirSubsys and file transfer ~ expansion when logging in as the user running Teleport. This PR adds a lock around changing and reverting the current directory, and makes the revert operation use a file rather than assuming that it's possible to go back to the original directory by absolute path, which is a little safer; the implementation follows the implementation of (*testing.T).Chdir.

In addition, this PR removes the change of directory to the self-discovered directory of the Teleport executable when executing Teleport for reexec purposes.

@espadolini espadolini added no-changelog Indicates that a PR does not require a changelog entry backport/branch/v18 labels Nov 20, 2025
@espadolini espadolini requested a review from eriktate November 20, 2025 21:31
@espadolini espadolini added this pull request to the merge queue Nov 21, 2025
Merged via the queue into master with commit 11661a2 Nov 21, 2025
46 checks passed
@espadolini espadolini deleted the espadolini/chdir-lock branch November 21, 2025 13:47
@backport-bot-workflows
Copy link
Copy Markdown
Contributor

@espadolini See the table below for backport results.

Branch Result
branch/v18 Create PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport/branch/v18 no-changelog Indicates that a PR does not require a changelog entry size/sm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants