From eb090e609f90a45f6986492c3e49c94a50e8e815 Mon Sep 17 00:00:00 2001 From: Alex Date: Sat, 3 Aug 2024 17:25:50 +0100 Subject: [PATCH 1/5] #3710 Fix for php sessions after upgrade --- install.sh | 22 ++++++++++++++++++++++ scripts/installUpgradeFunctions.sh | 13 +++++++++++++ 2 files changed, 35 insertions(+) diff --git a/install.sh b/install.sh index 12393a156..d1756ef5f 100755 --- a/install.sh +++ b/install.sh @@ -935,6 +935,28 @@ set_permissions() sudo find "${ALLSKY_WEBSITE}" -type d -exec chmod 775 '{}' \; sudo find "${ALLSKY_WEBSITE}" -type f -exec chmod 664 '{}' \; sudo chgrp --recursive "${WEBSERVER_GROUP}" "${ALLSKY_WEBSITE}" + + # Get the session handler type from th ephp ini file + SESSION_HANDLER="$( get_php_setting "session.save_handler" )" + # We need to make changes if the handler is using the filesystem + if [[ $SESSION_HANDLER == "files" ]]; then + # Get the path to the php sessions + SESSION_PATH="$( get_php_setting "session.save_path" )" + + # Loop over all files in the session folder and if any are not owned by the + # web server user then changs ALL of the php sessions to be owned by the + # web server user + sudo find "$SESSION_PATH" -type f -print0 | while read -r -d $'\0' SESSION_FILE + do + OWNER="$( sudo stat -c '%U' "$SESSION_FILE" )" + if [[ $OWNER != "$WEBSERVER_OWNER" ]]; then + display_msg --log progress "Found php sessions with wrong owner - fixing them" + sudo chown -R "$WEBSERVER_OWNER":"$WEBSERVER_OWNER" "$SESSION_PATH" + break + fi + done + fi + } diff --git a/scripts/installUpgradeFunctions.sh b/scripts/installUpgradeFunctions.sh index 89dd4fcec..24e94af9e 100644 --- a/scripts/installUpgradeFunctions.sh +++ b/scripts/installUpgradeFunctions.sh @@ -971,3 +971,16 @@ function get_computer() echo "${MODEL}, ${GB} GB" } +# +# Get a value from the php ini file, using php rather than parsing the ini +# files directly. This does assume that both the cli and cgi settings files +# work in the same way. +# +get_php_setting() { + local SETTING= + local SETTING_VALUE + + SETTING=$1 + SETTING_VALUE="$( php -r "echo ini_get('$SETTING');" )" + echo "$SETTING_VALUE" +} From 522a9171ec4af2f6b62cd87c0773cae32af295b9 Mon Sep 17 00:00:00 2001 From: Alex Date: Sat, 3 Aug 2024 17:59:16 +0100 Subject: [PATCH 2/5] 3710 Change log message to notice --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index d1756ef5f..c286dd567 100755 --- a/install.sh +++ b/install.sh @@ -950,7 +950,7 @@ set_permissions() do OWNER="$( sudo stat -c '%U' "$SESSION_FILE" )" if [[ $OWNER != "$WEBSERVER_OWNER" ]]; then - display_msg --log progress "Found php sessions with wrong owner - fixing them" + display_msg --log warning "Found php sessions with wrong owner - fixing them" sudo chown -R "$WEBSERVER_OWNER":"$WEBSERVER_OWNER" "$SESSION_PATH" break fi From 6b1d066cbc8a72eeafe83de1306e8c6f5358747d Mon Sep 17 00:00:00 2001 From: Alex Date: Sat, 3 Aug 2024 18:03:57 +0100 Subject: [PATCH 3/5] 3710 Change log message to info --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index c286dd567..dae0cebec 100755 --- a/install.sh +++ b/install.sh @@ -950,7 +950,7 @@ set_permissions() do OWNER="$( sudo stat -c '%U' "$SESSION_FILE" )" if [[ $OWNER != "$WEBSERVER_OWNER" ]]; then - display_msg --log warning "Found php sessions with wrong owner - fixing them" + display_msg --log info "Found php sessions with wrong owner - fixing them" sudo chown -R "$WEBSERVER_OWNER":"$WEBSERVER_OWNER" "$SESSION_PATH" break fi From 92922288734782ad8d9b01706d0aa399325c609d Mon Sep 17 00:00:00 2001 From: Eric Claeys <83164203+EricClaeys@users.noreply.github.com> Date: Sat, 3 Aug 2024 23:56:46 -0600 Subject: [PATCH 4/5] Update install.sh: add { } --- install.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/install.sh b/install.sh index dae0cebec..c256cfd9a 100755 --- a/install.sh +++ b/install.sh @@ -939,19 +939,19 @@ set_permissions() # Get the session handler type from th ephp ini file SESSION_HANDLER="$( get_php_setting "session.save_handler" )" # We need to make changes if the handler is using the filesystem - if [[ $SESSION_HANDLER == "files" ]]; then + if [[ ${SESSION_HANDLER} == "files" ]]; then # Get the path to the php sessions SESSION_PATH="$( get_php_setting "session.save_path" )" # Loop over all files in the session folder and if any are not owned by the # web server user then changs ALL of the php sessions to be owned by the # web server user - sudo find "$SESSION_PATH" -type f -print0 | while read -r -d $'\0' SESSION_FILE + sudo find "${SESSION_PATH}" -type f -print0 | while read -r -d $'\0' SESSION_FILE do - OWNER="$( sudo stat -c '%U' "$SESSION_FILE" )" - if [[ $OWNER != "$WEBSERVER_OWNER" ]]; then + OWNER="$( sudo stat -c '%U' "${SESSION_FILE}" )" + if [[ ${OWNER} != "${WEBSERVER_OWNER}" ]]; then display_msg --log info "Found php sessions with wrong owner - fixing them" - sudo chown -R "$WEBSERVER_OWNER":"$WEBSERVER_OWNER" "$SESSION_PATH" + sudo chown -R "${WEBSERVER_OWNER}":"${WEBSERVER_OWNER}" "${SESSION_PATH}" break fi done From dca119b8885e4b8d9be90b3bed03271d3e467ae5 Mon Sep 17 00:00:00 2001 From: Eric Claeys <83164203+EricClaeys@users.noreply.github.com> Date: Sun, 4 Aug 2024 00:03:27 -0600 Subject: [PATCH 5/5] Update installUpgradeFunctions.sh: use { } And a slight optimization --- scripts/installUpgradeFunctions.sh | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/scripts/installUpgradeFunctions.sh b/scripts/installUpgradeFunctions.sh index 24e94af9e..5b8a1c711 100644 --- a/scripts/installUpgradeFunctions.sh +++ b/scripts/installUpgradeFunctions.sh @@ -971,16 +971,13 @@ function get_computer() echo "${MODEL}, ${GB} GB" } -# + +#### # Get a value from the php ini file, using php rather than parsing the ini # files directly. This does assume that both the cli and cgi settings files # work in the same way. # get_php_setting() { - local SETTING= - local SETTING_VALUE - - SETTING=$1 - SETTING_VALUE="$( php -r "echo ini_get('$SETTING');" )" - echo "$SETTING_VALUE" + local SETTING="${1}" + php -r "echo ini_get('${SETTING}');" }