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

Move $HOME env variable outside web server's Document root #454

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion 7.4/Dockerfile.rhel7
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ ENV PHP_CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/php/ \
HTTPD_DATA_PATH=/var/www \
HTTPD_DATA_ORIG_PATH=/opt/rh/httpd24/root/var/www \
HTTPD_VAR_PATH=/opt/rh/httpd24/root/var \
SCL_ENABLED=rh-php74
SCL_ENABLED=rh-php74 \
HOME=/opt/app-root

# Copy the S2I scripts from the specific language image to $STI_SCRIPTS_PATH
COPY ./s2i/bin/ $STI_SCRIPTS_PATH
Expand Down
3 changes: 2 additions & 1 deletion 7.4/Dockerfile.rhel8
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ ENV PHP_CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/php/ \
HTTPD_VAR_RUN=/var/run/httpd \
HTTPD_DATA_PATH=/var/www \
HTTPD_DATA_ORIG_PATH=/var/www \
HTTPD_VAR_PATH=/var
HTTPD_VAR_PATH=/var \
HOME=/opt/app-root

# Copy the S2I scripts from the specific language image to $STI_SCRIPTS_PATH
COPY ./s2i/bin/ $STI_SCRIPTS_PATH
Expand Down
3 changes: 2 additions & 1 deletion 8.0/Dockerfile.rhel8
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ ENV PHP_CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/php/ \
HTTPD_VAR_RUN=/var/run/httpd \
HTTPD_DATA_PATH=/var/www \
HTTPD_DATA_ORIG_PATH=/var/www \
HTTPD_VAR_PATH=/var
HTTPD_VAR_PATH=/var \
HOME=/opt/app-root

# Copy the S2I scripts from the specific language image to $STI_SCRIPTS_PATH
COPY ./s2i/bin/ $STI_SCRIPTS_PATH
Expand Down
3 changes: 2 additions & 1 deletion 8.0/Dockerfile.rhel9
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ ENV PHP_CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/php/ \
HTTPD_VAR_RUN=/var/run/httpd \
HTTPD_DATA_PATH=/var/www \
HTTPD_DATA_ORIG_PATH=/var/www \
HTTPD_VAR_PATH=/var
HTTPD_VAR_PATH=/var \
HOME=/opt/app-root

# Copy the S2I scripts from the specific language image to $STI_SCRIPTS_PATH
COPY ./s2i/bin/ $STI_SCRIPTS_PATH
Expand Down
3 changes: 2 additions & 1 deletion 8.1/Dockerfile.fedora
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ ENV PHP_CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/php/ \
HTTPD_VAR_RUN=/var/run/httpd \
HTTPD_DATA_PATH=/var/www \
HTTPD_DATA_ORIG_PATH=/var/www \
HTTPD_VAR_PATH=/var
HTTPD_VAR_PATH=/var \
HOME=/opt/app-root

# Copy the S2I scripts from the specific language image to $STI_SCRIPTS_PATH
COPY ./s2i/bin/ $STI_SCRIPTS_PATH
Expand Down
3 changes: 2 additions & 1 deletion 8.1/Dockerfile.rhel9
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ ENV PHP_CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/php/ \
HTTPD_VAR_RUN=/var/run/httpd \
HTTPD_DATA_PATH=/var/www \
HTTPD_DATA_ORIG_PATH=/var/www \
HTTPD_VAR_PATH=/var
HTTPD_VAR_PATH=/var \
HOME=/opt/app-root

# Copy the S2I scripts from the specific language image to $STI_SCRIPTS_PATH
COPY ./s2i/bin/ $STI_SCRIPTS_PATH
Expand Down
3 changes: 2 additions & 1 deletion 8.2/Dockerfile.fedora
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ ENV PHP_CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/php/ \
HTTPD_VAR_RUN=/var/run/httpd \
HTTPD_DATA_PATH=/var/www \
HTTPD_DATA_ORIG_PATH=/var/www \
HTTPD_VAR_PATH=/var
HTTPD_VAR_PATH=/var \
HOME=/opt/app-root

# Copy the S2I scripts from the specific language image to $STI_SCRIPTS_PATH
COPY ./s2i/bin/ $STI_SCRIPTS_PATH
Expand Down
3 changes: 2 additions & 1 deletion 8.2/Dockerfile.rhel8
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ ENV PHP_CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/php/ \
HTTPD_VAR_RUN=/var/run/httpd \
HTTPD_DATA_PATH=/var/www \
HTTPD_DATA_ORIG_PATH=/var/www \
HTTPD_VAR_PATH=/var
HTTPD_VAR_PATH=/var \
HOME=/opt/app-root

# Copy the S2I scripts from the specific language image to $STI_SCRIPTS_PATH
COPY ./s2i/bin/ $STI_SCRIPTS_PATH
Expand Down
3 changes: 2 additions & 1 deletion 8.2/Dockerfile.rhel9
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ ENV PHP_CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/php/ \
HTTPD_VAR_RUN=/var/run/httpd \
HTTPD_DATA_PATH=/var/www \
HTTPD_DATA_ORIG_PATH=/var/www \
HTTPD_VAR_PATH=/var
HTTPD_VAR_PATH=/var \
HOME=/opt/app-root

# Copy the S2I scripts from the specific language image to $STI_SCRIPTS_PATH
COPY ./s2i/bin/ $STI_SCRIPTS_PATH
Expand Down
20 changes: 20 additions & 0 deletions test/run
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ test_ssl
test_ssl_own_cert
ct_npm_works
test_build_from_dockerfile
test_home_not_in_webroot
"

TEST_CLEAR_ENV="\
Expand Down Expand Up @@ -162,6 +163,25 @@ test_config_writeable() {
docker run --rm "${IMAGE_NAME}" /bin/bash -c "${run_cmd}"
}

test_home_not_in_webroot() {
cid_file=$CID_FILE_DIR/$(mktemp -u -p . --suffix .cid)
docker run -d --cidfile=${cid_file} ${IMAGE_NAME}-testapp

# Wait for container to initialize fully
test_connection ${test_port}

info "Testing whether \$HOME points to web server Document root"
local homef=$(docker exec -it $(cat ${cid_file}) /bin/bash -c "echo \$HOME")
ct_check_testcase_result $?
if [ "${homef}" = "${homef##/opt/app-root/src}" ]; then
echo "Home folder not set to Document root"
return 0
fi

info "Home folder set to Document root"
return 1
}

test_clear_env_setup() {
local run_cmd="[ -f /etc/php-fpm.d/www.conf ] && grep \"^clear_env = no\" /etc/php-fpm.d/www.conf"

Expand Down