Merge branch 'bugfix/installation-fixes-4941'

Important vagrant changes:
    - Drop databases and users for icingaweb
    - Run vagrant provision to apply changes

fixes #4941
This commit is contained in:
Marius Hein 2013-10-22 17:55:15 +02:00
commit bd6c1c7864
16 changed files with 259 additions and 180 deletions

View File

@ -15,7 +15,7 @@ exec { 'create-mysql-icinga-db':
exec{ 'create-pgsql-icinga-db': exec{ 'create-pgsql-icinga-db':
unless => 'sudo -u postgres psql -tAc "SELECT 1 FROM pg_roles WHERE rolname=\'icinga\'" | grep -q 1', unless => 'sudo -u postgres psql -tAc "SELECT 1 FROM pg_roles WHERE rolname=\'icinga\'" | grep -q 1',
command => 'sudo -u postgres psql -c "CREATE ROLE icinga WITH LOGIN PASSWORD \'icinga\';" && \ command => 'sudo -u postgres psql -c "CREATE ROLE icinga WITH LOGIN PASSWORD \'icingaweb\';" && \
sudo -u postgres createdb -O icinga -E UTF8 icinga && \ sudo -u postgres createdb -O icinga -E UTF8 icinga && \
sudo -u postgres createlang plpgsql icinga', sudo -u postgres createlang plpgsql icinga',
require => Service['postgresql'] require => Service['postgresql']
@ -340,7 +340,10 @@ configure { 'icingaweb':
flags => '--prefix=/vagrant \ flags => '--prefix=/vagrant \
--with-icinga-commandpipe="/usr/local/icinga-mysql/var/rw/icinga.cmd" \ --with-icinga-commandpipe="/usr/local/icinga-mysql/var/rw/icinga.cmd" \
--with-statusdat-file="/usr/local/icinga-mysql/var/status.dat" \ --with-statusdat-file="/usr/local/icinga-mysql/var/status.dat" \
--with-httpd-config-path="/etc/httpd/conf.d"' --with-httpd-config-path="/etc/httpd/conf.d" \
--with-ldap-authentication \
--with-internal-authentication \
--with-livestatus-socket="/usr/local/icinga-mysql/var/rw/live"'
} }
file { 'icingaweb-public': file { 'icingaweb-public':
@ -468,10 +471,10 @@ populate_monitoring_test_config_plugins{ ['test_hostcheck.pl', 'test_servicechec
# Following section creates and populates MySQL and PostgreSQL Icinga 2 Web databases # Following section creates and populates MySQL and PostgreSQL Icinga 2 Web databases
# #
exec { 'create-mysql-icingaweb-db': exec { 'create-mysql-icingaweb-db':
unless => 'mysql -uicingaweb -picinga icingaweb', unless => 'mysql -uicingaweb -picingaweb icingaweb',
command => 'mysql -uroot -e "CREATE DATABASE icingaweb; \ command => 'mysql -uroot -e "CREATE DATABASE icingaweb; \
GRANT ALL ON icingaweb.* TO icingaweb@localhost \ GRANT ALL ON icingaweb.* TO icingaweb@localhost \
IDENTIFIED BY \'icinga\';"', IDENTIFIED BY \'icingaweb\';"',
require => Service['mysqld'] require => Service['mysqld']
} }
@ -484,8 +487,8 @@ exec { 'create-pgsql-icingaweb-db':
} }
exec { 'populate-icingaweb-mysql-db-accounts': exec { 'populate-icingaweb-mysql-db-accounts':
unless => 'mysql -uicingaweb -picinga icingaweb -e "SELECT * FROM account;" &> /dev/null', unless => 'mysql -uicingaweb -picingaweb icingaweb -e "SELECT * FROM account;" &> /dev/null',
command => 'mysql -uicingaweb -picinga icingaweb < /vagrant/etc/schema/accounts.mysql.sql', command => 'mysql -uicingaweb -picingaweb icingaweb < /vagrant/etc/schema/accounts.mysql.sql',
require => [ Exec['create-mysql-icingaweb-db'] ] require => [ Exec['create-mysql-icingaweb-db'] ]
} }
@ -496,8 +499,8 @@ exec { 'populate-icingweba-pgsql-db-accounts':
} }
exec { 'populate-icingaweb-mysql-db-preferences': exec { 'populate-icingaweb-mysql-db-preferences':
unless => 'mysql -uicingaweb -picinga icingaweb -e "SELECT * FROM preference;" &> /dev/null', unless => 'mysql -uicingaweb -picingaweb icingaweb -e "SELECT * FROM preference;" &> /dev/null',
command => 'mysql -uicingaweb -picinga icingaweb < /vagrant/etc/schema/preferences.mysql.sql', command => 'mysql -uicingaweb -picingaweb icingaweb < /vagrant/etc/schema/preferences.mysql.sql',
require => [ Exec['create-mysql-icingaweb-db'] ] require => [ Exec['create-mysql-icingaweb-db'] ]
} }

21
aclocal.m4 vendored
View File

@ -52,7 +52,6 @@ AC_DEFUN([AC_CHECK_BIN], [
test "XX${$1}" == "XXnot found" && $1="" test "XX${$1}" == "XXnot found" && $1=""
]) ])
AC_DEFUN([AC_PATH_GUESS], [ AC_DEFUN([AC_PATH_GUESS], [
$2=$3 $2=$3
for x in $1; do for x in $1; do
@ -63,3 +62,23 @@ AC_DEFUN([AC_PATH_GUESS], [
) )
done done
]) ])
# ICINGA_CHECK_DBTYPE(DBTYPE, ARGUMENT_NAME)
# ------------------------------------------
AC_DEFUN([ICINGA_CHECK_DBTYPE], [
AC_MSG_CHECKING([Testing database type for $2])
AS_IF(echo "$1" | $GREP -q "^\(my\|pg\)sql$",
AC_MSG_RESULT([OK ($1)]),
AC_MSG_ERROR([$1])
)
])
# ICINGA_CHECK_BACKENDTYPE(BACKENDTYPE, ARGUMENT_NAME)
# ------------------------------------------
AC_DEFUN([ICINGA_CHECK_BACKENDTYPE], [
AC_MSG_CHECKING([Testing backend type for $2])
AS_IF(echo "$1" | $GREP -q "^\(ido\|statusdat\|livestatus\)$",
AC_MSG_RESULT([OK ($1)]),
AC_MSG_ERROR([$1])
)
])

View File

@ -12,22 +12,24 @@
; priority. ; priority.
@use_ldap_auth@[ldap_authentication] [ldap_authentication]
@use_ldap_auth@backend = "ldap" @ldap_auth_disabled@
@use_ldap_auth@target = "user" backend = "ldap"
@use_ldap_auth@hostname = "@ldap_host@" target = "user"
@use_ldap_auth@port = "@ldap_port@" hostname = "@ldap_host@"
@use_ldap_auth@root_dn = "@ldap_rootdn@" port = "@ldap_port@"
@use_ldap_auth@bind_dn = "@ldap_binddn@" root_dn = "@ldap_rootdn@"
@use_ldap_auth@bind_pw = "@ldap_bindpass@" bind_dn = "@ldap_binddn@"
bind_pw = "@ldap_bindpass@"
; Attributes for ldap user lookup ; Object class of the user
@use_ldap_auth@user_class = "@ldap_user_objectclass@" user_class = "@ldap_user_objectclass@"
@use_ldap_auth@user_name_attribute = "@ldap_attribute_username@"
@use_ldap_auth@user_password_attribute = "@ldap_attribute_password@"
; Attribute name for username
user_name_attribute = "@ldap_attribute_username@"
@use_internal_auth@[internal_authentication] [internal_authentication]
@use_internal_auth@backend = db @internal_auth_disabled@
@use_internal_auth@target = "user" backend = db
@use_internal_auth@resource = "internal_db" target = "user"
resource = "internal_db"

View File

@ -1,15 +1,17 @@
[localdb] [localdb]
@ido_enabled@
type = ido type = ido
resource = "ido" resource = "ido"
[locallive] [locallive]
@livestatus_enabled@
type = livestatus type = livestatus
socket = @livestatus_socket@ resource = livestatus
[localfile] [localfile]
@statusdat_enabled@
type = statusdat type = statusdat
status_file = @statusdat_file@ resource = statusdat
objects_file = @objects_cache_file@
;[localfailsafe] ;[localfailsafe]
;enabled=false ;enabled=false

18
config/resources.ini.in Normal file → Executable file
View File

@ -17,7 +17,8 @@
type = db type = db
db = @internal_db_type@ db = @internal_db_type@
host = @internal_db_host@ host = @internal_db_host@
password = @internal_db_pass@ port = @internal_db_port@
password = @internal_db_password@
username = @internal_db_user@ username = @internal_db_user@
dbname = @internal_db_name@ dbname = @internal_db_name@
@ -25,7 +26,16 @@ dbname = @internal_db_name@
type = db type = db
db = @ido_db_type@ db = @ido_db_type@
host = @ido_host@ host = @ido_host@
password = @ido_user@
username = @ido_user@
port = @ido_port@ port = @ido_port@
dbname = @ido_database@ password = @ido_password@
username = @ido_user@
dbname = @ido_db_name@
[statusdat]
type = statusdat
status_file = @statusdat_file@
object_file = @objects_cache_file@
[livestatus]
type = livestatus
socket = @livestatus_socket@

150
configure vendored
View File

@ -590,22 +590,22 @@ ac_subst_vars='LTLIBOBJS
LIBOBJS LIBOBJS
INSTALL_OPTS_WEB INSTALL_OPTS_WEB
INSTALL_OPTS INSTALL_OPTS
use_internal_auth internal_auth_disabled
use_ldap_auth ldap_auth_disabled
icinga_commandpipe icinga_commandpipe
livestatus_enabled
livestatus_socket livestatus_socket
objects_cache_file objects_cache_file
statusdat_file statusdat_file
statusdat_enabled
ido_password ido_password
ido_user ido_user
ido_database ido_db_name
ido_port ido_port
ido_host ido_host
ido_db_type ido_db_type
ido_enabled
icinga_backend icinga_backend
ldap_attribute_groupname
ldap_group_objectclass
ldap_attribute_password
ldap_attribute_username ldap_attribute_username
ldap_attribute_basedn ldap_attribute_basedn
ldap_user_objectclass ldap_user_objectclass
@ -614,7 +614,7 @@ ldap_binddn
ldap_rootdn ldap_rootdn
ldap_port ldap_port
ldap_host ldap_host
internal_db_pass internal_db_password
internal_db_user internal_db_user
internal_db_port internal_db_port
internal_db_host internal_db_host
@ -688,7 +688,7 @@ with_internal_db_type
with_internal_db_name with_internal_db_name
with_internal_db_host with_internal_db_host
with_internal_db_port with_internal_db_port
with_internal_db_pass with_internal_db_password
with_internal_db_user with_internal_db_user
with_internal_authentication with_internal_authentication
with_ldap_authentication with_ldap_authentication
@ -699,14 +699,11 @@ with_ldap_bindpass
with_ldap_rootdn with_ldap_rootdn
with_ldap_user_objectclass with_ldap_user_objectclass
with_ldap_attribute_username with_ldap_attribute_username
with_ldap_attribute_password
with_ldap_group_objectclass
with_ldap_attribute_groupname
with_icinga_backend with_icinga_backend
with_ido_db_type with_ido_db_type
with_ido_host with_ido_host
with_ido_port with_ido_port
with_ido_database with_ido_db_name
with_ido_user with_ido_user
with_ido_password with_ido_password
with_statusdat_file with_statusdat_file
@ -1350,7 +1347,7 @@ Optional Packages:
--with-internal-db-port=PORT --with-internal-db-port=PORT
database port to use for internal database (default: database port to use for internal database (default:
3306 for mysql, 5432 for pgsql) 3306 for mysql, 5432 for pgsql)
--with-internal-db-pass=PASS --with-internal-db-password=PASS
database pass to use for internal database (default database pass to use for internal database (default
icingaweb) icingaweb)
--with-internal-db-user=USER --with-internal-db-user=USER
@ -1379,15 +1376,6 @@ Optional Packages:
--with-ldap-attribute-username=LDAP_ATTRIBUTE --with-ldap-attribute-username=LDAP_ATTRIBUTE
user attribute to use for the username (default: user attribute to use for the username (default:
uid) uid)
--with-ldap-attribute-password=LDAP_ATTRIBUTE
user attribute to use for the password (default:
password)
--with-ldap-group-objectclass=LDAP_ATTRIBUTE
ldap object type to use for group authentication
(default: inetOrgPerson)
--with-ldap-attribute-groupname=LDAP_OBJECT_CLASS
user object type to use for the authentication
(default: inetOrgPerson)
--with-icinga-backend=(ido, statusdat, livestatus) --with-icinga-backend=(ido, statusdat, livestatus)
backend to use for rb (default: statusdat) backend to use for rb (default: statusdat)
--with-ido-db-type=(mysql, pgsql) --with-ido-db-type=(mysql, pgsql)
@ -1397,10 +1385,10 @@ Optional Packages:
(default: localhost) (default: localhost)
--with-ido-port=PORT backend to use for retrieving data from the ido db --with-ido-port=PORT backend to use for retrieving data from the ido db
(default: 3306 for mysql. 5432 for pgsql) (default: 3306 for mysql. 5432 for pgsql)
--with-ido-database=DATABASE --with-ido-db-name=DATABASE
database name to use for retrieving data from the database name to use for retrieving data from the
ido db (default: icinga) ido db (default: icinga)
--with-ido-host=USER user to use for retrieving data from the ido db --with-ido-user=USER user to use for retrieving data from the ido db
(default: icinga) (default: icinga)
--with-ido-password=PASSWORD --with-ido-password=PASSWORD
password to use for retrieving data from the ido db password to use for retrieving data from the ido db
@ -1409,7 +1397,7 @@ Optional Packages:
location of the status.dat file when retrieving data location of the status.dat file when retrieving data
from status.dat (default: from status.dat (default:
/usr/local/icinga/var/status.dat) /usr/local/icinga/var/status.dat)
--with-objects-file=FILE --with-objects-cache-file=FILE
location of the objects.cache file when retrieving location of the objects.cache file when retrieving
data from status.dat (default: data from status.dat (default:
/usr/local/icinga/var/objects.cache) /usr/local/icinga/var/objects.cache)
@ -1420,6 +1408,10 @@ Optional Packages:
location of the command pipe used for sending location of the command pipe used for sending
commands (default: commands (default:
/usr/local/icinga/var/rw/icinga.cmd) /usr/local/icinga/var/rw/icinga.cmd)
--with-objects-file=FILE
location of the objects.cache file when retrieving
data from status.dat (default:
/usr/local/icinga/var/objects.cache)
Some influential environment variables: Some influential environment variables:
PHP php cli binary PHP php cli binary
@ -2358,6 +2350,18 @@ fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking Testing database type for --with-internal-db-type" >&5
$as_echo_n "checking Testing database type for --with-internal-db-type... " >&6; }
if echo "$internal_db_type" | $GREP -q "^\(my\|pg\)sql$"; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: OK ($internal_db_type)" >&5
$as_echo "OK ($internal_db_type)" >&6; }
else
as_fn_error $? "$internal_db_type" "$LINENO" 5
fi
# Check whether --with-internal_db_name was given. # Check whether --with-internal_db_name was given.
if test "${with_internal_db_name+set}" = set; then : if test "${with_internal_db_name+set}" = set; then :
withval=$with_internal_db_name; internal_db_name=$withval withval=$with_internal_db_name; internal_db_name=$withval
@ -2388,11 +2392,11 @@ fi
# Check whether --with-internal_db_pass was given. # Check whether --with-internal_db_password was given.
if test "${with_internal_db_pass+set}" = set; then : if test "${with_internal_db_password+set}" = set; then :
withval=$with_internal_db_pass; internal_db_pass=$withval withval=$with_internal_db_password; internal_db_password=$withval
else else
internal_db_pass=icingaweb internal_db_password=icingaweb
fi fi
@ -2414,7 +2418,7 @@ fi
# Check whether --with-internal_authentication was given. # Check whether --with-internal_authentication was given.
if test "${with_internal_authentication+set}" = set; then : if test "${with_internal_authentication+set}" = set; then :
withval=$with_internal_authentication; internal_authentication=yes withval=$with_internal_authentication; internal_authentication=$withval
else else
internal_authentication=yes internal_authentication=yes
@ -2424,7 +2428,7 @@ fi
# Check whether --with-ldap_authentication was given. # Check whether --with-ldap_authentication was given.
if test "${with_ldap_authentication+set}" = set; then : if test "${with_ldap_authentication+set}" = set; then :
withval=$with_ldap_authentication; ldap_authentication=yes withval=$with_ldap_authentication; ldap_authentication=$withval
else else
ldap_authentication=no ldap_authentication=no
@ -2505,36 +2509,6 @@ else
fi fi
# Check whether --with-ldap_attribute_password was given.
if test "${with_ldap_attribute_password+set}" = set; then :
withval=$with_ldap_attribute_password; ldap_attribute_password=$withval
else
ldap_attribute_password="password"
fi
# Check whether --with-ldap_group_objectclass was given.
if test "${with_ldap_group_objectclass+set}" = set; then :
withval=$with_ldap_group_objectclass; ldap_group_objectclass=$withval
else
ldap_group_objectclass="group"
fi
# Check whether --with-ldap_attribute_groupname was given.
if test "${with_ldap_attribute_groupname+set}" = set; then :
withval=$with_ldap_attribute_groupname; ldap_attribute_groupname=$withval
else
ldap_attribute_groupname="guid"
fi
# #
# Icinga backend selection # Icinga backend selection
# #
@ -2549,6 +2523,18 @@ else
fi fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking Testing backend type for --with-icinga-backend" >&5
$as_echo_n "checking Testing backend type for --with-icinga-backend... " >&6; }
if echo "$icinga_backend" | $GREP -q "^\(ido\|statusdat\|livestatus\)$"; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: OK ($icinga_backend)" >&5
$as_echo "OK ($icinga_backend)" >&6; }
else
as_fn_error $? "$icinga_backend" "$LINENO" 5
fi
# #
# Ido settings # Ido settings
# #
@ -2564,6 +2550,18 @@ fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking Testing database type for --with-ido-db-type" >&5
$as_echo_n "checking Testing database type for --with-ido-db-type... " >&6; }
if echo "$ido_db_type" | $GREP -q "^\(my\|pg\)sql$"; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: OK ($ido_db_type)" >&5
$as_echo "OK ($ido_db_type)" >&6; }
else
as_fn_error $? "$ido_db_type" "$LINENO" 5
fi
# Check whether --with-ido_host was given. # Check whether --with-ido_host was given.
if test "${with_ido_host+set}" = set; then : if test "${with_ido_host+set}" = set; then :
withval=$with_ido_host; ido_host=$withval withval=$with_ido_host; ido_host=$withval
@ -2584,11 +2582,11 @@ fi
# Check whether --with-ido_database was given. # Check whether --with-ido_db_name was given.
if test "${with_ido_database+set}" = set; then : if test "${with_ido_db_name+set}" = set; then :
withval=$with_ido_database; ido_database=$withval withval=$with_ido_db_name; ido_db_name=$withval
else else
ido_database="icinga" ido_db_name="icinga"
fi fi
@ -2828,12 +2826,12 @@ fi
fi fi
# #
# Comment out the disabled backends per default # Disable authentication backends
# #
ido_enabled="disable=1" ido_enabled="disabled = \"1\""
statusdat_enabled="disable=1" statusdat_enabled="disabled = \"1\""
livestatus_enabled="disable=1" livestatus_enabled="disabled = \"1\""
case $icinga_backend in #( case $icinga_backend in #(
"ido") : "ido") :
@ -2846,7 +2844,7 @@ case $icinga_backend in #(
statusdat_enabled="" ;; statusdat_enabled="" ;;
esac esac
use_ldap_auth=";" ldap_auth_disabled="disabled = \"1\""
if test "x$ldap_authentication" != xno; then : if test "x$ldap_authentication" != xno; then :
for x in ldap;do for x in ldap;do
@ -2860,11 +2858,11 @@ else
fi fi
done done
use_ldap_auth="" ldap_auth_disabled=""
fi fi
use_internal_auth=";" internal_auth_disabled="disabled = \"1\""
if test "x$internal_authentication" != xno; then : if test "x$internal_authentication" != xno; then :
for x in ldap;do for x in ldap;do
@ -2878,7 +2876,7 @@ else
fi fi
done done
use_internal_auth="" internal_auth_disabled=""
fi fi
@ -2915,9 +2913,6 @@ fi
# backend setup # backend setup
@ -2929,13 +2924,16 @@ fi
# status.dat backend # status.dat backend
# livestatus backend # livestatus backend
# command pipe # command pipe

