X-Git-Url: https://jfr.im/git/irc/rqf/shadowircd.git/blobdiff_plain/212380e3f42f585dc1ea927402252eb943f91f7b..dc0490da84c267f4ad903a7b82bd31f6b00ad0a1:/modules/m_gline.c diff --git a/modules/m_gline.c b/modules/m_gline.c index d644bca..8301c87 100644 --- a/modules/m_gline.c +++ b/modules/m_gline.c @@ -21,11 +21,10 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * USA * - * $Id: m_gline.c 1146 2006-04-07 22:52:35Z jilles $ + * $Id: m_gline.c 3225 2007-03-04 23:42:55Z jilles $ */ #include "stdinc.h" -#include "tools.h" #include "s_gline.h" #include "channel.h" #include "client.h" @@ -36,7 +35,6 @@ #include "ircd.h" #include "hostmask.h" #include "numeric.h" -#include "commio.h" #include "s_conf.h" #include "s_newconf.h" #include "scache.h" @@ -47,6 +45,7 @@ #include "parse.h" #include "modules.h" #include "s_log.h" +#include "reject.h" static int mo_gline(struct Client *, struct Client *, int, const char **); static int mc_gline(struct Client *, struct Client *, int, const char **); @@ -63,7 +62,7 @@ struct Message ungline_msgtab = { }; mapi_clist_av1 gline_clist[] = { &gline_msgtab, &ungline_msgtab, NULL }; -DECLARE_MODULE_AV1(gline, NULL, NULL, gline_clist, NULL, NULL, "$Revision: 1146 $"); +DECLARE_MODULE_AV1(gline, NULL, NULL, gline_clist, NULL, NULL, "$Revision: 3225 $"); static int majority_gline(struct Client *source_p, const char *user, const char *host, const char *reason); @@ -93,8 +92,7 @@ mo_gline(struct Client *client_p, struct Client *source_p, int parc, const char if(!ConfigFileEntry.glines) { - sendto_one(source_p, ":%s NOTICE %s :GLINE disabled, perhaps you want a clustered or remote KLINE?", - me.name, source_p->name); + sendto_one_notice(source_p, ":GLINE disabled, perhaps you want a clustered or remote KLINE?"); return 0; } @@ -123,9 +121,7 @@ mo_gline(struct Client *client_p, struct Client *source_p, int parc, const char /* ok, its not a host.. abort */ if(strchr(parv[1], '.') == NULL) { - sendto_one(source_p, - ":%s NOTICE %s :Invalid parameters", - me.name, source_p->name); + sendto_one_notice(source_p, ":Invalid parameters"); return 0; } @@ -142,10 +138,8 @@ mo_gline(struct Client *client_p, struct Client *source_p, int parc, const char if(check_wild_gline(user, host)) { if(MyClient(source_p)) - sendto_one(source_p, - ":%s NOTICE %s :Please include at least %d non-wildcard " - "characters with the user@host", - me.name, source_p->name, + sendto_one_notice(source_p, + ":Please include at least %d non-wildcard characters with the user@host", ConfigFileEntry.min_nonwildcard); return 0; } @@ -160,8 +154,7 @@ mo_gline(struct Client *client_p, struct Client *source_p, int parc, const char { if(bitlen < ConfigFileEntry.gline_min_cidr) { - sendto_one(source_p, ":%s NOTICE %s :Cannot set G-Lines with cidr length < %d", - me.name, source_p->name, + sendto_one_notice(source_p, ":Cannot set G-Lines with cidr length < %d", ConfigFileEntry.gline_min_cidr); return 0; } @@ -169,8 +162,7 @@ mo_gline(struct Client *client_p, struct Client *source_p, int parc, const char /* ipv6 */ else if(bitlen < ConfigFileEntry.gline_min_cidr6) { - sendto_one(source_p, ":%s NOTICE %s :Cannot set G-Lines with cidr length < %d", - me.name, source_p->name, + sendto_one_notice(source_p, ":Cannot set G-Lines with cidr length < %d", ConfigFileEntry.gline_min_cidr6); return 0; } @@ -185,7 +177,7 @@ mo_gline(struct Client *client_p, struct Client *source_p, int parc, const char source_p->host, me.name, user, host, reason); ilog(L_GLINE, "R %s %s %s %s %s %s %s", source_p->name, source_p->username, source_p->host, - source_p->user->server, user, host, reason); + source_p->servptr->name, user, host, reason); /* If at least 3 opers agree this user should be G lined then do it */ majority_gline(source_p, user, host, reason); @@ -202,7 +194,7 @@ mo_gline(struct Client *client_p, struct Client *source_p, int parc, const char sendto_server(NULL, NULL, NOCAPS, CAP_GLN, ":%s GLINE %s %s %s %s %s %s :%s", me.name, source_p->name, source_p->username, - source_p->host, source_p->user->server, + source_p->host, source_p->servptr->name, user, host, reason); return 0; } @@ -240,9 +232,9 @@ mc_gline(struct Client *client_p, struct Client *source_p, acptr->name, user, host, reason); sendto_server(client_p, NULL, NOCAPS, CAP_GLN, ":%s GLINE %s %s %s %s %s %s :%s", - acptr->user->server, acptr->name, + acptr->servptr->name, acptr->name, acptr->username, acptr->host, - acptr->user->server, user, host, reason); + acptr->servptr->name, user, host, reason); if(!ConfigFileEntry.glines) return 0; @@ -254,7 +246,7 @@ mc_gline(struct Client *client_p, struct Client *source_p, "%s!%s@%s on %s is requesting a gline without " "%d non-wildcard characters for [%s@%s] [%s]", acptr->name, acptr->username, - acptr->host, acptr->user->server, + acptr->host, acptr->servptr->name, ConfigFileEntry.min_nonwildcard, user, host, reason); return 0; @@ -273,7 +265,7 @@ mc_gline(struct Client *client_p, struct Client *source_p, sendto_realops_snomask(SNO_GENERAL, L_ALL, "%s!%s@%s on %s is requesting a " "gline with a cidr mask < %d for [%s@%s] [%s]", acptr->name, acptr->username, acptr->host, - acptr->user->server, + acptr->servptr->name, ConfigFileEntry.gline_min_cidr, user, host, reason); return 0; @@ -285,7 +277,7 @@ mc_gline(struct Client *client_p, struct Client *source_p, sendto_realops_snomask(SNO_GENERAL, L_ALL, "%s!%s@%s on %s is requesting a " "gline with a cidr mask < %d for [%s@%s] [%s]", acptr->name, acptr->username, acptr->host, - acptr->user->server, + acptr->servptr->name, ConfigFileEntry.gline_min_cidr6, user, host, reason); return 0; @@ -296,11 +288,11 @@ mc_gline(struct Client *client_p, struct Client *source_p, sendto_realops_snomask(SNO_GENERAL, L_ALL, "%s!%s@%s on %s is requesting gline for [%s@%s] [%s]", acptr->name, acptr->username, acptr->host, - acptr->user->server, user, host, reason); + acptr->servptr->name, user, host, reason); ilog(L_GLINE, "R %s %s %s %s %s %s %s", source_p->name, source_p->username, source_p->host, - source_p->user->server, user, host, reason); + source_p->servptr->name, user, host, reason); /* If at least 3 opers agree this user should be G lined then do it */ majority_gline(acptr, user, host, reason); @@ -352,9 +344,9 @@ ms_gline(struct Client *client_p, struct Client *source_p, int parc, const char acptr->name, user, host, reason); sendto_server(client_p, NULL, NOCAPS, CAP_GLN, ":%s GLINE %s %s %s %s %s %s :%s", - acptr->user->server, acptr->name, + acptr->servptr->name, acptr->name, acptr->username, acptr->host, - acptr->user->server, user, host, reason); + acptr->servptr->name, user, host, reason); if(!ConfigFileEntry.glines) return 0; @@ -366,7 +358,7 @@ ms_gline(struct Client *client_p, struct Client *source_p, int parc, const char "%s!%s@%s on %s is requesting a gline without " "%d non-wildcard characters for [%s@%s] [%s]", acptr->name, acptr->username, - acptr->host, acptr->user->server, + acptr->host, acptr->servptr->name, ConfigFileEntry.min_nonwildcard, user, host, reason); return 0; @@ -375,11 +367,11 @@ ms_gline(struct Client *client_p, struct Client *source_p, int parc, const char sendto_realops_snomask(SNO_GENERAL, L_ALL, "%s!%s@%s on %s is requesting gline for [%s@%s] [%s]", acptr->name, acptr->username, acptr->host, - acptr->user->server, user, host, reason); + acptr->servptr->name, user, host, reason); ilog(L_GLINE, "R %s %s %s %s %s %s %s", acptr->name, acptr->username, acptr->host, - acptr->user->server, user, host, reason); + acptr->servptr->name, user, host, reason); /* If at least 3 opers agree this user should be G lined then do it */ majority_gline(acptr, user, host, reason); @@ -402,7 +394,7 @@ mo_ungline(struct Client *client_p, struct Client *source_p, int parc, const cha if(!ConfigFileEntry.glines) { - sendto_one(source_p, ":%s NOTICE %s :UNGLINE disabled, perhaps you want UNKLINE?", me.name, parv[0]); + sendto_one_notice(source_p, ":UNGLINE disabled, perhaps you want UNKLINE?"); return 0; } @@ -438,25 +430,23 @@ mo_ungline(struct Client *client_p, struct Client *source_p, int parc, const cha } else { - sendto_one(source_p, ":%s NOTICE %s :Invalid parameters", me.name, parv[0]); + sendto_one_notice(source_p, ":Invalid parameters"); return 0; } if(remove_temp_gline(user, host)) { - sendto_one(source_p, ":%s NOTICE %s :Un-glined [%s@%s]", - me.name, parv[0], user, host); + sendto_one_notice(source_p, ":Un-glined [%s@%s]", user, host); sendto_realops_snomask(SNO_GENERAL, L_ALL, "%s has removed the G-Line for: [%s@%s]", get_oper_name(source_p), user, host); ilog(L_GLINE, "U %s %s %s %s %s %s", source_p->name, source_p->username, source_p->host, - source_p->user->server, user, host); + source_p->servptr->name, user, host); } else { - sendto_one(source_p, ":%s NOTICE %s :No G-Line for %s@%s", - me.name, parv[0], user, host); + sendto_one_notice(source_p, ":No G-Line for %s@%s", user, host); } return 0; @@ -519,13 +509,12 @@ invalid_gline(struct Client *source_p, const char *luser, { if(strchr(luser, '!')) { - sendto_one(source_p, ":%s NOTICE %s :Invalid character '!' in gline", - me.name, source_p->name); + sendto_one_notice(source_p, ":Invalid character '!' in gline"); return 1; } - if(strlen(lreason) > REASONLEN) - lreason[REASONLEN] = '\0'; + if(strlen(lreason) > BANREASONLEN) + lreason[BANREASONLEN] = '\0'; return 0; } @@ -556,8 +545,8 @@ set_local_gline(struct Client *source_p, const char *user, aconf->status = CONF_GLINE; aconf->flags |= CONF_FLAGS_TEMPORARY; - if(strlen(my_reason) > REASONLEN) - my_reason[REASONLEN-1] = '\0'; + if(strlen(my_reason) > BANREASONLEN) + my_reason[BANREASONLEN-1] = '\0'; if((oper_reason = strchr(my_reason, '|')) != NULL) { @@ -565,25 +554,25 @@ set_local_gline(struct Client *source_p, const char *user, oper_reason++; if(!EmptyString(oper_reason)) - DupString(aconf->spasswd, oper_reason); + aconf->spasswd = rb_strdup(oper_reason); } - ircsnprintf(buffer, sizeof(buffer), "%s (%s)", reason, current_date); + rb_snprintf(buffer, sizeof(buffer), "%s (%s)", reason, current_date); - DupString(aconf->passwd, buffer); - DupString(aconf->user, user); - DupString(aconf->host, host); - aconf->hold = CurrentTime + ConfigFileEntry.gline_time; + aconf->passwd = rb_strdup(buffer); + aconf->user = rb_strdup(user); + aconf->host = rb_strdup(host); + aconf->hold = rb_current_time() + ConfigFileEntry.gline_time; add_gline(aconf); sendto_realops_snomask(SNO_GENERAL, L_ALL, "%s!%s@%s on %s has triggered gline for [%s@%s] [%s]", source_p->name, source_p->username, - source_p->host, source_p->user->server, + source_p->host, source_p->servptr->name, user, host, reason); ilog(L_GLINE, "T %s %s %s %s %s %s %s", source_p->name, source_p->username, source_p->host, - source_p->user->server, user, host, reason); + source_p->servptr->name, user, host, reason); check_glines(); } @@ -598,7 +587,7 @@ static int majority_gline(struct Client *source_p, const char *user, const char *host, const char *reason) { - dlink_node *pending_node; + rb_dlink_node *pending_node; struct gline_pending *pending; /* to avoid desync.. --fl */ @@ -608,7 +597,7 @@ majority_gline(struct Client *source_p, const char *user, if(find_is_glined(host, user)) return NO; - DLINK_FOREACH(pending_node, pending_glines.head) + RB_DLINK_FOREACH(pending_node, pending_glines.head) { pending = pending_node->data; @@ -622,7 +611,7 @@ majority_gline(struct Client *source_p, const char *user, sendto_realops_snomask(SNO_GENERAL, L_ALL, "oper has already voted"); return NO; } - else if(irccmp(pending->oper_server1, source_p->user->server) == 0) + else if(irccmp(pending->oper_server1, source_p->servptr->name) == 0) { sendto_realops_snomask(SNO_GENERAL, L_ALL, "server has already voted"); return NO; @@ -638,7 +627,7 @@ majority_gline(struct Client *source_p, const char *user, "oper has already voted"); return NO; } - else if(irccmp(pending->oper_server2, source_p->user->server) == 0) + else if(irccmp(pending->oper_server2, source_p->servptr->name) == 0) { sendto_realops_snomask(SNO_GENERAL, L_ALL, "server has already voted"); @@ -660,10 +649,10 @@ majority_gline(struct Client *source_p, const char *user, sizeof(pending->oper_user2)); strlcpy(pending->oper_host2, source_p->host, sizeof(pending->oper_host2)); - DupString(pending->reason2, reason); - pending->oper_server2 = find_or_add(source_p->user->server); - pending->last_gline_time = CurrentTime; - pending->time_request2 = CurrentTime; + pending->reason2 = rb_strdup(reason); + pending->oper_server2 = scache_get_name(source_p->servptr->serv->nameinfo); + pending->last_gline_time = rb_current_time(); + pending->time_request2 = rb_current_time(); return NO; } } @@ -671,7 +660,7 @@ majority_gline(struct Client *source_p, const char *user, /* no pending gline, create a new one */ pending = (struct gline_pending *) - MyMalloc(sizeof(struct gline_pending)); + rb_malloc(sizeof(struct gline_pending)); strlcpy(pending->oper_nick1, source_p->name, sizeof(pending->oper_nick1)); @@ -680,17 +669,17 @@ majority_gline(struct Client *source_p, const char *user, strlcpy(pending->oper_host1, source_p->host, sizeof(pending->oper_host1)); - pending->oper_server1 = find_or_add(source_p->user->server); + pending->oper_server1 = scache_get_name(source_p->servptr->serv->nameinfo); strlcpy(pending->user, user, sizeof(pending->user)); strlcpy(pending->host, host, sizeof(pending->host)); - DupString(pending->reason1, reason); + pending->reason1 = rb_strdup(reason); pending->reason2 = NULL; - pending->last_gline_time = CurrentTime; - pending->time_request1 = CurrentTime; + pending->last_gline_time = rb_current_time(); + pending->time_request1 = rb_current_time(); - dlinkAddAlloc(pending, &pending_glines); + rb_dlinkAddAlloc(pending, &pending_glines); return NO; } @@ -705,14 +694,14 @@ static int remove_temp_gline(const char *user, const char *host) { struct ConfItem *aconf; - dlink_node *ptr; - struct irc_sockaddr_storage addr, caddr; + rb_dlink_node *ptr; + struct rb_sockaddr_storage addr, caddr; int bits, cbits; int mtype, gtype; mtype = parse_netmask(host, (struct sockaddr *)&addr, &bits); - DLINK_FOREACH(ptr, glines.head) + RB_DLINK_FOREACH(ptr, glines.head) { aconf = ptr->data; @@ -731,7 +720,8 @@ remove_temp_gline(const char *user, const char *host) (struct sockaddr *)&caddr, bits)) continue; - dlinkDestroy(ptr, &glines); + rb_dlinkDestroy(ptr, &glines); + remove_reject_mask(aconf->user, aconf->host); delete_one_address_conf(aconf->host, aconf); return YES; }