Skip to content

Fix Windows home directory for specific user #861

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

Merged

Conversation

jmschonfeld
Copy link
Contributor

When looking up a home directory for a specific user, we currently have a bug that results in always using the fallback path. This PR updates the implementation to:

  • Expect LookupAccountNameW and RegGetValueW to fail at the first call with an empty buffer (since there is no space in the buffer and it needs to return a valid buffer size
  • Fix a minor typo in the registry key that ensures we interpolate the user name rather than putting the literal \(String(decodingC... text into the key string

The added unit test ensures we exercise this code path

@jmschonfeld
Copy link
Contributor Author

@swift-ci please test

Copy link
Member

@compnerd compnerd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops, thanks for fixing this!

@jmschonfeld
Copy link
Contributor Author

Hmm, it looks like ProcessInfo.processInfo.userName is returning an empty string causing this test to fail, I wonder if the CI environment is set up in such a way that we can't reliably get the current user's username?

@jmschonfeld
Copy link
Contributor Author

@swift-ci please test

@jmschonfeld jmschonfeld merged commit ecf5445 into swiftlang:main Aug 16, 2024
3 checks passed
@jmschonfeld jmschonfeld deleted the windows/fix-home-directory-for-user branch August 16, 2024 20:32
jmschonfeld added a commit to jmschonfeld/swift-foundation that referenced this pull request Aug 16, 2024
* Fix Windows home directory for specific user

* Fix test failure
jmschonfeld added a commit that referenced this pull request Aug 19, 2024
* Fix Windows home directory for specific user

* Fix test failure
cthielen pushed a commit to cthielen/swift-foundation that referenced this pull request Nov 8, 2024
* Fix Windows home directory for specific user

* Fix test failure
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants