ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid-8/modules/m_gline.c
Revision: 988
Committed: Sun Aug 16 14:00:36 2009 UTC (17 years, 2 months ago) by michael
Content type: text/x-csrc
Original Path: ircd-hybrid-7.2/modules/m_gline.c
File size: 21375 byte(s)
Log Message:
- removed remnants of --disable-gline-voting

File Contents

# User Rev Content
1 adx 30 /*
2     * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3     * m_gline.c: Votes towards globally banning a mask.
4     *
5     * Copyright (C) 2002 by the past and present ircd coders, and others.
6     *
7     * This program is free software; you can redistribute it and/or modify
8     * it under the terms of the GNU General Public License as published by
9     * the Free Software Foundation; either version 2 of the License, or
10     * (at your option) any later version.
11     *
12     * This program is distributed in the hope that it will be useful,
13     * but WITHOUT ANY WARRANTY; without even the implied warranty of
14     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15     * GNU General Public License for more details.
16     *
17     * You should have received a copy of the GNU General Public License
18     * along with this program; if not, write to the Free Software
19     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20     * USA
21     *
22 knight 31 * $Id$
23 adx 30 */
24    
25     #include "stdinc.h"
26     #include "tools.h"
27     #include "handlers.h"
28     #include "s_gline.h"
29     #include "channel.h"
30     #include "client.h"
31     #include "common.h"
32     #include "irc_string.h"
33     #include "sprintf_irc.h"
34     #include "ircd.h"
35     #include "hostmask.h"
36     #include "numeric.h"
37     #include "fdlist.h"
38     #include "s_bsd.h"
39     #include "s_conf.h"
40     #include "s_misc.h"
41     #include "send.h"
42     #include "msg.h"
43     #include "fileio.h"
44     #include "s_serv.h"
45     #include "hash.h"
46     #include "parse.h"
47     #include "modules.h"
48     #include "list.h"
49     #include "s_log.h"
50    
51     #define GLINE_NOT_PLACED 0
52     #define GLINE_ALREADY_VOTED -1
53     #define GLINE_PLACED 1
54    
55     extern dlink_list gdeny_items;
56    
57     /* internal functions */
58     static void set_local_gline(const struct Client *,
59     const char *, const char *, const char *);
60 michael 957 static int remove_gline_match(const char *, const char *);
61     static int check_majority(const struct Client *, const char *,
62     const char *, const char *, int);
63 db 937 static void add_new_majority(const struct Client *,
64     const char *, const char *, const char *);
65 adx 30
66 michael 958 static void do_sgline(struct Client *, struct Client *, int, char *[], int);
67 adx 30
68 michael 958 static void me_gline(struct Client *, struct Client *, int, char *[]);
69     static void ms_gline(struct Client *, struct Client *, int, char *[]);
70     static void mo_gline(struct Client *, struct Client *, int, char *[]);
71 adx 30
72 michael 958 static void do_sungline(struct Client *, struct Client *, int, char *[], int);
73 db 937
74 michael 958 static void me_gungline(struct Client *, struct Client *, int, char *[]);
75     static void mo_gungline(struct Client *, struct Client *, int, char *[]);
76 db 937
77 adx 30 /*
78     * gline enforces 3 parameters to force operator to give a reason
79     * a gline is not valid with "No reason"
80     * -db
81     */
82     struct Message gline_msgtab = {
83     "GLINE", 0, 0, 3, 0, MFLG_SLOW, 0,
84     {m_unregistered, m_not_oper, ms_gline, me_gline, mo_gline, m_ignore}
85     };
86    
87 db 937 struct Message ungline_msgtab = {
88 db 940 "GUNGLINE", 0, 0, 3, 0, MFLG_SLOW, 0,
89     {m_unregistered, m_not_oper, m_ignore, me_gungline, mo_gungline, m_ignore}
90 db 937 };
91    
92 michael 958
93 adx 30 #ifndef STATIC_MODULES
94     void
95     _modinit(void)
96     {
97 michael 957 mod_add_cmd(&gline_msgtab);
98     mod_add_cmd(&ungline_msgtab);
99     add_capability("GLN", CAP_GLN, 1);
100 adx 30 }
101    
102     void
103     _moddeinit(void)
104     {
105     mod_del_cmd(&gline_msgtab);
106 db 937 mod_del_cmd(&ungline_msgtab);
107 adx 30 delete_capability("GLN");
108     }
109    
110 knight 31 const char *_version = "$Revision$";
111 adx 30 #endif
112    
113     /* mo_gline()
114     *
115     * inputs - The usual for a m_ function
116     * output -
117     * side effects -
118     *
119     * Place a G line if 3 opers agree on the identical user@host
120     *
121     */
122     /* Allow this server to pass along GLINE if received and
123     * GLINES is not defined.
124     *
125     */
126    
127     static void
128     mo_gline(struct Client *client_p, struct Client *source_p,
129     int parc, char *parv[])
130     {
131     char *user = NULL;
132     char *host = NULL; /* user and host of GLINE "victim" */
133     char *reason = NULL; /* reason for "victims" demise */
134     char *p;
135    
136     if (!ConfigFileEntry.glines)
137     {
138     sendto_one(source_p, ":%s NOTICE %s :GLINE disabled",
139     me.name, source_p->name);
140     return;
141     }
142    
143     if (!IsOperGline(source_p))
144     {
145     sendto_one(source_p, form_str(ERR_NOPRIVS),
146     me.name, source_p->name, "gline");
147     return;
148     }
149    
150 michael 958 if (parse_aline("GLINE", source_p, parc, parv, AWILD,
151     &user, &host, NULL, NULL, &reason) < 0)
152 adx 30 return;
153    
154     if ((p = strchr(host, '/')) != NULL)
155     {
156     int bitlen = strtol(++p, NULL, 10);
157     int min_bitlen = strchr(host, ':') ? ConfigFileEntry.gline_min_cidr6 :
158     ConfigFileEntry.gline_min_cidr;
159     if (bitlen < min_bitlen)
160     {
161     sendto_one(source_p, ":%s NOTICE %s :Cannot set G-Lines with CIDR length < %d",
162     me.name, source_p->name, min_bitlen);
163     return;
164     }
165     }
166    
167     /* If at least 3 opers agree this user should be G lined then do it */
168 michael 958 if (check_majority(source_p, user, host, reason, GLINE_PENDING_ADD_TYPE) ==
169 adx 30 GLINE_ALREADY_VOTED)
170     {
171     sendto_one(source_p,
172     ":%s NOTICE %s :This server or oper has already voted",
173     me.name, source_p->name);
174     return;
175     }
176    
177 michael 552 /*
178     * call these two functions first so the 'requesting' notice always comes
179 adx 30 * before the 'has triggered' notice. -bill
180     */
181     sendto_realops_flags(UMODE_ALL, L_ALL,
182     "%s requesting G-Line for [%s@%s] [%s]",
183     get_oper_name(source_p),
184     user, host, reason);
185     ilog(L_TRACE, "#gline for %s@%s [%s] requested by %s!%s@%s",
186     user, host, reason, source_p->name, source_p->username,
187     source_p->host);
188 michael 988
189 adx 30 /* 4 param version for hyb-7 servers */
190 michael 885 sendto_server(NULL, NULL, CAP_GLN|CAP_TS6, NOCAPS,
191     ":%s GLINE %s %s :%s",
192 adx 30 ID(source_p), user, host, reason);
193 michael 885 sendto_server(NULL, NULL, CAP_GLN, CAP_TS6,
194     ":%s GLINE %s %s :%s",
195 adx 30 source_p->name, user, host, reason);
196    
197     /* 8 param for hyb-6 */
198 michael 885 sendto_server(NULL, NULL, CAP_TS6, CAP_GLN,
199 adx 30 ":%s GLINE %s %s %s %s %s %s :%s",
200     ID(&me),
201     ID(source_p), source_p->username,
202     source_p->host, source_p->servptr->name, user, host,
203     reason);
204 michael 885 sendto_server(NULL, NULL, NOCAPS, CAP_GLN|CAP_TS6,
205 adx 30 ":%s GLINE %s %s %s %s %s %s :%s",
206     me.name, source_p->name, source_p->username,
207     source_p->host, source_p->servptr->name, user, host,
208     reason);
209     }
210    
211     /* ms_gline()
212     * me_gline()
213     * do_sgline()
214     *
215     * inputs - The usual for a m_ function
216     * output -
217     * side effects -
218     *
219     * Place a G line if 3 opers agree on the identical user@host
220     *
221     * Allow this server to pass along GLINE if received and
222     * GLINES is not defined.
223     *
224     * ENCAP'd GLINES are propagated by encap code.
225     */
226    
227     static void
228     ms_gline(struct Client *client_p, struct Client *source_p,
229     int parc, char *parv[])
230     {
231     do_sgline(client_p, source_p, parc, parv, 1);
232     }
233    
234     static void
235     me_gline(struct Client *client_p, struct Client *source_p,
236     int parc, char *parv[])
237     {
238     do_sgline(client_p, source_p, parc, parv, 0);
239     }
240    
241     static void
242     do_sgline(struct Client *client_p, struct Client *source_p,
243     int parc, char *parv[], int prop)
244     {
245     const char *reason = NULL; /* reason for "victims" demise */
246     char *user = NULL;
247     char *host = NULL; /* user and host of GLINE "victim" */
248     int var_offset, logged = 0;
249     dlink_node *ptr;
250     struct ConfItem *conf;
251     struct AccessItem *aconf;
252    
253     /* hyb-7 style gline (post beta3) */
254     if (parc == 4 && IsClient(source_p))
255     var_offset = 0;
256     /* or it's a hyb-6 style */
257     else if (parc == 8 && IsServer(source_p))
258     {
259     var_offset = 4;
260    
261     /*
262     * if we are dealing with an old style formatted gline,
263     * the gline message is originating from the oper's server,
264     * so we update source_p to point to the oper now, so that
265     * logging works down the line. -bill
266     */
267     if ((source_p = find_person(client_p, parv[1])) == NULL)
268     return;
269    
270     if (irccmp(parv[2], source_p->username) != 0 ||
271     irccmp(parv[3], source_p->host) != 0 ||
272     irccmp(parv[4], source_p->servptr->name) != 0)
273     {
274     /*
275     * at this point we know one of the parameters provided by
276     * the h6 server was faulty. bail out.
277     */
278     return;
279     }
280     }
281     /* none of the above */
282     else
283     return;
284    
285     assert(source_p->servptr != NULL);
286    
287 michael 958 user = parv[++var_offset];
288     host = parv[++var_offset];
289     reason = parv[++var_offset];
290 adx 30 var_offset = 0;
291    
292     DLINK_FOREACH(ptr, gdeny_items.head)
293     {
294     conf = ptr->data;
295     aconf = (struct AccessItem *)map_to_conf(conf);
296    
297     if (match(conf->name, source_p->servptr->name) &&
298     match(aconf->user, source_p->username) &&
299     match(aconf->host, source_p->host))
300     {
301     var_offset = aconf->flags;
302     break;
303     }
304     }
305    
306     if (prop && !(var_offset & GDENY_BLOCK))
307     {
308 michael 885 sendto_server(client_p, NULL, CAP_GLN, NOCAPS,
309 adx 30 ":%s GLINE %s %s :%s",
310     source_p->name, user, host, reason);
311     /* hyb-6 version to the rest */
312 michael 885 sendto_server(client_p, NULL, NOCAPS, CAP_GLN,
313 adx 30 ":%s GLINE %s %s %s %s %s %s :%s",
314     source_p->servptr->name,
315     source_p->name, source_p->username, source_p->host,
316     source_p->servptr->name,
317     user, host, reason);
318     }
319     else if (ConfigFileEntry.gline_logging & GDENY_BLOCK && ServerInfo.hub)
320     {
321     sendto_realops_flags(UMODE_ALL, L_ALL, "Blocked G-Line %s requested on [%s@%s] [%s]",
322     get_oper_name(source_p), user, host, reason);
323     ilog(L_TRACE, "Blocked G-Line %s requested on [%s@%s] [%s]",
324     get_oper_name(source_p), user, host, reason);
325     logged = 1;
326     }
327    
328    
329     if (var_offset & GDENY_REJECT)
330     {
331     if (ConfigFileEntry.gline_logging & GDENY_REJECT && !logged)
332     {
333     sendto_realops_flags(UMODE_ALL, L_ALL, "Rejected G-Line %s requested on [%s@%s] [%s]",
334     get_oper_name(source_p), user, host, reason);
335     ilog(L_TRACE, "Rejected G-Line %s requested on [%s@%s] [%s]",
336     get_oper_name(source_p), user, host, reason);
337     }
338 michael 958
339 adx 30 return;
340     }
341    
342     if (ConfigFileEntry.glines)
343     {
344     if (!valid_wild_card(source_p, YES, 2, user, host))
345     return;
346    
347     if (IsClient(source_p))
348     {
349     const char *p = NULL;
350 michael 958
351 adx 30 if ((p = strchr(host, '/')))
352     {
353     int bitlen = strtol(++p, NULL, 10);
354     int min_bitlen = strchr(host, ':') ? ConfigFileEntry.gline_min_cidr6 :
355     ConfigFileEntry.gline_min_cidr;
356    
357     if (bitlen < min_bitlen)
358     {
359     sendto_realops_flags(UMODE_ALL, L_ALL, "%s!%s@%s on %s is requesting "
360     "a GLINE with a CIDR mask < %d for [%s@%s] [%s]",
361     source_p->name, source_p->username, source_p->host,
362     source_p->servptr->name, min_bitlen, user, host, reason);
363     return;
364     }
365     }
366     }
367    
368     /* If at least 3 opers agree this user should be G lined then do it */
369 michael 988 if (check_majority(source_p, user, host, reason, GLINE_PENDING_ADD_TYPE) ==
370 adx 30 GLINE_ALREADY_VOTED)
371     {
372     sendto_realops_flags(UMODE_ALL, L_ALL, "oper or server has already voted");
373     return;
374     }
375    
376 michael 554 sendto_realops_flags(UMODE_ALL, L_ALL,
377     "%s requesting G-Line for [%s@%s] [%s]",
378     get_oper_name(source_p),
379     user, host, reason);
380 adx 30 ilog(L_TRACE, "#gline for %s@%s [%s] requested by %s",
381     user, host, reason, get_oper_name(source_p));
382     }
383     }
384    
385     /* set_local_gline()
386     *
387     * inputs - pointer to client struct of oper
388     * - pointer to victim user
389     * - pointer to victim host
390     * - pointer reason
391     * output - NONE
392     * side effects -
393     */
394     static void
395     set_local_gline(const struct Client *source_p, const char *user,
396     const char *host, const char *reason)
397     {
398     char buffer[IRCD_BUFSIZE];
399     struct ConfItem *conf;
400     struct AccessItem *aconf;
401    
402    
403     conf = make_conf_item(GLINE_TYPE);
404 michael 957 aconf = map_to_conf(conf);
405 adx 30
406 michael 958 ircsprintf(buffer, "%s (%s)", reason, smalldate(CurrentTime));
407 adx 30 DupString(aconf->reason, buffer);
408     DupString(aconf->user, user);
409     DupString(aconf->host, host);
410    
411     aconf->hold = CurrentTime + ConfigFileEntry.gline_time;
412     add_temp_line(conf);
413    
414     sendto_realops_flags(UMODE_ALL, L_ALL,
415     "%s added G-Line for [%s@%s] [%s]",
416     get_oper_name(source_p),
417     aconf->user, aconf->host, aconf->reason);
418     ilog(L_TRACE, "%s added G-Line for [%s@%s] [%s]",
419     get_oper_name(source_p), aconf->user, aconf->host, aconf->reason);
420     log_oper_action(LOG_GLINE_TYPE, source_p, "[%s@%s] [%s]\n",
421 michael 958 aconf->user, aconf->host, aconf->reason);
422 adx 30 /* Now, activate gline against current online clients */
423     rehashed_klines = 1;
424     }
425    
426 db 937 /* add_new_majority()
427 adx 30 *
428     * inputs - operator requesting gline
429     * - username covered by the gline
430     * - hostname covered by the gline
431     * - reason for the gline
432     * output - NONE
433     * side effects -
434     * This function is called once a majority of opers
435     * have agreed on a gline, and it can be placed. The
436     * information about an operator being passed to us
437     * happens to be the operator who pushed us over the
438 db 937 * "majority" level needed. See check_majority()
439 adx 30 * for more information.
440     */
441     static void
442 michael 957 add_new_majority(const struct Client *source_p, const char *user,
443     const char *host, const char *reason)
444 adx 30 {
445     struct gline_pending *pending = MyMalloc(sizeof(struct gline_pending));
446    
447 michael 957 strlcpy(pending->vote_1.oper_nick, source_p->name, sizeof(pending->vote_1.oper_nick));
448     strlcpy(pending->vote_1.oper_user, source_p->username, sizeof(pending->vote_1.oper_user));
449 michael 958 strlcpy(pending->vote_1.oper_host, source_p->host, sizeof(pending->vote_1.oper_host));
450 michael 957 strlcpy(pending->vote_1.oper_server, source_p->servptr->name, sizeof(pending->vote_1.oper_server));
451 adx 30
452     strlcpy(pending->user, user, sizeof(pending->user));
453     strlcpy(pending->host, host, sizeof(pending->host));
454 michael 957 strlcpy(pending->vote_1.reason, reason, sizeof(pending->vote_1.reason));
455 adx 30
456     pending->last_gline_time = CurrentTime;
457 michael 988 pending->vote_1.time_request = CurrentTime;
458 adx 30
459 michael 957 dlinkAdd(pending, &pending->node, &pending_glines[GLINE_PENDING_ADD_TYPE]);
460 adx 30 }
461    
462 db 937 /* check_majority()
463 adx 30 *
464     * inputs - source, user, host, reason
465     *
466     * output - one of three results
467     *
468     * GLINE_ALREADY_VOTED - returned if oper/server has already voted
469     * GLINE_PLACED - returned if this triggers a gline
470     * GLINE_NOT_PLACED - returned if not triggered
471     *
472     * Side effects -
473     * See if there is a majority agreement on a GLINE on the given user
474     * There must be at least 3 different opers agreeing on this GLINE
475     *
476     */
477     static int
478 michael 957 check_majority(const struct Client *source_p, const char *user,
479     const char *host, const char *reason, int type)
480 adx 30 {
481 michael 957 dlink_node *dn_ptr = NULL;
482 adx 30
483 michael 957 cleanup_glines(NULL);
484    
485 adx 30 /* if its already glined, why bother? :) -- fl_ */
486 michael 957 if ((type == GLINE_PENDING_ADD_TYPE) && find_is_glined(host, user))
487     return GLINE_NOT_PLACED;
488 adx 30
489 michael 957 DLINK_FOREACH(dn_ptr, pending_glines[type].head)
490 adx 30 {
491 michael 957 struct gline_pending *gp_ptr = dn_ptr->data;
492 adx 30
493 michael 957 if (irccmp(gp_ptr->user, user) ||
494     irccmp(gp_ptr->host, host))
495     continue;
496 adx 30
497 michael 988 if ((!irccmp(gp_ptr->vote_1.oper_user, source_p->username) &&
498     !irccmp(gp_ptr->vote_1.oper_host, source_p->host)) ||
499 michael 957 !irccmp(gp_ptr->vote_1.oper_server, source_p->servptr->name))
500     return GLINE_ALREADY_VOTED;
501    
502     if (gp_ptr->vote_2.oper_user[0] != '\0')
503 adx 30 {
504 michael 958 /* if two other opers on two different servers have voted yes */
505 michael 988 if ((!irccmp(gp_ptr->vote_2.oper_user, source_p->username) &&
506     !irccmp(gp_ptr->vote_2.oper_host, source_p->host)) ||
507 michael 957 !irccmp(gp_ptr->vote_2.oper_server, source_p->servptr->name))
508     return GLINE_ALREADY_VOTED;
509    
510     if (type == GLINE_PENDING_DEL_TYPE)
511 adx 30 {
512 michael 957 if (remove_gline_match(user, host))
513     {
514     sendto_realops_flags(UMODE_ALL, L_ALL,
515     "%s has removed the G-Line for: [%s@%s]",
516     get_oper_name(source_p), user, host);
517     ilog(L_NOTICE, "%s removed G-Line for [%s@%s]",
518 michael 958 get_oper_name(source_p), user, host);
519 michael 957 }
520 adx 30 }
521 michael 957 else
522     /* trigger the gline using the original reason --fl */
523     set_local_gline(source_p, user, host, gp_ptr->vote_1.reason);
524 adx 30
525 michael 957 cleanup_glines(gp_ptr);
526     return GLINE_PLACED;
527     }
528 adx 30
529 michael 988 strlcpy(gp_ptr->vote_2.oper_nick, source_p->name,
530     sizeof(gp_ptr->vote_2.oper_nick));
531 michael 957 strlcpy(gp_ptr->vote_2.oper_user, source_p->username,
532 michael 988 sizeof(gp_ptr->vote_2.oper_user));
533 michael 957 strlcpy(gp_ptr->vote_2.oper_host, source_p->host,
534     sizeof(gp_ptr->vote_2.oper_host));
535     strlcpy(gp_ptr->vote_2.reason, reason,
536     sizeof(gp_ptr->vote_2.reason));
537     strlcpy(gp_ptr->vote_2.oper_server, source_p->servptr->name,
538     sizeof(gp_ptr->vote_2.oper_server));
539     gp_ptr->last_gline_time = CurrentTime;
540     gp_ptr->vote_2.time_request = CurrentTime;
541     return GLINE_NOT_PLACED;
542 adx 30 }
543    
544 michael 957 /*
545     * Didn't find this user@host gline in pending gline list
546 adx 30 * so add it.
547     */
548 michael 957 add_new_majority(source_p, user, host, reason);
549     return GLINE_NOT_PLACED;
550 adx 30 }
551    
552     static int
553     remove_gline_match(const char *user, const char *host)
554     {
555     struct AccessItem *aconf;
556     dlink_node *ptr = NULL;
557     struct irc_ssaddr addr, caddr;
558     int nm_t, cnm_t, bits, cbits;
559    
560     nm_t = parse_netmask(host, &addr, &bits);
561    
562     DLINK_FOREACH(ptr, temporary_glines.head)
563     {
564     aconf = map_to_conf(ptr->data);
565     cnm_t = parse_netmask(aconf->host, &caddr, &cbits);
566    
567     if (cnm_t != nm_t || irccmp(user, aconf->user))
568     continue;
569    
570     if ((nm_t == HM_HOST && !irccmp(aconf->host, host)) ||
571     (nm_t == HM_IPV4 && bits == cbits && match_ipv4(&addr, &caddr, bits))
572     #ifdef IPV6
573     || (nm_t == HM_IPV6 && bits == cbits && match_ipv6(&addr, &caddr, bits))
574     #endif
575 michael 957 )
576 adx 30 {
577     dlinkDelete(ptr, &temporary_glines);
578     delete_one_address_conf(aconf->host, aconf);
579 michael 957 return 1;
580 adx 30 }
581     }
582    
583 michael 957 return 0;
584 adx 30 }
585    
586 db 940 /*
587     * me_gungline()
588 db 937 * do_sungline()
589     *
590     * inputs - The usual for a m_ function
591     * output -
592     * side effects -
593     *
594     * Remove a G line if 3 opers agree on the identical user@host
595     *
596     * ENCAP'd UNGLINES are propagated by encap code.
597     */
598    
599     static void
600 db 940 me_gungline(struct Client *client_p, struct Client *source_p,
601 michael 957 int parc, char *parv[])
602 db 937 {
603 michael 958 if (ConfigFileEntry.glines)
604     do_sungline(client_p, source_p, parc, parv, 0);
605 db 937 }
606    
607     static void
608     do_sungline(struct Client *client_p, struct Client *source_p,
609 michael 957 int parc, char *parv[], int prop)
610 db 937 {
611 michael 958 const char *user = parv[1];
612     const char *host = parv[2]; /* user and host of GLINE "victim" */
613     const char *reason = parv[3];
614 db 937
615     assert(source_p->servptr != NULL);
616    
617 michael 957 sendto_realops_flags(UMODE_ALL, L_ALL,
618     "%s requesting UNG-Line for [%s@%s] [%s]",
619     get_oper_name(source_p),
620     user, host, reason);
621     ilog(L_TRACE, "#ungline for %s@%s [%s] requested by %s",
622     user, host, reason, get_oper_name(source_p));
623 db 937
624 michael 957 /* If at least 3 opers agree this user should be un G lined then do it */
625 michael 958 if (check_majority(source_p, user, host, reason, GLINE_PENDING_DEL_TYPE) ==
626 michael 957 GLINE_ALREADY_VOTED)
627     sendto_realops_flags(UMODE_ALL, L_ALL, "oper or server has already voted");
628 db 937 }
629    
630 db 940 /* mo_gungline()
631 db 937 *
632     * inputs - The usual for a m_ function
633     * output -
634     * side effects -
635     *
636     * Remove a G line if 3 opers agree on the identical user@host
637     *
638     */
639     /* Allow this server to pass along UNGLINE if received and
640     * GLINES is not defined.
641     *
642     */
643     static void
644 db 940 mo_gungline(struct Client *client_p, struct Client *source_p,
645 michael 957 int parc, char *parv[])
646 db 937 {
647     char *user = NULL;
648 michael 957 char *host = NULL; /* user and host of GLINE "victim" */
649     char *reason = NULL; /* reason for "victims" demise */
650 db 937
651     if (!ConfigFileEntry.glines)
652     {
653 michael 957 sendto_one(source_p, ":%s NOTICE %s :GUNGLINE disabled",
654 db 937 me.name, source_p->name);
655     return;
656     }
657    
658     if (!IsOperGline(source_p))
659     {
660     sendto_one(source_p, form_str(ERR_NOPRIVS),
661 michael 957 me.name, source_p->name, "gungline");
662 db 937 return;
663     }
664    
665 michael 957 if (parse_aline("GUNGLINE", source_p, parc, parv, 0, &user,
666     &host, NULL, NULL, &reason) < 0)
667 db 937 return;
668    
669     /*
670     * call these two functions first so the 'requesting' notice always comes
671     * before the 'has triggered' notice. -bill
672     */
673     sendto_realops_flags(UMODE_ALL, L_ALL,
674     "%s requesting UNG-Line for [%s@%s] [%s]",
675     get_oper_name(source_p),
676     user, host, reason);
677     ilog(L_TRACE, "#ungline for %s@%s [%s] requested by %s!%s@%s",
678     user, host, reason, source_p->name, source_p->username,
679     source_p->host);
680 michael 957
681     /* If at least 3 opers agree this user should be un G lined then do it */
682 michael 988 if (check_majority(source_p, user, host, reason, GLINE_PENDING_DEL_TYPE) ==
683 michael 957 GLINE_ALREADY_VOTED)
684     sendto_one(source_p,
685     ":%s NOTICE %s :This server or oper has already voted",
686     me.name, source_p->name);
687 michael 988
688 michael 957 sendto_server(client_p, NULL, CAP_ENCAP|CAP_TS6, NOCAPS,
689     ":%s ENCAP * GUNGLINE %s %s :%s",
690 michael 987 ID(source_p), user, host, reason);
691 michael 957 sendto_server(client_p, NULL, CAP_ENCAP, CAP_TS6,
692     ":%s ENCAP * GUNGLINE %s %s :%s",
693     source_p->name, user, host, reason);
694 db 937 }

Properties

Name Value
svn:eol-style native
svn:keywords Id Revision