ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/branches/8.2.x/modules/m_dline.c
(Generate patch)

Comparing ircd-hybrid/trunk/modules/m_dline.c (file contents):
Revision 2340 by michael, Wed Jul 3 13:31:23 2013 UTC vs.
Revision 3110 by michael, Thu Mar 6 20:33:17 2014 UTC

# Line 1 | Line 1
1   /*
2 < *  ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3 < *  m_dline.c: Bans a user.
2 > *  ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3   *
4 < *  Copyright (C) 2002 by the past and present ircd coders, and others.
4 > *  Copyright (c) 1997-2014 ircd-hybrid development team
5   *
6   *  This program is free software; you can redistribute it and/or modify
7   *  it under the terms of the GNU General Public License as published by
# Line 18 | Line 17
17   *  along with this program; if not, write to the Free Software
18   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
19   *  USA
20 < *
21 < *  $Id$
20 > */
21 >
22 > /*! \file m_dline.c
23 > * \brief Includes required functions for processing the DLINE/UNDLINE command.
24 > * \version $Id$
25   */
26  
27   #include "stdinc.h"
# Line 61 | Line 63 | apply_dline(struct Client *source_p, str
63                           "%s added temporary %d min. D-Line for [%s] [%s]",
64                           get_oper_name(source_p), tkline_time/60,
65                           conf->host, conf->reason);
66 <    sendto_one(source_p, ":%s NOTICE %s :Added temporary %d min. D-Line [%s]",
67 <               MyConnect(source_p) ? me.name : ID_or_name(&me, source_p->from),
66 <               source_p->name, tkline_time/60, conf->host);
66 >    sendto_one_notice(source_p, &me, ":Added temporary %d min. D-Line [%s]",
67 >                      tkline_time/60, conf->host);
68      ilog(LOG_TYPE_DLINE, "%s added temporary %d min. D-Line for [%s] [%s]",
69           get_oper_name(source_p), tkline_time/60, conf->host, conf->reason);
70    }
# Line 72 | Line 73 | apply_dline(struct Client *source_p, str
73      sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
74                           "%s added D-Line for [%s] [%s]",
75                           get_oper_name(source_p), conf->host, conf->reason);
76 <    sendto_one(source_p, ":%s NOTICE %s :Added D-Line [%s]",
76 <               MyConnect(source_p) ? me.name : ID_or_name(&me, source_p->from),
77 <               source_p->name, conf->host);
76 >    sendto_one_notice(source_p, &me, ":Added D-Line [%s]", conf->host);
77      ilog(LOG_TYPE_DLINE, "%s added D-Line for [%s] [%s]",
78           get_oper_name(source_p), conf->host, conf->reason);
79  
# Line 112 | Line 111 | remove_dline_match(const char *host)
111    else
112      piphost = NULL;
113  
114 <  if ((conf = find_conf_by_address(host, piphost, CONF_DLINE | 1, aftype, NULL, NULL, 0)))
114 >  if ((conf = find_conf_by_address(host, piphost, CONF_DLINE, aftype, NULL, NULL, 0)))
115    {
116      if (IsConfDatabase(conf))
117      {
# Line 134 | Line 133 | remove_dline_match(const char *host)
133   * side effects - D line is added
134   *
135   */
136 < static void
136 > static int
137   mo_dline(struct Client *client_p, struct Client *source_p,
138           int parc, char *parv[])
139   {
# Line 154 | Line 153 | mo_dline(struct Client *client_p, struct
153  
154    if (!HasOFlag(source_p, OPER_FLAG_DLINE))
155    {
156 <    sendto_one(source_p, form_str(ERR_NOPRIVS),
157 <               me.name, source_p->name, "dline");
159 <    return;
156 >    sendto_one_numeric(source_p, &me, ERR_NOPRIVS, "dline");
157 >    return 0;
158    }
159  
160    if (parse_aline("DLINE", source_p,  parc, parv, AWILD, &dlhost,
161                    NULL, &tkline_time, &target_server, &reason) < 0)
162 <    return;
162 >    return 0;
163  
164    if (target_server != NULL)
165    {
166 <    if (HasID(source_p))
167 <    {
168 <      sendto_server(NULL, CAP_DLN|CAP_TS6, NOCAPS,
171 <                    ":%s DLINE %s %lu %s :%s",
172 <                    source_p->id, target_server, (unsigned long)tkline_time,
173 <                    dlhost, reason);
174 <      sendto_server(NULL, CAP_DLN, CAP_TS6,
175 <                    ":%s DLINE %s %lu %s :%s",
176 <                    source_p->name, target_server, (unsigned long)tkline_time,
177 <                    dlhost, reason);
178 <    }
179 <    else
180 <      sendto_server(NULL, CAP_DLN, NOCAPS,
181 <                    ":%s DLINE %s %lu %s :%s",
182 <                    source_p->name, target_server, (unsigned long)tkline_time,
183 <                    dlhost, reason);
166 >    sendto_match_servs(source_p, target_server, CAP_DLN, "DLINE %s %lu %s :%s",
167 >                       target_server, (unsigned long)tkline_time,
168 >                       dlhost, reason);
169  
170      /* Allow ON to apply local kline as well if it matches */
171      if (match(target_server, me.name))
172 <      return;
172 >      return 0;
173    }
174    else
175      cluster_a_line(source_p, "DLINE", CAP_DLN, SHARED_DLINE,
# Line 192 | Line 177 | mo_dline(struct Client *client_p, struct
177  
178    if ((t = parse_netmask(dlhost, NULL, &bits)) == HM_HOST)
179    {
180 <    if ((target_p = find_chasing(client_p, source_p, dlhost, NULL)) == NULL)
181 <      return;
180 >    if ((target_p = find_chasing(source_p, dlhost, NULL)) == NULL)
181 >      return 0;
182  
183      if (!MyConnect(target_p))
184      {
185 <      sendto_one(source_p,
186 <                 ":%s NOTICE %s :Can't DLINE nick on another server",
202 <                 me.name, source_p->name);
203 <      return;
185 >      sendto_one_notice(source_p, &me, ":Can't DLINE nick on another server");
186 >      return 0;
187      }
188  
189      if (IsExemptKline(target_p))
190      {
191 <      sendto_one(source_p,
192 <                 ":%s NOTICE %s :%s is E-lined", me.name,
193 <                 source_p->name, target_p->name);
211 <      return;
191 >      sendto_one_notice(source_p, &me, ":%s is E-lined",
192 >                        target_p->name);
193 >      return 0;
194      }
195  
196      getnameinfo((struct sockaddr *)&target_p->localClient->ip,
# Line 221 | Line 203 | mo_dline(struct Client *client_p, struct
203  
204    if (bits < 8)
205    {
206 <    sendto_one(source_p,
207 <               ":%s NOTICE %s :For safety, bitmasks less than 8 require conf access.",
226 <               me.name, source_p->name);
227 <    return;
206 >    sendto_one_notice(source_p, &me, ":For safety, bitmasks less than 8 require conf access.");
207 >    return 0;
208    }
209  
210   #ifdef IPV6
# Line 239 | Line 219 | mo_dline(struct Client *client_p, struct
219    if ((conf = find_dline_conf(&daddr, aftype)) != NULL)
220    {
221      creason = conf->reason ? conf->reason : def_reason;
222 +
223      if (IsConfExemptKline(conf))
224 <      sendto_one(source_p,
225 <                 ":%s NOTICE %s :[%s] is (E)d-lined by [%s] - %s",
245 <                 me.name, source_p->name, dlhost, conf->host, creason);
224 >      sendto_one_notice(source_p, &me, ":[%s] is (E)d-lined by [%s] - %s",
225 >                        dlhost, conf->host, creason);
226      else
227 <      sendto_one(source_p,
228 <                 ":%s NOTICE %s :[%s] already D-lined by [%s] - %s",
229 <                 me.name, source_p->name, dlhost, conf->host, creason);
250 <    return;
227 >      sendto_one_notice(source_p, &me, ":[%s] already D-lined by [%s] - %s",
228 >                        dlhost, conf->host, creason);
229 >    return 0;
230    }
231  
232    cur_time = CurrentTime;
233    current_date = smalldate(cur_time);
234  
235    if (!valid_comment(source_p, reason, 1))
236 <    return;
236 >    return 0;
237  
238    conf = conf_make(CONF_DLINE);
239    conf->host = xstrdup(dlhost);
# Line 268 | Line 247 | mo_dline(struct Client *client_p, struct
247    conf->reason = xstrdup(buffer);
248    apply_dline(source_p, conf, tkline_time);
249    rehashed_klines = 1;
250 +  return 0;
251   }
252  
253 < static void
253 > static int
254   ms_dline(struct Client *client_p, struct Client *source_p,
255           int parc, char *parv[])
256   {
# Line 288 | Line 268 | ms_dline(struct Client *client_p, struct
268    char buffer[IRCD_BUFSIZE];
269  
270    if (parc != 5 || EmptyString(parv[4]))
271 <    return;
271 >    return 0;
272  
273    /* parv[0]  parv[1]        parv[2]      parv[3]  parv[4] */
274    /* oper     target_server  tkline_time  host     reason  */
# Line 297 | Line 277 | ms_dline(struct Client *client_p, struct
277                       parv[1], parv[2], parv[3], parv[4]);
278  
279    if (match(parv[1], me.name))
280 <    return;
280 >    return 0;
281  
282    tkline_time = valid_tkline(parv[2], TK_SECONDS);
283    dlhost = parv[3];
284    reason = parv[4];
285  
286 <  if (HasFlag(source_p, FLAGS_SERVICE) || find_matching_name_conf(CONF_ULINE, source_p->servptr->name,
286 >  if (HasFlag(source_p, FLAGS_SERVICE) ||
287 >      find_matching_name_conf(CONF_ULINE, source_p->servptr->name,
288                                source_p->username, source_p->host,
289                                SHARED_DLINE))
290    {
291      if (!IsClient(source_p))
292 <      return;
292 >      return 0;
293 >
294      if ((t = parse_netmask(dlhost, NULL, &bits)) == HM_HOST)
295      {
296 <      if ((target_p = find_chasing(client_p, source_p, dlhost, NULL)) == NULL)
297 <        return;
296 >      if ((target_p = find_chasing(source_p, dlhost, NULL)) == NULL)
297 >        return 0;
298  
299        if (!MyConnect(target_p))
300        {
301 <        sendto_one(source_p,
302 <                   ":%s NOTICE %s :Can't DLINE nick on another server",
321 <                   me.name, source_p->name);
322 <        return;
301 >        sendto_one_notice(source_p, &me, ":Can't DLINE nick on another server");
302 >        return 0;
303        }
304  
305        if (IsExemptKline(target_p))
306        {
307 <        sendto_one(source_p,
308 <                   ":%s NOTICE %s :%s is E-lined", me.name,
329 <                   source_p->name, target_p->name);
330 <        return;
307 >        sendto_one_notice(source_p, &me, ":%s is E-lined", target_p->name);
308 >        return 0;
309        }
310  
311        getnameinfo((struct sockaddr *)&target_p->localClient->ip,
# Line 340 | Line 318 | ms_dline(struct Client *client_p, struct
318  
319      if (bits < 8)
320      {
321 <      sendto_one(source_p,
322 <                 ":%s NOTICE %s :For safety, bitmasks less than 8 require conf access.",
345 <                 me.name, source_p->name);
346 <      return;
321 >      sendto_one_notice(source_p, &me, ":For safety, bitmasks less than 8 require conf access.");
322 >      return 0;
323      }
324  
325   #ifdef IPV6
# Line 359 | Line 335 | ms_dline(struct Client *client_p, struct
335      {
336        creason = conf->reason ? conf->reason : def_reason;
337        if (IsConfExemptKline(conf))
338 <        sendto_one(source_p,
339 <                   ":%s NOTICE %s :[%s] is (E)d-lined by [%s] - %s",
364 <                   me.name, source_p->name, dlhost, conf->host, creason);
338 >        sendto_one_notice(source_p, &me, ":[%s] is (E)d-lined by [%s] - %s",
339 >                          dlhost, conf->host, creason);
340        else
341 <        sendto_one(source_p,
342 <                   ":%s NOTICE %s :[%s] already D-lined by [%s] - %s",
343 <                   me.name, source_p->name, dlhost, conf->host, creason);
369 <      return;
341 >        sendto_one_notice(source_p, &me, ":[%s] already D-lined by [%s] - %s",
342 >                          dlhost, conf->host, creason);
343 >      return 0;
344      }
345  
346      cur_time = CurrentTime;
347      current_date = smalldate(cur_time);
348  
349      if (!valid_comment(source_p, reason, 1))
350 <      return;
350 >      return 0;
351  
352      conf = conf_make(CONF_DLINE);
353      conf->host = xstrdup(dlhost);
# Line 388 | Line 362 | ms_dline(struct Client *client_p, struct
362      apply_dline(source_p, conf, tkline_time);
363      rehashed_klines = 1;
364    }
365 +
366 +  return 0;
367   }
368  
369   /*
# Line 399 | Line 375 | ms_dline(struct Client *client_p, struct
375   **      parv[0] = sender nick
376   **      parv[1] = dline to remove
377   */
378 < static void
378 > static int
379   mo_undline(struct Client *client_p, struct Client *source_p,
380             int parc, char *parv[])
381   {
# Line 408 | Line 384 | mo_undline(struct Client *client_p, stru
384  
385    if (!HasOFlag(source_p, OPER_FLAG_UNDLINE))
386    {
387 <    sendto_one(source_p, form_str(ERR_NOPRIVS),
388 <               me.name, source_p->name, "undline");
413 <    return;
387 >    sendto_one_numeric(source_p, &me, ERR_NOPRIVS, "undline");
388 >    return 0;
389    }
390  
391    if (parc < 2 || EmptyString(parv[1]))
392    {
393 <    sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
394 <               me.name, source_p->name, "UNDLINE");
420 <    return;
393 >    sendto_one_numeric(source_p, &me, ERR_NEEDMOREPARAMS, "UNDLINE");
394 >    return 0;
395    }
396  
397    if (parse_aline("UNDLINE", source_p, parc, parv, 0, &user,
398                    &addr, NULL, &target_server, NULL) < 0)
399 <    return;
399 >    return 0;
400  
401    if (target_server != NULL)
402    {
# Line 431 | Line 405 | mo_undline(struct Client *client_p, stru
405  
406      /* Allow ON to apply local unkline as well if it matches */
407      if (match(target_server, me.name))
408 <      return;
408 >      return 0;
409    }
410    else
411      cluster_a_line(source_p, "UNDLINE", CAP_UNDLN, SHARED_UNDLINE,
# Line 439 | Line 413 | mo_undline(struct Client *client_p, stru
413  
414    if (remove_dline_match(addr))
415    {
416 <    sendto_one(source_p,
443 <               ":%s NOTICE %s :D-Line for [%s] is removed",
444 <               me.name, source_p->name, addr);
416 >    sendto_one_notice(source_p, &me, ":D-Line for [%s] is removed", addr);
417      sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
418                           "%s has removed the D-Line for: [%s]",
419                           get_oper_name(source_p), addr);
# Line 449 | Line 421 | mo_undline(struct Client *client_p, stru
421           get_oper_name(source_p), addr);
422    }
423    else
424 <    sendto_one(source_p, ":%s NOTICE %s :No D-Line for [%s] found",
425 <               me.name, source_p->name, addr);
424 >    sendto_one_notice(source_p, &me, ":No D-Line for [%s] found", addr);
425 >  return 0;
426   }
427  
428 < static void
429 < me_undline(struct Client *client_p, struct Client *source_p,
428 > static int
429 > ms_undline(struct Client *client_p, struct Client *source_p,
430             int parc, char *parv[])
431   {
432 <  const char *addr = NULL;
432 >  const char *addr = parv[1];
433  
434    if (parc != 3 || EmptyString(parv[2]))
435 <    return;
435 >    return 0;
436  
437 <  addr = parv[2];
437 >  sendto_match_servs(source_p, parv[1], CAP_UNDLN,
438 >                     "UNDLINE %s %s",
439 >                     parv[1], parv[2]);
440  
441    if (!IsClient(source_p) || match(parv[1], me.name))
442 <    return;
442 >    return 0;
443  
444 <  if (HasFlag(source_p, FLAGS_SERVICE) || find_matching_name_conf(CONF_ULINE,
445 <                                   source_p->servptr->name,
446 <                                   source_p->username, source_p->host,
447 <                                   SHARED_UNDLINE))
444 >  if (HasFlag(source_p, FLAGS_SERVICE) ||
445 >      find_matching_name_conf(CONF_ULINE, source_p->servptr->name,
446 >                              source_p->username, source_p->host,
447 >                              SHARED_UNDLINE))
448    {
449      if (remove_dline_match(addr))
450      {
451 <      sendto_one(source_p,
478 <                 ":%s NOTICE %s :D-Line for [%s] is removed",
479 <                 me.name, source_p->name, addr);
451 >      sendto_one_notice(source_p, &me, ":D-Line for [%s] is removed", addr);
452        sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
453                             "%s has removed the D-Line for: [%s]",
454                             get_oper_name(source_p), addr);
# Line 484 | Line 456 | me_undline(struct Client *client_p, stru
456             get_oper_name(source_p), addr);
457      }
458      else
459 <      sendto_one(source_p, ":%s NOTICE %s :No D-Line for [%s] found",
488 <                 me.name, source_p->name, addr);
459 >      sendto_one_notice(source_p, &me, ":No D-Line for [%s] found", addr);
460    }
490 }
491
492 static void
493 ms_undline(struct Client *client_p, struct Client *source_p,
494           int parc, char *parv[])
495 {
496  if (parc != 3 || EmptyString(parv[2]))
497    return;
498
499  sendto_match_servs(source_p, parv[1], CAP_UNDLN,
500                     "UNDLINE %s %s",
501                     parv[1], parv[2]);
461  
462 <  me_undline(client_p, source_p, parc, parv);
462 >  return 0;
463   }
464  
465 < static struct Message dline_msgtab = {
465 > static struct Message dline_msgtab =
466 > {
467    "DLINE", 0, 0, 2, MAXPARA, MFLG_SLOW, 0,
468 <   {m_unregistered, m_not_oper, ms_dline, m_ignore, mo_dline, m_ignore}
468 >  { m_unregistered, m_not_oper, ms_dline, m_ignore, mo_dline, m_ignore }
469   };
470  
471 < static struct Message undline_msgtab = {
471 > static struct Message undline_msgtab =
472 > {
473    "UNDLINE", 0, 0, 2, MAXPARA, MFLG_SLOW, 0,
474 <   {m_unregistered, m_not_oper, ms_undline, m_ignore, mo_undline, m_ignore}
474 >  { m_unregistered, m_not_oper, ms_undline, m_ignore, mo_undline, m_ignore }
475   };
476  
477   static void
# Line 531 | Line 492 | module_exit(void)
492    delete_capability("DLN");
493   }
494  
495 < struct module module_entry = {
495 > struct module module_entry =
496 > {
497    .node    = { NULL, NULL, NULL },
498    .name    = NULL,
499    .version = "$Revision$",

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)