diff --git a/install.sh b/install.sh index 12393a156..c256cfd9a 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 info "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..5b8a1c711 100644 --- a/scripts/installUpgradeFunctions.sh +++ b/scripts/installUpgradeFunctions.sh @@ -971,3 +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="${1}" + php -r "echo ini_get('${SETTING}');" +}