Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop statically compiling the FTP extension #1482

Merged
merged 2 commits into from
Jan 3, 2024

Conversation

TimWolla
Copy link
Contributor

According to the documentation of ftp_ssl_connect(), the limitation of requiring a static build was lifted with PHP 7.0. Thus stop forcibly including the FTP extension, which should be needed somewhat rarely.

Example:

root@2a4c93db4a86:/var/www/html# apt-get update -qqqqq
root@2a4c93db4a86:/var/www/html# apt-get install -yyyyqqqq libssl-dev
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package libssl-dev:amd64.
(Reading database ... 13257 files and directories currently installed.)
Preparing to unpack .../libssl-dev_3.0.11-1~deb12u2_amd64.deb ...
Unpacking libssl-dev:amd64 (3.0.11-1~deb12u2) ...
Setting up libssl-dev:amd64 (3.0.11-1~deb12u2) ...
root@2a4c93db4a86:/var/www/html# docker-php-ext-configure ftp --with-openssl-dir >/dev/null
root@2a4c93db4a86:/var/www/html# docker-php-ext-install ftp >/dev/null
+ strip --strip-all modules/ftp.so
root@2a4c93db4a86:/var/www/html# php -r "var_dump(function_exists('ftp_ssl_connect'));"
bool(true)

According to the documentation of `ftp_ssl_connect()`, the limitation of
requiring a static build was lifted with PHP 7.0. Thus stop forcibly including
the FTP extension, which should be needed somewhat rarely.

Example:

    root@2a4c93db4a86:/var/www/html# apt-get update -qqqqq
    root@2a4c93db4a86:/var/www/html# apt-get install -yyyyqqqq libssl-dev
    debconf: delaying package configuration, since apt-utils is not installed
    Selecting previously unselected package libssl-dev:amd64.
    (Reading database ... 13257 files and directories currently installed.)
    Preparing to unpack .../libssl-dev_3.0.11-1~deb12u2_amd64.deb ...
    Unpacking libssl-dev:amd64 (3.0.11-1~deb12u2) ...
    Setting up libssl-dev:amd64 (3.0.11-1~deb12u2) ...
    root@2a4c93db4a86:/var/www/html# docker-php-ext-configure ftp --with-openssl-dir >/dev/null
    root@2a4c93db4a86:/var/www/html# docker-php-ext-install ftp >/dev/null
    + strip --strip-all modules/ftp.so
    root@2a4c93db4a86:/var/www/html# php -r "var_dump(function_exists('ftp_ssl_connect'));"
    bool(true)
@@ -318,8 +318,10 @@ RUN set -eux; \
# https://github.com/docker-library/php/issues/822
--with-pic \
\
# --enable-ftp is included here because ftp_ssl_connect() needs ftp to be compiled statically (see https://github.com/docker-library/php/issues/236)
{{ if [ "8.1", "8.2", "8.3" ] | index(env.version | rtrimstr("-rc")) then ( -}}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How often is the ftp module used? I know this is extra conservative and so will only drop the module in 8.4 and above. Would it make sense to change at the next patch releases, like 8.1.28, 8.2.15, and 8.3.2 or would there be too much breakage? Or maybe just some of them, like 8.3.2 and above?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is extra conservative. I would expect the FTP extension to be used primarily in legacy code. Personally I've not used it ever.

GitHub's code search for ftp_connect reports 8.6k results (with some of them being the php-src stubs and some of them not being the actual ftp_connect function of the FTP extension).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, let's still be conservative for the current versions, but slightly more aggressive on even the next patch releases (the mitigation for the subset of affected users is pretty trivial); maybe something like this:

Suggested change
{{ if [ "8.1", "8.2", "8.3" ] | index(env.version | rtrimstr("-rc")) then ( -}}
{{ if .version as $v | [ "8.1.27", "8.2.14", "8.3.1" ] | index($v) then ( -}}

❤️

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Applied.

@tianon tianon merged commit 641cf9a into docker-library:master Jan 3, 2024
44 checks passed
@tianon
Copy link
Member

tianon commented Jan 3, 2024

Thank you!

docker-library-bot added a commit to docker-library-bot/official-images that referenced this pull request Jan 3, 2024
Changes:

- docker-library/php@641cf9a2: Stop statically compiling the FTP extension (docker-library/php#1482)
docker-library-bot added a commit to docker-library-bot/official-images that referenced this pull request Jan 4, 2024
Changes:

- docker-library/php@d25f4810: Update 8.3-rc to 8.3.2RC1
- docker-library/php@b8d8b370: Update 8.2-rc to 8.2.15RC1
- docker-library/php@641cf9a2: Stop statically compiling the FTP extension (docker-library/php#1482)
@TimWolla TimWolla deleted the enable-ftp branch January 5, 2024 12:20
TimWolla added a commit to TimWolla/docker-php that referenced this pull request Feb 1, 2024
8.1.x is security-only and future releases happen on a case to case basis to
fix security issues only. We likely should not break the build for those folks
still on 8.1.

see docker-library#1482
therealartz added a commit to DH-Enterprise/laradock that referenced this pull request Mar 18, 2024
martin-g pushed a commit to martin-g/docker-official-images that referenced this pull request Apr 3, 2024
Changes:

- docker-library/php@d25f4810: Update 8.3-rc to 8.3.2RC1
- docker-library/php@b8d8b370: Update 8.2-rc to 8.2.15RC1
- docker-library/php@641cf9a2: Stop statically compiling the FTP extension (docker-library/php#1482)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants