From b00a4da311a59a33f7b789e40f506d16adf5c004 Mon Sep 17 00:00:00 2001 From: Pan Date: Tue, 13 Feb 2018 21:13:14 +0100 Subject: [PATCH] Use SFTP flags for reading --- Changelog.rst | 1 + pssh/ssh2_client.py | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Changelog.rst b/Changelog.rst index 3e4d3dee..d95a2cea 100644 --- a/Changelog.rst +++ b/Changelog.rst @@ -14,6 +14,7 @@ Fixes -------- * ``ParallelSSH2Client.join`` timeout duration was incorrectly for per-host rather than total. +* SFTP read flags were not fully portable. 1.3.2 ++++++ diff --git a/pssh/ssh2_client.py b/pssh/ssh2_client.py index 0bd507e2..71b935a4 100644 --- a/pssh/ssh2_client.py +++ b/pssh/ssh2_client.py @@ -31,7 +31,7 @@ from ssh2.exceptions import AuthenticationError, AgentError, \ SessionHandshakeError, SFTPHandleError, SFTPIOError as SFTPIOError_ssh2 from ssh2.session import Session -from ssh2.sftp import LIBSSH2_FXF_CREAT, LIBSSH2_FXF_WRITE, \ +from ssh2.sftp import LIBSSH2_FXF_READ, LIBSSH2_FXF_CREAT, LIBSSH2_FXF_WRITE, \ LIBSSH2_FXF_TRUNC, LIBSSH2_SFTP_S_IRUSR, LIBSSH2_SFTP_S_IRGRP, \ LIBSSH2_SFTP_S_IWUSR, LIBSSH2_SFTP_S_IXUSR, LIBSSH2_SFTP_S_IROTH, \ LIBSSH2_SFTP_S_IXGRP, LIBSSH2_SFTP_S_IXOTH @@ -587,7 +587,9 @@ def _sftp_get(self, remote_fh, local_file): local_fh.write(data) def sftp_get(self, sftp, remote_file, local_file): - with self._sftp_openfh(sftp.open, remote_file, 0, 0) as remote_fh: + with self._sftp_openfh( + sftp.open, remote_file, + LIBSSH2_FXF_READ, LIBSSH2_SFTP_S_IRUSR) as remote_fh: try: self._sftp_get(remote_fh, local_file) # THREAD_POOL.apply(