Apache 2.4 now uses mod_authz_host for acces control. Horizon's
Apache config needs an update to allow access to its directory,
otherwise a 403 will be returned.
This change replaces a similar previous fixes done for Fedora 18
and Ubuntu 13.10, since this is an Apache version issue, not a
distro-specific one.
Change-Id: Iecc17600d8e1aae6a7b0929b1493d712c307616f
Closes-Bug: #1243075
| ... | ... |
@@ -557,6 +557,18 @@ function is_arch {
|
| 557 | 557 |
[ "($uname -m)" = "$ARCH_TYPE" ] |
| 558 | 558 |
} |
| 559 | 559 |
|
| 560 |
+# Checks if installed Apache is <= given version |
|
| 561 |
+# $1 = x.y.z (version string of Apache) |
|
| 562 |
+function check_apache_version {
|
|
| 563 |
+ local cmd="apachectl" |
|
| 564 |
+ if ! [[ -x $(which apachectl 2>/dev/null) ]]; then |
|
| 565 |
+ cmd="/usr/sbin/apachectl" |
|
| 566 |
+ fi |
|
| 567 |
+ |
|
| 568 |
+ local version=$($cmd -v | grep version | grep -Po 'Apache/\K[^ ]*') |
|
| 569 |
+ expr "$version" '>=' $1 > /dev/null |
|
| 570 |
+} |
|
| 571 |
+ |
|
| 560 | 572 |
# git clone only if directory doesn't exist already. Since ``DEST`` might not |
| 561 | 573 |
# be owned by the installation user, we create the directory and change the |
| 562 | 574 |
# ownership to the proper user. |
| ... | ... |
@@ -112,7 +112,12 @@ function init_horizon() {
|
| 112 | 112 |
# Create an empty directory that apache uses as docroot |
| 113 | 113 |
sudo mkdir -p $HORIZON_DIR/.blackhole |
| 114 | 114 |
|
| 115 |
+ # Apache 2.4 uses mod_authz_host for access control now (instead of "Allow") |
|
| 115 | 116 |
HORIZON_REQUIRE='' |
| 117 |
+ if check_apache_version "2.4" ; then |
|
| 118 |
+ HORIZON_REQUIRE='Require all granted' |
|
| 119 |
+ fi |
|
| 120 |
+ |
|
| 116 | 121 |
local horizon_conf=/etc/$APACHE_NAME/$APACHE_CONF_DIR/horizon.conf |
| 117 | 122 |
if is_ubuntu; then |
| 118 | 123 |
# Clean up the old config name |
| ... | ... |
@@ -120,17 +125,7 @@ function init_horizon() {
|
| 120 | 120 |
# Be a good citizen and use the distro tools here |
| 121 | 121 |
sudo touch $horizon_conf |
| 122 | 122 |
sudo a2ensite horizon.conf |
| 123 |
- if [[ "$DISTRO" == "saucy" ]]; then |
|
| 124 |
- # Ubuntu 13.10 has Require all denied in apache2.conf |
|
| 125 |
- # and requires explicit Require all granted |
|
| 126 |
- HORIZON_REQUIRE='Require all granted' |
|
| 127 |
- fi |
|
| 128 | 123 |
elif is_fedora; then |
| 129 |
- if [[ "$os_RELEASE" -ge "18" ]]; then |
|
| 130 |
- # fedora 18 has Require all denied in its httpd.conf |
|
| 131 |
- # and requires explicit Require all granted |
|
| 132 |
- HORIZON_REQUIRE='Require all granted' |
|
| 133 |
- fi |
|
| 134 | 124 |
sudo sed '/^Listen/s/^.*$/Listen 0.0.0.0:80/' -i /etc/httpd/conf/httpd.conf |
| 135 | 125 |
elif is_suse; then |
| 136 | 126 |
: # nothing to do |