summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRenato Botelho <renato@netgate.com>2015-10-01 08:51:22 -0300
committerRenato Botelho <renato@netgate.com>2015-10-01 08:51:22 -0300
commit339b88930513dec2bc986df7c0cd7255b6815d56 (patch)
tree6b775b1ad15a06a3af678a506783e6ad07ca0c07 /src
parent4169bf0c4f4899214de26c3b2bba664b0b618878 (diff)
downloadpfsense-339b88930513dec2bc986df7c0cd7255b6815d56.zip
pfsense-339b88930513dec2bc986df7c0cd7255b6815d56.tar.gz
Fix #5220, setup PHP timezone:
- Get defined zoneinfo in the following order: - /var/db/zoneinfo - /cf/conf/config.xml - /etc/inc/globals_override.inc - /etc/inc/globals.inc
Diffstat (limited to 'src')
-rwxr-xr-xsrc/etc/rc.php_ini_setup21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/etc/rc.php_ini_setup b/src/etc/rc.php_ini_setup
index 880f0f7..f456e6b 100755
--- a/src/etc/rc.php_ini_setup
+++ b/src/etc/rc.php_ini_setup
@@ -165,8 +165,25 @@ if [ -f /usr/local/lib/php.ini ]; then
fi
LOADED_MODULES=`/usr/local/bin/php-cgi -m | /usr/bin/grep -v "\["`
-# Fetch the timezone from the XML and set it here. We set it later too in the running scripts
-TIMEZONE=`cat /conf/config.xml | egrep -E '<timezone>(.*?)</timezone>' | awk -F'>' '{print $2}'|awk -F'<' '{print $1}'`
+# Fetch the timezone from /var/db/zoneinfo if present
+if [ -f /var/db/zoneinfo ]; then
+ TIMEZONE=$(cat /var/db/zoneinfo)
+# Second option is from config.xml
+elif grep -q '<timezone>' /cf/conf/config.xml; then
+ TIMEZONE=$(/usr/bin/sed -E \
+ '/<timezone>/!d; s,^.*<timezone>,,; s,<.*,,' \
+ /cf/conf/config.xml)
+# Last option, use default value
+else
+ globals_inc="/etc/inc/globals.inc"
+ if [ -f /etc/inc/globals_override.inc ]; then
+ globals_inc="/etc/inc/globals_override.inc ${globals_inc}"
+ fi
+ TIMEZONE=$(cat ${globals_inc} | \
+ grep default_timezone | \
+ head -n 1 | \
+ sed 's/^.*=>* *//; s/["\;,]*//g')
+fi
# Get a loaded module list in the stock php
# Populate a dummy php.ini to avoid
OpenPOWER on IntegriCloud