def put_file(local_path, path, share="C$", conn=None, host=None, username=None, password=None): """ Wrapper around impacket.smbconnection.putFile() that allows a file to be uploaded Example usage: import salt.utils.smb smb_conn = salt.utils.smb.get_conn('10.0.0.45', 'vagrant', 'vagrant') salt.utils.smb.put_file('/root/test.pdf', 'temp\\myfiles\\test1.pdf', conn=smb_conn) """ if HAS_SMBPROTOCOL: return _put_file_smbprotocol( local_path, path, share, conn=conn, host=host, username=username, password=password, ) raise MissingSmb("SMB library required (impacket or smbprotocol)")
def delete_directory( path, share="C$", conn=None, host=None, username=None, password=None ): if HAS_SMBPROTOCOL: return _delete_directory_smbprotocol( path, share, conn=conn, host=host, username=username, password=password ) raise MissingSmb("SMB library required (impacket or smbprotocol)")
def put_str(content, path, share='C$', conn=None, host=None, username=None, password=None): ''' Wrapper around impacket.smbconnection.putFile() that allows a string to be uploaded, without first writing it as a local file ''' if HAS_SMBPROTOCOL: return _put_str_smbprotocol( content, path, share, conn=conn, host=host, username=username, password=password ) elif HAS_IMPACKET: return _put_str_impacket( content, path, share, conn=conn, host=host, username=username, password=password ) raise MissingSmb("SMB library required (impacket or smbprotocol)")
def delete_file(path, share='C$', conn=None, host=None, username=None, password=None): if HAS_SMBPROTOCOL: return _delete_file_smbprotocol(path, share, conn=conn, host=host, username=username, password=password) elif HAS_IMPACKET: return _delete_file_impacket(path, share, conn=conn, host=host, username=username, password=password) raise MissingSmb("SMB library required (impacket or smbprotocol)")
def mkdirs(path, share="C$", conn=None, host=None, username=None, password=None): if HAS_SMBPROTOCOL: return _mkdirs_smbprotocol(path, share, conn=conn, host=host, username=username, password=password) elif HAS_IMPACKET: return _mkdirs_impacket(path, share, conn=conn, host=host, username=username, password=password) raise MissingSmb("SMB library required (impacket or smbprotocol)")