-
Notifications
You must be signed in to change notification settings - Fork 18.7k
Description
Currently os.exec allow us to use a Token to create a process under a different user, but its not clear how to do that; so please provide an proper example :-)
Please note that #35653 or #21105 are somewhat related to this, but they were closed by using the more complex CreateProcessWithLogon function and didn't provide an example of starting a process under a different user.
Also, I think it would also be useful to add support for setting the user domain/username/password in syscall.SysProcAttr and internally use CreateProcessWithLogonW/CreateProcessWithLogon function instead of CreateProcessAsUserW/CreateProcessAsUser (as done in Go).
If that makes sense, I can try to create a PR that adds the following properties to syscall.SysProcAttr:
- Domain
- Username
- Password
And use CreateProcessWithLogonW to launch the process when Username is set.
BTW, dotnet also uses the CreateProcessWithLogon function.
What do you think?