diff options
author | rob rob@31f1291d-b8d6-0310-a050-a5561fc1590b <rob rob@31f1291d-b8d6-0310-a050-a5561fc1590b@5417fbe8-f217-4b02-8779-1006273d7864> | 2006-10-17 20:42:40 +0000 |
---|---|---|
committer | rob rob@31f1291d-b8d6-0310-a050-a5561fc1590b <rob rob@31f1291d-b8d6-0310-a050-a5561fc1590b@5417fbe8-f217-4b02-8779-1006273d7864> | 2006-10-17 20:42:40 +0000 |
commit | 9bf8366451b60148699657ed966c0913fbae9465 (patch) | |
tree | 3a48a1aaa582ec259657ff1029dd691b3a99fb92 /src/modules.c | |
parent | 3dbe219758f5c9712a5c1935d85be1434cf0eee8 (diff) |
BUILD : 1.7.17 (1185) BUGS : N/A NOTES : Encryption now offers the choice of none, old and md5 - the md5 module is nicely taken from irc-services and actaully works, yes, real md5, in anope, wow eh?
git-svn-id: svn://svn.anope.org/anope/trunk@1185 31f1291d-b8d6-0310-a050-a5561fc1590b
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@905 5417fbe8-f217-4b02-8779-1006273d7864
Diffstat (limited to 'src/modules.c')
-rw-r--r-- | src/modules.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/modules.c b/src/modules.c index e1c2225da..44d7e4815 100644 --- a/src/modules.c +++ b/src/modules.c @@ -145,6 +145,26 @@ void modules_core_init(int number, char **list) } } } +/** + * + **/ +int encryption_module_init(void) { + int ret = 0; + Module *m; + + m = createModule(EncModule); + mod_current_module = m; + mod_current_user = NULL; + alog("Loading Encryption Module: [%s]", mod_current_module->name); + ret = loadModule(mod_current_module, NULL); + moduleSetType(ENCRYPTION); + alog("status: [%d][%s]", ret, ModuleGetErrStr(ret)); + mod_current_module = NULL; + if (ret != MOD_ERR_OK) { + destroyModule(m); + } + return ret; +} /** * Load the ircd protocol module up @@ -458,6 +478,25 @@ int protocolModuleLoaded() return 0; } +/** + * Search all loaded modules looking for an encryption module. + * @ return 1 if one is loaded + **/ +int encryptionModuleLoaded() +{ + int idx = 0; + ModuleHash *current = NULL; + + for (idx = 0; idx != MAX_CMD_HASH; idx++) { + for (current = MODULE_HASH[idx]; current; current = current->next) { + if (current->m->type == ENCRYPTION) { + return 1; + } + } + } + return 0; +} + /** * Copy the module from the modules folder to the runtime folder. * This will prevent module updates while the modules is loaded from @@ -624,6 +663,9 @@ int loadModule(Module * m, User * u) if (m->type == PROTOCOL && protocolModuleLoaded()) { alog("You cannot load two protocol modules"); ret = MOD_STOP; + } else if (m->type == ENCRYPTION && encryptionModuleLoaded()) { + alog("You cannot load two encryption modules"); + ret = MOD_STOP; } if (ret == MOD_STOP) { alog("%s requested unload...", m->name); @@ -671,6 +713,11 @@ int unloadModule(Module * m, User * u) notice_lang(s_OperServ, u, OPER_MODULE_NO_UNLOAD); } return MOD_ERR_NOUNLOAD; + } else if(m->type == ENCRYPTION) { + if (u) { + notice_lang(s_OperServ, u, OPER_MODULE_NO_UNLOAD); + } + return MOD_ERR_NOUNLOAD; } if (prepForUnload(mod_current_module) != MOD_ERR_OK) { |