Skip to content
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

syscall, os/exec: Support running child process as different user on Windows #35653

Closed
mappu opened this issue Nov 17, 2019 · 2 comments
Closed

Comments

@mappu
Copy link

mappu commented Nov 17, 2019

What version of Go are you using (go version)?

$ go version
go version go1.13.4 windows/amd64

Does this issue reproduce with the latest release?

n/a

What operating system and processor architecture are you using (go env)?

n/a

What did you do?

Try to launch a process as a different user. Found syscall.Credential can be supplied as a SysProcAttr to exec.Cmd.

What did you expect to see?

Ability to launch process as different user, on all supported OSes.

What did you see instead?

syscall.Credential only supports UID/GID and only works on Unix-like systems. There's no option for Windows (based on either CreateProcessWithLogonW call, or LogonUser/CreateProcessAsUserW pair call).

@acln0
Copy link
Contributor

acln0 commented Nov 18, 2019

On Windows, syscall.SysProcAttr is this: https://golang.org/pkg/syscall/?GOOS=windows#SysProcAttr

I think you can load the appropriate DLL for LogonUser (see https://godoc.org/golang.org/x/sys/windows#NewLazyDLL), call the function, which grants a syscall.Token, then use it with SysProcAttr.

@toothrot
Copy link
Contributor

Thanks @acln0, I think you're right.

I believe this is a duplicate of #21105. I think the associated CL, golang.org/cl/75253 includes an example of this. I'll close this as a duplicate, but please let me know if I am mistaken.

@golang golang locked and limited conversation to collaborators Nov 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants