Icinga / icingaweb2-module-director

The Director aims to be your new favourite Icinga config deployment tool. Director is designed for those who want to automate their configuration deployment and those who want to grant their “point & click” users easy access to the configuration.
https://icinga.com/docs/director/latest
GNU General Public License v2.0
413 stars 203 forks source link

Passed environment variables don't get escaped properly #2835

Open mocdaniel opened 1 year ago

mocdaniel commented 1 year ago

We came across a problem regarding escaping of passed environment variables when working on icinga/helm-charts:

Consider a database resource password being passed as follows:

-e icingaweb_resources_icingawebdb_password="testpassword!,123

This gets written into /etc/icingaweb2/resources.ini like this:

[icingawebdb]
password = testpassword!,123

This is problematic, as there are certain characters in the .ini spec which seemingly need to be escaped - in our case, the Director daemon crashes when trying to read .ini files which contain non-escaped strings with !, ,, etc.

Would it be possible to escape config values known to be strings with "..." during the startup routine?

See also icinga/helm-charts#12

Al2Klimov commented 12 months ago

Patched https://github.com/Al2Klimov/twintowers like this:

--- docker-compose.yml
+++ docker-compose.yml
@@ -45,3 +45,3 @@ x-dbweb: &x-dbweb
     MARIADB_USER: icingaweb2
-    MARIADB_PASSWORD: icingaweb2
+    MARIADB_PASSWORD: 'icingaweb2!,123'
     MARIADB_DATABASE: icingaweb2
@@ -86,3 +86,3 @@ x-web-env: &x-web-env
   icingaweb.resources.icingaweb_db.username: icingaweb2
-  icingaweb.resources.icingaweb_db.password: icingaweb2
+  icingaweb.resources.icingaweb_db.password: 'icingaweb2!,123'
   icingaweb.resources.icingaweb_db.charset: utf8

This is my resources.ini:

[icinga_ido]
username = ido
type     = db
host     = ido1
dbname   = ido
password = ido
db       = mysql

[icingadb]
username = icingadb
charset  = utf8mb4
dbname   = icingadb
host     = dbicinga1
db       = mysql
type     = db
password = icingadb

[icingaweb_db]
host     = dbweb1
password = icingaweb2!,123
charset  = utf8
username = icingaweb2
db       = mysql
dbname   = icingaweb2
type     = db

Icinga Web login works. My user is stored in the DB which Icinga Web has to access via above resource. The Director daemon is the problem.