X-Git-Url: https://jfr.im/git/solanum.git/blobdiff_plain/212380e3f42f585dc1ea927402252eb943f91f7b..62a0966666dc541931f7bf814d29b39cab0035fc:/modules/m_scan.c diff --git a/modules/m_scan.c b/modules/m_scan.c index 7fdb688f..25cbd538 100644 --- a/modules/m_scan.c +++ b/modules/m_scan.c @@ -38,10 +38,9 @@ #include "hash.h" #include "common.h" #include "hash.h" -#include "irc_string.h" +#include "match.h" #include "ircd.h" #include "numeric.h" -#include "commio.h" #include "s_serv.h" #include "s_conf.h" #include "s_newconf.h" @@ -50,20 +49,21 @@ #include "msg.h" #include "parse.h" #include "modules.h" +#include "logger.h" -static int mo_scan(struct Client *, struct Client *, int, const char **); -static int scan_umodes(struct Client *, struct Client *, int, const char **); -/*static int scan_cmodes(struct Client *, struct Client *, int, const char **);*/ +static int mo_scan(struct MsgBuf *, struct Client *, struct Client *, int, const char **); +static int scan_umodes(struct MsgBuf *, struct Client *, struct Client *, int, const char **); +/*static int scan_cmodes(struct MsgBuf *, struct Client *, struct Client *, int, const char **);*/ struct Message scan_msgtab = { - "SCAN", 0, 0, 0, MFLG_SLOW, + "SCAN", 0, 0, 0, 0, {mg_ignore, mg_not_oper, mg_ignore, mg_ignore, mg_ignore, {mo_scan, 2}} }; mapi_clist_av1 scan_clist[] = { &scan_msgtab, NULL }; DECLARE_MODULE_AV1(scan, NULL, NULL, scan_clist, NULL, NULL, "$Revision: 1853 $"); -typedef int (*scan_handler)(struct Client *, struct Client *, int, +typedef int (*scan_handler)(struct MsgBuf *, struct Client *, struct Client *, int, const char **); struct scan_cmd { @@ -80,12 +80,11 @@ static const char *spoofed_sockhost = "0"; /* * m_scan - * parv[0] = sender prefix * parv[1] = options [or target] * parv[2] = [target] */ static int -mo_scan(struct Client *client_p, struct Client *source_p, int parc, +mo_scan(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) { struct scan_cmd *sptr; @@ -98,7 +97,7 @@ mo_scan(struct Client *client_p, struct Client *source_p, int parc, !IsOperAdmin(source_p)) return -1; else - return sptr->handler(client_p, source_p, parc, parv); + return sptr->handler(msgbuf_p, client_p, source_p, parc, parv); } } @@ -109,20 +108,20 @@ mo_scan(struct Client *client_p, struct Client *source_p, int parc, } static int -scan_umodes(struct Client *client_p, struct Client *source_p, int parc, +scan_umodes(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) { unsigned int allowed_umodes = 0, disallowed_umodes = 0; int what = MODE_ADD; int mode; int list_users = YES; - int list_max = 0; + int list_max = 500; int list_count = 0, count = 0; const char *mask = NULL; const char *c; struct Client *target_p; - dlink_list *target_list = &lclient_list; /* local clients only by default */ - dlink_node *tn; + rb_dlink_list *target_list = &lclient_list; /* local clients only by default */ + rb_dlink_node *tn; int i; const char *sockhost; char buf[512]; @@ -136,6 +135,12 @@ scan_umodes(struct Client *client_p, struct Client *source_p, int parc, return -1; } + if (parv[2][0] != '+' && parv[2][0] != '-') + { + sendto_one_notice(source_p, ":SCAN UMODES: umodes parameter must start with '+' or '-'"); + return -1; + } + for (c = parv[2]; *c; c++) { switch(*c) @@ -171,19 +176,29 @@ scan_umodes(struct Client *client_p, struct Client *source_p, int parc, list_max = atoi(parv[++i]); else if (!irccmp(parv[i], "mask")) mask = parv[++i]; + else + { + sendto_one_notice(source_p, ":SCAN UMODES: invalid parameters"); + return -1; + } + } + else + { + sendto_one_notice(source_p, ":SCAN UMODES: invalid parameters"); + return -1; } } - if (target_list == &global_client_list && (list_users || mask)) + if (target_list == &global_client_list && list_users) { if (IsOperSpy(source_p)) { if (!ConfigFileEntry.operspy_dont_care_user_info) { - strlcpy(buf, "UMODES", sizeof buf); + rb_strlcpy(buf, "UMODES", sizeof buf); for (i = 2; i < parc; i++) { - strlcat(buf, " ", sizeof buf); - strlcat(buf, parv[i], sizeof buf); + rb_strlcat(buf, " ", sizeof buf); + rb_strlcat(buf, parv[i], sizeof buf); } report_operspy(source_p, "SCAN", buf); } @@ -196,7 +211,7 @@ scan_umodes(struct Client *client_p, struct Client *source_p, int parc, } } - DLINK_FOREACH(tn, target_list->head) + RB_DLINK_FOREACH(tn, target_list->head) { unsigned int working_umodes = 0; char maskbuf[BUFSIZE]; @@ -225,7 +240,7 @@ scan_umodes(struct Client *client_p, struct Client *source_p, int parc, if (mask != NULL) { - ircsnprintf(maskbuf, BUFSIZE, "%s!%s@%s", + snprintf(maskbuf, BUFSIZE, "%s!%s@%s", target_p->name, target_p->username, target_p->host); if (!match(mask, maskbuf)) @@ -252,7 +267,7 @@ scan_umodes(struct Client *client_p, struct Client *source_p, int parc, sendto_one_numeric(source_p, RPL_SCANUMODES, form_str(RPL_SCANUMODES), target_p->name, target_p->username, - target_p->host, sockhost, + target_p->host, sockhost, target_p->servptr->name, modebuf, target_p->info); }