NULL
};
+#define MOD_WARN_DELTA (90 * 86400) /* time in seconds, 86400 seconds in a day */
+
#define MODS_INCREMENT 10
int num_mods = 0;
int max_mods = MODS_INCREMENT;
if((len > 3) && !strcmp(ldirent->d_name+len-3, ".la"))
{
(void) snprintf(module_fq_name, sizeof(module_fq_name), "%s/%s", AUTOMODPATH, ldirent->d_name);
- (void) load_a_module(module_fq_name, warn, 0);
+ (void) load_a_module(module_fq_name, warn, MAPI_ORIGIN_CORE, 0);
}
}
snprintf(module_name, sizeof(module_name), "%s/%s%s", MODPATH,
core_module_table[i], ".la");
- if(load_a_module(module_name, warn, 1) == -1)
+ if(load_a_module(module_name, warn, MAPI_ORIGIN_CORE, 1) == -1)
{
ilog(L_MAIN,
"Error loading core module %s%s: terminating ircd",
* side effects -
*/
int
-load_one_module(const char *path, int coremodule)
+load_one_module(const char *path, int origin, int coremodule)
{
char modpath[PATH_MAX];
rb_dlink_node *pathst;
if (server_state_foreground == 1)
inotice("loading module %s ...", path);
+ if(coremodule != 0)
+ {
+ coremodule = 1;
+ origin = MAPI_ORIGIN_CORE;
+ }
+
RB_DLINK_FOREACH(pathst, mod_paths.head)
{
mpath = pathst->data;
if(S_ISREG(statbuf.st_mode))
{
/* Regular files only please */
- if(coremodule)
- return load_a_module(modpath, 1, 1);
- else
- return load_a_module(modpath, 1, 0);
+ return load_a_module(modpath, 1, origin, coremodule);
}
}
do_modload(struct Client *source_p, const char *module)
{
char *m_bn = rb_basename(module);
+ int origin;
if(findmodule_byname(m_bn) != -1)
{
return 0;
}
- load_one_module(module, 0);
+ origin = strcmp(module, m_bn) == 0 ? MAPI_ORIGIN_CORE : MAPI_ORIGIN_EXTENSION;
+ load_one_module(module, origin, 0);
rb_free(m_bn);
return 0;
}
- if((load_one_module(m_bn, check_core) == -1) && check_core)
+ if((load_one_module(m_bn, modlist[modindex]->origin, check_core) == -1) && check_core)
{
sendto_realops_snomask(SNO_GENERAL, L_NETWIDE,
"Error reloading core module: %s: terminating ircd", m_bn);
for (i = 0; i < num_mods; i++)
{
+ const char *origin;
+ switch (modlist[i]->origin)
+ {
+ case MAPI_ORIGIN_EXTENSION:
+ origin = "extension";
+ break;
+ case MAPI_ORIGIN_CORE:
+ origin = "builtin";
+ break;
+ default:
+ origin = "unknown";
+ break;
+ }
+
if(pattern)
{
if(match(pattern, modlist[i]->name))
sendto_one(source_p, form_str(RPL_MODLIST),
me.name, source_p->name,
modlist[i]->name,
- (unsigned long)(uintptr_t)modlist[i]->address,
- modlist[i]->version, modlist[i]->description, modlist[i]->core ? " (core)" : "");
+ (unsigned long)(uintptr_t)modlist[i]->address, origin,
+ modlist[i]->core ? " (core)" : "", modlist[i]->version, modlist[i]->description);
}
}
else
{
sendto_one(source_p, form_str(RPL_MODLIST),
me.name, source_p->name, modlist[i]->name,
- (unsigned long)(uintptr_t)modlist[i]->address,
- modlist[i]->version, modlist[i]->description, modlist[i]->core ? " (core)" : "");
+ (unsigned long)(uintptr_t)modlist[i]->address, origin,
+ modlist[i]->core ? " (core)" : "", modlist[i]->version, modlist[i]->description);
}
}
{
struct CapabilityIndex *idx;
- switch(m->cap_index)
+ switch (m->cap_index)
{
case MAPI_CAP_CLIENT:
idx = cli_capindex;
return 0;
}
-
/*
* load_a_module()
*
- * inputs - path name of module, int to notice, int of core
+ * inputs - path name of module, int to notice, int of origin, int of core
* output - -1 if error 0 if success
* side effects - loads a module if successful
*/
int
-load_a_module(const char *path, int warn, int core)
+load_a_module(const char *path, int warn, int origin, int core)
{
lt_dlhandle tmpptr;
char *mod_basename;
const char *ver, *description = NULL;
- int origin = 0;
int *mapi_version;
if(mheader->mapi_register && (mheader->mapi_register() == -1))
{
ilog(L_MAIN, "Module %s indicated failure during load.",
- mod_basename);
+ mod_basename);
sendto_realops_snomask(SNO_GENERAL, L_ALL,
"Module %s indicated failure during load.",
mod_basename);
rb_free(mod_basename);
return -1;
}
+
+ /* Basic date code checks
+ *
+ * Don't make them fatal, but do complain about differences within a certain time frame.
+ * Later on if there are major API changes we can add fatal checks.
+ * -- Elizafox
+ */
+ if(mheader->mapi_datecode != datecode && mheader->mapi_datecode > 0)
+ {
+ long int delta = datecode - mheader->mapi_datecode;
+ if (delta > MOD_WARN_DELTA)
+ {
+ delta /= 86400;
+ iwarn("Module %s build date is out of sync with ircd build date by %ld days, expect problems",
+ mod_basename, delta);
+ sendto_realops_snomask(SNO_GENERAL, L_ALL,
+ "Module %s build date is out of sync with ircd build date by %ld days, expect problems",
+ mod_basename, delta);
+ }
+ }
+
if(mheader->mapi_command_list)
{
struct Message **m;
/* New in MAPI v2 - version replacement */
ver = mheader->mapi_module_version ? mheader->mapi_module_version : ircd_version;
description = mheader->mapi_module_description;
- origin = mheader->mapi_origin;
if(mheader->mapi_cap_list)
{
struct CapabilityIndex *idx;
int result;
- switch(m->cap_index)
+ switch (m->cap_index)
{
case MAPI_CAP_CLIENT:
idx = cli_capindex;
{
const char *o;
- switch(origin)
+ switch (origin)
{
- case MAPI_ORIGIN_EXTERNAL:
- o = "external";
- break;
case MAPI_ORIGIN_EXTENSION:
o = "extension";
break;