Skip to content

Commit

Permalink
Added to str with length function in utils. Updated sftp realpath.
Browse files Browse the repository at this point in the history
    Removed unreachable code from agent.
  • Loading branch information
pkittenis committed Oct 18, 2017
1 parent 42d95e2 commit 4eee8db
Show file tree
Hide file tree
Showing 8 changed files with 619 additions and 470 deletions.
340 changes: 170 additions & 170 deletions ssh2/agent.c

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions ssh2/agent.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,12 @@ cdef int agent_auth(char * _username,
with gil:
raise AgentListIdentitiesError(
"Failure requesting identities from agent")
return 1
while 1:
if auth_identity(_username, agent, &identity, prev) == 1:
with gil:
raise AgentAuthenticationError(
"No identities match for user %s",
_username)
return 1
if c_ssh2.libssh2_agent_userauth(
agent, _username, identity) == 0:
clear_agent(agent)
Expand Down
6 changes: 3 additions & 3 deletions ssh2/session.c

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

370 changes: 187 additions & 183 deletions ssh2/sftp.c

Large diffs are not rendered by default.

9 changes: 4 additions & 5 deletions ssh2/sftp.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ from libc.stdlib cimport malloc, free
from session cimport Session
from error_codes cimport _LIBSSH2_ERROR_BUFFER_TOO_SMALL
from channel cimport Channel, PyChannel
from utils cimport to_bytes, to_str
from utils cimport to_bytes, to_str_len
from exceptions cimport SFTPHandleError, SFTPBufferTooSmall, SFTPIOError
from sftp_handle cimport SFTPHandle, PySFTPHandle, SFTPAttributes, SFTPStatVFS

Expand Down Expand Up @@ -371,7 +371,8 @@ cdef class SFTP:
rc = c_sftp.libssh2_sftp_symlink(self._sftp, _path, _target)
return rc

def realpath(self, path not None, size_t max_len=256):
def realpath(self, path not None, size_t max_len=256,
encoding='utf-8'):
"""Get real path for path.
:param: Path name to get real path for.
Expand All @@ -389,7 +390,6 @@ cdef class SFTP:
cdef int rc
cdef bytes b_path = to_bytes(path)
cdef char *_path = b_path
cdef bytes realpath
try:
with nogil:
rc = c_sftp.libssh2_sftp_realpath(
Expand All @@ -408,8 +408,7 @@ cdef class SFTP:
elif rc == c_ssh2.LIBSSH2_ERROR_EAGAIN:
with gil:
return rc
realpath = _target[:rc]
return to_str(realpath)
return to_str_len(_target, rc)
finally:
free(_target)

Expand Down

0 comments on commit 4eee8db

Please sign in to comment.