1
0
mirror of https://github.com/unrealircd/unrealircd.git synced 2026-07-01 13:26:38 +02:00

Update output of MODULE command (MODULE -all) to include the author,

slightly change the output and use RPL_TXT rather than NOTICE.
This commit is contained in:
Bram Matthys
2019-08-27 14:12:00 +02:00
parent fc69c5300e
commit 17c6b5976d
18 changed files with 106 additions and 78 deletions
+50 -17
View File
@@ -364,6 +364,33 @@ char *Module_GetRelPath(char *fullpath)
return buf;
}
/** Validate a modules' ModuleHeader.
* @returns Error message is returned, or NULL if everything is OK.
*/
static char *validate_mod_header(ModuleHeader *mod_header)
{
char *p;
if (!mod_header->name || !mod_header->version || !mod_header->author || !mod_header->description)
return "NULL values encountered in Mod_Header struct members";
/* Validate module name */
for (p = mod_header->name; *p; p++)
if (!isalnum(*p) && !strchr("._-/", *p))
return "ModuleHeader.name contains illegal characters (must be: a-zA-Z0-9._-/)";
/* Validate version, even more strict */
if (!isdigit(mod_header->version[0]))
return "ModuleHeader.version must start with a digit";
for (p = mod_header->version; *p; p++)
if (!isalnum(*p) && !strchr("._-", *p))
return "ModuleHeader.version contains illegal characters (must be: a-zA-Z0-9._-)";
/* Author and description are not checked, has no constraints */
return NULL; /* SUCCESS */
}
/*
* Returns an error if insucessful .. yes NULL is OK!
*/
@@ -384,6 +411,7 @@ char *Module_Create(char *path_)
char *path, *tmppath;
ModuleHeader *mod_header = NULL;
int ret = 0;
char *reterr;
Module *mod = NULL, **Mod_Handle = NULL;
char *expectedmodversion = our_mod_version;
unsigned int expectedcompilerversion = our_compiler_version;
@@ -466,12 +494,11 @@ char *Module_Create(char *path_)
remove(tmppath);
return(errorbuf);
}
if (!mod_header->name || !mod_header->version ||
!mod_header->description)
if ((reterr = validate_mod_header(mod_header)))
{
irc_dlclose(Mod);
remove(tmppath);
return("Lacking sane header pointer");
return(reterr);
}
if (Module_Find(mod_header->name))
{
@@ -887,9 +914,9 @@ CMD_FUNC(m_module)
return 0;
if (all)
sendnotice(sptr, "Showing ALL loaded modules:");
sendtxtnumeric(sptr, "Showing ALL loaded modules:");
else
sendnotice(sptr, "Showing loaded 3rd party modules (use \"MODULE -all\" to show all modules):");
sendtxtnumeric(sptr, "Showing loaded 3rd party modules (use \"MODULE -all\" to show all modules):");
for (mi = Modules; mi; mi = mi->next)
{
@@ -907,15 +934,21 @@ CMD_FUNC(m_module)
if (!(mi->options & MOD_OPT_OFFICIAL))
strlcat(tmp, "[3RD] ", sizeof(tmp));
if (!ValidatePermissionsForPath("server:module",sptr,NULL,NULL,NULL))
sendnotice(sptr, "*** %s (%s)%s",
mi->header->name, mi->header->description,
mi->options & MOD_OPT_OFFICIAL ? "" : " [3RD]");
sendtxtnumeric(sptr, "*** %s - %s - by %s %s",
mi->header->name,
mi->header->description,
mi->header->author,
mi->options & MOD_OPT_OFFICIAL ? "" : "[3RD]");
else
sendnotice(sptr, "*** %s - %s (%s) %s",
mi->header->name, mi->header->version, mi->header->description, tmp);
sendtxtnumeric(sptr, "*** %s %s - %s - by %s %s",
mi->header->name,
mi->header->version,
mi->header->description,
mi->header->author,
tmp);
}
sendnotice(sptr, "End of module list");
sendtxtnumeric(sptr, "End of module list");
if (!ValidatePermissionsForPath("server:module",sptr,NULL,NULL,NULL))
return 0;
@@ -930,12 +963,12 @@ CMD_FUNC(m_module)
p += strlen(p);
if (p > tmp + 380)
{
sendnotice(sptr, "Hooks: %s", tmp);
sendtxtnumeric(sptr, "Hooks: %s", tmp);
tmp[0] = '\0';
p = tmp;
}
}
sendnotice(sptr, "Hooks: %s ", tmp);
sendtxtnumeric(sptr, "Hooks: %s ", tmp);
tmp[0] = '\0';
p = tmp;
@@ -948,20 +981,20 @@ CMD_FUNC(m_module)
p += strlen(p);
if (p > tmp+380)
{
sendnotice(sptr, "Override: %s", tmp);
sendtxtnumeric(sptr, "Override: %s", tmp);
tmp[0] = '\0';
p = tmp;
}
}
}
sendnotice(sptr, "Override: %s", tmp);
sendtxtnumeric(sptr, "Override: %s", tmp);
#ifdef DEBUGMODE
sendnotice(sptr, "Efunctions dump:");
sendtxtnumeric(sptr, "Efunctions dump:");
for (i=0; i < MAXEFUNCTIONS; i++)
if ((e = Efunctions[i]))
{
sendnotice(sptr, "type=%d, name=%s, pointer=%p %s, owner=%s",
sendtxtnumeric(sptr, "type=%d, name=%s, pointer=%p %s, owner=%s",
e->type,
efunction_table[e->type].name ? efunction_table[e->type].name : "<null>",
e->func.voidfunc,
+2 -2
View File
@@ -36,8 +36,8 @@
ModuleHeader MOD_HEADER(antirandom)
= {
"antirandom",
"v1.4",
"Randomness detector",
"1.4",
"Detect and ban users with random names",
"UnrealIRCd Team",
"unrealircd-5",
};
+1 -1
View File
@@ -8,7 +8,7 @@
ModuleHeader MOD_HEADER(delayjoin)
= {
"delayjoin", /* Name of module */
"v0.0.1", /* Version */
"5.0", /* Version */
"delayed join (+D,+d)", /* Short description of module */
"UnrealIRCd Team",
"unrealircd-5",
+1 -1
View File
@@ -22,7 +22,7 @@
ModuleHeader MOD_HEADER(floodprot)
= {
"chanmodes/floodprot",
"$Id: floodprot.c,v 1.2 2019/08/10 syzop Exp $",
"5.0",
"Channel Mode +f",
"UnrealIRCd Team",
"unrealircd-5",
+8 -8
View File
@@ -6,6 +6,14 @@
#include "unrealircd.h"
ModuleHeader MOD_HEADER(channeldb) = {
"channeldb",
"1.0",
"Stores and retrieves channel settings for persistent (+P) channels",
"UnrealIRCd Team",
"unrealircd-5",
};
#define CHANNELDB_VERSION 100
#define CHANNELDB_SAVE_EVERY 299
@@ -61,14 +69,6 @@ static struct cfgstruct cfg;
static int channeldb_loaded = 0;
ModuleHeader MOD_HEADER(channeldb) = {
"channeldb",
"v1.0",
"Stores and retrieves channel settings for persistent (+P) channels",
"UnrealIRCd Team",
"unrealircd-5",
};
MOD_TEST(channeldb)
{
memset(&cfg, 0, sizeof(cfg));
+1 -1
View File
@@ -50,7 +50,7 @@ Callback *cloak = NULL, *cloak_csum = NULL;
ModuleHeader MOD_HEADER(cloak) = {
"cloak",
"v1.0",
"1.0",
"Official cloaking module (md5)",
"UnrealIRCd Team",
"unrealircd-5",
+1 -1
View File
@@ -73,7 +73,7 @@
ModuleHeader MOD_HEADER(textban)
= {
"textban",
"v2.2",
"2.2",
"ExtBan ~T (textban) by Syzop",
"UnrealIRCd Team",
"unrealircd-5",
+1 -3
View File
@@ -23,8 +23,6 @@
#include "unrealircd.h"
#define TIMEDBAN_VERSION "v1.0"
/* Maximum time (in minutes) for a ban */
#define TIMEDBAN_MAX_TIME 9999
@@ -50,7 +48,7 @@
ModuleHeader MOD_HEADER(timedban)
= {
"timedban",
TIMEDBAN_VERSION,
"1.0",
"ExtBan ~t: automatically removed timed bans",
"UnrealIRCd Team",
"unrealircd-5",
+1 -1
View File
@@ -28,7 +28,7 @@ CMD_FUNC(m_ircops);
ModuleHeader MOD_HEADER(ircops)
= {
"ircops",
"v3.71",
"3.71",
"/IRCOPS command that lists IRC Operators",
"UnrealIRCd Team",
"unrealircd-5",
+1 -1
View File
@@ -22,7 +22,7 @@
ModuleHeader MOD_HEADER(jumpserver)
= {
"jumpserver",
"v1.1",
"1.1",
"/jumpserver command",
"UnrealIRCd Team",
"unrealircd-5",
+2 -4
View File
@@ -20,14 +20,12 @@
#include "unrealircd.h"
#define NOCODES_VERSION "v1.2"
ModuleHeader MOD_HEADER(nocodes)
= {
"nocodes", /* Name of module */
NOCODES_VERSION, /* Version */
"1.2", /* Version */
"Strip/block bold/underline/reverse - by Syzop", /* Short description of module */
"UnrealIRCd Team",
"UnrealIRCd Team", /* Author */
"unrealircd-5",
};
+8 -8
View File
@@ -19,6 +19,14 @@
#include "unrealircd.h"
ModuleHeader MOD_HEADER(restrict-commands) = {
"restrict-commands",
"1.0",
"Restrict specific commands unless certain conditions have been met",
"UnrealIRCd Team",
"unrealircd-5",
};
#define GetReputation(acptr) (moddata_client_get(acptr, "reputation") ? atoi(moddata_client_get(acptr, "reputation")) : 0)
typedef struct restrictedcmd RestrictedCmd;
@@ -60,14 +68,6 @@ CmdMap conf_cmdmaps[] = {
{ NULL, NULL, }, // REQUIRED for the loop to properly work
};
ModuleHeader MOD_HEADER(restrict-commands) = {
"restrict-commands",
"v1.0",
"Restrict specific commands unless certain conditions have been met",
"UnrealIRCd Team",
"unrealircd-5",
};
MOD_TEST(restrict-commands)
{
memcpy(&ModInf, modinfo, modinfo->size);
+9 -8
View File
@@ -19,6 +19,14 @@
#include "unrealircd.h"
ModuleHeader MOD_HEADER(rmtkl) = {
"rmtkl",
"1.4",
"Adds /rmtkl command to easily remove *-Lines in bulk",
"Gottem and the UnrealIRCd Team",
"unrealircd-5",
};
#define IsParam(x) (parc > (x) && !BadPtr(parv[(x)]))
#define IsNotParam(x) (parc <= (x) || BadPtr(parv[(x)]))
@@ -69,16 +77,9 @@ static char *rmtkl_help[] = {
NULL
};
ModuleHeader MOD_HEADER(rmtkl) = {
"rmtkl",
"$Id: v1.4 2019/08/10 Gottem$",
"Adds /rmtkl command to easily remove *-Lines in bulk",
"UnrealIRCd Team",
"unrealircd-5",
};
MOD_INIT(rmtkl)
{
MARK_AS_OFFICIAL_MODULE(modinfo);
if (CommandExists("RMTKL"))
{
config_error("Command RMTKL already exists");
+1
View File
@@ -20,6 +20,7 @@ CMD_FUNC(m_sinfo);
MOD_INIT(sinfo)
{
MARK_AS_OFFICIAL_MODULE(modinfo);
CommandAdd(modinfo->handle, "SINFO", m_sinfo, MAXPARA, M_USER|M_SERVER);
return MOD_SUCCESS;
+9 -12
View File
@@ -19,9 +19,15 @@
*/
#include "unrealircd.h"
#ifdef USE_LIBCURL
#include "url.h"
#endif
ModuleHeader MOD_HEADER(staff)
= {
"staff",
"3.8",
"/STAFF command",
"UnrealIRCd Team",
"unrealircd-5",
};
#define MSG_STAFF "STAFF"
@@ -70,15 +76,6 @@ struct {
} Download;
#endif
ModuleHeader MOD_HEADER(staff)
= {
"staff",
"v3.8",
"/STAFF command",
"UnrealIRCd Team",
"unrealircd-5",
};
MOD_TEST(staff)
{
HookAdd(modinfo->handle, HOOKTYPE_CONFIGTEST, 0, cb_test);
+8 -8
View File
@@ -19,6 +19,14 @@
#include "unrealircd.h"
ModuleHeader MOD_HEADER(tkldb) = {
"tkldb",
"1.10",
"Stores active TKL entries (*-Lines) persistently/across IRCd restarts",
"UnrealIRCd Team",
"unrealircd-5",
};
#define TKL_DB_VERSION 1100
#define TKL_DB_SAVE_EVERY 299
@@ -104,14 +112,6 @@ static struct cfgstruct cfg;
static int tkls_loaded = 0;
ModuleHeader MOD_HEADER(tkldb) = {
"tkldb",
"v1.10",
"Stores active TKL entries (*-Lines) persistently/across IRCd restarts",
"UnrealIRCd Team",
"unrealircd-5",
};
MOD_TEST(tkldb)
{
memset(&cfg, 0, sizeof(cfg));
+1 -1
View File
@@ -8,7 +8,7 @@
ModuleHeader MOD_HEADER(privdeaf)
= {
"privdeaf",
"v1.2",
"1.2",
"Private Messages Deaf (+D) -- by Syzop",
"UnrealIRCd Team",
"unrealircd-5",
+1 -1
View File
@@ -26,7 +26,7 @@ CMD_FUNC(webredir);
ModuleHeader MOD_HEADER(webredir)
= {
"webredir",
"v1.0",
"1.0",
"Do 301 redirect for HEAD/GET/POST/PUT commands",
"UnrealIRCd Team",
"unrealircd-5",