View File

@ -98,6 +98,8 @@ AC_ARG_WITH([internal_db_type],
internal_db_type=mysql internal_db_type=mysql
) )
ICINGA_CHECK_DBTYPE($internal_db_type, [--with-internal-db-type])
AC_ARG_WITH([internal_db_name], AC_ARG_WITH([internal_db_name],
AS_HELP_STRING([--with-internal-db-name=NAME], [database name to use for internal database (default icingaweb)]), AS_HELP_STRING([--with-internal-db-name=NAME], [database name to use for internal database (default icingaweb)]),
internal_db_name=$withval, internal_db_name=$withval,
@ -116,10 +118,10 @@ AC_ARG_WITH([internal_db_port],
internal_db_port=db_default_port internal_db_port=db_default_port
) )
AC_ARG_WITH([internal_db_pass], AC_ARG_WITH([internal_db_password],
AS_HELP_STRING([--with-internal-db-pass=PASS], [database pass to use for internal database (default icingaweb)]), AS_HELP_STRING([--with-internal-db-password=PASS], [database pass to use for internal database (default icingaweb)]),
internal_db_pass=$withval, internal_db_password=$withval,
internal_db_pass=icingaweb internal_db_password=icingaweb
) )
AC_ARG_WITH([internal_db_user], AC_ARG_WITH([internal_db_user],
@ -134,13 +136,13 @@ AC_ARG_WITH([internal_db_user],
AC_ARG_WITH([internal_authentication], AC_ARG_WITH([internal_authentication],
AC_HELP_STRING([--with-internal-authentication], [use the internal database for authentication (default: yes)]), AC_HELP_STRING([--with-internal-authentication], [use the internal database for authentication (default: yes)]),
internal_authentication=yes, internal_authentication=$withval,
internal_authentication=yes internal_authentication=yes
) )
AC_ARG_WITH([ldap_authentication], AC_ARG_WITH([ldap_authentication],
AC_HELP_STRING([--with-ldap-authentication], [use a ldap server for authentication (default: no)]), AC_HELP_STRING([--with-ldap-authentication], [use a ldap server for authentication (default: no)]),
ldap_authentication=yes, ldap_authentication=$withval,
ldap_authentication=no ldap_authentication=no
) )
@ -190,24 +192,6 @@ AC_ARG_WITH([ldap_attribute_username],
ldap_attribute_username="uid" ldap_attribute_username="uid"
) )
AC_ARG_WITH([ldap_attribute_password],
AS_HELP_STRING([--with-ldap-attribute-password=LDAP_ATTRIBUTE], [user attribute to use for the password (default: password)]),
ldap_attribute_password=$withval,
ldap_attribute_password="password"
)
AC_ARG_WITH([ldap_group_objectclass],
AS_HELP_STRING([--with-ldap-group-objectclass=LDAP_ATTRIBUTE], [ldap object type to use for group authentication (default: inetOrgPerson)]),
ldap_group_objectclass=$withval,
ldap_group_objectclass="group"
)
AC_ARG_WITH([ldap_attribute_groupname],
AS_HELP_STRING([--with-ldap-attribute-groupname=LDAP_OBJECT_CLASS], [user object type to use for the authentication (default: inetOrgPerson)]),
ldap_attribute_groupname=$withval,
ldap_attribute_groupname="guid"
)
# #
# Icinga backend selection # Icinga backend selection
# #
@ -218,6 +202,8 @@ AC_ARG_WITH([icinga_backend],
icinga_backend="statusdat" icinga_backend="statusdat"
) )
ICINGA_CHECK_BACKENDTYPE($icinga_backend, [--with-icinga-backend])
# #
# Ido settings # Ido settings
# #
@ -228,6 +214,8 @@ AC_ARG_WITH([ido_db_type],
ido_db_type="mysql" ido_db_type="mysql"
) )
ICINGA_CHECK_DBTYPE($ido_db_type, [--with-ido-db-type])
AC_ARG_WITH([ido_host], AC_ARG_WITH([ido_host],
AS_HELP_STRING([--with-ido-host=HOST], [host to use for retrieving data from the ido db (default: localhost)]), AS_HELP_STRING([--with-ido-host=HOST], [host to use for retrieving data from the ido db (default: localhost)]),
ido_host=$withval, ido_host=$withval,
@ -240,14 +228,14 @@ AC_ARG_WITH([ido_port],
ido_port=db_default_port ido_port=db_default_port
) )
AC_ARG_WITH([ido_database], AC_ARG_WITH([ido_db_name],
AS_HELP_STRING([--with-ido-database=DATABASE], [database name to use for retrieving data from the ido db (default: icinga)]), AS_HELP_STRING([--with-ido-db-name=DATABASE], [database name to use for retrieving data from the ido db (default: icinga)]),
ido_database=$withval, ido_db_name=$withval,
ido_database="icinga" ido_db_name="icinga"
) )
AC_ARG_WITH([ido_user], AC_ARG_WITH([ido_user],
AS_HELP_STRING([--with-ido-host=USER], [user to use for retrieving data from the ido db (default: icinga)]), AS_HELP_STRING([--with-ido-user=USER], [user to use for retrieving data from the ido db (default: icinga)]),
ido_user=$withval, ido_user=$withval,
ido_user="icinga" ido_user="icinga"
) )
@ -269,7 +257,7 @@ AC_ARG_WITH([statusdat_file],
) )
AC_ARG_WITH([objects_cache_file], AC_ARG_WITH([objects_cache_file],
AS_HELP_STRING([--with-objects-file=FILE], [location of the objects.cache file when retrieving data from status.dat (default: /usr/local/icinga/var/objects.cache)]), AS_HELP_STRING([--with-objects-cache-file=FILE], [location of the objects.cache file when retrieving data from status.dat (default: /usr/local/icinga/var/objects.cache)]),
objects_cache_file=$withval, objects_cache_file=$withval,
objects_cache_file="/usr/local/icinga/var/objects.cache" objects_cache_file="/usr/local/icinga/var/objects.cache"
) )
@ -349,12 +337,12 @@ AS_IF([test "x$ido_db_type" = xpgsql], [
]) ])
# #
# Comment out the disabled backends per default # Disable authentication backends
# #
ido_enabled="disable=1" ido_enabled="disabled = \"1\""
statusdat_enabled="disable=1" statusdat_enabled="disabled = \"1\""
livestatus_enabled="disable=1" livestatus_enabled="disabled = \"1\""
AS_CASE([$icinga_backend], AS_CASE([$icinga_backend],
["ido"], [ido_enabled=""], ["ido"], [ido_enabled=""],
@ -362,16 +350,16 @@ AS_CASE([$icinga_backend],
["livestatus"], [livestatus_enabled=""], ["livestatus"], [livestatus_enabled=""],
[statusdat_enabled=""]) [statusdat_enabled=""])
use_ldap_auth=";" ldap_auth_disabled="disabled = \"1\""
AS_IF([test "x$ldap_authentication" != xno], AS_IF([test "x$ldap_authentication" != xno],
AC_CHECK_PHP_MODULE([ldap]) AC_CHECK_PHP_MODULE([ldap])
use_ldap_auth="" ldap_auth_disabled=""
) )
use_internal_auth=";" internal_auth_disabled="disabled = \"1\""
AS_IF([test "x$internal_authentication" != xno], AS_IF([test "x$internal_authentication" != xno],
AC_CHECK_PHP_MODULE([ldap]) AC_CHECK_PHP_MODULE([ldap])
use_internal_auth="" internal_auth_disabled=""
) )
# #
@ -395,7 +383,7 @@ AC_SUBST(internal_db_name)
AC_SUBST(internal_db_host) AC_SUBST(internal_db_host)
AC_SUBST(internal_db_port) AC_SUBST(internal_db_port)
AC_SUBST(internal_db_user) AC_SUBST(internal_db_user)
AC_SUBST(internal_db_pass) AC_SUBST(internal_db_password)
# ldap setup # ldap setup
AC_SUBST(ldap_host) AC_SUBST(ldap_host)
@ -406,35 +394,35 @@ AC_SUBST(ldap_bindpass)
AC_SUBST(ldap_user_objectclass) AC_SUBST(ldap_user_objectclass)
AC_SUBST(ldap_attribute_basedn) AC_SUBST(ldap_attribute_basedn)
AC_SUBST(ldap_attribute_username) AC_SUBST(ldap_attribute_username)
AC_SUBST(ldap_attribute_password)
AC_SUBST(ldap_group_objectclass)
AC_SUBST(ldap_attribute_groupname)
# backend setup # backend setup
AC_SUBST(icinga_backend) AC_SUBST(icinga_backend)
# ido backend variables # ido backend variables
AC_SUBST(ido_enabled)
AC_SUBST(ido_db_type) AC_SUBST(ido_db_type)
AC_SUBST(ido_host) AC_SUBST(ido_host)
AC_SUBST(ido_port) AC_SUBST(ido_port)
AC_SUBST(ido_database) AC_SUBST(ido_db_name)
AC_SUBST(ido_user) AC_SUBST(ido_user)
AC_SUBST(ido_password) AC_SUBST(ido_password)
# status.dat backend # status.dat backend
AC_SUBST(statusdat_enabled)
AC_SUBST(statusdat_file) AC_SUBST(statusdat_file)
AC_SUBST(objects_cache_file) AC_SUBST(objects_cache_file)
# livestatus backend # livestatus backend
AC_SUBST(livestatus_socket) AC_SUBST(livestatus_socket)
AC_SUBST(livestatus_enabled)
# command pipe # command pipe
AC_SUBST(icinga_commandpipe) AC_SUBST(icinga_commandpipe)
# Comment placeholders for toggling backends # Comment placeholders for toggling backends
AC_SUBST(use_ldap_auth) AC_SUBST(ldap_auth_disabled)
AC_SUBST(use_internal_auth) AC_SUBST(internal_auth_disabled)
# Application and installation # Application and installation
AC_SUBST(PHP) AC_SUBST(PHP)

View File

@ -219,8 +219,10 @@ class DbAdapterFactory implements ConfigAwareFactory
); );
switch ($config->db) { switch ($config->db) {
case 'mysql': case 'mysql':
$options['port'] = $config->get('port', 3306);
return self::callFactory('Pdo_Mysql', $options); return self::callFactory('Pdo_Mysql', $options);
case 'pgsql': case 'pgsql':
$options['port'] = $config->get('port', 5432);
return self::callFactory('Pdo_Pgsql', $options); return self::callFactory('Pdo_Pgsql', $options);
default: default:
if (!$config->db) { if (!$config->db) {

View File

@ -49,12 +49,12 @@ final class Logger
/** /**
* Default log target * Default log target
*/ */
const DEFAULT_LOG_TARGET = "./var/log/icinga.log"; const DEFAULT_LOG_TARGET = "./var/log/icingaweb.log";
/** /**
* Default debug target * Default debug target
*/ */
const DEFAULT_DEBUG_TARGET = "./var/log/icinga.debug.log"; const DEFAULT_DEBUG_TARGET = "./var/log/icingaweb.debug.log";
/** /**
* Array of writers * Array of writers

View File

@ -70,7 +70,7 @@ class LdapUserBackend implements UserBackend
*/ */
public function __construct(Zend_Config $config) public function __construct(Zend_Config $config)
{ {
$this->connection = new Ldap\Connection($config); $this->connection = new Connection($config);
$this->config = $config; $this->config = $config;
$this->name = $config->name; $this->name = $config->name;
} }

View File

@ -163,6 +163,11 @@ class Manager
private function setupBackends(Zend_Config $config) private function setupBackends(Zend_Config $config)
{ {
foreach ($config as $name => $backendConfig) { foreach ($config as $name => $backendConfig) {
// We won't initialize disabled backends
if ($backendConfig->get('disabled') == '1') {
continue;
}
if ($backendConfig->name === null) { if ($backendConfig->name === null) {
$backendConfig->name = $name; $backendConfig->name = $name;
} }

View File

@ -40,7 +40,7 @@ class ResourceFactory implements ConfigAwareFactory
$resource = new StatusdatReader($config); $resource = new StatusdatReader($config);
break; break;
default: default:
throw new ConfigurationError('Unsupported Backend "' + $config->type + '"'); throw new ConfigurationError('Unsupported resource type "' . $config->type . '"');
} }
return $resource; return $resource;

View File

@ -1,13 +1,37 @@
<?php <?php
// {{{ICINGA_LICENSE_HEADER}}}
/** /**
* LDAP connection handler * This file is part of Icinga 2 Web.
*
* Icinga 2 Web - Head for multiple monitoring backends.
* Copyright (C) 2013 Icinga Development Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* @copyright 2013 Icinga Development Team <info@icinga.org>
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2
* @author Icinga Development Team <info@icinga.org>
*/ */
// {{{ICINGA_LICENSE_HEADER}}}
namespace Icinga\Protocol\Ldap; namespace Icinga\Protocol\Ldap;
use Icinga\Application\Platform; use Icinga\Application\Platform;
use \Icinga\Application\Config; use Icinga\Application\Config;
use Icinga\Application\Logger as Log; use Icinga\Application\Logger as Log;
use \Zend_Config;
/** /**
* Backend class managing all the LDAP stuff for you. * Backend class managing all the LDAP stuff for you.
@ -89,14 +113,15 @@ class Connection
* *
* TODO: Allow to pass port and SSL options * TODO: Allow to pass port and SSL options
* *
* @param array LDAP connection credentials * @param Zend_Config $config
*/ */
public function __construct($config) public function __construct(Zend_Config $config)
{ {
$this->hostname = $config->hostname; $this->hostname = $config->hostname;
$this->bind_dn = $config->bind_dn; $this->bind_dn = $config->bind_dn;
$this->bind_pw = $config->bind_pw; $this->bind_pw = $config->bind_pw;
$this->root_dn = $config->root_dn; $this->root_dn = $config->root_dn;
$this->port = $config->get('port', $this->port);
} }

View File

@ -128,8 +128,17 @@ class Backend implements ConfigAwareFactory, DatasourceInterface
'Cannot get default backend as no backend has been configured' 'Cannot get default backend as no backend has been configured'
); );
} }
reset($configs);
return key($configs); // We won't have disabled backends
foreach ($configs as $name => $config) {
if (!$config->get('disabled') == '1') {
return $name;
}
}
throw new ConfigurationError(
'All backends are disabled'
);
} }
/** /**
@ -149,11 +158,19 @@ class Backend implements ConfigAwareFactory, DatasourceInterface
$name = self::getDefaultBackendName(); $name = self::getDefaultBackendName();
} }
$config = null;
if (isset(self::$backendConfigs[$name])) { if (isset(self::$backendConfigs[$name])) {
/** @var Zend_Config $config */
$config = self::$backendConfigs[$name]; $config = self::$backendConfigs[$name];
} else { if ($config->get('disabled') == '1') {
$config = null;
}
}
if ($config === null) {
throw new ConfigurationError( throw new ConfigurationError(
'No configuration for backend' . $name 'No configuration for backend:' . $name
); );
} }

