From 9fcf48e16a66145dc76daff23badfea4b67ae8a2 Mon Sep 17 00:00:00 2001 From: Panos Date: Fri, 14 Aug 2020 11:39:54 +0100 Subject: [PATCH 01/13] Removed obsolete openssl windows binary files. Updated manylinux dockerfile to pull openssl remotely, removed openssl manylinux file. --- ci/appveyor/openssl-1.0.2q-i386-win32.zip | 3 --- ci/appveyor/openssl-1.0.2q-x64_86-win64.zip | 3 --- ci/appveyor/openssl-1.1.0h-x32-VC2017.zip | 3 --- ci/docker/manylinux/Dockerfile | 7 ++++--- ci/docker/manylinux/openssl-1.1.1b.tar.gz | 3 --- 5 files changed, 4 insertions(+), 15 deletions(-) delete mode 100644 ci/appveyor/openssl-1.0.2q-i386-win32.zip delete mode 100644 ci/appveyor/openssl-1.0.2q-x64_86-win64.zip delete mode 100644 ci/appveyor/openssl-1.1.0h-x32-VC2017.zip delete mode 100644 ci/docker/manylinux/openssl-1.1.1b.tar.gz diff --git a/ci/appveyor/openssl-1.0.2q-i386-win32.zip b/ci/appveyor/openssl-1.0.2q-i386-win32.zip deleted file mode 100644 index 1a4c2ba9..00000000 --- a/ci/appveyor/openssl-1.0.2q-i386-win32.zip +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:301162cb82096fe2f47f93563ccc33fe9d497486a3313ead9a5500d8c7edbacf -size 1040327 diff --git a/ci/appveyor/openssl-1.0.2q-x64_86-win64.zip b/ci/appveyor/openssl-1.0.2q-x64_86-win64.zip deleted file mode 100644 index f606c85b..00000000 --- a/ci/appveyor/openssl-1.0.2q-x64_86-win64.zip +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:26de57cc4cf8f1780af9d5a83ae0417bb8700b566422ff936f021e687bd0c2d4 -size 1353101 diff --git a/ci/appveyor/openssl-1.1.0h-x32-VC2017.zip b/ci/appveyor/openssl-1.1.0h-x32-VC2017.zip deleted file mode 100644 index a23cd96c..00000000 --- a/ci/appveyor/openssl-1.1.0h-x32-VC2017.zip +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:3ce4b05192d1b62efb529e8c51da0bce26614c8cde47a3e397fd1c19b2403eb1 -size 1695059 diff --git a/ci/docker/manylinux/Dockerfile b/ci/docker/manylinux/Dockerfile index 01ed1929..26895428 100644 --- a/ci/docker/manylinux/Dockerfile +++ b/ci/docker/manylinux/Dockerfile @@ -1,7 +1,7 @@ FROM quay.io/pypa/manylinux1_x86_64 ENV CMAKE cmake-2.8.11.1-5.4.x86_64 -ENV OPENSSL openssl-1.1.1b +ENV OPENSSL openssl-1.1.1g ENV SYSTEM_LIBSSH2 1 ENV LIBSSH2_VERSION 1.9.0 @@ -9,7 +9,7 @@ RUN yum install zlib-devel -y ADD libssh2-${LIBSSH2_VERSION}.tar.gz libssh2-${LIBSSH2_VERSION}.tar.gz ADD ${CMAKE}.rpm cmake.rpm -ADD ${OPENSSL}.tar.gz ${OPENSSL}.tar.gz +ADD https://www.openssl.org/source/${OPENSSL}.tar.gz ${OPENSSL}.tar.gz ADD local-perl-5.10.0-62.ep.x86_64.rpm local-perl.rpm ADD local-perl-Pod-Simple-3.07-62.ep.x86_64.rpm local-perl-Pod-Simple.rpm ADD local-perl-Module-Pluggable-3.60-62.ep.x86_64.rpm local-perl-Module-Pluggable.rpm @@ -20,8 +20,9 @@ ADD local-perl-Pod-Escapes-1.04-62.ep.x86_64.rpm local-perl-Pod-Escapes.rpm RUN rpm -i cmake.rpm local-perl-Module-Pluggable.rpm local-perl-Pod-Escapes.rpm local-perl-Pod-Simple.rpm local-perl-XSLoader.rpm local-perl-version.rpm local-perl-libs.rpm local-perl.rpm +RUN tar -xzf ${OPENSSL}.tar.gz # Openssl -RUN cd ${OPENSSL}.tar.gz/${OPENSSL} && \ +RUN cd ${OPENSSL} && \ ./config --prefix=/usr --openssldir=/usr/openssl threads shared && \ make -j4 && make install diff --git a/ci/docker/manylinux/openssl-1.1.1b.tar.gz b/ci/docker/manylinux/openssl-1.1.1b.tar.gz deleted file mode 100644 index 0f24a0a7..00000000 --- a/ci/docker/manylinux/openssl-1.1.1b.tar.gz +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:5c557b023230413dfb0756f3137a13e6d726838ccd1430888ad15bfb2b43ea4b -size 8213737 From 1af6c9e47142b2f1f7e3899a384b0256b191a18f Mon Sep 17 00:00:00 2001 From: Panos Date: Fri, 14 Aug 2020 12:54:15 +0100 Subject: [PATCH 02/13] Migrated manylinux builds to 2010. --- ci/docker/manylinux/Dockerfile | 13 +------------ ci/docker/manylinux/cmake-2.8.11.1-5.4.x86_64.rpm | 3 --- .../manylinux/local-perl-5.10.0-62.ep.x86_64.rpm | 3 --- ...ocal-perl-Module-Pluggable-3.60-62.ep.x86_64.rpm | 3 --- .../local-perl-Pod-Escapes-1.04-62.ep.x86_64.rpm | 3 --- .../local-perl-Pod-Simple-3.07-62.ep.x86_64.rpm | 3 --- .../manylinux/local-perl-XSLoader-0.10-1.noarch.rpm | 3 --- .../local-perl-libs-5.10.0-62.ep.x86_64.rpm | 3 --- .../local-perl-version-0.74-62.ep.x86_64.rpm | 3 --- 9 files changed, 1 insertion(+), 36 deletions(-) delete mode 100644 ci/docker/manylinux/cmake-2.8.11.1-5.4.x86_64.rpm delete mode 100644 ci/docker/manylinux/local-perl-5.10.0-62.ep.x86_64.rpm delete mode 100644 ci/docker/manylinux/local-perl-Module-Pluggable-3.60-62.ep.x86_64.rpm delete mode 100644 ci/docker/manylinux/local-perl-Pod-Escapes-1.04-62.ep.x86_64.rpm delete mode 100644 ci/docker/manylinux/local-perl-Pod-Simple-3.07-62.ep.x86_64.rpm delete mode 100644 ci/docker/manylinux/local-perl-XSLoader-0.10-1.noarch.rpm delete mode 100644 ci/docker/manylinux/local-perl-libs-5.10.0-62.ep.x86_64.rpm delete mode 100644 ci/docker/manylinux/local-perl-version-0.74-62.ep.x86_64.rpm diff --git a/ci/docker/manylinux/Dockerfile b/ci/docker/manylinux/Dockerfile index 26895428..d9155799 100644 --- a/ci/docker/manylinux/Dockerfile +++ b/ci/docker/manylinux/Dockerfile @@ -1,6 +1,5 @@ -FROM quay.io/pypa/manylinux1_x86_64 +FROM quay.io/pypa/manylinux2010_x86_64 -ENV CMAKE cmake-2.8.11.1-5.4.x86_64 ENV OPENSSL openssl-1.1.1g ENV SYSTEM_LIBSSH2 1 ENV LIBSSH2_VERSION 1.9.0 @@ -8,17 +7,7 @@ ENV LIBSSH2_VERSION 1.9.0 RUN yum install zlib-devel -y ADD libssh2-${LIBSSH2_VERSION}.tar.gz libssh2-${LIBSSH2_VERSION}.tar.gz -ADD ${CMAKE}.rpm cmake.rpm ADD https://www.openssl.org/source/${OPENSSL}.tar.gz ${OPENSSL}.tar.gz -ADD local-perl-5.10.0-62.ep.x86_64.rpm local-perl.rpm -ADD local-perl-Pod-Simple-3.07-62.ep.x86_64.rpm local-perl-Pod-Simple.rpm -ADD local-perl-Module-Pluggable-3.60-62.ep.x86_64.rpm local-perl-Module-Pluggable.rpm -ADD local-perl-XSLoader-0.10-1.noarch.rpm local-perl-XSLoader.rpm -ADD local-perl-version-0.74-62.ep.x86_64.rpm local-perl-version.rpm -ADD local-perl-libs-5.10.0-62.ep.x86_64.rpm local-perl-libs.rpm -ADD local-perl-Pod-Escapes-1.04-62.ep.x86_64.rpm local-perl-Pod-Escapes.rpm - -RUN rpm -i cmake.rpm local-perl-Module-Pluggable.rpm local-perl-Pod-Escapes.rpm local-perl-Pod-Simple.rpm local-perl-XSLoader.rpm local-perl-version.rpm local-perl-libs.rpm local-perl.rpm RUN tar -xzf ${OPENSSL}.tar.gz # Openssl diff --git a/ci/docker/manylinux/cmake-2.8.11.1-5.4.x86_64.rpm b/ci/docker/manylinux/cmake-2.8.11.1-5.4.x86_64.rpm deleted file mode 100644 index aad454c5..00000000 --- a/ci/docker/manylinux/cmake-2.8.11.1-5.4.x86_64.rpm +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:2a9d22139e76b01932a4b7a2a463fa88982407fd37b64d8bbf2d662cdf3306a2 -size 11308385 diff --git a/ci/docker/manylinux/local-perl-5.10.0-62.ep.x86_64.rpm b/ci/docker/manylinux/local-perl-5.10.0-62.ep.x86_64.rpm deleted file mode 100644 index 986c8bab..00000000 --- a/ci/docker/manylinux/local-perl-5.10.0-62.ep.x86_64.rpm +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:331fd97d8cdac348c87b10534c9b28481a443906cd2643ec8743bddc1fc4ddf0 -size 15328393 diff --git a/ci/docker/manylinux/local-perl-Module-Pluggable-3.60-62.ep.x86_64.rpm b/ci/docker/manylinux/local-perl-Module-Pluggable-3.60-62.ep.x86_64.rpm deleted file mode 100644 index 421d6a7b..00000000 --- a/ci/docker/manylinux/local-perl-Module-Pluggable-3.60-62.ep.x86_64.rpm +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:e6f670fd4cd7c545bd75617e5ac0d7b79796d3ab8f85a6a39bf89c4e585135de -size 22167 diff --git a/ci/docker/manylinux/local-perl-Pod-Escapes-1.04-62.ep.x86_64.rpm b/ci/docker/manylinux/local-perl-Pod-Escapes-1.04-62.ep.x86_64.rpm deleted file mode 100644 index be4c877f..00000000 --- a/ci/docker/manylinux/local-perl-Pod-Escapes-1.04-62.ep.x86_64.rpm +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:e14f8cc8c6d13b1e9d66ba9ea09b9b0b431750f28111010e00366dd19edbc0fe -size 20219 diff --git a/ci/docker/manylinux/local-perl-Pod-Simple-3.07-62.ep.x86_64.rpm b/ci/docker/manylinux/local-perl-Pod-Simple-3.07-62.ep.x86_64.rpm deleted file mode 100644 index da6f14b9..00000000 --- a/ci/docker/manylinux/local-perl-Pod-Simple-3.07-62.ep.x86_64.rpm +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:192e4eea2cc51f4640f9b2279e0caea948c7971386e27719555456278c16fdca -size 156291 diff --git a/ci/docker/manylinux/local-perl-XSLoader-0.10-1.noarch.rpm b/ci/docker/manylinux/local-perl-XSLoader-0.10-1.noarch.rpm deleted file mode 100644 index 1953cdd1..00000000 --- a/ci/docker/manylinux/local-perl-XSLoader-0.10-1.noarch.rpm +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:74c6452fcbf48351911aa60e6b109b5ac8caaff77c491c64310bb5e9cf43173e -size 13149 diff --git a/ci/docker/manylinux/local-perl-libs-5.10.0-62.ep.x86_64.rpm b/ci/docker/manylinux/local-perl-libs-5.10.0-62.ep.x86_64.rpm deleted file mode 100644 index 20f4ac02..00000000 --- a/ci/docker/manylinux/local-perl-libs-5.10.0-62.ep.x86_64.rpm +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:90473006df6d55414c4b5410a6cd25321d25800140dcde98d5451b9dcfc05d37 -size 1608544 diff --git a/ci/docker/manylinux/local-perl-version-0.74-62.ep.x86_64.rpm b/ci/docker/manylinux/local-perl-version-0.74-62.ep.x86_64.rpm deleted file mode 100644 index 7d7da71a..00000000 --- a/ci/docker/manylinux/local-perl-version-0.74-62.ep.x86_64.rpm +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:a94a9b24c0e87e9522315b78bed2c0aa194ccccf76926e3597d37b7e36dce714 -size 24947 From fae066dcb0e3cf2f3a0ca5f6cac39776bbb285e7 Mon Sep 17 00:00:00 2001 From: Panos Date: Wed, 19 Aug 2020 15:39:50 +0100 Subject: [PATCH 03/13] Enabled agent fwd implementation --- .appveyor.yml | 4 +- .travis.yml | 2 - ssh2/c_ssh2.pxd | 3 +- ssh2/channel.c | 138 ++++++++++++++++++++++++++++++++++++++++++----- ssh2/channel.pyx | 13 +++-- 5 files changed, 132 insertions(+), 28 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index a9506909..aa17f15c 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -7,6 +7,7 @@ environment: PYTHONUNBUFFERED: 1 EMBEDDED_LIB: 1 OPENSSL_VER: 1.1.0h + SYSTEM_LIBSSH2: 1 PYPI_USER: secure: 2m0jy6JD/R9RExIosOT6YA== PYPI_PASS: @@ -17,21 +18,18 @@ environment: PYTHON_ARCH: "64" MSVC: "Visual Studio 14 Win64" ARCH: x64_86 - SYSTEM_LIBSSH2: 1 - PYTHON: "C:\\Python37-x64" PYTHON_VERSION: "3.7" PYTHON_ARCH: "64" MSVC: "Visual Studio 14 Win64" ARCH: x64_86 - SYSTEM_LIBSSH2: 1 - PYTHON: "C:\\Python38-x64" PYTHON_VERSION: "3.8" PYTHON_ARCH: "64" MSVC: "Visual Studio 14 Win64" ARCH: x64_86 - SYSTEM_LIBSSH2: 1 install: # If there is a newer build queued for the same PR, cancel this one. diff --git a/.travis.yml b/.travis.yml index 224b4480..5ea3fc61 100644 --- a/.travis.yml +++ b/.travis.yml @@ -53,9 +53,7 @@ jobs: before_cache: - brew cleanup before_install: - - brew update - brew install ccache - - brew outdated openssl || travis_wait brew upgrade openssl || echo "y" - sudo -H pip install twine - which twine - sudo ci/install-ssh2.sh diff --git a/ssh2/c_ssh2.pxd b/ssh2/c_ssh2.pxd index 6cd9708e..8634d605 100644 --- a/ssh2/c_ssh2.pxd +++ b/ssh2/c_ssh2.pxd @@ -450,5 +450,4 @@ cdef extern from "libssh2.h" nogil: int libssh2_trace_sethandler(LIBSSH2_SESSION *session, void* context, libssh2_trace_handler_func callback) - IF HAVE_AGENT_FWD: - int libssh2_channel_request_auth_agent(LIBSSH2_CHANNEL *channel) + int libssh2_channel_request_auth_agent(LIBSSH2_CHANNEL *channel) diff --git a/ssh2/channel.c b/ssh2/channel.c index 14061968..776ec433 100644 --- a/ssh2/channel.c +++ b/ssh2/channel.c @@ -1346,8 +1346,9 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_64poll_channel_read(struct __p static PyObject *__pyx_pf_4ssh2_7channel_7Channel_66handle_extended_data(struct __pyx_obj_4ssh2_7channel_Channel *__pyx_v_self, int __pyx_v_ignore_mode); /* proto */ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_68handle_extended_data2(struct __pyx_obj_4ssh2_7channel_Channel *__pyx_v_self, int __pyx_v_ignore_mode); /* proto */ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_70ignore_extended_data(struct __pyx_obj_4ssh2_7channel_Channel *__pyx_v_self, int __pyx_v_ignore_mode); /* proto */ -static PyObject *__pyx_pf_4ssh2_7channel_7Channel_72__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_4ssh2_7channel_Channel *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_4ssh2_7channel_7Channel_74__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_4ssh2_7channel_Channel *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */ +static PyObject *__pyx_pf_4ssh2_7channel_7Channel_72request_auth_agent(struct __pyx_obj_4ssh2_7channel_Channel *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_4ssh2_7channel_7Channel_74__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_4ssh2_7channel_Channel *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_4ssh2_7channel_7Channel_76__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_4ssh2_7channel_Channel *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */ static PyObject *__pyx_tp_new_4ssh2_7channel_Channel(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ static PyObject *__pyx_int_0; static PyObject *__pyx_tuple__2; @@ -7627,6 +7628,114 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_70ignore_extended_data(struct return __pyx_r; } +/* "ssh2/channel.pyx":558 + * self._channel, ignore_mode) + * + * def request_auth_agent(self): # <<<<<<<<<<<<<< + * """Request SSH agent authentication forwarding on channel.""" + * cdef int rc + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_4ssh2_7channel_7Channel_73request_auth_agent(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static char __pyx_doc_4ssh2_7channel_7Channel_72request_auth_agent[] = "Channel.request_auth_agent(self)\nRequest SSH agent authentication forwarding on channel."; +static PyObject *__pyx_pw_4ssh2_7channel_7Channel_73request_auth_agent(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("request_auth_agent (wrapper)", 0); + __pyx_r = __pyx_pf_4ssh2_7channel_7Channel_72request_auth_agent(((struct __pyx_obj_4ssh2_7channel_Channel *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_4ssh2_7channel_7Channel_72request_auth_agent(struct __pyx_obj_4ssh2_7channel_Channel *__pyx_v_self) { + int __pyx_v_rc; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("request_auth_agent", 0); + + /* "ssh2/channel.pyx":561 + * """Request SSH agent authentication forwarding on channel.""" + * cdef int rc + * with nogil: # <<<<<<<<<<<<<< + * rc = c_ssh2.libssh2_channel_request_auth_agent(self._channel) + * return handle_error_codes(rc) + */ + { + #ifdef WITH_THREAD + PyThreadState *_save; + Py_UNBLOCK_THREADS + __Pyx_FastGIL_Remember(); + #endif + /*try:*/ { + + /* "ssh2/channel.pyx":562 + * cdef int rc + * with nogil: + * rc = c_ssh2.libssh2_channel_request_auth_agent(self._channel) # <<<<<<<<<<<<<< + * return handle_error_codes(rc) + */ + __pyx_v_rc = libssh2_channel_request_auth_agent(__pyx_v_self->_channel); + } + + /* "ssh2/channel.pyx":561 + * """Request SSH agent authentication forwarding on channel.""" + * cdef int rc + * with nogil: # <<<<<<<<<<<<<< + * rc = c_ssh2.libssh2_channel_request_auth_agent(self._channel) + * return handle_error_codes(rc) + */ + /*finally:*/ { + /*normal exit:*/{ + #ifdef WITH_THREAD + __Pyx_FastGIL_Forget(); + Py_BLOCK_THREADS + #endif + goto __pyx_L5; + } + __pyx_L5:; + } + } + + /* "ssh2/channel.pyx":563 + * with nogil: + * rc = c_ssh2.libssh2_channel_request_auth_agent(self._channel) + * return handle_error_codes(rc) # <<<<<<<<<<<<<< + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __pyx_f_4ssh2_5utils_handle_error_codes(__pyx_v_rc, 0); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 563, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 563, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + goto __pyx_L0; + + /* "ssh2/channel.pyx":558 + * self._channel, ignore_mode) + * + * def request_auth_agent(self): # <<<<<<<<<<<<<< + * """Request SSH agent authentication forwarding on channel.""" + * cdef int rc + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("ssh2.channel.Channel.request_auth_agent", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + /* "(tree fragment)":1 * def __reduce_cython__(self): # <<<<<<<<<<<<<< * raise TypeError("no default __reduce__ due to non-trivial __cinit__") @@ -7634,20 +7743,20 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_70ignore_extended_data(struct */ /* Python wrapper */ -static PyObject *__pyx_pw_4ssh2_7channel_7Channel_73__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static char __pyx_doc_4ssh2_7channel_7Channel_72__reduce_cython__[] = "Channel.__reduce_cython__(self)"; -static PyObject *__pyx_pw_4ssh2_7channel_7Channel_73__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { +static PyObject *__pyx_pw_4ssh2_7channel_7Channel_75__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static char __pyx_doc_4ssh2_7channel_7Channel_74__reduce_cython__[] = "Channel.__reduce_cython__(self)"; +static PyObject *__pyx_pw_4ssh2_7channel_7Channel_75__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0); - __pyx_r = __pyx_pf_4ssh2_7channel_7Channel_72__reduce_cython__(((struct __pyx_obj_4ssh2_7channel_Channel *)__pyx_v_self)); + __pyx_r = __pyx_pf_4ssh2_7channel_7Channel_74__reduce_cython__(((struct __pyx_obj_4ssh2_7channel_Channel *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_pf_4ssh2_7channel_7Channel_72__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_4ssh2_7channel_Channel *__pyx_v_self) { +static PyObject *__pyx_pf_4ssh2_7channel_7Channel_74__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_4ssh2_7channel_Channel *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; @@ -7692,20 +7801,20 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_72__reduce_cython__(CYTHON_UNU */ /* Python wrapper */ -static PyObject *__pyx_pw_4ssh2_7channel_7Channel_75__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/ -static char __pyx_doc_4ssh2_7channel_7Channel_74__setstate_cython__[] = "Channel.__setstate_cython__(self, __pyx_state)"; -static PyObject *__pyx_pw_4ssh2_7channel_7Channel_75__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) { +static PyObject *__pyx_pw_4ssh2_7channel_7Channel_77__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/ +static char __pyx_doc_4ssh2_7channel_7Channel_76__setstate_cython__[] = "Channel.__setstate_cython__(self, __pyx_state)"; +static PyObject *__pyx_pw_4ssh2_7channel_7Channel_77__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0); - __pyx_r = __pyx_pf_4ssh2_7channel_7Channel_74__setstate_cython__(((struct __pyx_obj_4ssh2_7channel_Channel *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state)); + __pyx_r = __pyx_pf_4ssh2_7channel_7Channel_76__setstate_cython__(((struct __pyx_obj_4ssh2_7channel_Channel *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_pf_4ssh2_7channel_7Channel_74__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_4ssh2_7channel_Channel *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) { +static PyObject *__pyx_pf_4ssh2_7channel_7Channel_76__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_4ssh2_7channel_Channel *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; @@ -7837,8 +7946,9 @@ static PyMethodDef __pyx_methods_4ssh2_7channel_Channel[] = { {"handle_extended_data", (PyCFunction)__pyx_pw_4ssh2_7channel_7Channel_67handle_extended_data, METH_O, __pyx_doc_4ssh2_7channel_7Channel_66handle_extended_data}, {"handle_extended_data2", (PyCFunction)__pyx_pw_4ssh2_7channel_7Channel_69handle_extended_data2, METH_O, __pyx_doc_4ssh2_7channel_7Channel_68handle_extended_data2}, {"ignore_extended_data", (PyCFunction)__pyx_pw_4ssh2_7channel_7Channel_71ignore_extended_data, METH_O, __pyx_doc_4ssh2_7channel_7Channel_70ignore_extended_data}, - {"__reduce_cython__", (PyCFunction)__pyx_pw_4ssh2_7channel_7Channel_73__reduce_cython__, METH_NOARGS, __pyx_doc_4ssh2_7channel_7Channel_72__reduce_cython__}, - {"__setstate_cython__", (PyCFunction)__pyx_pw_4ssh2_7channel_7Channel_75__setstate_cython__, METH_O, __pyx_doc_4ssh2_7channel_7Channel_74__setstate_cython__}, + {"request_auth_agent", (PyCFunction)__pyx_pw_4ssh2_7channel_7Channel_73request_auth_agent, METH_NOARGS, __pyx_doc_4ssh2_7channel_7Channel_72request_auth_agent}, + {"__reduce_cython__", (PyCFunction)__pyx_pw_4ssh2_7channel_7Channel_75__reduce_cython__, METH_NOARGS, __pyx_doc_4ssh2_7channel_7Channel_74__reduce_cython__}, + {"__setstate_cython__", (PyCFunction)__pyx_pw_4ssh2_7channel_7Channel_77__setstate_cython__, METH_O, __pyx_doc_4ssh2_7channel_7Channel_76__setstate_cython__}, {0, 0, 0, 0} }; diff --git a/ssh2/channel.pyx b/ssh2/channel.pyx index ca33bfef..ee71c036 100644 --- a/ssh2/channel.pyx +++ b/ssh2/channel.pyx @@ -555,10 +555,9 @@ cdef class Channel: c_ssh2.libssh2_channel_handle_extended_data( self._channel, ignore_mode) - IF HAVE_AGENT_FWD: - def request_auth_agent(self): - """Request SSH agent authentication forwarding on channel.""" - cdef int rc - with nogil: - rc = c_ssh2.libssh2_channel_request_auth_agent(self._channel) - return handle_error_codes(rc) + def request_auth_agent(self): + """Request SSH agent authentication forwarding on channel.""" + cdef int rc + with nogil: + rc = c_ssh2.libssh2_channel_request_auth_agent(self._channel) + return handle_error_codes(rc) From a0231fb5e552bbb864fb2deb4dfa501252cac1b4 Mon Sep 17 00:00:00 2001 From: Panos Date: Wed, 19 Aug 2020 16:09:08 +0100 Subject: [PATCH 04/13] Added get and set agent identity path functions. Added agent tests and agent object initialisation from python. --- ssh2/agent.c | 512 ++++++++++++++++++++++++++++++++++++-------- ssh2/agent.pyx | 20 +- ssh2/c_ssh2.pxd | 6 +- ssh2/channel.c | 138 ++---------- ssh2/channel.pyx | 13 +- tests/test_agent.py | 37 ++++ 6 files changed, 500 insertions(+), 226 deletions(-) create mode 100644 tests/test_agent.py diff --git a/ssh2/agent.c b/ssh2/agent.c index ff0ad03a..b9ce5984 100644 --- a/ssh2/agent.c +++ b/ssh2/agent.c @@ -1258,6 +1258,7 @@ static PyObject *(*__pyx_f_4ssh2_5utils_to_bytes)(PyObject *); /*proto*/ static PyTypeObject *__pyx_ptype_4ssh2_5agent_Agent = 0; static int __pyx_f_4ssh2_5agent_auth_identity(char const *, LIBSSH2_AGENT *, struct libssh2_agent_publickey **, struct libssh2_agent_publickey *); /*proto*/ static void __pyx_f_4ssh2_5agent_clear_agent(LIBSSH2_AGENT *); /*proto*/ +static LIBSSH2_AGENT *__pyx_f_4ssh2_5agent_agent_init(LIBSSH2_SESSION *); /*proto*/ #define __Pyx_MODULE_NAME "ssh2.agent" extern int __pyx_module_is_main_ssh2__agent; int __pyx_module_is_main_ssh2__agent = 0; @@ -1331,8 +1332,10 @@ static PyObject *__pyx_pf_4ssh2_5agent_5Agent_6get_identities(struct __pyx_obj_4 static PyObject *__pyx_pf_4ssh2_5agent_5Agent_8userauth(struct __pyx_obj_4ssh2_5agent_Agent *__pyx_v_self, PyObject *__pyx_v_username, struct __pyx_obj_4ssh2_4pkey_PublicKey *__pyx_v_pkey); /* proto */ static PyObject *__pyx_pf_4ssh2_5agent_5Agent_10disconnect(struct __pyx_obj_4ssh2_5agent_Agent *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_4ssh2_5agent_5Agent_12connect(struct __pyx_obj_4ssh2_5agent_Agent *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_4ssh2_5agent_5Agent_14__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_4ssh2_5agent_Agent *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_4ssh2_5agent_5Agent_16__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_4ssh2_5agent_Agent *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */ +static PyObject *__pyx_pf_4ssh2_5agent_5Agent_14get_identity_path(struct __pyx_obj_4ssh2_5agent_Agent *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_4ssh2_5agent_5Agent_16set_identity_path(struct __pyx_obj_4ssh2_5agent_Agent *__pyx_v_self, PyObject *__pyx_v_path); /* proto */ +static PyObject *__pyx_pf_4ssh2_5agent_5Agent_18__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_4ssh2_5agent_Agent *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_4ssh2_5agent_5Agent_20__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_4ssh2_5agent_Agent *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */ static PyObject *__pyx_tp_new_4ssh2_5agent_Agent(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ static PyObject *__pyx_tuple_; static PyObject *__pyx_tuple__2; @@ -2465,8 +2468,8 @@ static PyObject *__pyx_f_4ssh2_5agent_PyAgent(LIBSSH2_AGENT *__pyx_v_agent, stru * cdef class Agent: * * def __cinit__(self, Session session): # <<<<<<<<<<<<<< - * self._agent = NULL - * self._session = session + * cdef c_ssh2.LIBSSH2_AGENT *_agent = agent_init(session._session) + * self._agent = _agent */ /* Python wrapper */ @@ -2528,22 +2531,37 @@ static int __pyx_pw_4ssh2_5agent_5Agent_1__cinit__(PyObject *__pyx_v_self, PyObj } static int __pyx_pf_4ssh2_5agent_5Agent___cinit__(struct __pyx_obj_4ssh2_5agent_Agent *__pyx_v_self, struct __pyx_obj_4ssh2_7session_Session *__pyx_v_session) { + LIBSSH2_AGENT *__pyx_v__agent; int __pyx_r; __Pyx_RefNannyDeclarations + LIBSSH2_AGENT *__pyx_t_1; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__cinit__", 0); /* "ssh2/agent.pyx":102 * * def __cinit__(self, Session session): - * self._agent = NULL # <<<<<<<<<<<<<< + * cdef c_ssh2.LIBSSH2_AGENT *_agent = agent_init(session._session) # <<<<<<<<<<<<<< + * self._agent = _agent * self._session = session - * */ - __pyx_v_self->_agent = NULL; + __pyx_t_1 = __pyx_f_4ssh2_5agent_agent_init(__pyx_v_session->_session); if (unlikely(__pyx_t_1 == ((LIBSSH2_AGENT *)NULL))) __PYX_ERR(1, 102, __pyx_L1_error) + __pyx_v__agent = __pyx_t_1; /* "ssh2/agent.pyx":103 * def __cinit__(self, Session session): - * self._agent = NULL + * cdef c_ssh2.LIBSSH2_AGENT *_agent = agent_init(session._session) + * self._agent = _agent # <<<<<<<<<<<<<< + * self._session = session + * + */ + __pyx_v_self->_agent = __pyx_v__agent; + + /* "ssh2/agent.pyx":104 + * cdef c_ssh2.LIBSSH2_AGENT *_agent = agent_init(session._session) + * self._agent = _agent * self._session = session # <<<<<<<<<<<<<< * * def __dealloc__(self): @@ -2558,17 +2576,22 @@ static int __pyx_pf_4ssh2_5agent_5Agent___cinit__(struct __pyx_obj_4ssh2_5agent_ * cdef class Agent: * * def __cinit__(self, Session session): # <<<<<<<<<<<<<< - * self._agent = NULL - * self._session = session + * cdef c_ssh2.LIBSSH2_AGENT *_agent = agent_init(session._session) + * self._agent = _agent */ /* function exit code */ __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_AddTraceback("ssh2.agent.Agent.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "ssh2/agent.pyx":105 +/* "ssh2/agent.pyx":106 * self._session = session * * def __dealloc__(self): # <<<<<<<<<<<<<< @@ -2591,7 +2614,7 @@ static void __pyx_pf_4ssh2_5agent_5Agent_2__dealloc__(struct __pyx_obj_4ssh2_5ag __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__dealloc__", 0); - /* "ssh2/agent.pyx":106 + /* "ssh2/agent.pyx":107 * * def __dealloc__(self): * with nogil: # <<<<<<<<<<<<<< @@ -2606,7 +2629,7 @@ static void __pyx_pf_4ssh2_5agent_5Agent_2__dealloc__(struct __pyx_obj_4ssh2_5ag #endif /*try:*/ { - /* "ssh2/agent.pyx":107 + /* "ssh2/agent.pyx":108 * def __dealloc__(self): * with nogil: * clear_agent(self._agent) # <<<<<<<<<<<<<< @@ -2616,7 +2639,7 @@ static void __pyx_pf_4ssh2_5agent_5Agent_2__dealloc__(struct __pyx_obj_4ssh2_5ag __pyx_f_4ssh2_5agent_clear_agent(__pyx_v_self->_agent); } - /* "ssh2/agent.pyx":106 + /* "ssh2/agent.pyx":107 * * def __dealloc__(self): * with nogil: # <<<<<<<<<<<<<< @@ -2635,7 +2658,7 @@ static void __pyx_pf_4ssh2_5agent_5Agent_2__dealloc__(struct __pyx_obj_4ssh2_5ag } } - /* "ssh2/agent.pyx":105 + /* "ssh2/agent.pyx":106 * self._session = session * * def __dealloc__(self): # <<<<<<<<<<<<<< @@ -2647,7 +2670,7 @@ static void __pyx_pf_4ssh2_5agent_5Agent_2__dealloc__(struct __pyx_obj_4ssh2_5ag __Pyx_RefNannyFinishContext(); } -/* "ssh2/agent.pyx":109 +/* "ssh2/agent.pyx":110 * clear_agent(self._agent) * * def list_identities(self): # <<<<<<<<<<<<<< @@ -2681,7 +2704,7 @@ static PyObject *__pyx_pf_4ssh2_5agent_5Agent_4list_identities(CYTHON_UNUSED str return __pyx_r; } -/* "ssh2/agent.pyx":115 +/* "ssh2/agent.pyx":116 * pass * * def get_identities(self): # <<<<<<<<<<<<<< @@ -2719,19 +2742,19 @@ static PyObject *__pyx_pf_4ssh2_5agent_5Agent_6get_identities(struct __pyx_obj_4 int __pyx_clineno = 0; __Pyx_RefNannySetupContext("get_identities", 0); - /* "ssh2/agent.pyx":120 + /* "ssh2/agent.pyx":121 * :rtype: list(:py:class:`ssh2.pkey.PublicKey`)""" * cdef int rc * cdef list identities = [] # <<<<<<<<<<<<<< * cdef c_ssh2.libssh2_agent_publickey *identity = NULL * cdef c_ssh2.libssh2_agent_publickey *prev = NULL */ - __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 120, __pyx_L1_error) + __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 121, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_identities = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/agent.pyx":121 + /* "ssh2/agent.pyx":122 * cdef int rc * cdef list identities = [] * cdef c_ssh2.libssh2_agent_publickey *identity = NULL # <<<<<<<<<<<<<< @@ -2740,7 +2763,7 @@ static PyObject *__pyx_pf_4ssh2_5agent_5Agent_6get_identities(struct __pyx_obj_4 */ __pyx_v_identity = NULL; - /* "ssh2/agent.pyx":122 + /* "ssh2/agent.pyx":123 * cdef list identities = [] * cdef c_ssh2.libssh2_agent_publickey *identity = NULL * cdef c_ssh2.libssh2_agent_publickey *prev = NULL # <<<<<<<<<<<<<< @@ -2749,7 +2772,7 @@ static PyObject *__pyx_pf_4ssh2_5agent_5Agent_6get_identities(struct __pyx_obj_4 */ __pyx_v_prev = NULL; - /* "ssh2/agent.pyx":123 + /* "ssh2/agent.pyx":124 * cdef c_ssh2.libssh2_agent_publickey *identity = NULL * cdef c_ssh2.libssh2_agent_publickey *prev = NULL * if c_ssh2.libssh2_agent_list_identities(self._agent) != 0: # <<<<<<<<<<<<<< @@ -2759,14 +2782,14 @@ static PyObject *__pyx_pf_4ssh2_5agent_5Agent_6get_identities(struct __pyx_obj_4 __pyx_t_2 = ((libssh2_agent_list_identities(__pyx_v_self->_agent) != 0) != 0); if (unlikely(__pyx_t_2)) { - /* "ssh2/agent.pyx":124 + /* "ssh2/agent.pyx":125 * cdef c_ssh2.libssh2_agent_publickey *prev = NULL * if c_ssh2.libssh2_agent_list_identities(self._agent) != 0: * raise AgentListIdentitiesError( # <<<<<<<<<<<<<< * "Failure requesting identities from agent." * "Agent must be connected first") */ - __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_AgentListIdentitiesError); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 124, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_AgentListIdentitiesError); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 125, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { @@ -2780,14 +2803,14 @@ static PyObject *__pyx_pf_4ssh2_5agent_5Agent_6get_identities(struct __pyx_obj_4 } __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_kp_s_Failure_requesting_identities_fr_2) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_kp_s_Failure_requesting_identities_fr_2); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 124, __pyx_L1_error) + if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 125, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __PYX_ERR(1, 124, __pyx_L1_error) + __PYX_ERR(1, 125, __pyx_L1_error) - /* "ssh2/agent.pyx":123 + /* "ssh2/agent.pyx":124 * cdef c_ssh2.libssh2_agent_publickey *identity = NULL * cdef c_ssh2.libssh2_agent_publickey *prev = NULL * if c_ssh2.libssh2_agent_list_identities(self._agent) != 0: # <<<<<<<<<<<<<< @@ -2796,7 +2819,7 @@ static PyObject *__pyx_pf_4ssh2_5agent_5Agent_6get_identities(struct __pyx_obj_4 */ } - /* "ssh2/agent.pyx":127 + /* "ssh2/agent.pyx":128 * "Failure requesting identities from agent." * "Agent must be connected first") * while c_ssh2.libssh2_agent_get_identity( # <<<<<<<<<<<<<< @@ -2805,7 +2828,7 @@ static PyObject *__pyx_pf_4ssh2_5agent_5Agent_6get_identities(struct __pyx_obj_4 */ while (1) { - /* "ssh2/agent.pyx":128 + /* "ssh2/agent.pyx":129 * "Agent must be connected first") * while c_ssh2.libssh2_agent_get_identity( * self._agent, &identity, prev) == 0: # <<<<<<<<<<<<<< @@ -2815,19 +2838,19 @@ static PyObject *__pyx_pf_4ssh2_5agent_5Agent_6get_identities(struct __pyx_obj_4 __pyx_t_2 = ((libssh2_agent_get_identity(__pyx_v_self->_agent, (&__pyx_v_identity), __pyx_v_prev) == 0) != 0); if (!__pyx_t_2) break; - /* "ssh2/agent.pyx":129 + /* "ssh2/agent.pyx":130 * while c_ssh2.libssh2_agent_get_identity( * self._agent, &identity, prev) == 0: * identities.append(PyPublicKey(identity)) # <<<<<<<<<<<<<< * prev = identity * return identities */ - __pyx_t_1 = __pyx_f_4ssh2_4pkey_PyPublicKey(__pyx_v_identity); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 129, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_4pkey_PyPublicKey(__pyx_v_identity); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 130, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_5 = __Pyx_PyList_Append(__pyx_v_identities, __pyx_t_1); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(1, 129, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyList_Append(__pyx_v_identities, __pyx_t_1); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(1, 130, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/agent.pyx":130 + /* "ssh2/agent.pyx":131 * self._agent, &identity, prev) == 0: * identities.append(PyPublicKey(identity)) * prev = identity # <<<<<<<<<<<<<< @@ -2837,7 +2860,7 @@ static PyObject *__pyx_pf_4ssh2_5agent_5Agent_6get_identities(struct __pyx_obj_4 __pyx_v_prev = __pyx_v_identity; } - /* "ssh2/agent.pyx":131 + /* "ssh2/agent.pyx":132 * identities.append(PyPublicKey(identity)) * prev = identity * return identities # <<<<<<<<<<<<<< @@ -2849,7 +2872,7 @@ static PyObject *__pyx_pf_4ssh2_5agent_5Agent_6get_identities(struct __pyx_obj_4 __pyx_r = __pyx_v_identities; goto __pyx_L0; - /* "ssh2/agent.pyx":115 + /* "ssh2/agent.pyx":116 * pass * * def get_identities(self): # <<<<<<<<<<<<<< @@ -2871,7 +2894,7 @@ static PyObject *__pyx_pf_4ssh2_5agent_5Agent_6get_identities(struct __pyx_obj_4 return __pyx_r; } -/* "ssh2/agent.pyx":133 +/* "ssh2/agent.pyx":134 * return identities * * def userauth(self, username not None, # <<<<<<<<<<<<<< @@ -2914,11 +2937,11 @@ static PyObject *__pyx_pw_4ssh2_5agent_5Agent_9userauth(PyObject *__pyx_v_self, case 1: if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pkey)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("userauth", 1, 2, 2, 1); __PYX_ERR(1, 133, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("userauth", 1, 2, 2, 1); __PYX_ERR(1, 134, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "userauth") < 0)) __PYX_ERR(1, 133, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "userauth") < 0)) __PYX_ERR(1, 134, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; @@ -2931,16 +2954,16 @@ static PyObject *__pyx_pw_4ssh2_5agent_5Agent_9userauth(PyObject *__pyx_v_self, } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("userauth", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 133, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("userauth", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 134, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("ssh2.agent.Agent.userauth", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(((PyObject *)__pyx_v_username) == Py_None)) { - PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "username"); __PYX_ERR(1, 133, __pyx_L1_error) + PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "username"); __PYX_ERR(1, 134, __pyx_L1_error) } - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_pkey), __pyx_ptype_4ssh2_4pkey_PublicKey, 1, "pkey", 0))) __PYX_ERR(1, 134, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_pkey), __pyx_ptype_4ssh2_4pkey_PublicKey, 1, "pkey", 0))) __PYX_ERR(1, 135, __pyx_L1_error) __pyx_r = __pyx_pf_4ssh2_5agent_5Agent_8userauth(((struct __pyx_obj_4ssh2_5agent_Agent *)__pyx_v_self), __pyx_v_username, __pyx_v_pkey); /* function exit code */ @@ -2970,19 +2993,19 @@ static PyObject *__pyx_pf_4ssh2_5agent_5Agent_8userauth(struct __pyx_obj_4ssh2_5 int __pyx_clineno = 0; __Pyx_RefNannySetupContext("userauth", 0); - /* "ssh2/agent.pyx":147 + /* "ssh2/agent.pyx":148 * :rtype: int""" * cdef int rc * cdef bytes b_username = to_bytes(username) # <<<<<<<<<<<<<< * cdef char *_username = b_username * with nogil: */ - __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_username); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 147, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_username); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 148, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_b_username = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/agent.pyx":148 + /* "ssh2/agent.pyx":149 * cdef int rc * cdef bytes b_username = to_bytes(username) * cdef char *_username = b_username # <<<<<<<<<<<<<< @@ -2991,12 +3014,12 @@ static PyObject *__pyx_pf_4ssh2_5agent_5Agent_8userauth(struct __pyx_obj_4ssh2_5 */ if (unlikely(__pyx_v_b_username == Py_None)) { PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); - __PYX_ERR(1, 148, __pyx_L1_error) + __PYX_ERR(1, 149, __pyx_L1_error) } - __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_username); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(1, 148, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_username); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(1, 149, __pyx_L1_error) __pyx_v__username = __pyx_t_2; - /* "ssh2/agent.pyx":149 + /* "ssh2/agent.pyx":150 * cdef bytes b_username = to_bytes(username) * cdef char *_username = b_username * with nogil: # <<<<<<<<<<<<<< @@ -3011,7 +3034,7 @@ static PyObject *__pyx_pf_4ssh2_5agent_5Agent_8userauth(struct __pyx_obj_4ssh2_5 #endif /*try:*/ { - /* "ssh2/agent.pyx":150 + /* "ssh2/agent.pyx":151 * cdef char *_username = b_username * with nogil: * rc = c_ssh2.libssh2_agent_userauth( # <<<<<<<<<<<<<< @@ -3020,7 +3043,7 @@ static PyObject *__pyx_pf_4ssh2_5agent_5Agent_8userauth(struct __pyx_obj_4ssh2_5 */ __pyx_v_rc = libssh2_agent_userauth(__pyx_v_self->_agent, __pyx_v__username, __pyx_v_pkey->_pkey); - /* "ssh2/agent.pyx":152 + /* "ssh2/agent.pyx":153 * rc = c_ssh2.libssh2_agent_userauth( * self._agent, _username, pkey._pkey) * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: # <<<<<<<<<<<<<< @@ -3038,7 +3061,7 @@ static PyObject *__pyx_pf_4ssh2_5agent_5Agent_8userauth(struct __pyx_obj_4ssh2_5 } if (__pyx_t_3) { - /* "ssh2/agent.pyx":153 + /* "ssh2/agent.pyx":154 * self._agent, _username, pkey._pkey) * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: * with gil: # <<<<<<<<<<<<<< @@ -3051,17 +3074,17 @@ static PyObject *__pyx_pf_4ssh2_5agent_5Agent_8userauth(struct __pyx_obj_4ssh2_5 #endif /*try:*/ { - /* "ssh2/agent.pyx":154 + /* "ssh2/agent.pyx":155 * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: * with gil: * raise AgentAuthenticationError( # <<<<<<<<<<<<<< * "Error authenticating user %s with provided public key", * username) */ - __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_AgentAuthenticationError); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 154, __pyx_L8_error) + __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_AgentAuthenticationError); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 155, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_4); - /* "ssh2/agent.pyx":156 + /* "ssh2/agent.pyx":157 * raise AgentAuthenticationError( * "Error authenticating user %s with provided public key", * username) # <<<<<<<<<<<<<< @@ -3083,7 +3106,7 @@ static PyObject *__pyx_pf_4ssh2_5agent_5Agent_8userauth(struct __pyx_obj_4ssh2_5 #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_kp_s_Error_authenticating_user_s_with, __pyx_v_username}; - __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 154, __pyx_L8_error) + __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 155, __pyx_L8_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_1); } else @@ -3091,13 +3114,13 @@ static PyObject *__pyx_pf_4ssh2_5agent_5Agent_8userauth(struct __pyx_obj_4ssh2_5 #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_kp_s_Error_authenticating_user_s_with, __pyx_v_username}; - __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 154, __pyx_L8_error) + __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 155, __pyx_L8_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_1); } else #endif { - __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 154, __pyx_L8_error) + __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 155, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_7); if (__pyx_t_5) { __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL; @@ -3108,17 +3131,17 @@ static PyObject *__pyx_pf_4ssh2_5agent_5Agent_8userauth(struct __pyx_obj_4ssh2_5 __Pyx_INCREF(__pyx_v_username); __Pyx_GIVEREF(__pyx_v_username); PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_v_username); - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 154, __pyx_L8_error) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 155, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __PYX_ERR(1, 154, __pyx_L8_error) + __PYX_ERR(1, 155, __pyx_L8_error) } - /* "ssh2/agent.pyx":153 + /* "ssh2/agent.pyx":154 * self._agent, _username, pkey._pkey) * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: * with gil: # <<<<<<<<<<<<<< @@ -3135,7 +3158,7 @@ static PyObject *__pyx_pf_4ssh2_5agent_5Agent_8userauth(struct __pyx_obj_4ssh2_5 } } - /* "ssh2/agent.pyx":152 + /* "ssh2/agent.pyx":153 * rc = c_ssh2.libssh2_agent_userauth( * self._agent, _username, pkey._pkey) * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: # <<<<<<<<<<<<<< @@ -3145,7 +3168,7 @@ static PyObject *__pyx_pf_4ssh2_5agent_5Agent_8userauth(struct __pyx_obj_4ssh2_5 } } - /* "ssh2/agent.pyx":149 + /* "ssh2/agent.pyx":150 * cdef bytes b_username = to_bytes(username) * cdef char *_username = b_username * with nogil: # <<<<<<<<<<<<<< @@ -3171,7 +3194,7 @@ static PyObject *__pyx_pf_4ssh2_5agent_5Agent_8userauth(struct __pyx_obj_4ssh2_5 } } - /* "ssh2/agent.pyx":157 + /* "ssh2/agent.pyx":158 * "Error authenticating user %s with provided public key", * username) * return rc # <<<<<<<<<<<<<< @@ -3179,13 +3202,13 @@ static PyObject *__pyx_pf_4ssh2_5agent_5Agent_8userauth(struct __pyx_obj_4ssh2_5 * def disconnect(self): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 157, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 158, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/agent.pyx":133 + /* "ssh2/agent.pyx":134 * return identities * * def userauth(self, username not None, # <<<<<<<<<<<<<< @@ -3208,7 +3231,7 @@ static PyObject *__pyx_pf_4ssh2_5agent_5Agent_8userauth(struct __pyx_obj_4ssh2_5 return __pyx_r; } -/* "ssh2/agent.pyx":159 +/* "ssh2/agent.pyx":160 * return rc * * def disconnect(self): # <<<<<<<<<<<<<< @@ -3240,7 +3263,7 @@ static PyObject *__pyx_pf_4ssh2_5agent_5Agent_10disconnect(struct __pyx_obj_4ssh int __pyx_clineno = 0; __Pyx_RefNannySetupContext("disconnect", 0); - /* "ssh2/agent.pyx":164 + /* "ssh2/agent.pyx":165 * :rtype: int""" * cdef int rc * with nogil: # <<<<<<<<<<<<<< @@ -3255,7 +3278,7 @@ static PyObject *__pyx_pf_4ssh2_5agent_5Agent_10disconnect(struct __pyx_obj_4ssh #endif /*try:*/ { - /* "ssh2/agent.pyx":165 + /* "ssh2/agent.pyx":166 * cdef int rc * with nogil: * rc = c_ssh2.libssh2_agent_disconnect(self._agent) # <<<<<<<<<<<<<< @@ -3265,7 +3288,7 @@ static PyObject *__pyx_pf_4ssh2_5agent_5Agent_10disconnect(struct __pyx_obj_4ssh __pyx_v_rc = libssh2_agent_disconnect(__pyx_v_self->_agent); } - /* "ssh2/agent.pyx":164 + /* "ssh2/agent.pyx":165 * :rtype: int""" * cdef int rc * with nogil: # <<<<<<<<<<<<<< @@ -3284,7 +3307,7 @@ static PyObject *__pyx_pf_4ssh2_5agent_5Agent_10disconnect(struct __pyx_obj_4ssh } } - /* "ssh2/agent.pyx":166 + /* "ssh2/agent.pyx":167 * with nogil: * rc = c_ssh2.libssh2_agent_disconnect(self._agent) * return rc # <<<<<<<<<<<<<< @@ -3292,13 +3315,13 @@ static PyObject *__pyx_pf_4ssh2_5agent_5Agent_10disconnect(struct __pyx_obj_4ssh * def connect(self): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 166, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 167, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/agent.pyx":159 + /* "ssh2/agent.pyx":160 * return rc * * def disconnect(self): # <<<<<<<<<<<<<< @@ -3317,7 +3340,7 @@ static PyObject *__pyx_pf_4ssh2_5agent_5Agent_10disconnect(struct __pyx_obj_4ssh return __pyx_r; } -/* "ssh2/agent.pyx":168 +/* "ssh2/agent.pyx":169 * return rc * * def connect(self): # <<<<<<<<<<<<<< @@ -3352,7 +3375,7 @@ static PyObject *__pyx_pf_4ssh2_5agent_5Agent_12connect(struct __pyx_obj_4ssh2_5 int __pyx_clineno = 0; __Pyx_RefNannySetupContext("connect", 0); - /* "ssh2/agent.pyx":176 + /* "ssh2/agent.pyx":177 * :rtype: int""" * cdef int rc * rc = c_ssh2.libssh2_agent_connect(self._agent) # <<<<<<<<<<<<<< @@ -3361,7 +3384,7 @@ static PyObject *__pyx_pf_4ssh2_5agent_5Agent_12connect(struct __pyx_obj_4ssh2_5 */ __pyx_v_rc = libssh2_agent_connect(__pyx_v_self->_agent); - /* "ssh2/agent.pyx":177 + /* "ssh2/agent.pyx":178 * cdef int rc * rc = c_ssh2.libssh2_agent_connect(self._agent) * if rc != 0: # <<<<<<<<<<<<<< @@ -3371,13 +3394,14 @@ static PyObject *__pyx_pf_4ssh2_5agent_5Agent_12connect(struct __pyx_obj_4ssh2_5 __pyx_t_1 = ((__pyx_v_rc != 0) != 0); if (unlikely(__pyx_t_1)) { - /* "ssh2/agent.pyx":178 + /* "ssh2/agent.pyx":179 * rc = c_ssh2.libssh2_agent_connect(self._agent) * if rc != 0: * raise AgentConnectionError("Unable to connect to agent") # <<<<<<<<<<<<<< * return rc + * */ - __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_AgentConnectionError); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 178, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_AgentConnectionError); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 179, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { @@ -3391,14 +3415,14 @@ static PyObject *__pyx_pf_4ssh2_5agent_5Agent_12connect(struct __pyx_obj_4ssh2_5 } __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_kp_s_Unable_to_connect_to_agent) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_kp_s_Unable_to_connect_to_agent); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 178, __pyx_L1_error) + if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 179, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __PYX_ERR(1, 178, __pyx_L1_error) + __PYX_ERR(1, 179, __pyx_L1_error) - /* "ssh2/agent.pyx":177 + /* "ssh2/agent.pyx":178 * cdef int rc * rc = c_ssh2.libssh2_agent_connect(self._agent) * if rc != 0: # <<<<<<<<<<<<<< @@ -3407,19 +3431,21 @@ static PyObject *__pyx_pf_4ssh2_5agent_5Agent_12connect(struct __pyx_obj_4ssh2_5 */ } - /* "ssh2/agent.pyx":179 + /* "ssh2/agent.pyx":180 * if rc != 0: * raise AgentConnectionError("Unable to connect to agent") * return rc # <<<<<<<<<<<<<< + * + * def get_identity_path(self): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 179, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 180, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; - /* "ssh2/agent.pyx":168 + /* "ssh2/agent.pyx":169 * return rc * * def connect(self): # <<<<<<<<<<<<<< @@ -3440,6 +3466,302 @@ static PyObject *__pyx_pf_4ssh2_5agent_5Agent_12connect(struct __pyx_obj_4ssh2_5 return __pyx_r; } +/* "ssh2/agent.pyx":182 + * return rc + * + * def get_identity_path(self): # <<<<<<<<<<<<<< + * cdef bytes _path + * cdef const char* c_path = NULL + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_4ssh2_5agent_5Agent_15get_identity_path(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static char __pyx_doc_4ssh2_5agent_5Agent_14get_identity_path[] = "Agent.get_identity_path(self)"; +static PyObject *__pyx_pw_4ssh2_5agent_5Agent_15get_identity_path(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("get_identity_path (wrapper)", 0); + __pyx_r = __pyx_pf_4ssh2_5agent_5Agent_14get_identity_path(((struct __pyx_obj_4ssh2_5agent_Agent *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_4ssh2_5agent_5Agent_14get_identity_path(struct __pyx_obj_4ssh2_5agent_Agent *__pyx_v_self) { + PyObject *__pyx_v__path = 0; + char const *__pyx_v_c_path; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("get_identity_path", 0); + + /* "ssh2/agent.pyx":184 + * def get_identity_path(self): + * cdef bytes _path + * cdef const char* c_path = NULL # <<<<<<<<<<<<<< + * with nogil: + * c_path = c_ssh2.libssh2_agent_get_identity_path(self._agent) + */ + __pyx_v_c_path = NULL; + + /* "ssh2/agent.pyx":185 + * cdef bytes _path + * cdef const char* c_path = NULL + * with nogil: # <<<<<<<<<<<<<< + * c_path = c_ssh2.libssh2_agent_get_identity_path(self._agent) + * if c_path is NULL: + */ + { + #ifdef WITH_THREAD + PyThreadState *_save; + Py_UNBLOCK_THREADS + __Pyx_FastGIL_Remember(); + #endif + /*try:*/ { + + /* "ssh2/agent.pyx":186 + * cdef const char* c_path = NULL + * with nogil: + * c_path = c_ssh2.libssh2_agent_get_identity_path(self._agent) # <<<<<<<<<<<<<< + * if c_path is NULL: + * return + */ + __pyx_v_c_path = libssh2_agent_get_identity_path(__pyx_v_self->_agent); + } + + /* "ssh2/agent.pyx":185 + * cdef bytes _path + * cdef const char* c_path = NULL + * with nogil: # <<<<<<<<<<<<<< + * c_path = c_ssh2.libssh2_agent_get_identity_path(self._agent) + * if c_path is NULL: + */ + /*finally:*/ { + /*normal exit:*/{ + #ifdef WITH_THREAD + __Pyx_FastGIL_Forget(); + Py_BLOCK_THREADS + #endif + goto __pyx_L5; + } + __pyx_L5:; + } + } + + /* "ssh2/agent.pyx":187 + * with nogil: + * c_path = c_ssh2.libssh2_agent_get_identity_path(self._agent) + * if c_path is NULL: # <<<<<<<<<<<<<< + * return + * _path = c_path + */ + __pyx_t_1 = ((__pyx_v_c_path == NULL) != 0); + if (__pyx_t_1) { + + /* "ssh2/agent.pyx":188 + * c_path = c_ssh2.libssh2_agent_get_identity_path(self._agent) + * if c_path is NULL: + * return # <<<<<<<<<<<<<< + * _path = c_path + * return _path + */ + __Pyx_XDECREF(__pyx_r); + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + + /* "ssh2/agent.pyx":187 + * with nogil: + * c_path = c_ssh2.libssh2_agent_get_identity_path(self._agent) + * if c_path is NULL: # <<<<<<<<<<<<<< + * return + * _path = c_path + */ + } + + /* "ssh2/agent.pyx":189 + * if c_path is NULL: + * return + * _path = c_path # <<<<<<<<<<<<<< + * return _path + * + */ + __pyx_t_2 = __Pyx_PyBytes_FromString(__pyx_v_c_path); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 189, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_v__path = ((PyObject*)__pyx_t_2); + __pyx_t_2 = 0; + + /* "ssh2/agent.pyx":190 + * return + * _path = c_path + * return _path # <<<<<<<<<<<<<< + * + * def set_identity_path(self, path not None): + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v__path); + __pyx_r = __pyx_v__path; + goto __pyx_L0; + + /* "ssh2/agent.pyx":182 + * return rc + * + * def get_identity_path(self): # <<<<<<<<<<<<<< + * cdef bytes _path + * cdef const char* c_path = NULL + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("ssh2.agent.Agent.get_identity_path", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v__path); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "ssh2/agent.pyx":192 + * return _path + * + * def set_identity_path(self, path not None): # <<<<<<<<<<<<<< + * cdef bytes b_path = to_bytes(path) + * cdef const char *c_path = b_path + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_4ssh2_5agent_5Agent_17set_identity_path(PyObject *__pyx_v_self, PyObject *__pyx_v_path); /*proto*/ +static char __pyx_doc_4ssh2_5agent_5Agent_16set_identity_path[] = "Agent.set_identity_path(self, path)"; +static PyObject *__pyx_pw_4ssh2_5agent_5Agent_17set_identity_path(PyObject *__pyx_v_self, PyObject *__pyx_v_path) { + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("set_identity_path (wrapper)", 0); + if (unlikely(((PyObject *)__pyx_v_path) == Py_None)) { + PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "path"); __PYX_ERR(1, 192, __pyx_L1_error) + } + __pyx_r = __pyx_pf_4ssh2_5agent_5Agent_16set_identity_path(((struct __pyx_obj_4ssh2_5agent_Agent *)__pyx_v_self), ((PyObject *)__pyx_v_path)); + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_4ssh2_5agent_5Agent_16set_identity_path(struct __pyx_obj_4ssh2_5agent_Agent *__pyx_v_self, PyObject *__pyx_v_path) { + PyObject *__pyx_v_b_path = 0; + char const *__pyx_v_c_path; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + char const *__pyx_t_2; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("set_identity_path", 0); + + /* "ssh2/agent.pyx":193 + * + * def set_identity_path(self, path not None): + * cdef bytes b_path = to_bytes(path) # <<<<<<<<<<<<<< + * cdef const char *c_path = b_path + * with nogil: + */ + __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_path); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 193, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_v_b_path = ((PyObject*)__pyx_t_1); + __pyx_t_1 = 0; + + /* "ssh2/agent.pyx":194 + * def set_identity_path(self, path not None): + * cdef bytes b_path = to_bytes(path) + * cdef const char *c_path = b_path # <<<<<<<<<<<<<< + * with nogil: + * c_ssh2.libssh2_agent_set_identity_path( + */ + if (unlikely(__pyx_v_b_path == Py_None)) { + PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); + __PYX_ERR(1, 194, __pyx_L1_error) + } + __pyx_t_2 = __Pyx_PyBytes_AsString(__pyx_v_b_path); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(1, 194, __pyx_L1_error) + __pyx_v_c_path = __pyx_t_2; + + /* "ssh2/agent.pyx":195 + * cdef bytes b_path = to_bytes(path) + * cdef const char *c_path = b_path + * with nogil: # <<<<<<<<<<<<<< + * c_ssh2.libssh2_agent_set_identity_path( + * self._agent, c_path) + */ + { + #ifdef WITH_THREAD + PyThreadState *_save; + Py_UNBLOCK_THREADS + __Pyx_FastGIL_Remember(); + #endif + /*try:*/ { + + /* "ssh2/agent.pyx":196 + * cdef const char *c_path = b_path + * with nogil: + * c_ssh2.libssh2_agent_set_identity_path( # <<<<<<<<<<<<<< + * self._agent, c_path) + */ + libssh2_agent_set_identity_path(__pyx_v_self->_agent, __pyx_v_c_path); + } + + /* "ssh2/agent.pyx":195 + * cdef bytes b_path = to_bytes(path) + * cdef const char *c_path = b_path + * with nogil: # <<<<<<<<<<<<<< + * c_ssh2.libssh2_agent_set_identity_path( + * self._agent, c_path) + */ + /*finally:*/ { + /*normal exit:*/{ + #ifdef WITH_THREAD + __Pyx_FastGIL_Forget(); + Py_BLOCK_THREADS + #endif + goto __pyx_L5; + } + __pyx_L5:; + } + } + + /* "ssh2/agent.pyx":192 + * return _path + * + * def set_identity_path(self, path not None): # <<<<<<<<<<<<<< + * cdef bytes b_path = to_bytes(path) + * cdef const char *c_path = b_path + */ + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("ssh2.agent.Agent.set_identity_path", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_b_path); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + /* "(tree fragment)":1 * def __reduce_cython__(self): # <<<<<<<<<<<<<< * raise TypeError("no default __reduce__ due to non-trivial __cinit__") @@ -3447,20 +3769,20 @@ static PyObject *__pyx_pf_4ssh2_5agent_5Agent_12connect(struct __pyx_obj_4ssh2_5 */ /* Python wrapper */ -static PyObject *__pyx_pw_4ssh2_5agent_5Agent_15__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static char __pyx_doc_4ssh2_5agent_5Agent_14__reduce_cython__[] = "Agent.__reduce_cython__(self)"; -static PyObject *__pyx_pw_4ssh2_5agent_5Agent_15__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { +static PyObject *__pyx_pw_4ssh2_5agent_5Agent_19__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static char __pyx_doc_4ssh2_5agent_5Agent_18__reduce_cython__[] = "Agent.__reduce_cython__(self)"; +static PyObject *__pyx_pw_4ssh2_5agent_5Agent_19__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0); - __pyx_r = __pyx_pf_4ssh2_5agent_5Agent_14__reduce_cython__(((struct __pyx_obj_4ssh2_5agent_Agent *)__pyx_v_self)); + __pyx_r = __pyx_pf_4ssh2_5agent_5Agent_18__reduce_cython__(((struct __pyx_obj_4ssh2_5agent_Agent *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_pf_4ssh2_5agent_5Agent_14__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_4ssh2_5agent_Agent *__pyx_v_self) { +static PyObject *__pyx_pf_4ssh2_5agent_5Agent_18__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_4ssh2_5agent_Agent *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; @@ -3505,20 +3827,20 @@ static PyObject *__pyx_pf_4ssh2_5agent_5Agent_14__reduce_cython__(CYTHON_UNUSED */ /* Python wrapper */ -static PyObject *__pyx_pw_4ssh2_5agent_5Agent_17__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/ -static char __pyx_doc_4ssh2_5agent_5Agent_16__setstate_cython__[] = "Agent.__setstate_cython__(self, __pyx_state)"; -static PyObject *__pyx_pw_4ssh2_5agent_5Agent_17__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) { +static PyObject *__pyx_pw_4ssh2_5agent_5Agent_21__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/ +static char __pyx_doc_4ssh2_5agent_5Agent_20__setstate_cython__[] = "Agent.__setstate_cython__(self, __pyx_state)"; +static PyObject *__pyx_pw_4ssh2_5agent_5Agent_21__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0); - __pyx_r = __pyx_pf_4ssh2_5agent_5Agent_16__setstate_cython__(((struct __pyx_obj_4ssh2_5agent_Agent *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state)); + __pyx_r = __pyx_pf_4ssh2_5agent_5Agent_20__setstate_cython__(((struct __pyx_obj_4ssh2_5agent_Agent *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_pf_4ssh2_5agent_5Agent_16__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_4ssh2_5agent_Agent *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) { +static PyObject *__pyx_pf_4ssh2_5agent_5Agent_20__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_4ssh2_5agent_Agent *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; @@ -3617,8 +3939,10 @@ static PyMethodDef __pyx_methods_4ssh2_5agent_Agent[] = { {"userauth", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4ssh2_5agent_5Agent_9userauth, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4ssh2_5agent_5Agent_8userauth}, {"disconnect", (PyCFunction)__pyx_pw_4ssh2_5agent_5Agent_11disconnect, METH_NOARGS, __pyx_doc_4ssh2_5agent_5Agent_10disconnect}, {"connect", (PyCFunction)__pyx_pw_4ssh2_5agent_5Agent_13connect, METH_NOARGS, __pyx_doc_4ssh2_5agent_5Agent_12connect}, - {"__reduce_cython__", (PyCFunction)__pyx_pw_4ssh2_5agent_5Agent_15__reduce_cython__, METH_NOARGS, __pyx_doc_4ssh2_5agent_5Agent_14__reduce_cython__}, - {"__setstate_cython__", (PyCFunction)__pyx_pw_4ssh2_5agent_5Agent_17__setstate_cython__, METH_O, __pyx_doc_4ssh2_5agent_5Agent_16__setstate_cython__}, + {"get_identity_path", (PyCFunction)__pyx_pw_4ssh2_5agent_5Agent_15get_identity_path, METH_NOARGS, __pyx_doc_4ssh2_5agent_5Agent_14get_identity_path}, + {"set_identity_path", (PyCFunction)__pyx_pw_4ssh2_5agent_5Agent_17set_identity_path, METH_O, __pyx_doc_4ssh2_5agent_5Agent_16set_identity_path}, + {"__reduce_cython__", (PyCFunction)__pyx_pw_4ssh2_5agent_5Agent_19__reduce_cython__, METH_NOARGS, __pyx_doc_4ssh2_5agent_5Agent_18__reduce_cython__}, + {"__setstate_cython__", (PyCFunction)__pyx_pw_4ssh2_5agent_5Agent_21__setstate_cython__, METH_O, __pyx_doc_4ssh2_5agent_5Agent_20__setstate_cython__}, {0, 0, 0, 0} }; diff --git a/ssh2/agent.pyx b/ssh2/agent.pyx index 166ec907..d8b55bfe 100644 --- a/ssh2/agent.pyx +++ b/ssh2/agent.pyx @@ -99,7 +99,8 @@ cdef object PyAgent(c_ssh2.LIBSSH2_AGENT *agent, Session session): cdef class Agent: def __cinit__(self, Session session): - self._agent = NULL + cdef c_ssh2.LIBSSH2_AGENT *_agent = agent_init(session._session) + self._agent = _agent self._session = session def __dealloc__(self): @@ -177,3 +178,20 @@ cdef class Agent: if rc != 0: raise AgentConnectionError("Unable to connect to agent") return rc + + def get_identity_path(self): + cdef bytes _path + cdef const char* c_path = NULL + with nogil: + c_path = c_ssh2.libssh2_agent_get_identity_path(self._agent) + if c_path is NULL: + return + _path = c_path + return _path + + def set_identity_path(self, path not None): + cdef bytes b_path = to_bytes(path) + cdef const char *c_path = b_path + with nogil: + c_ssh2.libssh2_agent_set_identity_path( + self._agent, c_path) diff --git a/ssh2/c_ssh2.pxd b/ssh2/c_ssh2.pxd index 8634d605..d62ec70a 100644 --- a/ssh2/c_ssh2.pxd +++ b/ssh2/c_ssh2.pxd @@ -450,4 +450,8 @@ cdef extern from "libssh2.h" nogil: int libssh2_trace_sethandler(LIBSSH2_SESSION *session, void* context, libssh2_trace_handler_func callback) - int libssh2_channel_request_auth_agent(LIBSSH2_CHANNEL *channel) + const char *libssh2_agent_get_identity_path(LIBSSH2_AGENT *agent) + void libssh2_agent_set_identity_path(LIBSSH2_AGENT *agent, + const char *path) + IF HAVE_AGENT_FWD: + int libssh2_channel_request_auth_agent(LIBSSH2_CHANNEL *channel) diff --git a/ssh2/channel.c b/ssh2/channel.c index 776ec433..14061968 100644 --- a/ssh2/channel.c +++ b/ssh2/channel.c @@ -1346,9 +1346,8 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_64poll_channel_read(struct __p static PyObject *__pyx_pf_4ssh2_7channel_7Channel_66handle_extended_data(struct __pyx_obj_4ssh2_7channel_Channel *__pyx_v_self, int __pyx_v_ignore_mode); /* proto */ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_68handle_extended_data2(struct __pyx_obj_4ssh2_7channel_Channel *__pyx_v_self, int __pyx_v_ignore_mode); /* proto */ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_70ignore_extended_data(struct __pyx_obj_4ssh2_7channel_Channel *__pyx_v_self, int __pyx_v_ignore_mode); /* proto */ -static PyObject *__pyx_pf_4ssh2_7channel_7Channel_72request_auth_agent(struct __pyx_obj_4ssh2_7channel_Channel *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_4ssh2_7channel_7Channel_74__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_4ssh2_7channel_Channel *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_4ssh2_7channel_7Channel_76__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_4ssh2_7channel_Channel *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */ +static PyObject *__pyx_pf_4ssh2_7channel_7Channel_72__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_4ssh2_7channel_Channel *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_4ssh2_7channel_7Channel_74__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_4ssh2_7channel_Channel *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */ static PyObject *__pyx_tp_new_4ssh2_7channel_Channel(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ static PyObject *__pyx_int_0; static PyObject *__pyx_tuple__2; @@ -7628,114 +7627,6 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_70ignore_extended_data(struct return __pyx_r; } -/* "ssh2/channel.pyx":558 - * self._channel, ignore_mode) - * - * def request_auth_agent(self): # <<<<<<<<<<<<<< - * """Request SSH agent authentication forwarding on channel.""" - * cdef int rc - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_4ssh2_7channel_7Channel_73request_auth_agent(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static char __pyx_doc_4ssh2_7channel_7Channel_72request_auth_agent[] = "Channel.request_auth_agent(self)\nRequest SSH agent authentication forwarding on channel."; -static PyObject *__pyx_pw_4ssh2_7channel_7Channel_73request_auth_agent(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("request_auth_agent (wrapper)", 0); - __pyx_r = __pyx_pf_4ssh2_7channel_7Channel_72request_auth_agent(((struct __pyx_obj_4ssh2_7channel_Channel *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_4ssh2_7channel_7Channel_72request_auth_agent(struct __pyx_obj_4ssh2_7channel_Channel *__pyx_v_self) { - int __pyx_v_rc; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - PyObject *__pyx_t_2 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("request_auth_agent", 0); - - /* "ssh2/channel.pyx":561 - * """Request SSH agent authentication forwarding on channel.""" - * cdef int rc - * with nogil: # <<<<<<<<<<<<<< - * rc = c_ssh2.libssh2_channel_request_auth_agent(self._channel) - * return handle_error_codes(rc) - */ - { - #ifdef WITH_THREAD - PyThreadState *_save; - Py_UNBLOCK_THREADS - __Pyx_FastGIL_Remember(); - #endif - /*try:*/ { - - /* "ssh2/channel.pyx":562 - * cdef int rc - * with nogil: - * rc = c_ssh2.libssh2_channel_request_auth_agent(self._channel) # <<<<<<<<<<<<<< - * return handle_error_codes(rc) - */ - __pyx_v_rc = libssh2_channel_request_auth_agent(__pyx_v_self->_channel); - } - - /* "ssh2/channel.pyx":561 - * """Request SSH agent authentication forwarding on channel.""" - * cdef int rc - * with nogil: # <<<<<<<<<<<<<< - * rc = c_ssh2.libssh2_channel_request_auth_agent(self._channel) - * return handle_error_codes(rc) - */ - /*finally:*/ { - /*normal exit:*/{ - #ifdef WITH_THREAD - __Pyx_FastGIL_Forget(); - Py_BLOCK_THREADS - #endif - goto __pyx_L5; - } - __pyx_L5:; - } - } - - /* "ssh2/channel.pyx":563 - * with nogil: - * rc = c_ssh2.libssh2_channel_request_auth_agent(self._channel) - * return handle_error_codes(rc) # <<<<<<<<<<<<<< - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __pyx_f_4ssh2_5utils_handle_error_codes(__pyx_v_rc, 0); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 563, __pyx_L1_error) - __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 563, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_r = __pyx_t_2; - __pyx_t_2 = 0; - goto __pyx_L0; - - /* "ssh2/channel.pyx":558 - * self._channel, ignore_mode) - * - * def request_auth_agent(self): # <<<<<<<<<<<<<< - * """Request SSH agent authentication forwarding on channel.""" - * cdef int rc - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_2); - __Pyx_AddTraceback("ssh2.channel.Channel.request_auth_agent", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - /* "(tree fragment)":1 * def __reduce_cython__(self): # <<<<<<<<<<<<<< * raise TypeError("no default __reduce__ due to non-trivial __cinit__") @@ -7743,20 +7634,20 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_72request_auth_agent(struct __ */ /* Python wrapper */ -static PyObject *__pyx_pw_4ssh2_7channel_7Channel_75__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static char __pyx_doc_4ssh2_7channel_7Channel_74__reduce_cython__[] = "Channel.__reduce_cython__(self)"; -static PyObject *__pyx_pw_4ssh2_7channel_7Channel_75__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { +static PyObject *__pyx_pw_4ssh2_7channel_7Channel_73__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static char __pyx_doc_4ssh2_7channel_7Channel_72__reduce_cython__[] = "Channel.__reduce_cython__(self)"; +static PyObject *__pyx_pw_4ssh2_7channel_7Channel_73__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0); - __pyx_r = __pyx_pf_4ssh2_7channel_7Channel_74__reduce_cython__(((struct __pyx_obj_4ssh2_7channel_Channel *)__pyx_v_self)); + __pyx_r = __pyx_pf_4ssh2_7channel_7Channel_72__reduce_cython__(((struct __pyx_obj_4ssh2_7channel_Channel *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_pf_4ssh2_7channel_7Channel_74__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_4ssh2_7channel_Channel *__pyx_v_self) { +static PyObject *__pyx_pf_4ssh2_7channel_7Channel_72__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_4ssh2_7channel_Channel *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; @@ -7801,20 +7692,20 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_74__reduce_cython__(CYTHON_UNU */ /* Python wrapper */ -static PyObject *__pyx_pw_4ssh2_7channel_7Channel_77__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/ -static char __pyx_doc_4ssh2_7channel_7Channel_76__setstate_cython__[] = "Channel.__setstate_cython__(self, __pyx_state)"; -static PyObject *__pyx_pw_4ssh2_7channel_7Channel_77__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) { +static PyObject *__pyx_pw_4ssh2_7channel_7Channel_75__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/ +static char __pyx_doc_4ssh2_7channel_7Channel_74__setstate_cython__[] = "Channel.__setstate_cython__(self, __pyx_state)"; +static PyObject *__pyx_pw_4ssh2_7channel_7Channel_75__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0); - __pyx_r = __pyx_pf_4ssh2_7channel_7Channel_76__setstate_cython__(((struct __pyx_obj_4ssh2_7channel_Channel *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state)); + __pyx_r = __pyx_pf_4ssh2_7channel_7Channel_74__setstate_cython__(((struct __pyx_obj_4ssh2_7channel_Channel *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_pf_4ssh2_7channel_7Channel_76__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_4ssh2_7channel_Channel *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) { +static PyObject *__pyx_pf_4ssh2_7channel_7Channel_74__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_4ssh2_7channel_Channel *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; @@ -7946,9 +7837,8 @@ static PyMethodDef __pyx_methods_4ssh2_7channel_Channel[] = { {"handle_extended_data", (PyCFunction)__pyx_pw_4ssh2_7channel_7Channel_67handle_extended_data, METH_O, __pyx_doc_4ssh2_7channel_7Channel_66handle_extended_data}, {"handle_extended_data2", (PyCFunction)__pyx_pw_4ssh2_7channel_7Channel_69handle_extended_data2, METH_O, __pyx_doc_4ssh2_7channel_7Channel_68handle_extended_data2}, {"ignore_extended_data", (PyCFunction)__pyx_pw_4ssh2_7channel_7Channel_71ignore_extended_data, METH_O, __pyx_doc_4ssh2_7channel_7Channel_70ignore_extended_data}, - {"request_auth_agent", (PyCFunction)__pyx_pw_4ssh2_7channel_7Channel_73request_auth_agent, METH_NOARGS, __pyx_doc_4ssh2_7channel_7Channel_72request_auth_agent}, - {"__reduce_cython__", (PyCFunction)__pyx_pw_4ssh2_7channel_7Channel_75__reduce_cython__, METH_NOARGS, __pyx_doc_4ssh2_7channel_7Channel_74__reduce_cython__}, - {"__setstate_cython__", (PyCFunction)__pyx_pw_4ssh2_7channel_7Channel_77__setstate_cython__, METH_O, __pyx_doc_4ssh2_7channel_7Channel_76__setstate_cython__}, + {"__reduce_cython__", (PyCFunction)__pyx_pw_4ssh2_7channel_7Channel_73__reduce_cython__, METH_NOARGS, __pyx_doc_4ssh2_7channel_7Channel_72__reduce_cython__}, + {"__setstate_cython__", (PyCFunction)__pyx_pw_4ssh2_7channel_7Channel_75__setstate_cython__, METH_O, __pyx_doc_4ssh2_7channel_7Channel_74__setstate_cython__}, {0, 0, 0, 0} }; diff --git a/ssh2/channel.pyx b/ssh2/channel.pyx index ee71c036..ca33bfef 100644 --- a/ssh2/channel.pyx +++ b/ssh2/channel.pyx @@ -555,9 +555,10 @@ cdef class Channel: c_ssh2.libssh2_channel_handle_extended_data( self._channel, ignore_mode) - def request_auth_agent(self): - """Request SSH agent authentication forwarding on channel.""" - cdef int rc - with nogil: - rc = c_ssh2.libssh2_channel_request_auth_agent(self._channel) - return handle_error_codes(rc) + IF HAVE_AGENT_FWD: + def request_auth_agent(self): + """Request SSH agent authentication forwarding on channel.""" + cdef int rc + with nogil: + rc = c_ssh2.libssh2_channel_request_auth_agent(self._channel) + return handle_error_codes(rc) diff --git a/tests/test_agent.py b/tests/test_agent.py new file mode 100644 index 00000000..7a191a4d --- /dev/null +++ b/tests/test_agent.py @@ -0,0 +1,37 @@ +import os +import socket +from unittest import skipUnless + +from .base_test import SSH2TestCase +from ssh2.session import Session, LIBSSH2_HOSTKEY_HASH_MD5, \ + LIBSSH2_HOSTKEY_HASH_SHA1 +# from ssh2.sftp import SFTP +from ssh2.agent import Agent +# from ssh2.error_codes import LIBSSH2_ERROR_EAGAIN +from ssh2.exceptions import AuthenticationError, AgentAuthenticationError, \ + SCPProtocolError, RequestDeniedError, InvalidRequestError, \ + SocketSendError, FileError, PublickeyUnverifiedError +from ssh2.utils import wait_socket + + +class SessionTestCase(SSH2TestCase): + + def test_agent_pyobject(self): + agent = Agent(self.session) + self.assertIsInstance(agent, Agent) + + def test_agent_get_identities(self): + agent = Agent(self.session) + agent.connect() + ids = agent.get_identities() + self.assertIsInstance(ids, list) + agent.disconnect() + + def test_agent_id_path(self): + agent = Agent(self.session) + agent.connect() + _path = b'my_path' + agent.set_identity_path(_path) + path = agent.get_identity_path() + self.assertEqual(_path, path) + agent.disconnect() From f5653cd9b06e8a8d71ba9f956766bca002172eec Mon Sep 17 00:00:00 2001 From: Panos Date: Wed, 19 Aug 2020 18:49:59 +0100 Subject: [PATCH 05/13] Updated osx wheels --- .travis.yml | 89 ++++++++++++++++++++++++------------------------- ci/osx-wheel.sh | 27 +++++++++++++++ 2 files changed, 70 insertions(+), 46 deletions(-) create mode 100755 ci/osx-wheel.sh diff --git a/.travis.yml b/.travis.yml index 5ea3fc61..905e69bb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -53,15 +53,12 @@ jobs: before_cache: - brew cleanup before_install: - - brew install ccache - - sudo -H pip install twine + - brew install ccache cmake python libssh2 + - pip3 install twine - which twine - - sudo ci/install-ssh2.sh - - cp /usr/local/lib/libssh2* . - - mkdir -p wheels install: skip script: - - travis_wait ./ci/travis/pyenv-wheel.sh + - ./ci/osx-wheel.sh after_success: - if [[ ! -z "$TRAVIS_TAG" ]]; then twine upload --skip-existing -u $PYPI_U -p $PYPI_P wheels/*.whl; @@ -69,50 +66,50 @@ jobs: language: generic python: skip - - <<: *osx-wheels - osx_image: xcode11.3 - env: - - PYENV: 3.6.11 - - SYSTEM_LIBSSH2: 1 - install: skip - script: - - travis_wait ./ci/travis/pyenv-wheel.sh + # - <<: *osx-wheels + # osx_image: xcode11.3 + # env: + # - PYENV: 3.6.11 + # - SYSTEM_LIBSSH2: 1 + # install: skip + # script: + # - travis_wait ./ci/travis/pyenv-wheel.sh - - <<: *osx-wheels - osx_image: xcode11.6 - env: - - PYENV: 3.7.8 - - SYSTEM_LIBSSH2: 1 - install: skip - script: - - travis_wait ./ci/travis/pyenv-wheel.sh + # - <<: *osx-wheels + # osx_image: xcode11.6 + # env: + # - PYENV: 3.7.8 + # - SYSTEM_LIBSSH2: 1 + # install: skip + # script: + # - travis_wait ./ci/travis/pyenv-wheel.sh - - <<: *osx-wheels - osx_image: xcode11.3 - env: - - PYENV: 3.7.8 - - SYSTEM_LIBSSH2: 1 - install: skip - script: - - travis_wait ./ci/travis/pyenv-wheel.sh + # - <<: *osx-wheels + # osx_image: xcode11.3 + # env: + # - PYENV: 3.7.8 + # - SYSTEM_LIBSSH2: 1 + # install: skip + # script: + # - travis_wait ./ci/travis/pyenv-wheel.sh - - <<: *osx-wheels - osx_image: xcode11.3 - env: - - PYENV: 3.8.5 - - SYSTEM_LIBSSH2: 1 - install: skip - script: - - travis_wait ./ci/travis/pyenv-wheel.sh + # - <<: *osx-wheels + # osx_image: xcode11.3 + # env: + # - PYENV: 3.8.5 + # - SYSTEM_LIBSSH2: 1 + # install: skip + # script: + # - travis_wait ./ci/travis/pyenv-wheel.sh - - <<: *osx-wheels - osx_image: xcode11.6 - env: - - PYENV: 3.8.5 - - SYSTEM_LIBSSH2: 1 - install: skip - script: - - travis_wait ./ci/travis/pyenv-wheel.sh + # - <<: *osx-wheels + # osx_image: xcode11.6 + # env: + # - PYENV: 3.8.5 + # - SYSTEM_LIBSSH2: 1 + # install: skip + # script: + # - travis_wait ./ci/travis/pyenv-wheel.sh - stage: build packages os: linux diff --git a/ci/osx-wheel.sh b/ci/osx-wheel.sh new file mode 100755 index 00000000..6014eee8 --- /dev/null +++ b/ci/osx-wheel.sh @@ -0,0 +1,27 @@ +#!/bin/bash -xe + +pip3 install -U virtualenv +python3 -m virtualenv -p "$(which python3)" venv + +set +x +source venv/bin/activate +set -x + +python -V +pip3 install -U setuptools pip +pip3 install -U delocate wheel +SYSTEM_LIBSSH2=1 python3 setup.py bdist_wheel +ls -lhtr /usr/local/lib/ +delocate-listdeps dist/*.whl +delocate-wheel -v -w wheels dist/*.whl +delocate-listdeps wheels/*.whl + +ls -l wheels/*.whl +rm -f /usr/local/lib/libssh2* +pip3 install -v wheels/*.whl +pwd; mkdir -p temp; cd temp; pwd +python3 -c "from ssh2.session import Session; Session()" && echo "Import successfull" +cd ..; pwd +set +x +deactivate +set -x From 2ad4434cc4d249467615190d988b5780dff465be Mon Sep 17 00:00:00 2001 From: Panos Date: Wed, 19 Aug 2020 19:19:24 +0100 Subject: [PATCH 06/13] Updated travis cfg --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 905e69bb..d4d3b9e6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -53,7 +53,7 @@ jobs: before_cache: - brew cleanup before_install: - - brew install ccache cmake python libssh2 + - brew install libssh2 - pip3 install twine - which twine install: skip From d2e5bc57fc2ec396ac12be538b4acdc527053493 Mon Sep 17 00:00:00 2001 From: Panos Date: Wed, 19 Aug 2020 19:36:33 +0100 Subject: [PATCH 07/13] Added conditionals --- .travis.yml | 71 +++++++++++++++++++++++++++++------------------------ 1 file changed, 39 insertions(+), 32 deletions(-) diff --git a/.travis.yml b/.travis.yml index d4d3b9e6..41497d5f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,44 +7,50 @@ cache: - "$HOME/.git/lfs" notifications: email: false -sudo: required -dist: xenial -services: - - docker -python: - - 2.7 - - 3.6 - - 3.7 - - 3.8 -addons: - apt: - packages: - - openssh-server - - rpm - - dpkg - - cmake -install: - - pip install flake8 jinja2 sphinx sphinx_rtd_theme - - python setup.py build_ext --inplace - - eval "$(ssh-agent -s)" -script: - - pytest tests - - flake8 ssh2 - # Test source distribution builds - - python setup.py sdist - - cd dist - - pip install * - - python -c 'from ssh2.session import Session; Session()' - - cd .. - - cd doc - - make html - - cd .. jobs: include: + - stage: test + if: (type == push) OR \ + (type == pull_request AND fork == true) + sudo: required + dist: xenial + services: + - docker + python: + - 2.7 + - 3.6 + - 3.7 + - 3.8 + addons: + apt: + packages: + - openssh-server + - rpm + - dpkg + - cmake + install: + - pip install flake8 jinja2 sphinx sphinx_rtd_theme + - python setup.py build_ext --inplace + - eval "$(ssh-agent -s)" + script: + - pytest tests + - flake8 ssh2 + # Test source distribution builds + - python setup.py sdist + - cd dist + - pip install * + - python -c 'from ssh2.session import Session; Session()' + - cd .. + - cd doc + - make html + - cd .. + - &osx-wheels stage: build packages + if: (type == push) OR \ + (type == pull_request AND fork == true) os: osx osx_image: xcode11.6 env: @@ -112,6 +118,7 @@ jobs: # - travis_wait ./ci/travis/pyenv-wheel.sh - stage: build packages + if: tag IS present os: linux python: 3.6 env: From 35ea92a34e8ea7126d1f176f8661d7378ddd280e Mon Sep 17 00:00:00 2001 From: Panos Date: Wed, 19 Aug 2020 19:37:33 +0100 Subject: [PATCH 08/13] Updated cfg --- .travis.yml | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index 41497d5f..5fc1d049 100644 --- a/.travis.yml +++ b/.travis.yml @@ -54,7 +54,6 @@ jobs: os: osx osx_image: xcode11.6 env: - - PYENV: 3.6.11 - SYSTEM_LIBSSH2: 1 before_cache: - brew cleanup @@ -72,14 +71,8 @@ jobs: language: generic python: skip - # - <<: *osx-wheels - # osx_image: xcode11.3 - # env: - # - PYENV: 3.6.11 - # - SYSTEM_LIBSSH2: 1 - # install: skip - # script: - # - travis_wait ./ci/travis/pyenv-wheel.sh + - <<: *osx-wheels + osx_image: xcode11.3 # - <<: *osx-wheels # osx_image: xcode11.6 From 7bd4816c3e43f7887043c2a57dd03771efa4f35b Mon Sep 17 00:00:00 2001 From: Panos Date: Wed, 19 Aug 2020 20:36:26 +0100 Subject: [PATCH 09/13] Updated cfg --- .travis.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5fc1d049..8eefb33f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,8 +12,8 @@ jobs: include: - stage: test - if: (type == push) OR \ - (type == pull_request AND fork == true) + # if: (type == push) OR \ + # (type == pull_request AND fork == true) sudo: required dist: xenial services: @@ -49,8 +49,8 @@ jobs: - &osx-wheels stage: build packages - if: (type == push) OR \ - (type == pull_request AND fork == true) + # if: (type == push) OR \ + # (type == pull_request AND fork == true) os: osx osx_image: xcode11.6 env: From 7d134ec18309b508bbd5a86f6a70ef8c2e27d491 Mon Sep 17 00:00:00 2001 From: Panos Date: Wed, 19 Aug 2020 20:53:45 +0100 Subject: [PATCH 10/13] Updated travis, appveyor cfgs --- .appveyor.yml | 48 +++++++-------- .travis.yml | 14 ++--- ci/appveyor/anaconda_upload.py | 13 ----- ci/appveyor/build_ssh2.bat | 56 ++++-------------- ci/appveyor/openssl-1.1.0h-x64-VC2017.zip | 3 - ci/appveyor/run_with_env.cmd | 71 ----------------------- requirements_dev.txt | 1 + 7 files changed, 41 insertions(+), 165 deletions(-) delete mode 100644 ci/appveyor/anaconda_upload.py delete mode 100644 ci/appveyor/openssl-1.1.0h-x64-VC2017.zip delete mode 100644 ci/appveyor/run_with_env.cmd diff --git a/.appveyor.yml b/.appveyor.yml index aa17f15c..4d7cfad5 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -1,12 +1,12 @@ +max_jobs: 5 +build: + parallel: true + verbosity: minimal +skip_branch_with_pr: true environment: global: - # SDK v7.0 MSVC Express 2008's SetEnv.cmd script will fail if the - # /E:ON and /V:ON options are not enabled in the batch script intepreter - # See: http://stackoverflow.com/a/13751649/163740 - CMD_IN_ENV: "cmd /E:ON /V:ON /C %APPVEYOR_BUILD_FOLDER%\\ci\\appveyor\\run_with_env.cmd" PYTHONUNBUFFERED: 1 EMBEDDED_LIB: 1 - OPENSSL_VER: 1.1.0h SYSTEM_LIBSSH2: 1 PYPI_USER: secure: 2m0jy6JD/R9RExIosOT6YA== @@ -41,8 +41,12 @@ install: https://ci.appveyor.com/api/projects/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG/history?recordsNumber=50).builds | ` Where-Object pullRequestId -eq $env:APPVEYOR_PULL_REQUEST_NUMBER)[0].buildNumber) { ` throw "There are newer queued builds for this pull request, failing early." } - - ECHO "Installed SDKs:" - - ps: "ls \"C:/Program Files/Microsoft SDKs/Windows\"" + - set OPENSSL_DIR="C:\OpenSSL-v11-Win%PYTHON_ARCH%" + - set VCLIBDIR=%WINDIR%\System32 + - cp %VCLIBDIR%/vcruntime*.dll ssh2/ + - cp %VCLIBDIR%/msvcp*.dll ssh2/ + - cp %VCLIBDIR%/msvcr*.dll ssh2/ + - cp %OPENSSL_DIR%/bin/*.dll ssh2/ # Prepend newly installed Python to the PATH of this build (this cannot be # done from inside the powershell script as it would require to restart @@ -53,17 +57,7 @@ install: - "python --version" - "python -c \"import struct; print(struct.calcsize('P') * 8)\"" - # Upgrade to the latest version of pip to avoid it displaying warnings - # about it being out of date. - # - "pip install --disable-pip-version-check --user --upgrade pip" - - # Install the build dependencies of the project. If some dependencies contain - # compiled extensions and are not provided as pre-built wheel packages, - # pip will build them from source using the MSVC compiler matching the - # target Python version and architecture - - "%CMD_IN_ENV% pip install -r requirements_dev.txt" - - "%CMD_IN_ENV% pip install -U wheel setuptools twine" - - git submodule update --init --recursive + - pip install -U wheel setuptools twine cython # .c files need to be generated on Windows to handle platform # specific code. @@ -72,17 +66,17 @@ install: - python ci/appveyor/fix_version.py . - mv -f .git .git.bak - 7z x ci\appveyor\zlib1211.zip - - 7z x ci\appveyor\openssl-%OPENSSL_VER%-x%PYTHON_ARCH%-VC2017.zip - - cp openssl-%OPENSSL_VER%-x%PYTHON_ARCH%-VC2017\libssl-1_1-x%PYTHON_ARCH%.dll ssh2\ || cp openssl-%OPENSSL_VER%-x%PYTHON_ARCH%-VC2017\libssl-1_1.dll ssh2\ - - cp openssl-%OPENSSL_VER%-x%PYTHON_ARCH%-VC2017\libcrypto-1_1-x%PYTHON_ARCH%.dll ssh2\ || cp openssl-%OPENSSL_VER%-x%PYTHON_ARCH%-VC2017\libcrypto-1_1.dll ssh2\ - ps: ls ssh2 + build_script: - - "%CMD_IN_ENV% ci\\appveyor\\build_zlib.bat" - - "%CMD_IN_ENV% ci\\appveyor\\build_ssh2.bat" + - ci\\appveyor\\build_zlib.bat + - ci\\appveyor\\build_ssh2.bat - rm -f ssh2/*.c - - "%CMD_IN_ENV% python setup.py build_ext -I libssh2/include" - - "%CMD_IN_ENV% python setup.py build" - - "%CMD_IN_ENV% python setup.py install" + - python -V + - python setup.py build_ext + - python setup.py build + - python setup.py install + - ps: ls ssh2 test_script: - cd dist @@ -91,7 +85,7 @@ test_script: after_test: # If tests are successful, create binary packages for the project. - - "%CMD_IN_ENV% python setup.py bdist_wheel " + - python setup.py bdist_wheel - mv dist/* . artifacts: diff --git a/.travis.yml b/.travis.yml index 8eefb33f..cfc9b924 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,22 +7,22 @@ cache: - "$HOME/.git/lfs" notifications: email: false +python: + - 2.7 + - 3.6 + - 3.7 + - 3.8 jobs: include: - stage: test - # if: (type == push) OR \ - # (type == pull_request AND fork == true) + if: type = push OR \ + (type = pull_request AND fork = true) sudo: required dist: xenial services: - docker - python: - - 2.7 - - 3.6 - - 3.7 - - 3.8 addons: apt: packages: diff --git a/ci/appveyor/anaconda_upload.py b/ci/appveyor/anaconda_upload.py deleted file mode 100644 index 82060cc4..00000000 --- a/ci/appveyor/anaconda_upload.py +++ /dev/null @@ -1,13 +0,0 @@ -import sys -import os -from glob import glob -import subprocess -import traceback - - -cmd = ['anaconda', '-t', os.environ['ANACONDA_TOKEN'], 'upload'] -cmd.extend(glob('*.tar.bz2')) -try: - subprocess.check_call(cmd) -except subprocess.CalledProcessError: - sys.exit(1) diff --git a/ci/appveyor/build_ssh2.bat b/ci/appveyor/build_ssh2.bat index 6246f879..fdfbde04 100755 --- a/ci/appveyor/build_ssh2.bat +++ b/ci/appveyor/build_ssh2.bat @@ -1,55 +1,23 @@ mkdir src cd src -IF "%PYTHON_ARCH%" == "32" ( - set OPENSSL_DIR="C:\OpenSSL-v11-Win32" -) ELSE ( - set OPENSSL_DIR="C:\OpenSSL-v11-Win64" +ECHO "Building with platform %MSVC%" +cmake ..\libssh2 -G "NMake Makefiles" ^ + -DCMAKE_BUILD_TYPE=Release ^ + -DCRYPTO_BACKEND=OpenSSL ^ + -G"%MSVC%" ^ + -DBUILD_SHARED_LIBS=OFF ^ + -DENABLE_ZLIB_COMPRESSION=ON ^ + -DENABLE_CRYPT_NONE=ON ^ + -DENABLE_MAC_NONE=ON ^ + -DZLIB_LIBRARY=C:/zlib/lib/zlib.lib ^ + -DZLIB_INCLUDE_DIR=C:/zlib/include ^ + -DOPENSSL_ROOT_DIR=%OPENSSL_DIR% ) -ls %OPENSSL_DIR%\lib -ls %OPENSSL_DIR%\lib\VC -ls %OPENSSL_DIR%\lib\VC\static - -IF "%MSVC%" == "Visual Studio 9" ( - ECHO "Building without platform set" - cmake ..\libssh2 -G "NMake Makefiles" ^ - -DCMAKE_BUILD_TYPE=Release ^ - -DCRYPTO_BACKEND=OpenSSL ^ - -DBUILD_SHARED_LIBS=OFF ^ - -DENABLE_ZLIB_COMPRESSION=ON ^ - -DENABLE_CRYPT_NONE=ON ^ - -DENABLE_MAC_NONE=ON ^ - -DZLIB_LIBRARY=C:/zlib/lib/zlib.lib ^ - -DZLIB_INCLUDE_DIR=C:/zlib/include ^ - -DOPENSSL_ROOT_DIR=%OPENSSL_DIR% -REM -DOPENSSL_MSVC_STATIC_RT=TRUE -REM -DOPENSSL_USE_STATIC_LIBS=TRUE -) ELSE ( - ECHO "Building with platform %MSVC%" - cmake ..\libssh2 -G "NMake Makefiles" ^ - -DCMAKE_BUILD_TYPE=Release ^ - -DCRYPTO_BACKEND=OpenSSL ^ - -G"%MSVC%" ^ - -DBUILD_SHARED_LIBS=OFF ^ - -DENABLE_ZLIB_COMPRESSION=ON ^ - -DENABLE_CRYPT_NONE=ON ^ - -DENABLE_MAC_NONE=ON ^ - -DZLIB_LIBRARY=C:/zlib/lib/zlib.lib ^ - -DZLIB_INCLUDE_DIR=C:/zlib/include ^ - -DOPENSSL_ROOT_DIR=%OPENSSL_DIR% -REM -DOPENSSL_MSVC_STATIC_RT=TRUE -REM -DOPENSSL_USE_STATIC_LIBS=TRUE -) - - cp %OPENSSL_DIR%\lib\VC\libcrypto%PYTHON_ARCH%MD.lib %APPVEYOR_BUILD_FOLDER% cp %OPENSSL_DIR%\lib\VC\libssl%PYTHON_ARCH%MD.lib %APPVEYOR_BUILD_FOLDER% cmake --build . --config Release cd .. -ls -ls ssh2 -ls src/src cp src/src/libssh2.lib %PYTHON%/libs/ || cp src/src/Release/libssh2.lib %PYTHON%/libs/ -ls %PYTHON%/libs/ diff --git a/ci/appveyor/openssl-1.1.0h-x64-VC2017.zip b/ci/appveyor/openssl-1.1.0h-x64-VC2017.zip deleted file mode 100644 index 55570d66..00000000 --- a/ci/appveyor/openssl-1.1.0h-x64-VC2017.zip +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:c3592481c530ec3a74cf9e3f436a629ad50eeb820173482782e7bfee0bebc69f -size 1806520 diff --git a/ci/appveyor/run_with_env.cmd b/ci/appveyor/run_with_env.cmd deleted file mode 100644 index 68379b1f..00000000 --- a/ci/appveyor/run_with_env.cmd +++ /dev/null @@ -1,71 +0,0 @@ -:: To build extensions for 64 bit Python 3.5 or later no special environment needs -:: to be configured for the Python extension code alone, however, all dependent -:: libraries also need to be compiled with the same SDK in order to be able to -:: link them together. -:: -:: This script sets SDK version and environment for all commands. -:: -:: To build extensions for 64 bit Python 3.4 or earlier, we need to configure environment -:: variables to use the MSVC 2010 C++ compilers from GRMSDKX_EN_DVD.iso of: -:: MS Windows SDK for Windows 7 and .NET Framework 4 (SDK v7.1) -:: -:: To build extensions for 64 bit Python 2, we need to configure environment -:: variables to use the MSVC 2008 C++ compilers from GRMSDKX_EN_DVD.iso of: -:: MS Windows SDK for Windows 7 and .NET Framework 3.5 (SDK v7.0) -:: -:: 32 bit builds do not require specific environment configurations. -:: -:: Note: this script needs to be run with the /E:ON and /V:ON flags for the -:: cmd interpreter, at least for (SDK v7.0) -:: -:: More details at: -:: https://github.com/cython/cython/wiki/64BitCythonExtensionsOnWindows -:: https://stackoverflow.com/a/13751649/163740 -:: -:: Original Author: Olivier Grisel -:: License: CC0 1.0 Universal: https://creativecommons.org/publicdomain/zero/1.0/ -:: This version based on updates for python 3.5 by Phil Elson at: -:: https://github.com/pelson/Obvious-CI/tree/master/scripts -:: Further updates to always correctly set SDK version and environment so -:: that compiled library dependencies use same SDK as Python extension. - -@ECHO OFF - -SET COMMAND_TO_RUN=%* -SET WIN_SDK_ROOT=C:\Program Files\Microsoft SDKs\Windows - -SET MAJOR_PYTHON_VERSION="%PYTHON_VERSION:~0,1%" -SET MINOR_PYTHON_VERSION=%PYTHON_VERSION:~2,1% -IF %MAJOR_PYTHON_VERSION% == "2" ( - SET WINDOWS_SDK_VERSION="v7.0" - SET SET_SDK_64=Y -) ELSE IF %MAJOR_PYTHON_VERSION% == "3" ( - SET WINDOWS_SDK_VERSION="v7.1" - IF %MINOR_PYTHON_VERSION% LEQ 4 ( - SET SET_SDK_64=Y - ) ELSE ( - SET SET_SDK_64=N - ) -) ELSE ( - ECHO Unsupported Python version: "%MAJOR_PYTHON_VERSION%" - EXIT 1 -) - -"%WIN_SDK_ROOT%\%WINDOWS_SDK_VERSION%\Setup\WindowsSdkVer.exe" -q -version:%WINDOWS_SDK_VERSION% - -IF "%PYTHON_ARCH%"=="64" ( - IF %SET_SDK_64% == Y ( - ECHO Configuring Windows SDK %WINDOWS_SDK_VERSION% for Python %MAJOR_PYTHON_VERSION% on a 64 bit architecture - SET DISTUTILS_USE_SDK=1 - SET MSSdk=1 - ) - ECHO Setting MSVC %WINDOWS_SDK_VERSION% build environment for 64 bit architecture - "%WIN_SDK_ROOT%\%WINDOWS_SDK_VERSION%\Bin\SetEnv.cmd" /x64 /release - ECHO Executing: %COMMAND_TO_RUN% - call %COMMAND_TO_RUN% || EXIT 1 -) ELSE ( - ECHO Setting MSVC %WINDOWS_SDK_VERSION% build environment for 32 bit architecture - "%WIN_SDK_ROOT%\%WINDOWS_SDK_VERSION%\Bin\SetEnv.cmd" /x86 /release - ECHO Executing: %COMMAND_TO_RUN% - call %COMMAND_TO_RUN% || EXIT 1 -) diff --git a/requirements_dev.txt b/requirements_dev.txt index 7383b387..8bf2de5c 100644 --- a/requirements_dev.txt +++ b/requirements_dev.txt @@ -4,3 +4,4 @@ jinja2 sphinx sphinx_rtd_theme pytest +pytest-rerunfailures From 8b45323161084c1d561a684240b21372c0ea56a9 Mon Sep 17 00:00:00 2001 From: Panos Date: Wed, 19 Aug 2020 20:57:17 +0100 Subject: [PATCH 11/13] Updated cfg --- .travis.yml | 56 ++++++++++++++++++++++++++--------------------------- 1 file changed, 27 insertions(+), 29 deletions(-) diff --git a/.travis.yml b/.travis.yml index cfc9b924..9288ca88 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,6 +12,33 @@ python: - 3.6 - 3.7 - 3.8 +install: + - pip install flake8 jinja2 sphinx sphinx_rtd_theme + - python setup.py build_ext --inplace + - eval "$(ssh-agent -s)" +script: + - pytest tests + - flake8 ssh2 + # Test source distribution builds + - python setup.py sdist + - cd dist + - pip install * + - python -c 'from ssh2.session import Session; Session()' + - cd .. + - cd doc + - make html + - cd .. +sudo: required +dist: xenial +services: + - docker +addons: + apt: + packages: + - openssh-server + - rpm + - dpkg + - cmake jobs: include: @@ -19,33 +46,6 @@ jobs: - stage: test if: type = push OR \ (type = pull_request AND fork = true) - sudo: required - dist: xenial - services: - - docker - addons: - apt: - packages: - - openssh-server - - rpm - - dpkg - - cmake - install: - - pip install flake8 jinja2 sphinx sphinx_rtd_theme - - python setup.py build_ext --inplace - - eval "$(ssh-agent -s)" - script: - - pytest tests - - flake8 ssh2 - # Test source distribution builds - - python setup.py sdist - - cd dist - - pip install * - - python -c 'from ssh2.session import Session; Session()' - - cd .. - - cd doc - - make html - - cd .. - &osx-wheels stage: build packages @@ -55,8 +55,6 @@ jobs: osx_image: xcode11.6 env: - SYSTEM_LIBSSH2: 1 - before_cache: - - brew cleanup before_install: - brew install libssh2 - pip3 install twine From 814db699cbb32c1c5eab00c25acdfdabb2f4b04e Mon Sep 17 00:00:00 2001 From: Panos Date: Wed, 19 Aug 2020 21:10:58 +0100 Subject: [PATCH 12/13] Updated cfgs --- .appveyor.yml | 2 +- .travis.yml | 39 +-------------------------------------- 2 files changed, 2 insertions(+), 39 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index 4d7cfad5..20f3b5c8 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -73,7 +73,7 @@ build_script: - ci\\appveyor\\build_ssh2.bat - rm -f ssh2/*.c - python -V - - python setup.py build_ext + - python setup.py build_ext -I libssh2/include - python setup.py build - python setup.py install - ps: ls ssh2 diff --git a/.travis.yml b/.travis.yml index 9288ca88..77ba7240 100644 --- a/.travis.yml +++ b/.travis.yml @@ -49,8 +49,7 @@ jobs: - &osx-wheels stage: build packages - # if: (type == push) OR \ - # (type == pull_request AND fork == true) + if: tag IS present os: osx osx_image: xcode11.6 env: @@ -72,42 +71,6 @@ jobs: - <<: *osx-wheels osx_image: xcode11.3 - # - <<: *osx-wheels - # osx_image: xcode11.6 - # env: - # - PYENV: 3.7.8 - # - SYSTEM_LIBSSH2: 1 - # install: skip - # script: - # - travis_wait ./ci/travis/pyenv-wheel.sh - - # - <<: *osx-wheels - # osx_image: xcode11.3 - # env: - # - PYENV: 3.7.8 - # - SYSTEM_LIBSSH2: 1 - # install: skip - # script: - # - travis_wait ./ci/travis/pyenv-wheel.sh - - # - <<: *osx-wheels - # osx_image: xcode11.3 - # env: - # - PYENV: 3.8.5 - # - SYSTEM_LIBSSH2: 1 - # install: skip - # script: - # - travis_wait ./ci/travis/pyenv-wheel.sh - - # - <<: *osx-wheels - # osx_image: xcode11.6 - # env: - # - PYENV: 3.8.5 - # - SYSTEM_LIBSSH2: 1 - # install: skip - # script: - # - travis_wait ./ci/travis/pyenv-wheel.sh - - stage: build packages if: tag IS present os: linux From 8a465e2090258f1d17fa75f60dd18bc492d1ad5a Mon Sep 17 00:00:00 2001 From: Panos Date: Wed, 19 Aug 2020 21:14:29 +0100 Subject: [PATCH 13/13] Updated package data --- setup.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index c0a6af26..992b0426 100644 --- a/setup.py +++ b/setup.py @@ -90,6 +90,7 @@ if ON_WINDOWS: package_data['ssh2'].extend([ 'libcrypto*.dll', 'libssl*.dll', + 'msvc*.dll', 'vcruntime*.dll', ]) cmdclass = versioneer.get_cmdclass() @@ -123,9 +124,9 @@ 'Programming Language :: Python :: 2', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', 'Topic :: System :: Shells', 'Topic :: System :: Networking', 'Topic :: Software Development :: Libraries',