Merge pull request #46847 from dwoz/missing-strdup

strdup from libc is not available on windows
This commit is contained in:
Nicole Thomas 2018-04-03 15:51:31 -04:00 committed by GitHub
commit e3d17ab7bc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -48,15 +48,20 @@ from salt.ext.six.moves import range # pylint: disable=import-error,redefined-b
# Import 3rd-party libs
import salt.ext.six as six
LIBC = CDLL(find_library('c'))
try:
LIBC = CDLL(find_library('c'))
CALLOC = LIBC.calloc
CALLOC.restype = c_void_p
CALLOC.argtypes = [c_uint, c_uint]
CALLOC = LIBC.calloc
CALLOC.restype = c_void_p
CALLOC.argtypes = [c_uint, c_uint]
STRDUP = LIBC.strdup
STRDUP.argstypes = [c_char_p]
STRDUP.restype = POINTER(c_char) # NOT c_char_p !!!!
STRDUP = LIBC.strdup
STRDUP.argstypes = [c_char_p]
STRDUP.restype = POINTER(c_char) # NOT c_char_p !!!!
except AttributeError:
HAS_LIBC = False
else:
HAS_LIBC = True
# Various constants
PAM_PROMPT_ECHO_OFF = 1
@ -147,7 +152,7 @@ def __virtual__():
'''
Only load on Linux systems
'''
return HAS_PAM
return HAS_LIBC and HAS_PAM
def authenticate(username, password):