Merge pull request #40357 from sergeizv/check-has-win32

Check salt.utils.win_functions.HAS_WIN32 in salt.utils.get_user
This commit is contained in:
Nicole Thomas 2017-03-29 17:11:45 -06:00 committed by GitHub
commit d3633cf8a2

View File

@ -86,9 +86,9 @@ except ImportError:
try:
import salt.utils.win_functions
HAS_WIN32 = True
HAS_WIN_FUNCTIONS = True
except ImportError:
HAS_WIN32 = False
HAS_WIN_FUNCTIONS = False
try:
import grp
@ -290,7 +290,7 @@ def get_user():
'''
if HAS_PWD:
return pwd.getpwuid(os.geteuid()).pw_name
elif HAS_WIN32:
elif HAS_WIN_FUNCTIONS and salt.utils.win_functions.HAS_WIN32:
return salt.utils.win_functions.get_current_user()
else:
raise CommandExecutionError("Required external libraries not found. Need 'pwd' or 'win32api")