David Sparks wrote:
I wanted to add some kind of extended config support for plugins that
I'm writing that run at connect, mail from and rcpt to stages. I hacked
in YAML support into lib/Qpsmtpd.pm (the diff is below but I'm not
submitting this as a patch ... at this point at least).
Robert, at least, has expressed a distinct lack of interest in adding YAML
support to the core code. As long as the "damage" is limited to your own
plugins, though, I don't think it should be a problem.
I've noticed
that the config file is loaded every time a new connection comes in (I
put the config into connection->notes()).
Unless you are running the forkserver (or Apache?) variant, there is no
persistent object to store global configurations in (if you run with tcpserver,
you have a completely new process every time). If you check out the trunk code,
there is [preliminary] support for a pre-connection hook (which can be called in
the controlling process before forking a new connection). There is also a
global Qpsmtpd::TcpServer object which you can use to store global configuration
information in (actually that's a lie, since what happens is that each fork gets
a copy of an object created in the parent to use as it's own, but the effect is
the same).
I was also unsure of how to get the config read relative to qpsmtpd on
disk so I hacked config_dir() to look for a config directory relative to
the current dir. What is the proper way of doing this?
Don't change the core code and just dump your config file into the ./config
directory. That's how the config code works; it pulls from ./config unless it
is one of the special qmail control files, in which case it pulls from
/var/qmail/control (typical installation). Why do you want to have the YAML
file outside of ./config?
John