]> Cypherpunks repositories - gostls13.git/commit
os/user: support calling Current on impersonated threads
authorqmuntal <quimmuntal@gmail.com>
Thu, 1 Aug 2024 14:26:00 +0000 (16:26 +0200)
committerQuim Muntal <quimmuntal@gmail.com>
Thu, 8 Aug 2024 20:06:37 +0000 (20:06 +0000)
commitfe392d0dff0089c70f6addf83c122100af7d24be
tree43f778834534fa97ad1f398bb66339014b293f96
parentdb0b6a85c27b6ae8bd132be11ba07c29c01f4165
os/user: support calling Current on impersonated threads

The syscall.OpenCurrentProcessToken call in user.Current fails
when called from an impersonated thread, as the process token is
normally in that case.

This change ensures that the current thread is not impersonated
when calling OpenCurrentProcessToken, and then restores the
impersonation state, if any.

Fixes #68647

Change-Id: I3197535dd8355d21029a42f7aa3936d8fb021202
Reviewed-on: https://go-review.googlesource.com/c/go/+/602415
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
src/internal/syscall/windows/security_windows.go
src/internal/syscall/windows/syscall_windows.go
src/internal/syscall/windows/zsyscall_windows.go
src/os/user/lookup_windows.go
src/os/user/user_windows_test.go [new file with mode: 0644]