Repository navigation
fix(site): stop following symlinks from a site's php config volume in restore, update --php and migrations #522
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
Open
mrrobot47
wants to merge
45
commits into
EasyEngine:develop
Choose a base branch
from
mrrobot47:fix/safe-container-config-writes
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
45 commits
Select commit
Hold shift + click to select a range
5f2fff3
fix(templates): drop deprecated session ID ini settings from the PHP …
mrrobot47 e2b97b0
feat(migrations): drop deprecated session ID settings from PHP 8.4 an…
mrrobot47 f43f991
chore(templates): remove the unused phplatest.zip
mrrobot47 afa4eb7
fix(restore): keep session upload progress off after restoring an old…
mrrobot47 d5a67dc
fix(migrations): rewrite php.ini in place instead of through a temp file
mrrobot47 3f9436c
docs(migrations): correct why php.ini is rewritten in place
mrrobot47 671cf81
fix(restore): find PATH and HOST sections with any header layout
mrrobot47 b1792c3
fix(restore): name each section header from the header itself
mrrobot47 5e0b969
fix(restore): detect section headers where the parser expects an entry
mrrobot47 98b44c5
fix(templates): turn off session upload progress in the PHP 8.1 to 8.…
mrrobot47 987a58f
fix(migrations): turn off session upload progress where the v4.13.3 c…
mrrobot47 fff8880
fix(restore): count entries under a bare [PATH] or [HOST] header as g…
mrrobot47 463ac65
fix(migrations): never follow a swapped custom.ini in the recheck mig…
mrrobot47 50432dc
fix(migrations): check the directories above custom.ini in the rechec…
mrrobot47 30264f5
fix(restore): re-add the upload-progress line through a checked handle
mrrobot47 16beb4d
fix(migrations): use the checked file helpers in the recheck migration
mrrobot47 51f14ff
fix(restore): remove and chown created config files from inside their…
mrrobot47 0c36b0c
fix(migrations): bound the recheck migration's reads and chown throug…
mrrobot47 3684b8f
fix(restore): don't create a missing custom.ini, bound the write check
mrrobot47 afda75a
fix(migrations): skip a missing custom.ini in the recheck migration
mrrobot47 af79546
fix(helpers): open container files without blocking on a FIFO
mrrobot47 b97ac06
ci(behat): test this checkout and set up a local rclone remote
mrrobot47 115cd7d
test(behat): cover the upload progress re-check and the restore re-apply
mrrobot47 e59c6db
test(behat): guard the destructive steps and check that the migration…
mrrobot47 3b1e877
fix(migrations): print the manual fix when the recheck fails on a site
mrrobot47 3ba48a8
test(behat): set upload progress On in the fixtures' php.ini
mrrobot47 e3f6300
Merge branch 'fix/php-session-sid-deprecations' into fix/safe-contain…
mrrobot47 5abe8df
fix(utils): check container files before opening them and add shared …
mrrobot47 12fc780
fix(restore): restore the php config in place through checked handles…
mrrobot47 afce73d
fix(migrations): read and rewrite php.ini through the shared checked …
mrrobot47 65ba2be
fix(site): stop the php container while update --php replaces its config
mrrobot47 9fb0691
fix(utils): compare before opening a container file for writing
mrrobot47 cabd2db
fix(restore): create php config files the site lacks from inside its …
mrrobot47 45dbd1f
fix(site): pull the new image before stopping php and roll back a fai…
mrrobot47 7e25409
fix(migrations): drop the php.ini backup when the file was left uncha…
mrrobot47 018f215
fix(migrations): split CR-only php.ini into lines before dropping the…
mrrobot47 62d123a
fix(site): check that no other container mounts the php config volume…
mrrobot47 e06c286
fix(restore): recreate php config subfolders from inside the php cont…
mrrobot47 db09a28
fix(restore): run in-container restore steps as the parent's owner an…
mrrobot47 f8e6049
fix(migrations): leave php.ini as it is when removing the session ID …
mrrobot47 27e6a5f
Merge branch 'fix/php-session-sid-deprecations' into fix/safe-contain…
mrrobot47 ce4b6b2
fix(restore): keep restored php config directories writable until the…
mrrobot47 f1e5456
fix(restore): count control-character names against the php config en…
mrrobot47 0b358b8
fix(update): roll back a PHP switch when saving the site after enabli…
mrrobot47 86b683c
fix(restore): create restored php config files with O_EXCL inside the…
mrrobot47 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,170 @@ | ||
| @remote @destructive | ||
| Feature: Session upload progress stays off | ||
| Re-runs the upgrade migrations on the host (destructive) and backs up to the rclone remote from config.yml. | ||
| Those steps run only on CI or with EE_BEHAT_DESTRUCTIVE=1. | ||
|
|
||
| # "STDOUT should return exactly" checks a scenario's first command, so each check is its own scenario. | ||
| # The scenarios share their sites and run in order. | ||
|
|
||
| Scenario: Sites with a CRLF PATH-only setting, an explicit global On and no custom.ini | ||
| When I run 'bin/ee site create bh-site-command-upload-crlf.test --type=php' | ||
| And I run 'bash features/upload-progress.sh php-ini-on bh-site-command-upload-crlf.test && bash features/upload-progress.sh crlf-path bh-site-command-upload-crlf.test' | ||
| And I run 'bash features/upload-progress.sh probe bh-site-command-upload-crlf.test' | ||
| And I run 'bin/ee site reload bh-site-command-upload-crlf.test' | ||
| And I run 'bin/ee site create bh-site-command-upload-on.test --type=php' | ||
| And I run 'bash features/upload-progress.sh append-on bh-site-command-upload-on.test' | ||
| And I run 'bash features/upload-progress.sh probe bh-site-command-upload-on.test' | ||
| And I run 'bin/ee site reload bh-site-command-upload-on.test' | ||
| And I run 'bash features/upload-progress.sh save bh-site-command-upload-on.test' | ||
| And I run 'bin/ee site create bh-site-command-upload-missing.test --type=php' | ||
| And I run 'bash features/upload-progress.sh remove bh-site-command-upload-missing.test' | ||
| And I run 'bin/ee site reload bh-site-command-upload-missing.test' | ||
| Then return value of command 1 should be 0 | ||
| And return value of command 2 should be 0 | ||
| And return value of command 3 should be 0 | ||
| And return value of command 4 should be 0 | ||
| And return value of command 5 should be 0 | ||
| And return value of command 6 should be 0 | ||
| And return value of command 7 should be 0 | ||
| And return value of command 8 should be 0 | ||
| And return value of command 9 should be 0 | ||
| And return value of command 10 should be 0 | ||
| And return value of command 11 should be 0 | ||
| And return value of command 12 should be 0 | ||
|
|
||
| Scenario: Before the upgrade the PATH-only site runs with upload progress On | ||
| When I run 'curl -s http://bh-site-command-upload-crlf.test/upe.php' | ||
| Then STDOUT should return exactly | ||
| """ | ||
| string(1) "1" | ||
| """ | ||
|
|
||
| Scenario: Upgrade | ||
| When I run 'bash features/upload-progress.sh upgrade' | ||
| Then return value should be 0 | ||
| And STDERR should return something like | ||
| """ | ||
| Skipped disabling session.upload_progress for bh-site-command-upload-missing.test: custom.ini is missing or not a regular file. | ||
| """ | ||
|
|
||
| Scenario: The PATH-only site runs with upload progress Off | ||
| When I run 'sleep 3; curl -s http://bh-site-command-upload-crlf.test/upe.php' | ||
| Then STDOUT should return exactly | ||
| """ | ||
| string(0) "" | ||
| """ | ||
|
|
||
| Scenario: The Off line is at the top | ||
| When I run 'bash features/upload-progress.sh line2 bh-site-command-upload-crlf.test' | ||
| Then STDOUT should return exactly | ||
| """ | ||
| session.upload_progress.enabled = Off | ||
| """ | ||
|
|
||
| Scenario: The explicit On is kept | ||
| When I run 'curl -s http://bh-site-command-upload-on.test/upe.php' | ||
| Then STDOUT should return exactly | ||
| """ | ||
| string(1) "1" | ||
| """ | ||
|
|
||
| Scenario: The file with the explicit On is unchanged | ||
| When I run 'bash features/upload-progress.sh same bh-site-command-upload-on.test' | ||
| Then STDOUT should return exactly | ||
| """ | ||
| same | ||
| """ | ||
|
|
||
| Scenario: A missing custom.ini is not created by the upgrade | ||
| When I run 'bash features/upload-progress.sh exists bh-site-command-upload-missing.test' | ||
| Then STDOUT should return exactly | ||
| """ | ||
| missing | ||
| """ | ||
|
|
||
| Scenario: Run the migration again | ||
| When I run 'bash features/upload-progress.sh save bh-site-command-upload-crlf.test && bash features/upload-progress.sh upgrade' | ||
| Then return value should be 0 | ||
| And STDERR should return something like | ||
| """ | ||
| Skipped disabling session.upload_progress for bh-site-command-upload-missing.test: custom.ini is missing or not a regular file. | ||
| """ | ||
|
|
||
| Scenario: A second run changes nothing | ||
| When I run 'bash features/upload-progress.sh same bh-site-command-upload-crlf.test' | ||
| Then STDOUT should return exactly | ||
| """ | ||
| same | ||
| """ | ||
|
|
||
| Scenario: Back up a site whose custom.ini lacks the Off line | ||
| When I run 'bin/ee site create bh-site-command-upload-restore.test --type=php' | ||
| And I run 'bash features/upload-progress.sh php-ini-on bh-site-command-upload-restore.test && bash features/upload-progress.sh strip bh-site-command-upload-restore.test' | ||
| And I run 'bash features/upload-progress.sh probe bh-site-command-upload-restore.test' | ||
| And I run 'bin/ee site reload bh-site-command-upload-restore.test' | ||
| And I run 'bash features/upload-progress.sh backup bh-site-command-upload-restore.test' | ||
| Then return value of command 1 should be 0 | ||
| And return value of command 2 should be 0 | ||
| And return value of command 3 should be 0 | ||
| And return value of command 4 should be 0 | ||
| And return value of command 5 should be 0 | ||
|
|
||
| Scenario: Without the Off line the site runs with upload progress On | ||
| When I run 'curl -s http://bh-site-command-upload-restore.test/upe.php' | ||
| Then STDOUT should return exactly | ||
| """ | ||
| string(1) "1" | ||
| """ | ||
|
|
||
| Scenario: Restoring that backup turns upload progress off again | ||
| When I run 'bash features/upload-progress.sh restore bh-site-command-upload-restore.test' | ||
| Then return value should be 0 | ||
| And STDOUT should return something like | ||
| """ | ||
| The restored custom.ini did not set session.upload_progress.enabled, so it was set to Off again. | ||
| """ | ||
|
|
||
| Scenario: The restored file has the Off line at the top | ||
| When I run 'bash features/upload-progress.sh line2 bh-site-command-upload-restore.test' | ||
| Then STDOUT should return exactly | ||
| """ | ||
| session.upload_progress.enabled = Off | ||
| """ | ||
|
|
||
| Scenario: The restored site runs with upload progress Off | ||
| When I run 'sleep 3; curl -s http://bh-site-command-upload-restore.test/upe.php' | ||
| Then STDOUT should return exactly | ||
| """ | ||
| string(0) "" | ||
| """ | ||
|
|
||
| Scenario: Back up the site without custom.ini | ||
| When I run 'bash features/upload-progress.sh backup bh-site-command-upload-missing.test' | ||
| Then return value should be 0 | ||
|
|
||
| Scenario: Restoring a backup without custom.ini warns instead of creating it | ||
| When I run 'bash features/upload-progress.sh restore bh-site-command-upload-missing.test' | ||
| Then return value should be 0 | ||
| And STDERR should return something like | ||
| """ | ||
| Could not check session.upload_progress in the restored custom.ini: it is missing or not a regular file. | ||
| """ | ||
|
|
||
| Scenario: The restore did not create custom.ini | ||
| When I run 'bash features/upload-progress.sh exists bh-site-command-upload-missing.test' | ||
| Then STDOUT should return exactly | ||
| """ | ||
| missing | ||
| """ | ||
|
|
||
| Scenario: Clean up | ||
| When I run 'bin/ee site delete bh-site-command-upload-crlf.test --yes' | ||
| And I run 'bin/ee site delete bh-site-command-upload-on.test --yes' | ||
| And I run 'bin/ee site delete bh-site-command-upload-missing.test --yes' | ||
| And I run 'bin/ee site delete bh-site-command-upload-restore.test --yes' | ||
| And I run 'bash features/upload-progress.sh clean' | ||
| Then return value of command 1 should be 0 | ||
| And return value of command 2 should be 0 | ||
| And return value of command 3 should be 0 | ||
| And return value of command 4 should be 0 | ||
| And return value of command 5 should be 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| #!/bin/bash | ||
| # upload-progress.sh <action> [<site>]: helpers for upload-progress.feature, whose steps can't nest quotes. | ||
| set -e | ||
| ini=/opt/easyengine/sites/$2/config/php/php/conf.d/custom.ini | ||
| guard() { | ||
| if [ -z "$CI" ] && [ "$EE_BEHAT_DESTRUCTIVE" != 1 ]; then | ||
| echo "$1 re-runs the upgrade migrations or uses the rclone remote: only on CI or with EE_BEHAT_DESTRUCTIVE=1" >&2 | ||
| exit 1 | ||
| fi | ||
| } | ||
| case $1 in | ||
| # Before v4.13.3 neither php.ini nor custom.ini set it; On is set explicitly so newer templates and images don't hide the gap. | ||
| php-ini-on) sed -i '/session\.upload_progress\.enabled/d' "${ini%/conf.d/custom.ini}/php.ini"; printf '\nsession.upload_progress.enabled = On\n' >> "${ini%/conf.d/custom.ini}/php.ini" ;; | ||
| crlf-path) printf 'upload_max_filesize = 100M\r\n[PATH=/var/www/htdocs/x]\r\nsession.upload_progress.enabled = Off\r\n' > "$ini" ;; | ||
| append-on) printf '\nsession.upload_progress.enabled = On\n' >> "$ini" ;; | ||
| strip) sed -i '/session\.upload_progress\.enabled/d; /Session upload progress is off/d' "$ini" ;; | ||
| remove) rm "$ini" ;; | ||
| exists) if [ -e "$ini" ] || [ -L "$ini" ]; then echo present; else echo missing; fi ;; | ||
| probe) printf '%s' '<?php var_dump(ini_get("session.upload_progress.enabled"));' > "/opt/easyengine/sites/$2/app/htdocs/upe.php" ;; | ||
| # Runs the upgrade migrations again, the re-check included. | ||
| upgrade) | ||
| guard upgrade | ||
| php <<'PHP' | ||
| <?php | ||
| $db = new PDO( 'sqlite:/opt/easyengine/db/ee.sqlite' ); | ||
| $db->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION ); | ||
| $db->exec( "DELETE FROM migrations WHERE migration LIKE '%recheck_session_upload_progress%'" ); | ||
| $db->exec( "UPDATE options SET value = '4.13.2' WHERE key = 'version'" ); | ||
| PHP | ||
| bin/ee cli info ;; | ||
| backup | restore) guard "$1"; bin/ee site "$1" "$2" ;; | ||
| save) cp "$ini" "/tmp/upload-progress-$2.before" ;; | ||
| same) cmp "/tmp/upload-progress-$2.before" "$ini" && echo same ;; | ||
| line2) tr -s '\r\n' '\n' < "$ini" | sed -n 2p ;; | ||
| clean) rm -f /tmp/upload-progress-bh-site-command-upload-*.before ;; | ||
| *) echo "unknown action $1" >&2; exit 1 ;; | ||
| esac |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.