mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Fix runas function for System Account
This commit is contained in:
parent
3808d849fe
commit
e9d2402c0b
1 changed files with 6 additions and 2 deletions
|
@ -298,6 +298,10 @@ def runas_system(cmd, username, password):
|
|||
win32con.LOGON32_LOGON_INTERACTIVE,
|
||||
win32con.LOGON32_PROVIDER_DEFAULT)
|
||||
|
||||
# Get Unrestricted Token (UAC) if this is an Admin Account
|
||||
elevated_token = win32security.GetTokenInformation(
|
||||
token, win32security.TokenLinkedToken)
|
||||
|
||||
# Get Security Attributes
|
||||
security_attributes = win32security.SECURITY_ATTRIBUTES()
|
||||
security_attributes.bInheritHandle = 1
|
||||
|
@ -337,8 +341,8 @@ def runas_system(cmd, username, password):
|
|||
None,
|
||||
startup_info)
|
||||
|
||||
hProcess, hThread, PId, TId = win32process.CreateProcessAsUser(token,
|
||||
*procArgs)
|
||||
hProcess, hThread, PId, TId = \
|
||||
win32process.CreateProcessAsUser(elevated_token, *procArgs)
|
||||
|
||||
if stdin_read is not None:
|
||||
stdin_read.Close()
|
||||
|
|
Loading…
Add table
Reference in a new issue