From fd092caca37ed0cc992ed08e3357b28f2bfc3c9b Mon Sep 17 00:00:00 2001 From: Oguz Kocer Date: Wed, 14 Aug 2024 13:44:38 -0400 Subject: [PATCH 1/3] Run integration test server as 'www-data' user --- scripts/start-wp-api-integration-tests-backend.sh | 2 ++ wordpress.Dockerfile | 3 --- wp_cli/src/lib.rs | 4 +--- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/scripts/start-wp-api-integration-tests-backend.sh b/scripts/start-wp-api-integration-tests-backend.sh index 76a350a4..02611097 100755 --- a/scripts/start-wp-api-integration-tests-backend.sh +++ b/scripts/start-wp-api-integration-tests-backend.sh @@ -4,4 +4,6 @@ cd /app cargo build --release -p wp_api_integration_tests_backend + +su -s /bin/bash www-data nohup ./target/release/wp_api_integration_tests_backend > ./target/release/wp_api_integration_tests_backend.log & diff --git a/wordpress.Dockerfile b/wordpress.Dockerfile index dd3cf53c..90f67021 100644 --- a/wordpress.Dockerfile +++ b/wordpress.Dockerfile @@ -13,9 +13,6 @@ RUN mkdir -p /var/www/.wp-cli ENV PATH="/root/.cargo/bin:${PATH}" RUN chown -R www-data:www-data /var/www/.wp-cli/ -# Run this command as root user since that's what the Docker will use when we run --http=http://localhost commands -RUN wp --allow-root package install wp-cli/restful - # Setup Rust RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y RUN rustup target add x86_64-linux-android i686-linux-android armv7-linux-androideabi aarch64-linux-android diff --git a/wp_cli/src/lib.rs b/wp_cli/src/lib.rs index 828ce5b7..e38ebe8b 100644 --- a/wp_cli/src/lib.rs +++ b/wp_cli/src/lib.rs @@ -12,9 +12,7 @@ where S: AsRef, { let mut c = Command::new("wp"); - c.arg("--allow-root") - .arg("--http=http://localhost") - .arg("--path=/var/www/html") + c.arg("--path=/var/www/html") .arg("--format=json") .args(args); println!("Running wp_cli command: {:#?}", c); From eacf6ecd2d717ef9f66db4f3ab3c0a7bf4dcc547 Mon Sep 17 00:00:00 2001 From: Oguz Kocer Date: Wed, 14 Aug 2024 13:49:24 -0400 Subject: [PATCH 2/3] Update run-wp-cli-command Make task to use `www-data` user --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 145fdda1..cfe39e00 100644 --- a/Makefile +++ b/Makefile @@ -279,7 +279,7 @@ setup-rust-android-targets: aarch64-linux-android run-wp-cli-command: - @docker exec wordpress /bin/bash -c "wp --allow-root $(ARGS)" + @docker exec --user www-data wordpress /bin/bash -c "wp $(ARGS)" help: @printf "%-40s %s\n" "Target" "Description" From 8e4615dc92a6718762cfcc413d11d51683f12ff6 Mon Sep 17 00:00:00 2001 From: Oguz Kocer Date: Wed, 14 Aug 2024 14:15:39 -0400 Subject: [PATCH 3/3] Try reverting the removal of wp-cli/restful --- scripts/setup-test-site.sh | 2 ++ wp_cli/src/lib.rs | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/setup-test-site.sh b/scripts/setup-test-site.sh index df410d0d..f4be04a9 100755 --- a/scripts/setup-test-site.sh +++ b/scripts/setup-test-site.sh @@ -12,6 +12,8 @@ set -e # be any weird permissions issues) su -s /bin/bash www-data +wp package install wp-cli/restful + ## Wait for the DB to be ready before attempting install – Docker can do this for us, but we get way better ## diagnostic information from `wp db check`, whereas if `wp core install` fails it won't tell us about issues ## like incompatible SSL cipher suites (which is a problem in the WP 5.7 image when used with MySQL 8+) diff --git a/wp_cli/src/lib.rs b/wp_cli/src/lib.rs index e38ebe8b..3dbfdf7b 100644 --- a/wp_cli/src/lib.rs +++ b/wp_cli/src/lib.rs @@ -12,7 +12,8 @@ where S: AsRef, { let mut c = Command::new("wp"); - c.arg("--path=/var/www/html") + c.arg("--http=http://localhost") + .arg("--path=/var/www/html") .arg("--format=json") .args(args); println!("Running wp_cli command: {:#?}", c);