Fix horizon config under Apache 2.4
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
This commit is contained in:
parent
e8aa8306b1
commit
610af8cfa7
12
functions
12
functions
@ -557,6 +557,18 @@ function is_arch {
|
|||||||
[ "($uname -m)" = "$ARCH_TYPE" ]
|
[ "($uname -m)" = "$ARCH_TYPE" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Checks if installed Apache is <= given version
|
||||||
|
# $1 = x.y.z (version string of Apache)
|
||||||
|
function check_apache_version {
|
||||||
|
local cmd="apachectl"
|
||||||
|
if ! [[ -x $(which apachectl 2>/dev/null) ]]; then
|
||||||
|
cmd="/usr/sbin/apachectl"
|
||||||
|
fi
|
||||||
|
|
||||||
|
local version=$($cmd -v | grep version | grep -Po 'Apache/\K[^ ]*')
|
||||||
|
expr "$version" '>=' $1 > /dev/null
|
||||||
|
}
|
||||||
|
|
||||||
# git clone only if directory doesn't exist already. Since ``DEST`` might not
|
# git clone only if directory doesn't exist already. Since ``DEST`` might not
|
||||||
# be owned by the installation user, we create the directory and change the
|
# be owned by the installation user, we create the directory and change the
|
||||||
# ownership to the proper user.
|
# ownership to the proper user.
|
||||||
|
15
lib/horizon
15
lib/horizon
@ -112,7 +112,12 @@ function init_horizon() {
|
|||||||
# Create an empty directory that apache uses as docroot
|
# Create an empty directory that apache uses as docroot
|
||||||
sudo mkdir -p $HORIZON_DIR/.blackhole
|
sudo mkdir -p $HORIZON_DIR/.blackhole
|
||||||
|
|
||||||
|
# Apache 2.4 uses mod_authz_host for access control now (instead of "Allow")
|
||||||
HORIZON_REQUIRE=''
|
HORIZON_REQUIRE=''
|
||||||
|
if check_apache_version "2.4" ; then
|
||||||
|
HORIZON_REQUIRE='Require all granted'
|
||||||
|
fi
|
||||||
|
|
||||||
local horizon_conf=/etc/$APACHE_NAME/$APACHE_CONF_DIR/horizon.conf
|
local horizon_conf=/etc/$APACHE_NAME/$APACHE_CONF_DIR/horizon.conf
|
||||||
if is_ubuntu; then
|
if is_ubuntu; then
|
||||||
# Clean up the old config name
|
# Clean up the old config name
|
||||||
@ -120,17 +125,7 @@ function init_horizon() {
|
|||||||
# Be a good citizen and use the distro tools here
|
# Be a good citizen and use the distro tools here
|
||||||
sudo touch $horizon_conf
|
sudo touch $horizon_conf
|
||||||
sudo a2ensite horizon.conf
|
sudo a2ensite horizon.conf
|
||||||
if [[ "$DISTRO" == "saucy" ]]; then
|
|
||||||
# Ubuntu 13.10 has Require all denied in apache2.conf
|
|
||||||
# and requires explicit Require all granted
|
|
||||||
HORIZON_REQUIRE='Require all granted'
|
|
||||||
fi
|
|
||||||
elif is_fedora; then
|
elif is_fedora; then
|
||||||
if [[ "$os_RELEASE" -ge "18" ]]; then
|
|
||||||
# fedora 18 has Require all denied in its httpd.conf
|
|
||||||
# and requires explicit Require all granted
|
|
||||||
HORIZON_REQUIRE='Require all granted'
|
|
||||||
fi
|
|
||||||
sudo sed '/^Listen/s/^.*$/Listen 0.0.0.0:80/' -i /etc/httpd/conf/httpd.conf
|
sudo sed '/^Listen/s/^.*$/Listen 0.0.0.0:80/' -i /etc/httpd/conf/httpd.conf
|
||||||
elif is_suse; then
|
elif is_suse; then
|
||||||
: # nothing to do
|
: # nothing to do
|
||||||
|
Loading…
x
Reference in New Issue
Block a user