View File

@ -3,6 +3,7 @@ namespace Tests\Icinga\Protocol\Ldap;
require_once '../../library/Icinga/Protocol/Ldap/Query.php'; require_once '../../library/Icinga/Protocol/Ldap/Query.php';
require_once '../../library/Icinga/Protocol/Ldap/Connection.php'; require_once '../../library/Icinga/Protocol/Ldap/Connection.php';
require_once '../../library/Icinga/Protocol/Ldap/LdapUtils.php'; require_once '../../library/Icinga/Protocol/Ldap/LdapUtils.php';
require_once('Zend/Config.php');
/** /**
* *
* Test class for Query * Test class for Query
@ -13,12 +14,16 @@ class QueryTest extends \PHPUnit_Framework_TestCase
{ {
private function emptySelect() private function emptySelect()
{ {
$connection = new \Icinga\Protocol\Ldap\Connection((object) array( $config = new \Zend_Config(
array(
'hostname' => 'localhost', 'hostname' => 'localhost',
'root_dn' => 'dc=example,dc=com', 'root_dn' => 'dc=example,dc=com',
'bind_dn' => 'cn=user,ou=users,dc=example,dc=com', 'bind_dn' => 'cn=user,ou=users,dc=example,dc=com',
'bind_pw' => '***' 'bind_pw' => '***'
)); )
);
$connection = new \Icinga\Protocol\Ldap\Connection($config);
return $connection->select(); return $connection->select();
} }

View File

@ -46,10 +46,13 @@ namespace Tests\Icinga\Regression
{ {
$request = $this->getRequest(); $request = $this->getRequest();
$request->setMethod("POST")->setPost(array( $request->setMethod("POST")->setPost(
array(
"username" => "test", "username" => "test",
"password" => "test" "password" => "test",
)); "btn_submit" => "1"
)
);
$view = new \Zend_View(); $view = new \Zend_View();
$form = new LoginForm(); $form = new LoginForm();