From 571171a0c6e9bbf1de4fe5fb843a5756860f7fad Mon Sep 17 00:00:00 2001 From: Joshua Tauberer Date: Sun, 30 Aug 2015 17:14:00 -0400 Subject: [PATCH] ownCloud 8.1.1's autoconfig resets trusted_domains / update trusted_domains if PRIMARY_HOSTNAME changes Seems like ownCloud 8.1.1 now doesn't play nice with trusted_domains. Whatever is put in ahead of time gets reset to an array containing 'localhost' only, probably because we invoke autoconfiguration from the command line where it doesn't know the hostname it's being accessed from. We now set this value after running autoconfig. This has the added benefit of also fixing the problem that if PRIMARY_HOSTNAME changes, trusted_domains wasn't updated. Now it is. Fixes #503. See #514. --- CHANGELOG.md | 5 +++++ setup/owncloud.sh | 19 +++++++++++-------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 573a781..b3e731b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ CHANGELOG ========= +v0.13b (August 30, 2015) +------------------------ + +Another ownCloud 8.1.1 issue was found. New installations left ownCloud improperly setup ("You are accessing the server from an untrusted domain."). Upgrading to this version will fix that. + v0.13a (August 23, 2015) ------------------------ diff --git a/setup/owncloud.sh b/setup/owncloud.sh index 4cd8c97..1fd5f7e 100755 --- a/setup/owncloud.sh +++ b/setup/owncloud.sh @@ -91,7 +91,7 @@ if [ ! -f $STORAGE_ROOT/owncloud/owncloud.db ]; then # Create user data directory mkdir -p $STORAGE_ROOT/owncloud - # Create a configuration file. + # Create an initial configuration file. TIMEZONE=$(cat /etc/timezone) instanceid=oc$(echo $PRIMARY_HOSTNAME | sha1sum | fold -w 10 | head -n 1) cat > $STORAGE_ROOT/owncloud/config.php < '$instanceid', - 'trusted_domains' => - array ( - 0 => '$PRIMARY_HOSTNAME', - ), 'forcessl' => true, # if unset/false, ownCloud sends a HSTS=0 header, which conflicts with nginx config 'overwritewebroot' => '/cloud', @@ -162,15 +158,22 @@ EOF (cd /usr/local/lib/owncloud; sudo -u www-data php /usr/local/lib/owncloud/index.php;) fi -# Update existing configuration files with changed settings that weren't included in -# previous versions of Mail-in-a-Box. Use PHP to read the settings file, modify it, -# and write out the new settings array. +# Update config.php. +# * trusted_domains is reset to localhost by autoconfig starting with ownCloud 8.1.1, +# so set it here. It also can change if the box's PRIMARY_HOSTNAME changes, so +# this will make sure it has the right value. +# * Some settings weren't included in previous versions of Mail-in-a-Box. +# Use PHP to read the settings file, modify it, and write out the new settings array. CONFIG_TEMP=$(/bin/mktemp) php < $CONFIG_TEMP && mv $CONFIG_TEMP $STORAGE_ROOT/owncloud/config.php;