whitespace in db password doesn't work and gets logged
Describe the bug
If a (postgresql, possibly other db) password specified in kea-dhcp4.conf contains whitespace, it causes the config processing to fail and the password to be logged unredacted.
To Reproduce
Steps to reproduce the behavior:
-
Configure a database user for the kea database with a password containing whitespace - e.g. "foo bar":
-
Run Kea dhcpv4 with the following hosts-database in the config:
"hosts-database": { "type": "postgresql", "host": "localhost", "name": "kea", "user": "kea", "password": "foo bar" }
- Examine logs, find errors like these:
ERROR [kea-dhcp4.database] DATABASE_INVALID_ACCESS invalid database access string: host=localhost name=kea password=foo bar type=postgresql user=kea universe=4
ERROR [kea-dhcp4.dhcp4/17119] DHCP4_CONFIG_LOAD_FAIL configuration error using file: /etc/kea/kea-dhcp4.conf, reason: Unable to open database: Cannot parse bar, expected format is name=value
Expected behavior
The server should start up just as it does when both the password configured for the database user and the password
Environment:
- Kea version: 1.5.0, compiled myself from the version released in Debian Sid
- OS: Debian Stretch
- Compiled as determined by the Debian Sid package, at least with postgresql support.
Additional Information
I think the problem happens because DbAccessParser::getDbAccessString() const does not do anything like quoting when serializing the values of the ParameterMap, so when the string gets reparsed confusion ensues. As hinted by this comment in process::ConfigControlParser::parse(...), perhaps it's not necessary to serialize the ParameterMap into a string at all.