def list_dir(self, path): """List the files in a directory on the remote host. Forwards to SFTPClient.listdir(), but also warns about empty results that may be caused by paramiko not reporting missing execute permission on the directory correctly. path - directory to list """ content = self.sftp.listdir(self._sftpify(path)) if len(content) == 0: m = stat.S_IMODE(self.sftp.stat(path).st_mode) for role in ['USR', 'GRP', 'OTH']: mask = util.get_fmask('R', role)|util.get_fmask('X',role) if (m & mask) != mask: _logger.debug('Directory '+path+' does not have both read and execute permission for ' + role + '.\nIf you depend on '+role+ ' for access, the empty directory listing may not be correct') return content
def list_dir(self, path): """List the files in a directory on the remote host. Forwards to SFTPClient.listdir(), but also warns about empty results that may be caused by paramiko not reporting missing execute permission on the directory correctly. path - directory to list """ _logger.debug('\nRCH--> ' + 'remote_ch, list dir, %s', path) content = self.sftp.listdir(self._sftpify(path)) if not content: m = stat.S_IMODE(self.sftp.stat(path).st_mode) for role in ['USR', 'GRP', 'OTH']: mask = util.get_fmask('R', role)|util.get_fmask('X', role) if (m & mask) != mask: log_what = ('\nRCH--> Directory %s does not have both read and execute ' 'permission for %s.\nIf you depend on %s for access, the empty ' 'directory listing may not be correct') _logger.debug(log_what, path, role, role) return content
def list_dir(self, path): """List the files in a directory on the remote host. Forwards to SFTPClient.listdir(), but also warns about empty results that may be caused by paramiko not reporting missing execute permission on the directory correctly. path - directory to list """ content = self.sftp.listdir(self._sftpify(path)) if len(content) == 0: m = stat.S_IMODE(self.sftp.stat(path).st_mode) for role in ['USR', 'GRP', 'OTH']: mask = util.get_fmask('R', role) | util.get_fmask('X', role) if (m & mask) != mask: _logger.debug( 'Directory ' + path + ' does not have both read and execute permission for ' + role + '.\nIf you depend on ' + role + ' for access, the empty directory listing may not be correct' ) return content