Skip to content

os/exec: windows: support simple way of launching process with username/password #42773

@rgl

Description

@rgl

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.OS-Windows

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions