diff options
author | Remi Collet <remi@remirepo.net> | 2020-09-10 16:30:55 +0200 |
---|---|---|
committer | Remi Collet <remi@remirepo.net> | 2020-09-10 16:30:55 +0200 |
commit | 74a655216900967d84bd92b50ccf19d8a938bb8a (patch) | |
tree | e542bf0e83fd690a543e9b0e540d0269e8eedc41 | |
parent | 6e4b4e941feae33dbd31e32d710fc24beff69ab2 (diff) |
add fix for PHP 8 from
https://github.com/php/pecl-networking-ssh2/pull/42
-rw-r--r-- | 44.patch | 287 | ||||
-rw-r--r-- | php-pecl-ssh2.spec | 36 |
2 files changed, 307 insertions, 16 deletions
diff --git a/44.patch b/44.patch new file mode 100644 index 0000000..3af71f1 --- /dev/null +++ b/44.patch @@ -0,0 +1,287 @@ +From 167a679db79a93c27b7bb367bef9e0d9abdc47d0 Mon Sep 17 00:00:00 2001 +From: Andy Postnikov <apostnikov@gmail.com> +Date: Mon, 13 Jul 2020 20:13:34 +0300 +Subject: [PATCH 1/4] Fix compatibility with 8.0 - call_user_function_ex + +--- + ssh2.c | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +diff --git a/ssh2.c b/ssh2.c +index 5a1deef..ee60f7b 100644 +--- a/ssh2.c ++++ b/ssh2.c +@@ -100,7 +100,7 @@ LIBSSH2_DEBUG_FUNC(php_ssh2_debug_cb) + ZVAL_STRINGL(&args[1], language, language_len); + ZVAL_LONG(&args[2], always_display); + +- if (FAILURE == call_user_function_ex(NULL, NULL, data->disconnect_cb, NULL, 3, args, 0, NULL)) { ++ if (FAILURE == call_user_function(NULL, NULL, data->disconnect_cb, NULL, 3, args)) { + php_error_docref(NULL, E_WARNING, "Failure calling disconnect callback"); + } + } +@@ -125,7 +125,7 @@ LIBSSH2_IGNORE_FUNC(php_ssh2_ignore_cb) + + ZVAL_STRINGL(&args[0], message, message_len); + +- if (FAILURE == call_user_function_ex(NULL, NULL, data->ignore_cb, &zretval, 1, args, 0, NULL)) { ++ if (FAILURE == call_user_function(NULL, NULL, data->ignore_cb, &zretval, 1, args)) { + php_error_docref(NULL, E_WARNING, "Failure calling ignore callback"); + } + if (Z_TYPE_P(&zretval) != IS_UNDEF) { +@@ -155,7 +155,7 @@ LIBSSH2_MACERROR_FUNC(php_ssh2_macerror_cb) + + ZVAL_STRINGL(&args[0], packet, packet_len); + +- if (FAILURE == call_user_function_ex(NULL, NULL, data->macerror_cb, &zretval, 1, args, 0, NULL)) { ++ if (FAILURE == call_user_function(NULL, NULL, data->macerror_cb, &zretval, 1, args)) { + php_error_docref(NULL, E_WARNING, "Failure calling macerror callback"); + } else { + retval = zval_is_true(&zretval) ? 0 : -1; +@@ -188,7 +188,7 @@ LIBSSH2_DISCONNECT_FUNC(php_ssh2_disconnect_cb) + ZVAL_STRINGL(&args[1], message, message_len); + ZVAL_STRINGL(&args[2], language, language_len); + +- if (FAILURE == call_user_function_ex(NULL, NULL, data->disconnect_cb, NULL, 3, args, 0, NULL)) { ++ if (FAILURE == call_user_function(NULL, NULL, data->disconnect_cb, NULL, 3, args)) { + php_error_docref(NULL, E_WARNING, "Failure calling disconnect callback"); + } + } + +From 9e6074a4eae3b4ebbe883ba1b93c9eccb9c78d02 Mon Sep 17 00:00:00 2001 +From: Andy Postnikov <apostnikov@gmail.com> +Date: Mon, 13 Jul 2020 23:32:53 +0300 +Subject: [PATCH 3/4] Fix function definition arguments + +- ssh2_poll() updated outdated ZEND_ARG_PASS_INFO usage and argument names +- added argument definition for ssh2_forward_listen() and ssh2_forward_accept() +--- + ssh2.c | 28 +++++++++++++++++++++------- + 1 file changed, 21 insertions(+), 7 deletions(-) + +diff --git a/ssh2.c b/ssh2.c +index ee60f7b..4605f1a 100644 +--- a/ssh2.c ++++ b/ssh2.c +@@ -45,10 +45,6 @@ int le_ssh2_listener; + int le_ssh2_sftp; + int le_ssh2_pkey_subsys; + +-ZEND_BEGIN_ARG_INFO(php_ssh2_first_arg_force_ref, 0) +- ZEND_ARG_PASS_INFO(1) +-ZEND_END_ARG_INFO() +- + /* ************* + * Callbacks * + ************* */ +@@ -1416,6 +1412,19 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_ssh2_auth_hostbased_file, 0, 0, 5) + ZEND_ARG_INFO(0, local_username) + ZEND_END_ARG_INFO() + ++ZEND_BEGIN_ARG_INFO_EX(arginfo_ssh2_forward_listen, 0, 0, 2) ++ ZEND_ARG_INFO(0, session) ++ ZEND_ARG_INFO(0, port) ++ ZEND_ARG_INFO(0, host) ++ ZEND_ARG_INFO(0, max_connections) ++ZEND_END_ARG_INFO() ++ ++ZEND_BEGIN_ARG_INFO_EX(arginfo_ssh2_forward_accept, 0, 0, 1) ++ ZEND_ARG_INFO(0, listener) ++ ZEND_ARG_INFO(1, host) ++ ZEND_ARG_INFO(0, port) ++ZEND_END_ARG_INFO() ++ + ZEND_BEGIN_ARG_INFO_EX(arginfo_ssh2_shell, 0, 0, 1) + ZEND_ARG_INFO(0, session) + ZEND_ARG_INFO(0, termtype) +@@ -1459,6 +1468,11 @@ ZEND_BEGIN_ARG_INFO(arginfo_ssh2_fetch_stream, 2) + ZEND_ARG_INFO(0, streamid) + ZEND_END_ARG_INFO() + ++ZEND_BEGIN_ARG_INFO_EX(arginfo_ssh2_poll, 0, 0, 1) ++ ZEND_ARG_INFO(1, polldes) ++ ZEND_ARG_INFO(0, timeout) ++ZEND_END_ARG_INFO() ++ + ZEND_BEGIN_ARG_INFO(arginfo_ssh2_sftp, 1) + ZEND_ARG_INFO(0, session) + ZEND_END_ARG_INFO() +@@ -1559,8 +1573,8 @@ zend_function_entry ssh2_functions[] = { + PHP_FE(ssh2_auth_pubkey_file, arginfo_ssh2_auth_pubkey_file) + PHP_FE(ssh2_auth_hostbased_file, arginfo_ssh2_auth_hostbased_file) + +- PHP_FE(ssh2_forward_listen, NULL) +- PHP_FE(ssh2_forward_accept, NULL) ++ PHP_FE(ssh2_forward_listen, arginfo_ssh2_forward_listen) ++ PHP_FE(ssh2_forward_accept, arginfo_ssh2_forward_accept) + + /* Stream Stuff */ + PHP_FE(ssh2_shell, arginfo_ssh2_shell) +@@ -1569,7 +1583,7 @@ zend_function_entry ssh2_functions[] = { + PHP_FE(ssh2_scp_recv, arginfo_ssh2_scp_recv) + PHP_FE(ssh2_scp_send, arginfo_ssh2_scp_send) + PHP_FE(ssh2_fetch_stream, arginfo_ssh2_fetch_stream) +- PHP_FE(ssh2_poll, php_ssh2_first_arg_force_ref) ++ PHP_FE(ssh2_poll, arginfo_ssh2_poll) + + /* SFTP Stuff */ + PHP_FE(ssh2_sftp, arginfo_ssh2_sftp) + +From c9647c5d296e8693d0b5672f1c22945ea024ebdc Mon Sep 17 00:00:00 2001 +From: Remi Collet <remi@remirepo.net> +Date: Thu, 10 Sep 2020 15:53:52 +0200 +Subject: [PATCH 4/4] fix for PHP 7.4 (stream API) and 8.0 + +--- + ssh2.c | 4 +--- + ssh2_fopen_wrappers.c | 26 +++++++++++++++++++------- + ssh2_sftp.c | 20 ++++++++++++++++++++ + 3 files changed, 40 insertions(+), 10 deletions(-) + +diff --git a/ssh2.c b/ssh2.c +index 4605f1a..31ee8f7 100644 +--- a/ssh2.c ++++ b/ssh2.c +@@ -436,9 +436,7 @@ PHP_FUNCTION(ssh2_disconnect) + RETURN_FALSE; + } + +- if (zend_list_close(Z_RES_P(zsession)) != SUCCESS) { +- RETURN_FALSE; +- } ++ zend_list_close(Z_RES_P(zsession)); + + RETURN_TRUE; + } +diff --git a/ssh2_fopen_wrappers.c b/ssh2_fopen_wrappers.c +index ef82134..d79a051 100644 +--- a/ssh2_fopen_wrappers.c ++++ b/ssh2_fopen_wrappers.c +@@ -40,10 +40,14 @@ void *php_ssh2_zval_from_resource_handle(int handle) { + * channel_stream_ops * + ********************** */ + ++#if PHP_VERSION_ID < 70400 + static size_t php_ssh2_channel_stream_write(php_stream *stream, const char *buf, size_t count) ++#else ++static ssize_t php_ssh2_channel_stream_write(php_stream *stream, const char *buf, size_t count) ++#endif + { + php_ssh2_channel_data *abstract = (php_ssh2_channel_data*)stream->abstract; +- size_t writestate; ++ ssize_t writestate; + LIBSSH2_SESSION *session; + + libssh2_channel_set_blocking(abstract->channel, abstract->is_blocking); +@@ -64,24 +68,31 @@ static size_t php_ssh2_channel_stream_write(php_stream *stream, const char *buf, + libssh2_session_set_timeout(session, 0); + } + #endif ++ + if (writestate == LIBSSH2_ERROR_EAGAIN) { ++#if PHP_VERSION_ID < 70400 + writestate = 0; +- } +- +- if (writestate < 0) { ++#endif ++ } else if (writestate < 0) { + char *error_msg = NULL; + if (libssh2_session_last_error(session, &error_msg, NULL, 0) == writestate) { + php_error_docref(NULL, E_WARNING, "Failure '%s' (%ld)", error_msg, writestate); + } + + stream->eof = 1; ++#if PHP_VERSION_ID < 70400 + writestate = 0; ++#endif + } + + return writestate; + } + ++#if PHP_VERSION_ID < 70400 + static size_t php_ssh2_channel_stream_read(php_stream *stream, char *buf, size_t count) ++#else ++static ssize_t php_ssh2_channel_stream_read(php_stream *stream, char *buf, size_t count) ++#endif + { + php_ssh2_channel_data *abstract = (php_ssh2_channel_data*)stream->abstract; + ssize_t readstate; +@@ -104,11 +115,12 @@ static size_t php_ssh2_channel_stream_read(php_stream *stream, char *buf, size_t + libssh2_session_set_timeout(session, 0); + } + #endif ++ + if (readstate == LIBSSH2_ERROR_EAGAIN) { ++#if PHP_VERSION_ID < 70400 + readstate = 0; +- } +- +- if (readstate < 0) { ++#endif ++ } else if (readstate < 0) { + char *error_msg = NULL; + if (libssh2_session_last_error(session, &error_msg, NULL, 0) == readstate) { + php_error_docref(NULL, E_WARNING, "Failure '%s' (%ld)", error_msg, readstate); +diff --git a/ssh2_sftp.c b/ssh2_sftp.c +index ae8f6f8..0f62d35 100644 +--- a/ssh2_sftp.c ++++ b/ssh2_sftp.c +@@ -103,20 +103,32 @@ typedef struct _php_ssh2_sftp_handle_data { + + /* {{{ php_ssh2_sftp_stream_write + */ ++#if PHP_VERSION_ID < 70400 + static size_t php_ssh2_sftp_stream_write(php_stream *stream, const char *buf, size_t count) ++#else ++static ssize_t php_ssh2_sftp_stream_write(php_stream *stream, const char *buf, size_t count) ++#endif + { + php_ssh2_sftp_handle_data *data = (php_ssh2_sftp_handle_data*)stream->abstract; + ssize_t bytes_written; + + bytes_written = libssh2_sftp_write(data->handle, buf, count); + ++#if PHP_VERSION_ID < 70400 + return (size_t)(bytes_written<0 ? 0 : bytes_written); ++#else ++ return bytes_written; ++#endif + } + /* }}} */ + + /* {{{ php_ssh2_sftp_stream_read + */ ++#if PHP_VERSION_ID < 70400 + static size_t php_ssh2_sftp_stream_read(php_stream *stream, char *buf, size_t count) ++#else ++static ssize_t php_ssh2_sftp_stream_read(php_stream *stream, char *buf, size_t count) ++#endif + { + php_ssh2_sftp_handle_data *data = (php_ssh2_sftp_handle_data*)stream->abstract; + ssize_t bytes_read; +@@ -125,7 +137,11 @@ static size_t php_ssh2_sftp_stream_read(php_stream *stream, char *buf, size_t co + + stream->eof = (bytes_read <= 0 && bytes_read != LIBSSH2_ERROR_EAGAIN); + ++#if PHP_VERSION_ID < 70400 + return (size_t)(bytes_read<0 ? 0 : bytes_read); ++#else ++ return bytes_read; ++#endif + } + /* }}} */ + +@@ -264,7 +280,11 @@ static php_stream *php_ssh2_sftp_stream_opener(php_stream_wrapper *wrapper, cons + + /* {{{ php_ssh2_sftp_dirstream_read + */ ++#if PHP_VERSION_ID < 70400 + static size_t php_ssh2_sftp_dirstream_read(php_stream *stream, char *buf, size_t count) ++#else ++static ssize_t php_ssh2_sftp_dirstream_read(php_stream *stream, char *buf, size_t count) ++#endif + { + php_ssh2_sftp_handle_data *data = (php_ssh2_sftp_handle_data*)stream->abstract; + php_stream_dirent *ent = (php_stream_dirent*)buf; diff --git a/php-pecl-ssh2.spec b/php-pecl-ssh2.spec index 287b8f4..63787cf 100644 --- a/php-pecl-ssh2.spec +++ b/php-pecl-ssh2.spec @@ -1,7 +1,7 @@ # remirepo spec file for php-pecl-ssh2 # with SCL compatibility # -# Copyright (c) 2011-2019 Remi Collet +# Copyright (c) 2011-2020 Remi Collet # # Fedora spec file for php-pecl-ssh2 # @@ -23,22 +23,23 @@ %global with_zts 0%{!?_without_zts:%{?__ztsphp:1}} %global pecl_name ssh2 %global ini_name 40-%{pecl_name}.ini +%global buildver %(pkg-config --silence-errors --modversion libssh2 2>/dev/null || echo 65536) Name: %{?sub_prefix}php-pecl-ssh2 +Summary: Bindings for the libssh2 library Version: 1.2 %if 0%{?gh_date} Release: 0.7.%{gh_date}git%{gh_short}%{?dist}%{!?scl:%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')}} Source0: https://github.com/%{gh_owner}/%{gh_project}/archive/%{gh_commit}/%{gh_project}-%{version}%{?prever}-%{gh_short}.tar.gz %else -Release: 1%{?dist}%{!?scl:%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')}} -Source0: http://pecl.php.net/get/%{pecl_name}-%{version}.tgz +Release: 3%{?dist}%{!?scl:%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')}} +Source0: https://pecl.php.net/get/%{pecl_name}-%{version}.tgz %endif -Summary: Bindings for the libssh2 library -%global buildver %(pkg-config --silence-errors --modversion libssh2 2>/dev/null || echo 65536) +Patch0: https://patch-diff.githubusercontent.com/raw/php/pecl-networking-ssh2/pull/44.patch License: PHP -URL: http://pecl.php.net/package/%{pecl_name} +URL: https://pecl.php.net/package/%{pecl_name} BuildRequires: libssh2-devel >= 1.2 BuildRequires: %{?dtsprefix}gcc @@ -59,29 +60,23 @@ Provides: %{?scl_prefix}php-pecl-%{pecl_name} = %{version}-%{rele Provides: %{?scl_prefix}php-pecl-%{pecl_name}%{?_isa} = %{version}-%{release} %endif -%if "%{?vendor}" == "Remi Collet" && 0%{!?scl:1} && 0%{?rhel} +%if "%{?packager}" == "Remi Collet" && 0%{!?scl:1} && 0%{?rhel} # Other third party repo stuff Obsoletes: php53-pecl-%{pecl_name} <= %{version} Obsoletes: php53u-pecl-%{pecl_name} <= %{version} Obsoletes: php54-pecl-%{pecl_name} <= %{version} -Obsoletes: php55u-pecl-%{pecl_name} <= %{version} -Obsoletes: php55w-pecl-%{pecl_name} <= %{version} Obsoletes: php56u-pecl-%{pecl_name} <= %{version} -%if "%{php_version}" > "7.1" -Obsoletes: php71u-pecl-%{pecl_name} <= %{version} -Obsoletes: php71w-pecl-%{pecl_name} <= %{version} -%endif %if "%{php_version}" > "7.2" Obsoletes: php72u-pecl-%{pecl_name} <= %{version} -Obsoletes: php72w-pecl-%{pecl_name} <= %{version} %endif %if "%{php_version}" > "7.3" Obsoletes: php73-pecl-%{pecl_name} <= %{version} -Obsoletes: php73w-pecl-%{pecl_name} <= %{version} %endif %if "%{php_version}" > "7.4" Obsoletes: php74-pecl-%{pecl_name} <= %{version} -Obsoletes: php74w-pecl-%{pecl_name} <= %{version} +%endif +%if "%{php_version}" > "8.0" +Obsoletes: php80-pecl-%{pecl_name} <= %{version} %endif %endif @@ -123,6 +118,8 @@ sed -e 's/role="test"/role="src"/' \ -i package.xml cd NTS +%patch0 -p1 -b .pr43 + extver=$(sed -n '/#define PHP_SSH2_VERSION/{s/.*\t"//;s/".*$//;p}' php_ssh2.h) if test "x${extver}" != "x%{version}%{?gh_date:-dev}"; then : Error: Upstream version is now ${extver}, expecting %{version}%{?gh_date:-dev}. @@ -235,6 +232,13 @@ fi %changelog +* Thu Sep 10 2020 Remi Collet <remi@remirepo.net> - 1.2-3 +- add fix for PHP 8 from + https://github.com/php/pecl-networking-ssh2/pull/42 + +* Wed Mar 11 2020 Remi Collet <remi@remirepo.net> - 1.2-2 +- rebuild + * Wed Sep 18 2019 Remi Collet <remi@remirepo.net> - 1.2-1 - update to 1.2 |