23 |
|
*/ |
24 |
|
|
25 |
|
#include "stdinc.h" |
26 |
< |
#include "tools.h" |
26 |
> |
#include "list.h" |
27 |
|
#include "channel.h" |
28 |
|
#include "channel_mode.h" |
29 |
|
#include "client.h" |
33 |
|
#include "irc_string.h" |
34 |
|
#include "sprintf_irc.h" |
35 |
|
#include "ircd.h" |
36 |
– |
#include "list.h" |
36 |
|
#include "numeric.h" |
37 |
|
#include "s_serv.h" /* captab */ |
38 |
|
#include "s_user.h" |
43 |
|
#include "memory.h" |
44 |
|
#include "balloc.h" |
45 |
|
#include "s_log.h" |
46 |
+ |
#include "msg.h" |
47 |
|
|
48 |
|
/* some small utility functions */ |
49 |
|
static char *check_string(char *); |
82 |
|
int, int *, char **, int *, int, int, char, void *, |
83 |
|
const char *); |
84 |
|
static void send_cap_mode_changes(struct Client *, struct Client *, |
85 |
< |
struct Channel *, int, int); |
85 |
> |
struct Channel *, unsigned int, unsigned int); |
86 |
|
static void send_mode_changes(struct Client *, struct Client *, |
87 |
|
struct Channel *, char *); |
88 |
|
|
91 |
|
#define NCHCAPS (sizeof(channel_capabs)/sizeof(int)) |
92 |
|
#define NCHCAP_COMBOS (1 << NCHCAPS) |
93 |
|
|
94 |
+ |
static char nuh_mask[MAXPARA][IRCD_BUFSIZE]; |
95 |
|
/* some buffers for rebuilding channel/nick lists with ,'s */ |
96 |
|
static char modebuf[IRCD_BUFSIZE]; |
97 |
|
static char parabuf[MODEBUFLEN]; |
125 |
|
static char star[] = "*"; |
126 |
|
|
127 |
|
if (EmptyString(s)) |
128 |
< |
return (star); |
128 |
> |
return star; |
129 |
|
|
130 |
|
for (; *s; ++s) |
131 |
|
{ |
136 |
|
} |
137 |
|
} |
138 |
|
|
139 |
< |
return (str); |
139 |
> |
return str; |
140 |
|
} |
141 |
|
|
142 |
|
/* |
149 |
|
int |
150 |
|
add_id(struct Client *client_p, struct Channel *chptr, char *banid, int type) |
151 |
|
{ |
152 |
< |
dlink_list *list; |
153 |
< |
dlink_node *ban; |
152 |
> |
dlink_list *list = NULL; |
153 |
> |
dlink_node *ban = NULL; |
154 |
|
size_t len = 0; |
155 |
< |
struct Ban *actualBan; |
155 |
> |
struct Ban *ban_p = NULL; |
156 |
|
unsigned int num_mask; |
157 |
< |
char *name = NULL, *user = NULL, *host = NULL; |
157 |
> |
char name[NICKLEN]; |
158 |
> |
char user[USERLEN + 1]; |
159 |
> |
char host[HOSTLEN + 1]; |
160 |
> |
struct split_nuh_item nuh; |
161 |
|
|
162 |
|
/* dont let local clients overflow the b/e/I lists */ |
163 |
|
if (MyClient(client_p)) |
176 |
|
collapse(banid); |
177 |
|
} |
178 |
|
|
179 |
< |
split_nuh(check_string(banid), &name, &user, &host); |
179 |
> |
nuh.nuhmask = check_string(banid); |
180 |
> |
nuh.nickptr = name; |
181 |
> |
nuh.userptr = user; |
182 |
> |
nuh.hostptr = host; |
183 |
> |
|
184 |
> |
nuh.nicksize = sizeof(name); |
185 |
> |
nuh.usersize = sizeof(user); |
186 |
> |
nuh.hostsize = sizeof(host); |
187 |
> |
|
188 |
> |
split_nuh(&nuh); |
189 |
|
|
190 |
|
/* |
191 |
< |
* Assemble a n!u@h and print it back to banid for sending |
191 |
> |
* Re-assemble a new n!u@h and print it back to banid for sending |
192 |
|
* the mode to the channel. |
193 |
|
*/ |
194 |
|
len = ircsprintf(banid, "%s!%s@%s", name, user, host); |
213 |
|
|
214 |
|
DLINK_FOREACH(ban, list->head) |
215 |
|
{ |
216 |
< |
actualBan = ban->data; |
217 |
< |
if (!irccmp(actualBan->name, name) && |
218 |
< |
!irccmp(actualBan->username, user) && |
219 |
< |
!irccmp(actualBan->host, host)) |
216 |
> |
ban_p = ban->data; |
217 |
> |
if (!irccmp(ban_p->name, name) && |
218 |
> |
!irccmp(ban_p->username, user) && |
219 |
> |
!irccmp(ban_p->host, host)) |
220 |
|
{ |
208 |
– |
MyFree(name); |
209 |
– |
MyFree(user); |
210 |
– |
MyFree(host); |
221 |
|
return 0; |
222 |
|
} |
223 |
|
} |
224 |
|
|
225 |
< |
actualBan = BlockHeapAlloc(ban_heap); |
226 |
< |
actualBan->when = CurrentTime; |
227 |
< |
actualBan->name = name; |
228 |
< |
actualBan->username = user; |
229 |
< |
actualBan->host = host; |
230 |
< |
actualBan->len = len-2; /* -2 for @ and ! */ |
231 |
< |
actualBan->type = parse_netmask(host, &actualBan->addr, &actualBan->bits); |
225 |
> |
ban_p = BlockHeapAlloc(ban_heap); |
226 |
> |
|
227 |
> |
DupString(ban_p->name, name); |
228 |
> |
DupString(ban_p->username, user); |
229 |
> |
DupString(ban_p->host, host); |
230 |
> |
|
231 |
> |
ban_p->when = CurrentTime; |
232 |
> |
ban_p->len = len - 2; /* -2 for @ and ! */ |
233 |
> |
ban_p->type = parse_netmask(host, &ban_p->addr, &ban_p->bits); |
234 |
|
|
235 |
|
if (IsClient(client_p)) |
236 |
|
{ |
237 |
< |
actualBan->who = |
238 |
< |
MyMalloc(strlen(client_p->name) + |
239 |
< |
strlen(client_p->username) + |
240 |
< |
strlen(client_p->host) + 3); |
241 |
< |
ircsprintf(actualBan->who, "%s!%s@%s", |
230 |
< |
client_p->name, client_p->username, client_p->host); |
237 |
> |
ban_p->who = MyMalloc(strlen(client_p->name) + |
238 |
> |
strlen(client_p->username) + |
239 |
> |
strlen(client_p->host) + 3); |
240 |
> |
ircsprintf(ban_p->who, "%s!%s@%s", client_p->name, |
241 |
> |
client_p->username, client_p->host); |
242 |
|
} |
243 |
|
else |
244 |
< |
DupString(actualBan->who, client_p->name); |
244 |
> |
DupString(ban_p->who, client_p->name); |
245 |
|
|
246 |
< |
dlinkAdd(actualBan, &actualBan->node, list); |
246 |
> |
dlinkAdd(ban_p, &ban_p->node, list); |
247 |
|
|
248 |
|
return 1; |
249 |
|
} |
261 |
|
dlink_list *list; |
262 |
|
dlink_node *ban; |
263 |
|
struct Ban *banptr; |
264 |
< |
char *name = NULL, *user = NULL, *host = NULL; |
264 |
> |
char name[NICKLEN]; |
265 |
> |
char user[USERLEN + 1]; |
266 |
> |
char host[HOSTLEN + 1]; |
267 |
> |
struct split_nuh_item nuh; |
268 |
|
|
269 |
|
if (banid == NULL) |
270 |
|
return 0; |
271 |
|
|
272 |
< |
split_nuh(check_string(banid), &name, &user, &host); |
272 |
> |
nuh.nuhmask = check_string(banid); |
273 |
> |
nuh.nickptr = name; |
274 |
> |
nuh.userptr = user; |
275 |
> |
nuh.hostptr = host; |
276 |
> |
|
277 |
> |
nuh.nicksize = sizeof(name); |
278 |
> |
nuh.usersize = sizeof(user); |
279 |
> |
nuh.hostsize = sizeof(host); |
280 |
> |
|
281 |
> |
split_nuh(&nuh); |
282 |
|
|
283 |
|
/* |
284 |
< |
* Assemble a n!u@h and print it back to banid for sending |
284 |
> |
* Re-assemble a new n!u@h and print it back to banid for sending |
285 |
|
* the mode to the channel. |
286 |
|
*/ |
287 |
|
ircsprintf(banid, "%s!%s@%s", name, user, host); |
302 |
|
default: |
303 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, |
304 |
|
"del_id() called with unknown ban type %d!", type); |
305 |
< |
MyFree(name); |
283 |
< |
MyFree(user); |
284 |
< |
MyFree(host); |
285 |
< |
return(0); |
305 |
> |
return 0; |
306 |
|
} |
307 |
|
|
308 |
|
DLINK_FOREACH(ban, list->head) |
310 |
|
banptr = ban->data; |
311 |
|
|
312 |
|
if (!irccmp(name, banptr->name) && |
313 |
< |
!irccmp(user, banptr->username) && |
314 |
< |
!irccmp(host, banptr->host)) |
313 |
> |
!irccmp(user, banptr->username) && |
314 |
> |
!irccmp(host, banptr->host)) |
315 |
|
{ |
316 |
|
remove_ban(banptr, list); |
297 |
– |
MyFree(name); |
298 |
– |
MyFree(user); |
299 |
– |
MyFree(host); |
317 |
|
return 1; |
318 |
|
} |
319 |
|
} |
320 |
|
|
304 |
– |
MyFree(name); |
305 |
– |
MyFree(user); |
306 |
– |
MyFree(host); |
321 |
|
return 0; |
322 |
|
} |
323 |
|
|
655 |
|
if (MyClient(source_p) && (++mode_limit > MAXMODEPARAMS)) |
656 |
|
return; |
657 |
|
|
658 |
< |
mask = parv[(*parn)++]; |
659 |
< |
|
658 |
> |
mask = nuh_mask[*parn]; |
659 |
> |
memcpy(mask, parv[*parn], sizeof(nuh_mask[*parn])); |
660 |
> |
++*parn; |
661 |
> |
|
662 |
|
if (IsServer(client_p)) |
663 |
|
if (strchr(mask, ' ')) |
664 |
|
return; |
752 |
|
if (MyClient(source_p) && (++mode_limit > MAXMODEPARAMS)) |
753 |
|
return; |
754 |
|
|
755 |
< |
mask = parv[(*parn)++]; |
755 |
> |
mask = nuh_mask[*parn]; |
756 |
> |
memcpy(mask, parv[*parn], sizeof(nuh_mask[*parn])); |
757 |
> |
++*parn; |
758 |
|
|
759 |
|
if (IsServer(client_p)) |
760 |
|
if (strchr(mask, ' ')) |
846 |
|
if (MyClient(source_p) && (++mode_limit > MAXMODEPARAMS)) |
847 |
|
return; |
848 |
|
|
849 |
< |
mask = parv[(*parn)++]; |
849 |
> |
mask = nuh_mask[*parn]; |
850 |
> |
memcpy(mask, parv[*parn], sizeof(nuh_mask[*parn])); |
851 |
> |
++*parn; |
852 |
|
|
853 |
|
if (IsServer(client_p)) |
854 |
|
if (strchr(mask, ' ')) |
892 |
|
{ |
893 |
|
dlink_node *ptr = NULL; |
894 |
|
|
895 |
< |
DLINK_FOREACH(ptr, chptr->locmembers.head) |
895 |
> |
DLINK_FOREACH(ptr, chptr->members.head) |
896 |
> |
{ |
897 |
> |
struct Membership *ms = ptr->data; |
898 |
> |
|
899 |
> |
if (MyConnect(ms->client_p)) |
900 |
> |
ms->flags &= ~(CHFL_BAN_SILENCED|CHFL_BAN_CHECKED); |
901 |
> |
} |
902 |
> |
} |
903 |
> |
|
904 |
> |
void |
905 |
> |
clear_ban_cache_client(struct Client *client_p) |
906 |
> |
{ |
907 |
> |
dlink_node *ptr = NULL; |
908 |
> |
|
909 |
> |
DLINK_FOREACH(ptr, client_p->channel.head) |
910 |
|
{ |
911 |
|
struct Membership *ms = ptr->data; |
912 |
|
ms->flags &= ~(CHFL_BAN_SILENCED|CHFL_BAN_CHECKED); |
963 |
|
{ |
964 |
|
#ifdef HALFOPS |
965 |
|
if (has_member_flags(member, CHFL_HALFOP)) |
966 |
+ |
{ |
967 |
+ |
--*parn; |
968 |
|
chm_hop(client_p, source_p, chptr, parc, parn, parv, errors, alev, |
969 |
|
dir, c, d, chname); |
970 |
+ |
} |
971 |
|
#endif |
972 |
|
return; |
973 |
|
} |
1429 |
|
|
1430 |
|
static void |
1431 |
|
send_cap_mode_changes(struct Client *client_p, struct Client *source_p, |
1432 |
< |
struct Channel *chptr, int cap, int nocap) |
1432 |
> |
struct Channel *chptr, unsigned int cap, unsigned int nocap) |
1433 |
|
{ |
1434 |
|
int i, mbl, pbl, arglen, nc, mc; |
1435 |
|
int len; |
1487 |
|
(pbl + arglen + BAN_FUDGE) >= MODEBUFLEN) |
1488 |
|
{ |
1489 |
|
if (nc != 0) |
1490 |
< |
sendto_server(client_p, source_p, chptr, cap, nocap, |
1491 |
< |
LL_ICHAN | LL_ICLIENT, "%s %s", |
1490 |
> |
sendto_server(client_p, chptr, cap, nocap, |
1491 |
> |
"%s %s", |
1492 |
|
modebuf, parabuf); |
1493 |
|
nc = 0; |
1494 |
|
mc = 0; |
1529 |
|
parabuf[pbl - 1] = 0; |
1530 |
|
|
1531 |
|
if (nc != 0) |
1532 |
< |
sendto_server(client_p, source_p, chptr, cap, nocap, |
1533 |
< |
LL_ICLIENT, "%s %s", modebuf, parabuf); |
1532 |
> |
sendto_server(client_p, chptr, cap, nocap, |
1533 |
> |
"%s %s", modebuf, parabuf); |
1534 |
|
} |
1535 |
|
|
1536 |
|
/* void send_mode_changes(struct Client *client_p, |