aboutsummaryrefslogtreecommitdiffstats
path: root/modules/m_alias.c
Commit message (Expand)AuthorAgeFilesLines
* 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. Gravatar Aaron Jones2026-03-221-10/+2
* hook_fn casts were hiding UB (#265)Gravatar Eric Mertens2021-08-191-5/+4
* m_alias: Preserve protocol framing charactersGravatar Ed Kellett2020-07-051-4/+4
* msgbuf: s_assert is not a substitute for proper code•••(dns, m_alias, m_stats updated as msgbuf no longer includes s_assert.h) Gravatar Simon Arlott2017-07-261-0/+1
* cppcheck: fix various warnings/errors•••[ircd/match.c:316]: (error) Shifting a negative value is undefined behaviour [librb/src/patricia.c:55]: (error) Shifting a negative value is undefined behaviour [modules/m_alias.c:64]: (portability) '(void*)message' is of type 'void *'. When using void pointers in calculations, the behaviour is undefined. [modules/m_time.c:111]: (warning) %u in format string (no. 9) requires 'unsigned int' but the argument type is 'signed int'. [modules/m_time.c:111]: (warning) %u in format string (no. 10) requires 'unsigned int' but the argument type is 'signed int'. [librb/src/dictionary.c:819]: (warning) %d in format string (no. 3) requires 'int' but the argument type is 'unsigned int'. [librb/src/radixtree.c:1080]: (warning) %d in format string (no. 3) requires 'int' but the argument type is 'unsigned int'. [ircd/s_user.c:351] -> [ircd/s_user.c:357]: (warning) Either the condition '0!=source_p' is redundant or there is possible null pointer dereference: source_p. [extensions/ip_cloaking_3.0.c:109]: (warning, inconclusive) The buffer 'buf' may not be null-terminated after the call to strncpy(). [ircd/chmode.c:256]: (style) Clarify calculation precedence for '&' and '?'. [modules/m_help.c:100]: (style) Clarify calculation precedence for '&' and '?'. [modules/m_knock.c:169]: (style) Clarify calculation precedence for '&' and '?'. [modules/m_stats.c:628]: (style) Clarify calculation precedence for '&' and '?'. [modules/m_stats.c:727]: (style) Clarify calculation precedence for '&' and '?'. [librb/src/radixtree.c:601]: (style) Clarify calculation precedence for '&' and '?'. [librb/src/radixtree.c:704]: (style) Clarify calculation precedence for '&' and '?'. [librb/src/radixtree.c:739]: (style) Clarify calculation precedence for '&' and '?'. [librb/src/radixtree.c:763]: (style) Clarify calculation precedence for '&' and '?'. [librb/src/radixtree.c:768]: (style) Clarify calculation precedence for '&' and '?'. [librb/src/radixtree.c:774]: (style) Clarify calculation precedence for '&' and '?'. [librb/src/radixtree.c:781]: (style) Clarify calculation precedence for '&' and '?'. [librb/src/radixtree.c:786]: (style) Clarify calculation precedence for '&' and '?'. [librb/src/radixtree.c:791]: (style) Clarify calculation precedence for '&' and '?'. [librb/src/radixtree.c:804]: (style) Clarify calculation precedence for '&' and '?'. [ircd/wsproc.c:372]: (style) Unused variable: len [modules/core/m_modules.c:382]: (style) Unused variable: i [modules/m_stats.c:741]: (style) Unused variable: amsg [ircd/authproc.c:390]: (style) Unused variable: iter [ircd/authproc.c:391]: (style) Unused variable: client_p Gravatar Simon Arlott2016-10-281-1/+1
* m_alias: correctly construct string to be sentGravatar Simon Arlott2016-05-121-1/+1
* m_alias: restore old behaviour of joining all parameters.•••There are two important caveats here, however: 1) Aliased commands have more than 8 parameters will be truncated; there's nothing I can do about this. 2) Parameters with colons will not be handled as you expect. Again, nothing I can do about this. Gravatar Elizabeth Myers2016-05-011-11/+4
* m_alias: store a copy of alias->name as it will be freed on a rehashGravatar Simon Arlott2016-04-241-2/+5
* Remove useless alias_entry hits memberGravatar Elizabeth Myers2016-04-061-3/+0
* m_alias: fix an assertGravatar Elizabeth Myers2016-04-061-1/+1
* m_alias: fix build with --enable-assertGravatar Elizabeth Myers2016-04-061-1/+1
* m_alias: minor cleanupGravatar Elizabeth Myers2016-04-061-10/+11
* Move alias handling into a dedicated module.•••Not yet tested, caveat emptor! Closes #166 Gravatar Elizabeth Myers2016-04-061-0/+170