Skip to content

Commit 4eee8db

Browse files
author
Pan
committed
Added to str with length function in utils. Updated sftp realpath.
Removed unreachable code from agent.
1 parent 42d95e2 commit 4eee8db

File tree

8 files changed

+619
-470
lines changed

8 files changed

+619
-470
lines changed

ssh2/agent.c

Lines changed: 170 additions & 170 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ssh2/agent.pyx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,12 @@ cdef int agent_auth(char * _username,
3030
with gil:
3131
raise AgentListIdentitiesError(
3232
"Failure requesting identities from agent")
33-
return 1
3433
while 1:
3534
if auth_identity(_username, agent, &identity, prev) == 1:
3635
with gil:
3736
raise AgentAuthenticationError(
3837
"No identities match for user %s",
3938
_username)
40-
return 1
4139
if c_ssh2.libssh2_agent_userauth(
4240
agent, _username, identity) == 0:
4341
clear_agent(agent)

ssh2/session.c

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ssh2/sftp.c

Lines changed: 187 additions & 183 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ssh2/sftp.pyx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ from libc.stdlib cimport malloc, free
6060
from session cimport Session
6161
from error_codes cimport _LIBSSH2_ERROR_BUFFER_TOO_SMALL
6262
from channel cimport Channel, PyChannel
63-
from utils cimport to_bytes, to_str
63+
from utils cimport to_bytes, to_str_len
6464
from exceptions cimport SFTPHandleError, SFTPBufferTooSmall, SFTPIOError
6565
from sftp_handle cimport SFTPHandle, PySFTPHandle, SFTPAttributes, SFTPStatVFS
6666

@@ -371,7 +371,8 @@ cdef class SFTP:
371371
rc = c_sftp.libssh2_sftp_symlink(self._sftp, _path, _target)
372372
return rc
373373

374-
def realpath(self, path not None, size_t max_len=256):
374+
def realpath(self, path not None, size_t max_len=256,
375+
encoding='utf-8'):
375376
"""Get real path for path.
376377
377378
:param: Path name to get real path for.
@@ -389,7 +390,6 @@ cdef class SFTP:
389390
cdef int rc
390391
cdef bytes b_path = to_bytes(path)
391392
cdef char *_path = b_path
392-
cdef bytes realpath
393393
try:
394394
with nogil:
395395
rc = c_sftp.libssh2_sftp_realpath(
@@ -408,8 +408,7 @@ cdef class SFTP:
408408
elif rc == c_ssh2.LIBSSH2_ERROR_EAGAIN:
409409
with gil:
410410
return rc
411-
realpath = _target[:rc]
412-
return to_str(realpath)
411+
return to_str_len(_target, rc)
413412
finally:
414413
free(_target)
415414

0 commit comments

Comments
 (0)