Files
macports-ports/lang/php/files/patch-php52-ext-ftp-ftp_ssl_connect.diff
2020-01-19 00:41:52 -06:00

263 lines
6.4 KiB
Diff

Enable ftps for shared ext/ftp
https://github.com/php/php-src/commit/167979fe76215978efc64fccad454abb22de862a
--- ext/ftp/config.m4.orig 2005-10-31 18:32:21.000000000 -0600
+++ ext/ftp/config.m4 2020-01-19 00:36:18.000000000 -0600
@@ -18,5 +18,6 @@
if test "$PHP_OPENSSL" != "no" || test "$PHP_OPENSSL_DIR" != "no"; then
PHP_SETUP_OPENSSL(FTP_SHARED_LIBADD)
PHP_SUBST(FTP_SHARED_LIBADD)
+ AC_DEFINE(HAVE_FTP_SSL,1,[Whether FTP over SSL is supported])
fi
fi
--- ext/ftp/config.w32.orig 2003-12-02 17:17:04.000000000 -0600
+++ ext/ftp/config.w32 2020-01-19 00:36:18.000000000 -0600
@@ -4,6 +4,16 @@
ARG_ENABLE("ftp", "ftp support", "yes");
if (PHP_FTP == "yes") {
+
EXTENSION("ftp", "php_ftp.c ftp.c");
+
+ if (CHECK_HEADER_ADD_INCLUDE("openssl/ssl.h", "CFLAGS_FTP") &&
+ CHECK_LIB("ssleay32.lib", "ftp", PHP_FTP) &&
+ CHECK_LIB("libeay32.lib", "ftp", PHP_FTP) &&
+ ADD_EXTENSION_DEP("ftp", "openssl", true)) {
+ MESSAGE("Enabling SSL support for ext\\ftp");
+ AC_DEFINE('HAVE_FTP_SSL', 1, 'Have FTP over SSL support');
+ }
+
AC_DEFINE('HAVE_FTP', 1, 'Have FTP support');
}
--- ext/ftp/ftp.c.orig 2010-03-04 06:52:58.000000000 -0600
+++ ext/ftp/ftp.c 2020-01-19 00:36:18.000000000 -0600
@@ -65,7 +65,7 @@
#include <sys/select.h>
#endif
-#if HAVE_OPENSSL_EXT
+#ifdef HAVE_FTP_SSL
#include <openssl/ssl.h>
#endif
@@ -179,7 +179,7 @@
data_close(ftp, ftp->data);
}
if (ftp->fd != -1) {
-#if HAVE_OPENSSL_EXT
+#ifdef HAVE_FTP_SSL
if (ftp->ssl_active) {
SSL_shutdown(ftp->ssl_handle);
}
@@ -241,14 +241,14 @@
int
ftp_login(ftpbuf_t *ftp, const char *user, const char *pass TSRMLS_DC)
{
-#if HAVE_OPENSSL_EXT
+#ifdef HAVE_FTP_SSL
SSL_CTX *ctx = NULL;
#endif
if (ftp == NULL) {
return 0;
}
-#if HAVE_OPENSSL_EXT
+#ifdef HAVE_FTP_SSL
if (ftp->use_ssl && !ftp->ssl_active) {
if (!ftp_putcmd(ftp, "AUTH", "TLS")) {
return 0;
@@ -1243,7 +1243,7 @@
return -1;
}
-#if HAVE_OPENSSL_EXT
+#ifdef HAVE_FTP_SSL
if (ftp->use_ssl && ftp->fd == s && ftp->ssl_active) {
sent = SSL_write(ftp->ssl_handle, buf, size);
} else if (ftp->use_ssl && ftp->fd != s && ftp->use_ssl_for_data && ftp->data->ssl_active) {
@@ -1251,7 +1251,7 @@
} else {
#endif
sent = send(s, buf, size, 0);
-#if HAVE_OPENSSL_EXT
+#ifdef HAVE_FTP_SSL
}
#endif
if (sent == -1) {
@@ -1283,7 +1283,7 @@
return -1;
}
-#if HAVE_OPENSSL_EXT
+#ifdef HAVE_FTP_SSL
if (ftp->use_ssl && ftp->fd == s && ftp->ssl_active) {
nr_bytes = SSL_read(ftp->ssl_handle, buf, len);
} else if (ftp->use_ssl && ftp->fd != s && ftp->use_ssl_for_data && ftp->data->ssl_active) {
@@ -1291,7 +1291,7 @@
} else {
#endif
nr_bytes = recv(s, buf, len, 0);
-#if HAVE_OPENSSL_EXT
+#ifdef HAVE_FTP_SSL
}
#endif
return (nr_bytes);
@@ -1490,7 +1490,7 @@
php_sockaddr_storage addr;
socklen_t size;
-#if HAVE_OPENSSL_EXT
+#ifdef HAVE_FTP_SSL
SSL_CTX *ctx;
#endif
@@ -1508,7 +1508,7 @@
}
data_accepted:
-#if HAVE_OPENSSL_EXT
+#ifdef HAVE_FTP_SSL
/* now enable ssl if we need to */
if (ftp->use_ssl && ftp->use_ssl_for_data) {
@@ -1558,7 +1558,7 @@
return NULL;
}
if (data->listener != -1) {
-#if HAVE_OPENSSL_EXT
+#ifdef HAVE_FTP_SSL
if (data->ssl_active) {
SSL_shutdown(data->ssl_handle);
data->ssl_active = 0;
@@ -1567,7 +1567,7 @@
closesocket(data->listener);
}
if (data->fd != -1) {
-#if HAVE_OPENSSL_EXT
+#ifdef HAVE_FTP_SSL
if (data->ssl_active) {
SSL_shutdown(data->ssl_handle);
data->ssl_active = 0;
--- ext/ftp/ftp.h.orig 2010-01-03 03:23:27.000000000 -0600
+++ ext/ftp/ftp.h 2020-01-19 00:36:18.000000000 -0600
@@ -49,7 +49,7 @@
php_socket_t fd; /* data connection */
ftptype_t type; /* transfer type */
char buf[FTP_BUFSIZE]; /* data buffer */
-#if HAVE_OPENSSL_EXT
+#ifdef HAVE_FTP_SSL
SSL *ssl_handle; /* ssl handle */
int ssl_active; /* flag if ssl is active or not */
#endif
@@ -78,7 +78,7 @@
int lastch; /* last char of previous call */
int direction; /* recv = 0 / send = 1 */
int closestream;/* close or not close stream */
-#if HAVE_OPENSSL_EXT
+#ifdef HAVE_FTP_SSL
int use_ssl; /* enable(1) or disable(0) ssl */
int use_ssl_for_data; /* en/disable ssl for the dataconnection */
int old_ssl; /* old mode = forced data encryption */
--- ext/ftp/php_ftp.c.orig 2010-01-03 03:23:27.000000000 -0600
+++ ext/ftp/php_ftp.c 2020-01-19 00:36:57.000000000 -0600
@@ -29,7 +29,7 @@
#include <novsock2.h>
#endif
-#if HAVE_OPENSSL_EXT
+#ifdef HAVE_FTP_SSL
# include <openssl/ssl.h>
#endif
@@ -52,7 +52,7 @@
ZEND_ARG_INFO(0, timeout)
ZEND_END_ARG_INFO()
-#if HAVE_OPENSSL_EXT
+#ifdef HAVE_FTP_SSL
static
ZEND_BEGIN_ARG_INFO_EX(arginfo_ftp_ssl_connect, 0, 0, 1)
ZEND_ARG_INFO(0, host)
@@ -276,7 +276,7 @@
zend_function_entry php_ftp_functions[] = {
PHP_FE(ftp_connect, arginfo_ftp_connect)
-#if HAVE_OPENSSL_EXT
+#ifdef HAVE_FTP_SSL
PHP_FE(ftp_ssl_connect, arginfo_ftp_ssl_connect)
#endif
PHP_FE(ftp_login, arginfo_ftp_login)
@@ -314,8 +314,22 @@
{NULL, NULL, NULL}
};
+#ifdef HAVE_FTP_SSL
+/* {{{ ftp_deps */
+static const zend_module_dep ftp_deps[] = {
+ ZEND_MOD_REQUIRED("openssl")
+ {NULL, NULL, NULL}
+};/*}}}*/
+#endif
+
zend_module_entry php_ftp_module_entry = {
- STANDARD_MODULE_HEADER,
+ STANDARD_MODULE_HEADER_EX,
+ NULL,
+#ifdef HAVE_FTP_SSL
+ ftp_deps,
+#else
+ NULL,
+#endif
"ftp",
php_ftp_functions,
PHP_MINIT(ftp),
@@ -323,7 +337,7 @@
NULL,
NULL,
PHP_MINFO(ftp),
- NO_VERSION_YET,
+ NO_VERSION_YET,
STANDARD_MODULE_PROPERTIES
};
@@ -358,6 +372,11 @@
{
php_info_print_table_start();
php_info_print_table_row(2, "FTP support", "enabled");
+#ifdef HAVE_FTP_SSL
+ php_info_print_table_row(2, "FTPS support", "enabled");
+#else
+ php_info_print_table_row(2, "FTPS support", "disabled");
+#endif
php_info_print_table_end();
}
@@ -396,7 +415,7 @@
/* autoseek for resuming */
ftp->autoseek = FTP_DEFAULT_AUTOSEEK;
-#if HAVE_OPENSSL_EXT
+#ifdef HAVE_FTP_SSL
/* disable ssl */
ftp->use_ssl = 0;
#endif
@@ -405,7 +424,7 @@
}
/* }}} */
-#if HAVE_OPENSSL_EXT
+#ifdef HAVE_FTP_SSL
/* {{{ proto resource ftp_ssl_connect(string host [, int port [, int timeout]])
Opens a FTP-SSL stream */
PHP_FUNCTION(ftp_ssl_connect)
--- ext/ftp/php_ftp.h.orig 2010-01-03 03:23:27.000000000 -0600
+++ ext/ftp/php_ftp.h 2020-01-19 00:36:18.000000000 -0600
@@ -35,7 +35,7 @@
PHP_MINFO_FUNCTION(ftp);
PHP_FUNCTION(ftp_connect);
-#ifdef HAVE_OPENSSL_EXT
+#ifdef HAVE_FTP_SSL
PHP_FUNCTION(ftp_ssl_connect);
#endif
PHP_FUNCTION(ftp_login);