haraka / haraka-config

Haraka config file loader and parser
https://www.npmjs.com/package/haraka-config
MIT License
10 stars 13 forks source link

Problems with overriding via yaml? #66

Closed adamkusmirek closed 6 months ago

adamkusmirek commented 2 years ago

I noticed that when adding a smtp.yaml to the config path, the values are not being loaded on startup.

Example: no smtp.ini present in config path and smtp.yaml has contents

"!smtp.ini":
  "main":
     "nodes": 0
"!smtpgreeting": [ "This is some custom greeting!"]

The logoutput on startup then includes:

Overriding file smtp.ini with config from /usr/local/haraka/config/smtp.yaml
Overriding file smtpgreeting with config from /usr/local/haraka/config/smtp.yaml
[WARN] [-] [core] smtp.ini.nodes unset, using 1, see https://github.com/haraka/Haraka/wiki/Performance-Tuning

which tells me, that my override was not applied.

Printing out the contents of Server.cfg at where this message is being printed yields:

{
  "main": {
     "daemonize":false,
     "strict_rfc1869":false,
     "smtputf8":true,
     "graceful_shutdown":false
  },
 "headers":{
     "add_received":true,
     "show_version":true,
     "clean_auth_results":true
 }
}

which apparently are the passed default booleans in the Server.config.get('smtp.ini'...... call in Server.load_smtp_ini.

Weirdly enough, the !smtpgreeting override works and is being loaded/used.

edit: this problem only applies to .ini file overrides

I also tried to comment out the default booleans in Server.load_smtp_ini and in this case the !smpt.ini override is being loaded correctly.

I suspect that there could be a problem in configfile.js, specifically in get_cache_key() regarding the way booleans are handled there since I noticed that they get appended to the name for some reason?

Maybe I also have a misconception about how this mechanism is supposed to work, especially regarding the booleans. The documentation is a little bit sparse on this detail.

Any help or pointers would be welcome!