diff options
author | Andy Postnikov <apostnikov@gmail.com> | 2020-09-10 18:56:13 +0300 |
---|---|---|
committer | Andy Postnikov <apostnikov@gmail.com> | 2020-09-10 18:56:13 +0300 |
commit | ff9d151348f709b81b8d3587fab4eac90bf076a8 (patch) | |
tree | 04d185011ddbf8cfe0dd8c31d0c9ceaff4da9d86 | |
parent | 3834f84f435cc158a3c8ab70f6808992a72e7558 (diff) |
community/php7-pecl-ssh2: add patch to fix bugs
streams support for PHP 7.4 and function definitions
-rw-r--r-- | community/php7-pecl-ssh2/APKBUILD | 23 | ||||
-rw-r--r-- | community/php7-pecl-ssh2/fix-streams.patch | 287 |
2 files changed, 298 insertions, 12 deletions
diff --git a/community/php7-pecl-ssh2/APKBUILD b/community/php7-pecl-ssh2/APKBUILD index 7ae2d39d180..2789db6f1a1 100644 --- a/community/php7-pecl-ssh2/APKBUILD +++ b/community/php7-pecl-ssh2/APKBUILD @@ -3,18 +3,16 @@ pkgname=php7-pecl-ssh2 _pkgreal=ssh2 pkgver=1.2 -pkgrel=1 +pkgrel=2 pkgdesc="PHP extension provide bindings for the libssh2 library - PECL" url="https://pecl.php.net/package/ssh2" arch="all" license="PHP-3.01" depends="php7-common" -makedepends="php7-dev autoconf libssh2-dev re2c" -# PECL source is not avaliable for 1.2 https://bugs.php.net/bug.php?id=78560 -_ver="${pkgver//./_}" -_ghdir="pecl-networking-ssh2-RELEASE_$_ver" -source="$_ghdir.tgz::https://github.com/php/pecl-networking-ssh2/archive/RELEASE_$_ver.tar.gz" -builddir="$srcdir/$_ghdir" +makedepends="php7-dev libssh2-dev" +source="$pkgname.tgz::https://pecl.php.net/get/$_pkgreal-$pkgver.tgz + fix-streams.patch" # ref https://github.com/php/pecl-networking-ssh2/pull/44 +builddir="$srcdir/$_pkgreal-$pkgver" provides="php7-ssh2=$pkgver-r$pkgrel" # for backward compatibility replaces="php7-ssh2" # for backward compatibility @@ -27,14 +25,15 @@ build() { check() { make NO_INTERACTION=1 REPORT_EXIT_STATUS=1 test # Check extension loading, testsuite skips tests if extension broken - php7 -d extension="$builddir"/modules/$_pkgreal.so --ri $_pkgreal + php7 -d extension=modules/$_pkgreal.so --ri $_pkgreal } package() { make INSTALL_ROOT="$pkgdir/" install - - install -d "$pkgdir"/etc/php7/conf.d - echo "extension=$_pkgreal.so" > "$pkgdir"/etc/php7/conf.d/$_pkgreal.ini + local _confdir=/etc/php7/conf.d + install -d "$pkgdir"$_confdir + echo "extension=$_pkgreal.so" > "$pkgdir"$_confdir/$_pkgreal.ini } -sha512sums="8b5dad15028d60b059d1b6721879ad53956e77ded4fb39218907019f7b8a28b0d77641f9f8ed502c14b9757bbb10232aa1cf192146d9ee5a0c025d132c0ada82 pecl-networking-ssh2-RELEASE_1_2.tgz" +sha512sums="7b7d311cd5f88835e124d70a0295468f75d0fa6936a58808c936d1a185bb630b9e02c21f49b4bd777194a7b104aa3ff85c4fbf480f43d5906787e532ba2d3e04 php7-pecl-ssh2.tgz +b8df2018b8b3645077299f54d0dc4daf81606d5dad84248c8ff014b0bafb0217c92685efad21bfbb42b32b55602ed308706f40cd0bacbaee6e7771dbb9fe4a4d fix-streams.patch" diff --git a/community/php7-pecl-ssh2/fix-streams.patch b/community/php7-pecl-ssh2/fix-streams.patch new file mode 100644 index 00000000000..3af71f10ed8 --- /dev/null +++ b/community/php7-pecl-ssh2/fix-streams.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; |