diff options
Diffstat (limited to 'modules')
-rw-r--r-- | modules/m_dline.c | 66 | ||||
-rw-r--r-- | modules/m_kline.c | 322 |
2 files changed, 195 insertions, 193 deletions
diff --git a/modules/m_dline.c b/modules/m_dline.c index b89de45..b03303d 100644 --- a/modules/m_dline.c +++ b/modules/m_dline.c @@ -1,8 +1,7 @@ /* - * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). - * m_dline.c: Bans a user. + * ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd) * - * Copyright (C) 2002 by the past and present ircd coders, and others. + * Copyright (c) 2002-2014 ircd-hybrid development team * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,8 +17,11 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * USA - * - * $Id$ + */ + +/*! \file m_dline.c + * \brief Includes required functions for processing the DLINE/UNDLINE command. + * \version $Id$ */ #include "stdinc.h" @@ -154,8 +156,8 @@ mo_dline(struct Client *client_p, struct Client *source_p, if (!HasOFlag(source_p, OPER_FLAG_DLINE)) { - sendto_one(source_p, form_str(ERR_NOPRIVS), - me.name, source_p->name, "dline"); + sendto_one(source_p, form_str(ERR_NOPRIVS), me.name, + source_p->name, "dline"); return; } @@ -192,9 +194,8 @@ mo_dline(struct Client *client_p, struct Client *source_p, if (IsExemptKline(target_p)) { - sendto_one(source_p, - ":%s NOTICE %s :%s is E-lined", me.name, - source_p->name, target_p->name); + sendto_one(source_p, ":%s NOTICE %s :%s is E-lined", + me.name, source_p->name, target_p->name); return; } @@ -226,14 +227,13 @@ mo_dline(struct Client *client_p, struct Client *source_p, if ((conf = find_dline_conf(&daddr, aftype)) != NULL) { creason = conf->reason ? conf->reason : def_reason; + if (IsConfExemptKline(conf)) - sendto_one(source_p, - ":%s NOTICE %s :[%s] is (E)d-lined by [%s] - %s", - me.name, source_p->name, dlhost, conf->host, creason); + sendto_one(source_p, ":%s NOTICE %s :[%s] is (E)d-lined by [%s] - %s", + me.name, source_p->name, dlhost, conf->host, creason); else - sendto_one(source_p, - ":%s NOTICE %s :[%s] already D-lined by [%s] - %s", - me.name, source_p->name, dlhost, conf->host, creason); + sendto_one(source_p, ":%s NOTICE %s :[%s] already D-lined by [%s] - %s", + me.name, source_p->name, dlhost, conf->host, creason); return; } @@ -290,7 +290,8 @@ ms_dline(struct Client *client_p, struct Client *source_p, dlhost = parv[3]; reason = parv[4]; - if (HasFlag(source_p, FLAGS_SERVICE) || find_matching_name_conf(CONF_ULINE, source_p->servptr->name, + if (HasFlag(source_p, FLAGS_SERVICE) || + find_matching_name_conf(CONF_ULINE, source_p->servptr->name, source_p->username, source_p->host, SHARED_DLINE)) { @@ -395,8 +396,8 @@ mo_undline(struct Client *client_p, struct Client *source_p, if (!HasOFlag(source_p, OPER_FLAG_UNDLINE)) { - sendto_one(source_p, form_str(ERR_NOPRIVS), - me.name, source_p->name, "undline"); + sendto_one(source_p, form_str(ERR_NOPRIVS), me.name, + source_p->name, "undline"); return; } @@ -426,8 +427,7 @@ mo_undline(struct Client *client_p, struct Client *source_p, if (remove_dline_match(addr)) { - sendto_one(source_p, - ":%s NOTICE %s :D-Line for [%s] is removed", + sendto_one(source_p, ":%s NOTICE %s :D-Line for [%s] is removed", me.name, source_p->name, addr); sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, "%s has removed the D-Line for: [%s]", @@ -454,15 +454,14 @@ me_undline(struct Client *client_p, struct Client *source_p, if (!IsClient(source_p) || match(parv[1], me.name)) return; - if (HasFlag(source_p, FLAGS_SERVICE) || find_matching_name_conf(CONF_ULINE, - source_p->servptr->name, - source_p->username, source_p->host, - SHARED_UNDLINE)) + if (HasFlag(source_p, FLAGS_SERVICE) || + find_matching_name_conf(CONF_ULINE, source_p->servptr->name, + source_p->username, source_p->host, + SHARED_UNDLINE)) { if (remove_dline_match(addr)) { - sendto_one(source_p, - ":%s NOTICE %s :D-Line for [%s] is removed", + sendto_one(source_p, ":%s NOTICE %s :D-Line for [%s] is removed", me.name, source_p->name, addr); sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, "%s has removed the D-Line for: [%s]", @@ -490,14 +489,16 @@ ms_undline(struct Client *client_p, struct Client *source_p, me_undline(client_p, source_p, parc, parv); } -static struct Message dline_msgtab = { +static struct Message dline_msgtab = +{ "DLINE", 0, 0, 2, MAXPARA, MFLG_SLOW, 0, - {m_unregistered, m_not_oper, ms_dline, m_ignore, mo_dline, m_ignore} + { m_unregistered, m_not_oper, ms_dline, m_ignore, mo_dline, m_ignore } }; -static struct Message undline_msgtab = { +static struct Message undline_msgtab = +{ "UNDLINE", 0, 0, 2, MAXPARA, MFLG_SLOW, 0, - {m_unregistered, m_not_oper, ms_undline, m_ignore, mo_undline, m_ignore} + { m_unregistered, m_not_oper, ms_undline, m_ignore, mo_undline, m_ignore } }; static void @@ -518,7 +519,8 @@ module_exit(void) delete_capability("DLN"); } -struct module module_entry = { +struct module module_entry = +{ .node = { NULL, NULL, NULL }, .name = NULL, .version = "$Revision$", diff --git a/modules/m_kline.c b/modules/m_kline.c index 0753f30..28ce68b 100644 --- a/modules/m_kline.c +++ b/modules/m_kline.c @@ -1,8 +1,7 @@ /* - * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). - * m_kline.c: Bans a user. + * ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd) * - * Copyright (C) 2002 by the past and present ircd coders, and others. + * Copyright (c) 2002-2014 ircd-hybrid development team * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,8 +17,11 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * USA - * - * $Id$ + */ + +/*! \file m_kline.c + * \brief Includes required functions for processing the KLINE/UNKLINE command. + * \version $Id$ */ #include "stdinc.h" @@ -44,12 +46,138 @@ #include "conf_db.h" #include "memory.h" -static int already_placed_kline(struct Client *, const char *, const char *, int); -static void m_kline_add_kline(struct Client *, struct MaskItem *, time_t); -static char buffer[IRCD_BUFSIZE]; -static int remove_kline_match(const char *, const char *); +/* apply_tkline() + * + * inputs - + * output - NONE + * side effects - tkline as given is placed + */ +static void +m_kline_add_kline(struct Client *source_p, struct MaskItem *conf, + time_t tkline_time) +{ + if (tkline_time) + { + conf->until = CurrentTime + tkline_time; + sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, + "%s added temporary %d min. K-Line for [%s@%s] [%s]", + get_oper_name(source_p), tkline_time/60, + conf->user, conf->host, + conf->reason); + sendto_one(source_p, ":%s NOTICE %s :Added temporary %d min. K-Line [%s@%s]", + MyConnect(source_p) ? me.name : ID_or_name(&me, source_p->from), + source_p->name, tkline_time/60, conf->user, conf->host); + ilog(LOG_TYPE_KLINE, "%s added temporary %d min. K-Line for [%s@%s] [%s]", + get_oper_name(source_p), tkline_time/60, + conf->user, conf->host, conf->reason); + } + else + { + sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, + "%s added K-Line for [%s@%s] [%s]", + get_oper_name(source_p), + conf->user, conf->host, conf->reason); + sendto_one(source_p, ":%s NOTICE %s :Added K-Line [%s@%s]", + MyConnect(source_p) ? me.name : ID_or_name(&me, source_p->from), + source_p->name, conf->user, conf->host); + ilog(LOG_TYPE_KLINE, "%s added K-Line for [%s@%s] [%s]", + get_oper_name(source_p), conf->user, conf->host, conf->reason); + } + + conf->setat = CurrentTime; + SetConfDatabase(conf); + + add_conf_by_address(CONF_KLINE, conf); + rehashed_klines = 1; +} + +/* static int remove_tkline_match(const char *host, const char *user) + * Input: A hostname, a username to unkline. + * Output: returns YES on success, NO if no tkline removed. + * Side effects: Any matching tklines are removed. + */ +static int +remove_kline_match(const char *host, const char *user) +{ + struct irc_ssaddr iphost, *piphost; + struct MaskItem *conf; + int t = 0; + int aftype = 0; + + if ((t = parse_netmask(host, &iphost, NULL)) != HM_HOST) + { +#ifdef IPV6 + if (t == HM_IPV6) + aftype = AF_INET6; + else +#endif + aftype = AF_INET; + piphost = &iphost; + } + else + piphost = NULL; + + if ((conf = find_conf_by_address(host, piphost, CONF_KLINE, aftype, user, NULL, 0))) + { + if (IsConfDatabase(conf)) + { + delete_one_address_conf(host, conf); + return 1; + } + } + + return 0; +} + +/* already_placed_kline() + * inputs - user to complain to, username & host to check for + * outputs - returns 1 on existing K-line, 0 if doesn't exist + * side effects - notifies source_p if the K-line already exists + */ +/* + * Note: This currently works if the new K-line is a special case of an + * existing K-line, but not the other way round. To do that we would + * have to walk the hash and check every existing K-line. -A1kmm. + */ +static int +already_placed_kline(struct Client *source_p, const char *luser, const char *lhost, int warn) +{ + const char *reason; + struct irc_ssaddr iphost, *piphost; + struct MaskItem *conf = NULL; + int t = 0; + int aftype = 0; + + if ((t = parse_netmask(lhost, &iphost, NULL)) != HM_HOST) + { +#ifdef IPV6 + if (t == HM_IPV6) + aftype = AF_INET6; + else +#endif + aftype = AF_INET; + piphost = &iphost; + } + else + piphost = NULL; + + if ((conf = find_conf_by_address(lhost, piphost, CONF_KLINE, aftype, luser, NULL, 0))) + { + if (warn) + { + reason = conf->reason ? conf->reason : CONF_NOREASON; + sendto_one(source_p, + ":%s NOTICE %s :[%s@%s] already K-Lined by [%s@%s] - %s", + me.name, source_p->name, luser, lhost, conf->user, + conf->host, reason); + } + + return 1; + } + return 0; +} /* mo_kline() * @@ -64,6 +192,7 @@ static void mo_kline(struct Client *client_p, struct Client *source_p, int parc, char *parv[]) { + char buffer[IRCD_BUFSIZE]; char *reason = NULL; char *user = NULL; char *host = NULL; @@ -75,13 +204,13 @@ mo_kline(struct Client *client_p, struct Client *source_p, if (!HasOFlag(source_p, OPER_FLAG_K)) { - sendto_one(source_p, form_str(ERR_NOPRIVS), - me.name, source_p->name, "kline"); + sendto_one(source_p, form_str(ERR_NOPRIVS), me.name, + source_p->name, "kline"); return; } - if (parse_aline("KLINE", source_p, parc, parv, - AWILD, &user, &host, &tkline_time, &target_server, &reason) < 0) + if (parse_aline("KLINE", source_p, parc, parv, AWILD, &user, &host, + &tkline_time, &target_server, &reason) < 0) return; if (target_server != NULL) @@ -123,9 +252,10 @@ static void me_kline(struct Client *client_p, struct Client *source_p, int parc, char *parv[]) { + char buffer[IRCD_BUFSIZE]; struct MaskItem *conf = NULL; int tkline_time = 0; - const char* current_date; + const char *current_date; time_t cur_time; char *kuser, *khost, *kreason; @@ -143,7 +273,8 @@ me_kline(struct Client *client_p, struct Client *source_p, cur_time = CurrentTime; current_date = smalldate(cur_time); - if (HasFlag(source_p, FLAGS_SERVICE) || find_matching_name_conf(CONF_ULINE, source_p->servptr->name, + if (HasFlag(source_p, FLAGS_SERVICE) || + find_matching_name_conf(CONF_ULINE, source_p->servptr->name, source_p->username, source_p->host, SHARED_KLINE)) { @@ -182,100 +313,6 @@ ms_kline(struct Client *client_p, struct Client *source_p, me_kline(client_p, source_p, parc, parv); } -/* apply_tkline() - * - * inputs - - * output - NONE - * side effects - tkline as given is placed - */ -static void -m_kline_add_kline(struct Client *source_p, struct MaskItem *conf, - time_t tkline_time) -{ - if (tkline_time) - { - conf->until = CurrentTime + tkline_time; - sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, - "%s added temporary %d min. K-Line for [%s@%s] [%s]", - get_oper_name(source_p), tkline_time/60, - conf->user, conf->host, - conf->reason); - sendto_one(source_p, ":%s NOTICE %s :Added temporary %d min. K-Line [%s@%s]", - MyConnect(source_p) ? me.name : ID_or_name(&me, source_p->from), - source_p->name, tkline_time/60, conf->user, conf->host); - ilog(LOG_TYPE_KLINE, "%s added temporary %d min. K-Line for [%s@%s] [%s]", - get_oper_name(source_p), tkline_time/60, - conf->user, conf->host, conf->reason); - } - else - { - sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, - "%s added K-Line for [%s@%s] [%s]", - get_oper_name(source_p), - conf->user, conf->host, conf->reason); - sendto_one(source_p, ":%s NOTICE %s :Added K-Line [%s@%s]", - MyConnect(source_p) ? me.name : ID_or_name(&me, source_p->from), - source_p->name, conf->user, conf->host); - ilog(LOG_TYPE_KLINE, "%s added K-Line for [%s@%s] [%s]", - get_oper_name(source_p), conf->user, conf->host, conf->reason); - } - - conf->setat = CurrentTime; - SetConfDatabase(conf); - - add_conf_by_address(CONF_KLINE, conf); - rehashed_klines = 1; -} - -/* already_placed_kline() - * inputs - user to complain to, username & host to check for - * outputs - returns 1 on existing K-line, 0 if doesn't exist - * side effects - notifies source_p if the K-line already exists - */ -/* - * Note: This currently works if the new K-line is a special case of an - * existing K-line, but not the other way round. To do that we would - * have to walk the hash and check every existing K-line. -A1kmm. - */ -static int -already_placed_kline(struct Client *source_p, const char *luser, const char *lhost, int warn) -{ - const char *reason; - struct irc_ssaddr iphost, *piphost; - struct MaskItem *conf = NULL; - int t = 0; - int aftype = 0; - - if ((t = parse_netmask(lhost, &iphost, NULL)) != HM_HOST) - { -#ifdef IPV6 - if (t == HM_IPV6) - aftype = AF_INET6; - else -#endif - aftype = AF_INET; - piphost = &iphost; - } - else - piphost = NULL; - - if ((conf = find_conf_by_address(lhost, piphost, CONF_KLINE, aftype, luser, NULL, 0))) - { - if (warn) - { - reason = conf->reason ? conf->reason : CONF_NOREASON; - sendto_one(source_p, - ":%s NOTICE %s :[%s@%s] already K-Lined by [%s@%s] - %s", - me.name, source_p->name, luser, lhost, conf->user, - conf->host, reason); - } - - return 1; - } - - return 0; -} - /* ** mo_unkline ** Added Aug 31, 1997 @@ -295,8 +332,8 @@ mo_unkline(struct Client *client_p,struct Client *source_p, if (!HasOFlag(source_p, OPER_FLAG_UNKLINE)) { - sendto_one(source_p, form_str(ERR_NOPRIVS), - me.name, source_p->name, "unkline"); + sendto_one(source_p, form_str(ERR_NOPRIVS), me.name, + source_p->name, "unkline"); return; } @@ -327,8 +364,7 @@ mo_unkline(struct Client *client_p,struct Client *source_p, if (remove_kline_match(host, user)) { - sendto_one(source_p, - ":%s NOTICE %s :K-Line for [%s@%s] is removed", + sendto_one(source_p, ":%s NOTICE %s :K-Line for [%s@%s] is removed", me.name, source_p->name, user, host); sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, "%s has removed the K-Line for: [%s@%s]", @@ -366,15 +402,14 @@ me_unkline(struct Client *client_p, struct Client *source_p, if (!IsClient(source_p) || match(parv[1], me.name)) return; - if (HasFlag(source_p, FLAGS_SERVICE) || find_matching_name_conf(CONF_ULINE, - source_p->servptr->name, - source_p->username, source_p->host, - SHARED_UNKLINE)) + if (HasFlag(source_p, FLAGS_SERVICE) || + find_matching_name_conf(CONF_ULINE, source_p->servptr->name, + source_p->username, source_p->host, + SHARED_UNKLINE)) { if (remove_kline_match(khost, kuser)) { - sendto_one(source_p, - ":%s NOTICE %s :K-Line for [%s@%s] is removed", + sendto_one(source_p, ":%s NOTICE %s :K-Line for [%s@%s] is removed", me.name, source_p->name, kuser, khost); sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, "%s has removed the K-Line for: [%s@%s]", @@ -403,52 +438,16 @@ ms_unkline(struct Client *client_p, struct Client *source_p, me_unkline(client_p, source_p, parc, parv); } -/* static int remove_tkline_match(const char *host, const char *user) - * Input: A hostname, a username to unkline. - * Output: returns YES on success, NO if no tkline removed. - * Side effects: Any matching tklines are removed. - */ -static int -remove_kline_match(const char *host, const char *user) +static struct Message kline_msgtab = { - struct irc_ssaddr iphost, *piphost; - struct MaskItem *conf; - int t = 0; - int aftype = 0; - - if ((t = parse_netmask(host, &iphost, NULL)) != HM_HOST) - { -#ifdef IPV6 - if (t == HM_IPV6) - aftype = AF_INET6; - else -#endif - aftype = AF_INET; - piphost = &iphost; - } - else - piphost = NULL; - - if ((conf = find_conf_by_address(host, piphost, CONF_KLINE, aftype, user, NULL, 0))) - { - if (IsConfDatabase(conf)) - { - delete_one_address_conf(host, conf); - return 1; - } - } - - return 0; -} - -static struct Message kline_msgtab = { "KLINE", 0, 0, 2, MAXPARA, MFLG_SLOW, 0, - {m_unregistered, m_not_oper, ms_kline, me_kline, mo_kline, m_ignore} + { m_unregistered, m_not_oper, ms_kline, me_kline, mo_kline, m_ignore } }; -static struct Message unkline_msgtab = { +static struct Message unkline_msgtab = +{ "UNKLINE", 0, 0, 2, MAXPARA, MFLG_SLOW, 0, - {m_unregistered, m_not_oper, ms_unkline, me_unkline, mo_unkline, m_ignore} + { m_unregistered, m_not_oper, ms_unkline, me_unkline, mo_unkline, m_ignore } }; static void @@ -469,7 +468,8 @@ module_exit(void) delete_capability("KLN"); } -struct module module_entry = { +struct module module_entry = +{ .node = { NULL, NULL, NULL }, .name = NULL, .version = "$Revision$", |