X-Git-Url: https://jfr.im/git/solanum.git/blobdiff_plain/de2934965c2c685270d123aa2e4fd0088511803c..c1b01bf5ec318463ab076ac2d7c0a4b02631f745:/modules/m_dline.c diff --git a/modules/m_dline.c b/modules/m_dline.c index cc62d572..5960c8a2 100644 --- a/modules/m_dline.c +++ b/modules/m_dline.c @@ -78,7 +78,6 @@ mo_dline(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source char def[] = "No Reason"; const char *dlhost; char *reason = def; - char cidr_form_host[HOSTLEN + 1]; int tdline_time = 0; const char *target_server = NULL; int loc = 1; @@ -92,14 +91,26 @@ mo_dline(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source if((tdline_time = valid_temp_time(parv[loc])) >= 0) loc++; + if (loc >= parc) + { + sendto_one_notice(source_p, ":Need an IP to D-Line"); + return; + } + dlhost = parv[loc]; - rb_strlcpy(cidr_form_host, dlhost, sizeof(cidr_form_host)); loc++; /* would break the protocol */ if (*dlhost == ':') { - sendto_one_notice(source_p, ":Invalid D-Line"); + sendto_one_notice(source_p, ":Invalid D-Line [%s] - IP cannot start with :", dlhost); + return; + } + + int ty = parse_netmask_strict(dlhost, NULL, NULL); + if (ty != HM_IPV4 && ty != HM_IPV6) + { + sendto_one_notice(source_p, ":Invalid D-Line [%s] - doesn't look like IP[/cidr]", dlhost); return; } @@ -184,11 +195,6 @@ me_dline(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source if(!IsPerson(source_p)) return; - if(!find_shared_conf(source_p->username, source_p->host, - source_p->servptr->name, - tdline_time > 0 ? SHARED_TDLINE : SHARED_PDLINE)) - return; - apply_dline(source_p, parv[2], tdline_time, LOCAL_COPY(parv[3])); check_dlines(); @@ -200,10 +206,6 @@ me_undline(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sour if(!IsPerson(source_p)) return; - if(!find_shared_conf(source_p->username, source_p->host, - source_p->servptr->name, SHARED_UNDLINE)) - return; - apply_undline(source_p, parv[1]); } @@ -216,8 +218,8 @@ apply_dline(struct Client *source_p, const char *dlhost, int tdline_time, char * int t = AF_INET, ty, b; const char *creason; - ty = parse_netmask(dlhost, &daddr, &b); - if(ty == HM_HOST) + ty = parse_netmask_strict(dlhost, &daddr, &b); + if(ty != HM_IPV4 && ty != HM_IPV6) { sendto_one(source_p, ":%s NOTICE %s :Invalid D-Line", me.name, source_p->name); return; @@ -252,8 +254,9 @@ apply_dline(struct Client *source_p, const char *dlhost, int tdline_time, char * if((aconf = find_dline((struct sockaddr *) &daddr, t)) != NULL) { int bx; - parse_netmask(aconf->host, NULL, &bx); - if(b >= bx) + int masktype = parse_netmask_strict(aconf->host, NULL, &bx); + + if (masktype != HM_ERROR && b >= bx) { creason = aconf->passwd ? aconf->passwd : ""; if(IsConfExemptKline(aconf)) @@ -277,7 +280,6 @@ apply_dline(struct Client *source_p, const char *dlhost, int tdline_time, char * aconf->status = CONF_DLINE; aconf->created = rb_current_time(); aconf->host = rb_strdup(dlhost); - aconf->passwd = rb_strdup(reason); aconf->info.oper = operhash_add(get_oper_name(source_p)); if(strlen(reason) > BANREASONLEN) @@ -293,6 +295,8 @@ apply_dline(struct Client *source_p, const char *dlhost, int tdline_time, char * aconf->spasswd = rb_strdup(oper_reason); } + aconf->passwd = rb_strdup(reason); + if(tdline_time > 0) { aconf->hold = rb_current_time() + tdline_time; @@ -300,7 +304,7 @@ apply_dline(struct Client *source_p, const char *dlhost, int tdline_time, char * if(EmptyString(oper_reason)) { - sendto_realops_snomask(SNO_GENERAL, L_ALL, + sendto_realops_snomask(SNO_GENERAL, L_NETWIDE, "%s added temporary %d min. D-Line for [%s] [%s]", get_oper_name(source_p), tdline_time / 60, aconf->host, reason); @@ -309,7 +313,7 @@ apply_dline(struct Client *source_p, const char *dlhost, int tdline_time, char * } else { - sendto_realops_snomask(SNO_GENERAL, L_ALL, + sendto_realops_snomask(SNO_GENERAL, L_NETWIDE, "%s added temporary %d min. D-Line for [%s] [%s|%s]", get_oper_name(source_p), tdline_time / 60, aconf->host, reason, oper_reason); @@ -330,7 +334,7 @@ apply_dline(struct Client *source_p, const char *dlhost, int tdline_time, char * if(EmptyString(oper_reason)) { - sendto_realops_snomask(SNO_GENERAL, L_ALL, + sendto_realops_snomask(SNO_GENERAL, L_NETWIDE, "%s added D-Line for [%s] [%s]", get_oper_name(source_p), aconf->host, reason); ilog(L_KLINE, "D %s 0 %s %s", @@ -338,7 +342,7 @@ apply_dline(struct Client *source_p, const char *dlhost, int tdline_time, char * } else { - sendto_realops_snomask(SNO_GENERAL, L_ALL, + sendto_realops_snomask(SNO_GENERAL, L_NETWIDE, "%s added D-Line for [%s] [%s|%s]", get_oper_name(source_p), aconf->host, reason, oper_reason); ilog(L_KLINE, "D %s 0 %s %s|%s", @@ -354,9 +358,11 @@ apply_undline(struct Client *source_p, const char *cidr) char buf[BUFSIZE]; struct ConfItem *aconf; - if(parse_netmask(cidr, NULL, NULL) == HM_HOST) + int masktype = parse_netmask(cidr, NULL, NULL); + + if(masktype != HM_IPV4 && masktype != HM_IPV6) { - sendto_one_notice(source_p, ":Invalid D-Line"); + sendto_one_notice(source_p, ":Invalid D-Line [%s] - doesn't look like IP[/cidr]", cidr); return; } @@ -373,7 +379,7 @@ apply_undline(struct Client *source_p, const char *cidr) sendto_one(source_p, ":%s NOTICE %s :Un-dlined [%s] from temporary D-lines", me.name, source_p->name, buf); - sendto_realops_snomask(SNO_GENERAL, L_ALL, + sendto_realops_snomask(SNO_GENERAL, L_NETWIDE, "%s has removed the temporary D-Line for: [%s]", get_oper_name(source_p), buf); ilog(L_KLINE, "UD %s %s", get_oper_name(source_p), buf); @@ -384,7 +390,7 @@ apply_undline(struct Client *source_p, const char *cidr) sendto_one(source_p, ":%s NOTICE %s :D-Line for [%s] is removed", me.name, source_p->name, aconf->host); - sendto_realops_snomask(SNO_GENERAL, L_ALL, "%s has removed the D-Line for: [%s]", + sendto_realops_snomask(SNO_GENERAL, L_NETWIDE, "%s has removed the D-Line for: [%s]", get_oper_name(source_p), aconf->host); ilog(L_KLINE, "UD %s %s", get_oper_name(source_p), aconf->host); delete_one_address_conf(aconf->host, aconf);