]> jfr.im git - irc/rqf/shadowircd.git/blob - extensions/m_oaccept.c
Fix a segfault in oaccept.
[irc/rqf/shadowircd.git] / extensions / m_oaccept.c
1 #include "stdinc.h"
2 #include "ircd.h"
3 #include "client.h"
4 #include "modules.h"
5 #include "send.h"
6 #include "numeric.h"
7 #include "hash.h"
8
9 void mo_oaccept(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]);
10
11 struct Message oaccept_msgtab = {
12 "OACCEPT", 0, 0, 0, MFLG_SLOW,
13 {mg_unreg, mg_not_oper, mg_ignore, mg_ignore, mg_ignore, {mo_oaccept, 2}}
14 };
15
16 mapi_clist_av1 oaccept_clist[] = { &oaccept_msgtab, NULL };
17
18 DECLARE_MODULE_AV1(omode, NULL, NULL, oaccept_clist, NULL, NULL, "$Id $");
19
20 void
21 mo_oaccept(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
22 {
23 struct Metadata *md;
24 struct Client *target_p;
25
26 if(!(target_p = find_client(parv[1])))
27 {
28 sendto_one(source_p, form_str(ERR_NOSUCHNICK), parv[1]);
29 return;
30 }
31
32 /* Don't allow someone to pointlessly fill up someone's metadata
33 * with identical OACCEPT entries. */
34 if((md = user_metadata_find(target_p, "OACCEPT")))
35 if(!strcmp(source_p->id, md->value))
36 {
37 sendto_one_notice(source_p, ":You're already on %s's OACCEPT list", target_p->name);
38 return;
39 }
40
41 user_metadata_add(target_p, "OACCEPT", source_p->id, 1);
42
43 sendto_wallops_flags(UMODE_WALLOP, &me,
44 "OACCEPT called for %s by %s!%s@%s",
45 target_p->name,
46 source_p->name, source_p->username, source_p->host);
47 }