fix user profile unload - #872
Open
Tess Gauthier (tgauth) wants to merge 7 commits into
Open
Tess Gauthier (tgauth) wants to merge 7 commits into
Tess Gauthier (tgauth) wants to merge 7 commits into
Conversation
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
There was a problem hiding this comment.
Pull request overview
This PR fixes a Windows-specific resource leak by ensuring user profiles loaded for session processes are reliably unloaded when the corresponding sshd-session child process is reaped, and it tightens token lifecycle handling for password-auth and SSPI/GSS scenarios. It also adds a Pester regression test targeting Win32-OpenSSH issue #1694.
Changes:
- Track per-child loaded profile handles + a dedicated token for later
UnloadUserProfile()during SIGCHLD-based child reaping. - Fix token cleanup semantics (avoid closing SSPI-owned tokens; clear
password_auth_tokenafter use). - Add a Pester regression test that checks the user hive is unloaded after a session ends.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| regress/pesterTests/UserProfileUnload.Tests.ps1 | Adds a regression test for user hive unload after session exit. |
| contrib/win32/win32compat/win32_usertoken_utils.c | Returns the loaded profile handle from load_user_profile() and adds unload_user_profile(). |
| contrib/win32/win32compat/spawn-ext.c | Loads profile before spawning, duplicates a minimal token for later unload, registers child/profile association, and corrects token cleanup behavior. |
| contrib/win32/win32compat/signal_sigchld.c | Stores and unloads per-child profiles/tokens when removing children from the tracking table. |
| contrib/win32/win32compat/signal_internal.h | Extends child tracking structure and adds register_child_profile() declaration. |
| contrib/win32/win32compat/misc_internal.h | Updates load_user_profile() signature and declares unload_user_profile(). |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Collaborator
Author
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
Collaborator
Author
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
Collaborator
Author
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
Collaborator
Author
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
Collaborator
Author
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Summary
UnloadUserProfile()is called when sshd-session child process for the connection is reaped using user's token (duplicated to ensure only permissions required toUnloadUserProfile()are persisted).CloseHandle(user_token)for gss-api as its owned bygss_release_cred()and ensures globalpassword_auth_tokenis not left dangling.UnloadUserProfile()is working.PR Context