]>
Commit | Line | Data |
---|---|---|
443acdf4 VY |
1 | diff -r a9a4e710ca64 include/s_newconf.h |
2 | --- a/include/s_newconf.h Sun Apr 20 01:03:54 2008 -0500 | |
3 | +++ b/include/s_newconf.h Sun Apr 20 11:13:46 2008 +0400 | |
4 | @@ -95,10 +95,14 @@ | |
5 | #define SHARED_PRESV 0x0100 | |
6 | #define SHARED_UNRESV 0x0200 | |
7 | #define SHARED_REHASH 0x0400 | |
8 | +#define SHARED_TDLINE 0x0800 | |
9 | +#define SHARED_PDLINE 0x1000 | |
10 | +#define SHARED_UNDLINE 0x2000 | |
11 | ||
12 | #define SHARED_ALL (SHARED_TKLINE | SHARED_PKLINE | SHARED_UNKLINE |\ | |
13 | SHARED_PXLINE | SHARED_TXLINE | SHARED_UNXLINE |\ | |
14 | - SHARED_TRESV | SHARED_PRESV | SHARED_UNRESV) | |
15 | + SHARED_TRESV | SHARED_PRESV | SHARED_UNRESV |\ | |
16 | + SHARED_TDLINE | SHARED_PDLINE | SHARED_UNDLINE) | |
17 | #define CLUSTER_ALL (SHARED_ALL | SHARED_LOCOPS) | |
18 | ||
19 | /* flags used in hub/leaf */ | |
20 | diff -r a9a4e710ca64 modules/m_dline.c | |
21 | --- a/modules/m_dline.c Sun Apr 20 01:03:54 2008 -0500 | |
22 | +++ b/modules/m_dline.c Sun Apr 20 11:13:46 2008 +0400 | |
23 | @@ -44,15 +44,17 @@ | |
24 | #include "modules.h" | |
25 | ||
26 | static int mo_dline(struct Client *, struct Client *, int, const char **); | |
27 | +static int me_dline(struct Client *, struct Client *, int, const char **); | |
28 | static int mo_undline(struct Client *, struct Client *, int, const char **); | |
29 | +static int me_undline(struct Client *, struct Client *, int, const char **); | |
30 | ||
31 | struct Message dline_msgtab = { | |
32 | "DLINE", 0, 0, 0, MFLG_SLOW, | |
33 | - {mg_unreg, mg_not_oper, mg_ignore, mg_ignore, mg_ignore, {mo_dline, 2}} | |
34 | + {mg_unreg, mg_not_oper, mg_ignore, mg_ignore, {me_dline, 3}, {mo_dline, 2}} | |
35 | }; | |
36 | struct Message undline_msgtab = { | |
37 | "UNDLINE", 0, 0, 0, MFLG_SLOW, | |
38 | - {mg_unreg, mg_not_oper, mg_ignore, mg_ignore, mg_ignore, {mo_undline, 2}} | |
39 | + {mg_unreg, mg_not_oper, mg_ignore, mg_ignore, {me_undline, 1}, {mo_undline, 2}} | |
40 | }; | |
41 | ||
42 | mapi_clist_av1 dline_clist[] = { &dline_msgtab, &undline_msgtab, NULL }; | |
43 | @@ -61,6 +63,8 @@ | |
44 | static int valid_comment(char *comment); | |
45 | static int flush_write(struct Client *, FILE *, char *, char *); | |
46 | static int remove_temp_dline(struct ConfItem *); | |
47 | +static int apply_dline(struct Client *, const char *, int, char *);\r | |
48 | +static int apply_undline(struct Client *, const char *); | |
49 | ||
50 | /* mo_dline() | |
51 | * | |
52 | @@ -73,15 +77,10 @@ | |
53 | { | |
54 | char def[] = "No Reason"; | |
55 | const char *dlhost; | |
56 | - char *oper_reason; | |
57 | char *reason = def; | |
58 | - struct rb_sockaddr_storage daddr; | |
59 | char cidr_form_host[HOSTLEN + 1]; | |
60 | - struct ConfItem *aconf; | |
61 | - int bits; | |
62 | - char dlbuffer[IRCD_BUFSIZE]; | |
63 | - const char *current_date; | |
64 | int tdline_time = 0; | |
65 | + const char *target_server = NULL; | |
66 | int loc = 1; | |
67 | ||
68 | if(!IsOperK(source_p)) | |
69 | @@ -94,72 +93,178 @@ | |
70 | if((tdline_time = valid_temp_time(parv[loc])) >= 0) | |
71 | loc++; | |
72 | ||
73 | - if(parc < loc + 1) | |
74 | - { | |
75 | - sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS), | |
76 | - me.name, source_p->name, "DLINE"); | |
77 | - return 0; | |
78 | - } | |
79 | - | |
80 | dlhost = parv[loc]; | |
81 | rb_strlcpy(cidr_form_host, dlhost, sizeof(cidr_form_host)); | |
82 | ||
83 | - if(!parse_netmask(dlhost, NULL, &bits)) | |
84 | + loc++; | |
85 | + | |
86 | + if(parc >= loc+2 && !irccmp(parv[loc], "ON")) | |
87 | + { | |
88 | + target_server = parv[loc+1]; | |
89 | + loc += 2; | |
90 | + } | |
91 | + | |
92 | + if(parc >= loc + 1 && !EmptyString(parv[loc])) | |
93 | + reason = LOCAL_COPY(parv[loc]); | |
94 | + | |
95 | + if(target_server != NULL) | |
96 | + { | |
97 | + sendto_match_servs(source_p, target_server, | |
98 | + CAP_ENCAP, NOCAPS, | |
99 | + "ENCAP %s DLINE %d %s :%s", | |
100 | + target_server, tdline_time, dlhost, reason); | |
101 | + | |
102 | + if(!match(target_server, me.name)) | |
103 | + return 0; | |
104 | + } | |
105 | + | |
106 | + apply_dline(source_p, dlhost, tdline_time, reason); | |
107 | + | |
108 | + check_dlines(); | |
109 | + return 0; | |
110 | +} | |
111 | + | |
112 | +/* mo_undline() | |
113 | + * | |
114 | + * parv[1] = dline to remove | |
115 | + */ | |
116 | +static int | |
117 | +mo_undline(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) | |
118 | +{ | |
119 | + const char *cidr; | |
120 | + const char *target_server = NULL; | |
121 | + | |
122 | + if(!IsOperK(source_p)) | |
123 | + { | |
124 | + sendto_one(source_p, form_str(ERR_NOPRIVS), | |
125 | + me.name, source_p->name, "unkline"); | |
126 | + return 0; | |
127 | + } | |
128 | + | |
129 | + cidr = parv[1]; | |
130 | + | |
131 | + if(parc >= 4 && !irccmp(parv[2], "ON")) | |
132 | + { | |
133 | + target_server = parv[3]; | |
134 | + sendto_match_servs(source_p, target_server, | |
135 | + CAP_ENCAP, NOCAPS, | |
136 | + "ENCAP %s UNDLINE %s", | |
137 | + target_server, cidr); | |
138 | + | |
139 | + if(!match(target_server, me.name)) | |
140 | + return 0; | |
141 | + } | |
142 | + | |
143 | + apply_undline(source_p, cidr); | |
144 | + | |
145 | + return 0; | |
146 | +} | |
147 | + | |
148 | +static int\r | |
149 | +me_dline(struct Client *client_p, struct Client *source_p, int parc, const char **parv)\r | |
150 | +{\r | |
151 | + int tdline_time = atoi(parv[1]);\r | |
152 | + /* Since this is coming over a server link, assume that the originating\r | |
153 | + * server did the relevant permission/sanity checks...\r | |
154 | + */\r | |
155 | +\r | |
156 | + if(!IsPerson(source_p))\r | |
157 | + return 0;\r | |
158 | +\r | |
159 | + if(!find_shared_conf(source_p->username, source_p->host,\r | |
160 | + source_p->servptr->name, tdline_time > 0 ? SHARED_TDLINE : SHARED_PDLINE))\r | |
161 | + {\r | |
162 | + sendto_realops_snomask(SNO_DEBUG, L_NETWIDE, "undline failed %s %s %s",\r | |
163 | + source_p->name, parv[1], parv[2]);\r | |
164 | + return 0;\r | |
165 | + }\r | |
166 | +\r | |
167 | + apply_dline(source_p, parv[2], tdline_time, LOCAL_COPY(parv[3]));\r | |
168 | +\r | |
169 | + check_dlines();\r | |
170 | + return 0;\r | |
171 | +}\r | |
172 | +\r | |
173 | +static int\r | |
174 | +me_undline(struct Client *client_p, struct Client *source_p, int parc, const char **parv)\r | |
175 | +{\r | |
176 | + if(!IsPerson(source_p))\r | |
177 | + return 0;\r | |
178 | +\r | |
179 | + if(!find_shared_conf(source_p->username, source_p->host,\r | |
180 | + source_p->servptr->name, SHARED_UNDLINE))\r | |
181 | + return 0;\r | |
182 | +\r | |
183 | + apply_undline(source_p, parv[1]);\r | |
184 | +\r | |
185 | + return 0;\r | |
186 | +} | |
187 | + | |
188 | +static int | |
189 | +apply_dline(struct Client *source_p, const char *dlhost, int tdline_time, char *reason) | |
190 | +{ | |
191 | + struct ConfItem *aconf; | |
192 | + char *oper_reason; | |
193 | + char dlbuffer[IRCD_BUFSIZE]; | |
194 | + const char *current_date; | |
195 | + struct rb_sockaddr_storage daddr; | |
196 | + int t = AF_INET, ty, b; | |
197 | + const char *creason; | |
198 | + | |
199 | + ty = parse_netmask(dlhost, (struct sockaddr *)&daddr, &b); | |
200 | + if(ty == HM_HOST) | |
201 | { | |
202 | sendto_one(source_p, ":%s NOTICE %s :Invalid D-Line", | |
203 | me.name, source_p->name); | |
204 | return 0; | |
205 | } | |
206 | +#ifdef RB_IPV6 | |
207 | + if(ty == HM_IPV6) | |
208 | + t = AF_INET6; | |
209 | + else | |
210 | +#endif | |
211 | + t = AF_INET; | |
212 | ||
213 | - loc++; | |
214 | - | |
215 | - if(parc >= loc + 1) /* host :reason */ | |
216 | - { | |
217 | - if(!EmptyString(parv[loc])) | |
218 | - reason = LOCAL_COPY(parv[loc]); | |
219 | - | |
220 | - if(!valid_comment(reason)) | |
221 | - { | |
222 | - sendto_one(source_p, | |
223 | - ":%s NOTICE %s :Invalid character '\"' in comment", | |
224 | - me.name, source_p->name); | |
225 | - return 0; | |
226 | - } | |
227 | - } | |
228 | - | |
229 | + /* This means dlines wider than /16 cannot be set remotely */ | |
230 | if(IsOperAdmin(source_p)) | |
231 | { | |
232 | - if(bits < 8) | |
233 | + if(b < 8) | |
234 | { | |
235 | - sendto_one(source_p, | |
236 | - ":%s NOTICE %s :For safety, bitmasks less than 8 require conf access.", | |
237 | - me.name, parv[0]); | |
238 | + sendto_one_notice(source_p, | |
239 | + ":For safety, bitmasks less than 8 require conf access."); | |
240 | return 0; | |
241 | } | |
242 | } | |
243 | else | |
244 | { | |
245 | - if(bits < 16) | |
246 | + if(b < 16) | |
247 | { | |
248 | - sendto_one(source_p, | |
249 | - ":%s NOTICE %s :Dline bitmasks less than 16 are for admins only.", | |
250 | - me.name, parv[0]); | |
251 | + sendto_one_notice(source_p, | |
252 | + ":Dline bitmasks less than 16 are for admins only."); | |
253 | return 0; | |
254 | } | |
255 | } | |
256 | ||
257 | + if(!valid_comment(reason)) | |
258 | + { | |
259 | + sendto_one(source_p, | |
260 | + ":%s NOTICE %s :Invalid character '\"' in comment", | |
261 | + me.name, source_p->name); | |
262 | + return 0; | |
263 | + } | |
264 | + | |
265 | + /* Look for an oper reason */ | |
266 | + if((oper_reason = strchr(reason, '|')) != NULL) | |
267 | + { | |
268 | + *oper_reason = '\0'; | |
269 | + oper_reason++; | |
270 | + | |
271 | + if(!EmptyString(oper_reason)) | |
272 | + aconf->spasswd = rb_strdup(oper_reason); | |
273 | + } | |
274 | + | |
275 | if(ConfigFileEntry.non_redundant_klines) | |
276 | { | |
277 | - const char *creason; | |
278 | - int t = AF_INET, ty, b; | |
279 | - ty = parse_netmask(dlhost, (struct sockaddr *)&daddr, &b); | |
280 | -#ifdef RB_IPV6 | |
281 | - if(ty == HM_IPV6) | |
282 | - t = AF_INET6; | |
283 | - else | |
284 | -#endif | |
285 | - t = AF_INET; | |
286 | - | |
287 | if((aconf = find_dline((struct sockaddr *)&daddr, t)) != NULL) | |
288 | { | |
289 | int bx; | |
290 | @@ -170,11 +275,11 @@ | |
291 | if(IsConfExemptKline(aconf)) | |
292 | sendto_one(source_p, | |
293 | ":%s NOTICE %s :[%s] is (E)d-lined by [%s] - %s", | |
294 | - me.name, parv[0], dlhost, aconf->host, creason); | |
295 | + me.name, source_p->name, dlhost, aconf->host, creason); | |
296 | else | |
297 | sendto_one(source_p, | |
298 | ":%s NOTICE %s :[%s] already D-lined by [%s] - %s", | |
299 | - me.name, parv[0], dlhost, aconf->host, creason); | |
300 | + me.name, source_p->name, dlhost, aconf->host, creason); | |
301 | return 0; | |
302 | } | |
303 | } | |
304 | @@ -187,16 +292,6 @@ | |
305 | aconf->status = CONF_DLINE; | |
306 | aconf->host = rb_strdup(dlhost); | |
307 | ||
308 | - /* Look for an oper reason */ | |
309 | - if((oper_reason = strchr(reason, '|')) != NULL) | |
310 | - { | |
311 | - *oper_reason = '\0'; | |
312 | - oper_reason++; | |
313 | - | |
314 | - if(!EmptyString(oper_reason)) | |
315 | - aconf->spasswd = rb_strdup(oper_reason); | |
316 | - } | |
317 | - | |
318 | if(tdline_time > 0) | |
319 | { | |
320 | rb_snprintf(dlbuffer, sizeof(dlbuffer), | |
321 | @@ -208,7 +303,7 @@ | |
322 | ||
323 | if(EmptyString(oper_reason)) | |
324 | { | |
325 | - sendto_realops_snomask(SNO_GENERAL, L_ALL, | |
326 | + sendto_realops_snomask(SNO_GENERAL, L_NETWIDE, | |
327 | "%s added temporary %d min. D-Line for [%s] [%s]", | |
328 | get_oper_name(source_p), tdline_time / 60, | |
329 | aconf->host, reason); | |
330 | @@ -218,7 +313,7 @@ | |
331 | } | |
332 | else | |
333 | { | |
334 | - sendto_realops_snomask(SNO_GENERAL, L_ALL, | |
335 | + sendto_realops_snomask(SNO_GENERAL, L_NETWIDE, | |
336 | "%s added temporary %d min. D-Line for [%s] [%s|%s]", | |
337 | get_oper_name(source_p), tdline_time / 60, | |
338 | aconf->host, reason, oper_reason); | |
339 | @@ -239,42 +334,27 @@ | |
340 | oper_reason, current_date, 0); | |
341 | } | |
342 | ||
343 | - check_dlines(); | |
344 | return 0; | |
345 | } | |
346 | ||
347 | -/* mo_undline() | |
348 | - * | |
349 | - * parv[1] = dline to remove | |
350 | - */ | |
351 | static int | |
352 | -mo_undline(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) | |
353 | +apply_undline(struct Client *source_p, const char *cidr) | |
354 | { | |
355 | FILE *in; | |
356 | FILE *out; | |
357 | char buf[BUFSIZE], buff[BUFSIZE], temppath[BUFSIZE], *p; | |
358 | const char *filename, *found_cidr; | |
359 | - const char *cidr; | |
360 | - struct ConfItem *aconf; | |
361 | int pairme = NO, error_on_write = NO; | |
362 | mode_t oldumask; | |
363 | - | |
364 | - rb_snprintf(temppath, sizeof(temppath), "%s.tmp", ConfigFileEntry.dlinefile); | |
365 | - | |
366 | - if(!IsOperUnkline(source_p)) | |
367 | - { | |
368 | - sendto_one(source_p, form_str(ERR_NOPRIVS), | |
369 | - me.name, source_p->name, "unkline"); | |
370 | - return 0; | |
371 | - } | |
372 | - | |
373 | - cidr = parv[1]; | |
374 | + struct ConfItem *aconf; | |
375 | ||
376 | if(parse_netmask(cidr, NULL, NULL) == HM_HOST) | |
377 | { | |
378 | sendto_one_notice(source_p, ":Invalid D-Line"); | |
379 | return 0; | |
380 | } | |
381 | + | |
382 | + rb_snprintf(temppath, sizeof(temppath), "%s.tmp", ConfigFileEntry.dlinefile); | |
383 | ||
384 | aconf = find_exact_conf_by_address(cidr, CONF_DLINE, NULL); | |
385 | if(aconf == NULL) | |
386 | @@ -288,7 +368,7 @@ | |
387 | { | |
388 | sendto_one(source_p, | |
389 | ":%s NOTICE %s :Un-dlined [%s] from temporary D-lines", | |
390 | - me.name, parv[0], buf); | |
391 | + me.name, source_p->name, buf); | |
392 | sendto_realops_snomask(SNO_GENERAL, L_ALL, | |
393 | "%s has removed the temporary D-Line for: [%s]", | |
394 | get_oper_name(source_p), buf); | |
395 | @@ -300,14 +380,14 @@ | |
396 | ||
397 | if((in = fopen(filename, "r")) == 0) | |
398 | { | |
399 | - sendto_one(source_p, ":%s NOTICE %s :Cannot open %s", me.name, parv[0], filename); | |
400 | + sendto_one(source_p, ":%s NOTICE %s :Cannot open %s", me.name, source_p->name, filename); | |
401 | return 0; | |
402 | } | |
403 | ||
404 | oldumask = umask(0); | |
405 | if((out = fopen(temppath, "w")) == 0) | |
406 | { | |
407 | - sendto_one(source_p, ":%s NOTICE %s :Cannot open %s", me.name, parv[0], temppath); | |
408 | + sendto_one(source_p, ":%s NOTICE %s :Cannot open %s", me.name, source_p->name, temppath); | |
409 | fclose(in); | |
410 | umask(oldumask); | |
411 | return 0; | |
412 | @@ -336,7 +416,7 @@ | |
413 | continue; | |
414 | } | |
415 | ||
416 | - if(irccmp(found_cidr, aconf->host) == 0) | |
417 | + if(irccmp(found_cidr, cidr) == 0) | |
418 | { | |
419 | pairme++; | |
420 | } | |
421 | @@ -356,13 +436,13 @@ | |
422 | { | |
423 | sendto_one(source_p, | |
424 | ":%s NOTICE %s :Couldn't write D-line file, aborted", | |
425 | - me.name, parv[0]); | |
426 | + me.name, source_p->name); | |
427 | return 0; | |
428 | } | |
429 | else if(!pairme) | |
430 | { | |
431 | - sendto_one_notice(source_p, ":Cannot find D-Line for %s in file", | |
432 | - aconf->host); | |
433 | + sendto_one(source_p, ":%s NOTICE %s :No D-Line for %s", | |
434 | + me.name, source_p->name, cidr); | |
435 | ||
436 | if(temppath != NULL) | |
437 | (void) unlink(temppath); | |
438 | @@ -375,13 +455,13 @@ | |
439 | sendto_one_notice(source_p, ":Couldn't rename temp file, aborted"); | |
440 | return 0; | |
441 | } | |
442 | + rehash_bans(0); | |
443 | ||
444 | - sendto_one(source_p, ":%s NOTICE %s :D-Line for [%s] is removed", me.name, parv[0], aconf->host); | |
445 | - sendto_realops_snomask(SNO_GENERAL, L_ALL, | |
446 | - "%s has removed the D-Line for: [%s]", get_oper_name(source_p), aconf->host); | |
447 | - ilog(L_KLINE, "UD %s %s", get_oper_name(source_p), aconf->host); | |
448 | ||
449 | - delete_one_address_conf(aconf->host, aconf); | |
450 | + sendto_one(source_p, ":%s NOTICE %s :D-Line for [%s] is removed", me.name, source_p->name, cidr); | |
451 | + sendto_realops_snomask(SNO_GENERAL, L_NETWIDE, | |
452 | + "%s has removed the D-Line for: [%s]", get_oper_name(source_p), cidr); | |
453 | + ilog(L_KLINE, "UD %s %s", get_oper_name(source_p), cidr); | |
454 | ||
455 | return 0; | |
456 | } | |
457 | diff -r a9a4e710ca64 modules/m_stats.c | |
458 | --- a/modules/m_stats.c Sun Apr 20 01:03:54 2008 -0500 | |
459 | +++ b/modules/m_stats.c Sun Apr 20 11:13:46 2008 +0400 | |
460 | @@ -951,6 +951,9 @@ | |
461 | { SHARED_UNRESV, 'R' }, | |
462 | { SHARED_LOCOPS, 'L' }, | |
463 | { SHARED_REHASH, 'H' }, | |
464 | + { SHARED_TDLINE, 'd' }, | |
465 | + { SHARED_PDLINE, 'D' }, | |
466 | + { SHARED_UNDLINE, 'E' }, | |
467 | { 0, '\0'} | |
468 | }; | |
469 | ||
470 | diff -r a9a4e710ca64 src/newconf.c | |
471 | --- a/src/newconf.c Sun Apr 20 01:03:54 2008 -0500 | |
472 | +++ b/src/newconf.c Sun Apr 20 11:13:46 2008 +0400 | |
473 | @@ -373,6 +373,10 @@ | |
474 | { "kline", SHARED_PKLINE|SHARED_TKLINE }, | |
475 | { "xline", SHARED_PXLINE|SHARED_TXLINE }, | |
476 | { "resv", SHARED_PRESV|SHARED_TRESV }, | |
477 | + { "dline", SHARED_PDLINE|SHARED_TDLINE }, | |
478 | + { "tdline", SHARED_TDLINE }, | |
479 | + { "pdline", SHARED_PDLINE }, | |
480 | + { "undline", SHARED_UNDLINE }, | |
481 | { "tkline", SHARED_TKLINE }, | |
482 | { "unkline", SHARED_UNKLINE }, | |
483 | { "txline", SHARED_TXLINE }, |