Tidy up module loading code
The existing code had several defects:
- Core module file names were hardcoded, while autoloaded non-
core module filenames were not. Code that loaded core modules
had a different but in some places duplicated structure to the
code that loaded autoloaded modules.
- Module loading for autoloaded modules happened in dentry
order, making it unpredictable from one server to the next, or
even across instances of `make install` on the same server.
- Module loading for autoloaded modules did not verify that the
dentry was a file before trying to load it.
- An IRCd start (or a conftest) only printed lines about loading
modules mentioned in the configuration file.
- The configuration file was parsed before loading core and
autoloaded modules, meaning any modules specified in the
configuration file would be loaded first.
- Once a module was loaded, it was added to the head of the
module list, making MODLIST show them in reverse loaded order
(newest (re)loaded modules at the top of the list).
These are addressed as follows:
- We now scan the core and autoload module directories and use
this to determine which modules to load.
- We now sort the dentries according to their filename before
iterating them to load them, making module load order finally
deterministic.
- We now test if a dentry is actually a file before trying to
load it.
- We now print a message to the console (if running in
foreground or conftest mode) when loading any module,
including core and autoloaded modules.
- The message printed to the console now has the IRCd module
directory prefix stripped from it if it matches.
- The configuration file is now parsed after loading core and
autoload modules.
- The modules are added to the module list in the order that
they are loaded. This now makes MODLIST show the order that
modules were (re)loaded in.
Modifications to two modules are part of this effort:
- The autoload module `m_alias` relied upon the alias dict not
being NULL when loaded, but this is only the case after the
configuration file has been parsed.
The module already had a "rehash" hook to destroy all existing
aliases and create new ones, so we can just make the module do
nothing on load (remove its modinit function) and change it to
use the "conf_read_end" hook instead of the "rehash" hook, and
it will still create aliases after the configuration file is
subsequently parsed.
With this modification, there are now no in-tree consumers of
the "rehash" hook.
- The autoload module `m_services` iterated `service_list` upon
loading it, which will now be empty (a no-op) since the module
is loaded before configuration file is parsed.
This module too handles the configuration file being parsed
with a "conf_read_end" hook and takes the appropriate action,
so we can just remove this code from its modinit function.
All other modules' modinit functions have been audited for
behaviour like this; there was nothing of note.
Add m_quarantine
This extension module provides a new usermode (+q) and two commands that
allow opers to set/unset that mode. The mode can be set either via
ircd.conf (general::default_umodes or auth::umodes) or via the
QUARANTINE command. When using the command, a reason is required which
will be broadcast to all other opers via the snote.
The quarantine will be automatically removed if the target opers up or
logs into a services account, and opers and logged in users cannot be
quarantined. The UNQUARNTINE command may additionally be used to remove
the quarantine status from a user. Users cannot otherwise set or remove
this usermode from themselves.
The QUARANTINE and UNQUARANTINE commands require a new priv
oper:quarantine.
To support this, a new account_change hook was added to m_services and
m_signon. This hook is fired whenever a user's services account changes
(via logging in or logging out) from the SVSLOGIN, SIGNON, LOGIN, or SU
services commands. It is **not** fired for SVSLOGIN on unknown
(pre-registration) users.
Documentation was updated for the new usermode, hook, and commands.
Usermode help was alphabetized for consistency, a missing entry for
helpops was added, and cloaking was moved to +x (since all modern
cloaking modules use that mode instead) since I was touching the file
anyway.
Add m_quarantine
This extension module provides a new usermode (+q) and two commands that
allow opers to set/unset that mode. The mode can be set either via
ircd.conf (general::default_umodes or auth::umodes) or via the
QUARANTINE command. When using the command, a reason is required which
will be broadcast to all other opers via the snote.
The quarantine will be automatically removed if the target opers up or
logs into a services account, and opers and logged in users cannot be
quarantined. The UNQUARNTINE command may additionally be used to remove
the quarantine status from a user. Users cannot otherwise set or remove
this usermode from themselves.
The QUARANTINE and UNQUARANTINE commands require a new priv
oper:quarantine.
To support this, a new account_change hook was added to m_services and
m_signon. This hook is fired whenever a user's services account changes
(via logging in or logging out) from the SVSLOGIN, SIGNON, LOGIN, or SU
services commands. It is **not** fired for SVSLOGIN on unknown
(pre-registration) users.
Documentation was updated for the new usermode, hook, and commands.
Usermode help was alphabetized for consistency, a missing entry for
helpops was added, and cloaking was moved to +x (since all modern
cloaking modules use that mode instead) since I was touching the file
anyway.