]> jfr.im git - solanum.git/blame_incremental - extensions/extb_extgecos.c
Revert "Accept expired certificates"
[solanum.git] / extensions / extb_extgecos.c
... / ...
CommitLineData
1/*
2 * Extended extban type: bans all users with matching nick!user@host#gecos.
3 * Requested by Lockwood.
4 * - nenolod
5 */
6
7#include "stdinc.h"
8#include "modules.h"
9#include "client.h"
10#include "ircd.h"
11
12static const char extb_desc[] = "Extended mask ($x) extban type";
13
14static int _modinit(void);
15static void _moddeinit(void);
16static int eb_extended(const char *data, struct Client *client_p, struct Channel *chptr, long mode_type);
17
18DECLARE_MODULE_AV2(extb_extended, _modinit, _moddeinit, NULL, NULL, NULL, NULL, NULL, extb_desc);
19
20static int
21_modinit(void)
22{
23 extban_table['x'] = eb_extended;
24
25 return 0;
26}
27
28static void
29_moddeinit(void)
30{
31 extban_table['x'] = NULL;
32}
33
34static int eb_extended(const char *data, struct Client *client_p,
35 struct Channel *chptr, long mode_type)
36{
37 (void)chptr;
38
39 if (data == NULL)
40 return EXTBAN_INVALID;
41
42 const char *idx = strchr(data, '#');
43
44 if (idx != NULL && idx[1] == '\0')
45 /* Users cannot have empty realnames,
46 * so don't let a ban be set matching one
47 */
48 return EXTBAN_INVALID;
49
50 char buf[BUFSIZE];
51
52 if (idx != NULL)
53 {
54 // Copy the nick!user@host part of the ban
55 memcpy(buf, data, (idx - data));
56 buf[(idx - data)] = '\0';
57
58 // Advance to the realname part of the ban
59 idx++;
60
61 if (client_matches_mask(client_p, buf) && match(idx, client_p->info))
62 return EXTBAN_MATCH;
63 }
64 else
65 {
66 // Treat data as a pattern to match against the full nick!user@host#gecos.
67 snprintf(buf, sizeof buf, "%s!%s@%s#%s",
68 client_p->name, client_p->username, client_p->host, client_p->info);
69
70 if (match(data, buf))
71 return EXTBAN_MATCH;
72 }
73
74 return EXTBAN_NOMATCH;
75}