Merge pull request #27168 from techhat/gateimpacket

Add further gating of impacket library
This commit is contained in:
Nicole Thomas 2015-09-16 12:55:56 -06:00
commit 4495f4f4d0
2 changed files with 12 additions and 0 deletions

View file

@ -852,6 +852,9 @@ def deploy_windows(host,
newtimeout = timeout - (time.mktime(time.localtime()) - starttime)
smb_conn = salt.utils.smb.get_conn(host, username, password)
if smb_conn is False:
log.error('Please install impacket to enable SMB functionality')
return False
creds = "-U '{0}%{1}' //{2}".format(
username, password, host)

View file

@ -41,6 +41,9 @@ def get_conn(host=None, username=None, password=None):
'''
Get an SMB connection
'''
if not HAS_IMPACKET:
return False
conn = impacket.smbconnection.SMBConnection(
remoteName='*SMBSERVER',
remoteHost=host,
@ -59,6 +62,9 @@ def mkdirs(path, share='C$', conn=None, host=None, username=None, password=None)
if conn is None:
conn = get_conn(host, username, password)
if conn is False:
return False
comps = path.split('/')
pos = 1
for comp in comps:
@ -78,5 +84,8 @@ def put_str(content, path, share='C$', conn=None, host=None, username=None, pass
if conn is None:
conn = get_conn(host, username, password)
if conn is False:
return False
fh_ = StrHandle(content)
conn.putFile(share, path, fh_.string)