From: Michael Poole Date: Sun, 17 Apr 2005 02:57:57 +0000 (+0000) Subject: Make realname Kill blocks more predictable, and add username="x" field. X-Git-Url: http://git.pk910.de/?p=ircu2.10.12-pk.git;a=commitdiff_plain;h=cf665d9eea076d336955e2b8f0da9d26f27a7e3d Make realname Kill blocks more predictable, and add username="x" field. git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/trunk@1365 c9e4aea6-c8fd-4c43-8297-357d70d61c8c --- diff --git a/ChangeLog b/ChangeLog index a67dd1d..532e6e2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,24 @@ +2005-04-16 Michael Poole + + * doc/example.conf (Kill): Document newly supported syntax. + + * include/s_conf.h (DenyConf): Split realname mask into its own + field. Remove the unused DENY_FLAGS_{IP,REALNAME}. + + * ircd/ircd_parser.y (Kill): Only require one of usermask, + hostmask, realmask to be set for a valid block. + (killitem): Add new production killusername. + + * ircd/s_conf.c (conf_erase_deny_list): Free realmask field. + (find_kill): Rearrange slightly to clarify control flow. + + * ircd/s_err.c (RPL_STATSKLINE): Stick usermask before hostmask, + so the old usermask field can be adopted for realname mask. Add + double quotes around the realmask field. + + * ircd/s_stats.c (report_deny_list): Do so. + (stats_klines): Likewise. + 2005-04-17 Perry Lorier * tools/convert-conf.py: Fix lots of conversion problems with diff --git a/doc/example.conf b/doc/example.conf index 28796d6..5b81cf4 100644 --- a/doc/example.conf +++ b/doc/example.conf @@ -483,8 +483,12 @@ Jupe { Kill { host = "*.au"; reason = "Please use a nearer server"; }; Kill { host = "*.edu"; reason = "Please use a nearer server"; }; +# You can also kill based on username. +Kill { username = "sub7"; realname = "s*7*"; reason = "You are infected with a Trojan"; + # The file can contain for example, a reason, a link to the -# server rules and a contact address. +# server rules and a contact address. Note the combination +# of username and host in the host field. Kill { host = "*luser@unixbox.flooder.co.uk"; diff --git a/include/s_conf.h b/include/s_conf.h index 3775427..8860e0b 100644 --- a/include/s_conf.h +++ b/include/s_conf.h @@ -80,17 +80,16 @@ struct qline /** Local K-line structure. */ struct DenyConf { struct DenyConf* next; /**< Next DenyConf in #denyConfList. */ - char* hostmask; /**< Mask for realname, IP or hostname. */ + char* hostmask; /**< Mask for IP or hostname. */ char* message; /**< Message to send to denied users. */ char* usermask; /**< Mask for client's username. */ + char* realmask; /**< Mask for realname. */ struct irc_in_addr address; /**< Address for IP-based denies. */ unsigned int flags; /**< Interpretation flags for the above. */ unsigned char bits; /**< Number of bits for ipkills */ }; #define DENY_FLAGS_FILE 0x0001 /**< Comment is a filename */ -#define DENY_FLAGS_IP 0x0002 /**< K-line by IP address */ -#define DENY_FLAGS_REALNAME 0x0004 /**< K-line by real name */ /** Local server configuration. */ struct LocalConf { diff --git a/ircd/ircd_parser.y b/ircd/ircd_parser.y index c132991..1c65d65 100644 --- a/ircd/ircd_parser.y +++ b/ircd/ircd_parser.y @@ -732,16 +732,15 @@ killblock: KILL dconf = (struct DenyConf*) MyCalloc(1, sizeof(*dconf)); } '{' killitems '}' { - if (dconf->hostmask != NULL) - { - if (dconf->usermask == NULL) - DupString(dconf->usermask, "*"); + if (dconf->usermask || dconf->hostmask ||dconf->realmask) { dconf->next = denyConfList; denyConfList = dconf; } else { + MyFree(dconf->usermask); MyFree(dconf->hostmask); + MyFree(dconf->realmask); MyFree(dconf->message); MyFree(dconf); parse_error("Bad kill block"); @@ -749,11 +748,10 @@ killblock: KILL dconf = NULL; } ';'; killitems: killitem killitems | killitem; -killitem: killuhost | killreal | killreasonfile | killreason | error; +killitem: killuhost | killreal | killusername | killreasonfile | killreason | error; killuhost: HOST '=' QSTRING ';' { char *u, *h; - dconf->flags &= ~DENY_FLAGS_REALNAME; MyFree(dconf->hostmask); MyFree(dconf->usermask); if ((h = strchr($3, '@')) == NULL) @@ -771,13 +769,16 @@ killuhost: HOST '=' QSTRING ';' ipmask_parse(dconf->hostmask, &dconf->address, &dconf->bits); }; +killusername: USERNAME '=' QSTRING ';' +{ + MyFree(dconf->usermask); + DupString(dconf->usermask, $3); +}; + killreal: REAL '=' QSTRING ';' { - dconf->flags &= ~DENY_FLAGS_IP; - dconf->flags |= DENY_FLAGS_REALNAME; - MyFree(dconf->hostmask); - /* Leave usermask so you can specify user and real... */ - DupString(dconf->hostmask, $3); + MyFree(dconf->realmask); + DupString(dconf->realmask, $3); }; killreason: REASON '=' QSTRING ';' diff --git a/ircd/s_conf.c b/ircd/s_conf.c index 536087b..51c0971 100644 --- a/ircd/s_conf.c +++ b/ircd/s_conf.c @@ -756,6 +756,7 @@ void conf_erase_deny_list(void) MyFree(p->hostmask); MyFree(p->usermask); MyFree(p->message); + MyFree(p->realmask); MyFree(p); } denyConfList = 0; @@ -1016,28 +1017,16 @@ int find_kill(struct Client *cptr) * -- Isomer */ for (deny = denyConfList; deny; deny = deny->next) { - if (0 != match(deny->usermask, name)) + if (deny->usermask && match(deny->usermask, name)) + continue; + if (deny->realmask && match(deny->realmask, realname)) + continue; + if (deny->bits > 0) { + if (!ipmask_check(&cli_ip(cptr), &deny->address, deny->bits)) + continue; + } else if (deny->hostmask && match(deny->hostmask, host)) continue; - if (EmptyString(deny->hostmask)) - break; - - if (deny->flags & DENY_FLAGS_REALNAME) { /* K: by real name */ - if (0 == match(deny->hostmask, realname)) - break; - } else if (deny->flags & DENY_FLAGS_IP) { /* k: by IP */ -#ifdef DEBUGMODE - char tbuf1[SOCKIPLEN], tbuf2[SOCKIPLEN]; - Debug((DEBUG_DEBUG, "ip: %s network: %s/%u", - ircd_ntoa_r(tbuf1, &cli_ip(cptr)), ircd_ntoa_r(tbuf2, &deny->address), deny->bits)); -#endif - if (ipmask_check(&cli_ip(cptr), &deny->address, deny->bits)) - break; - } - else if (0 == match(deny->hostmask, host)) - break; - } - if (deny) { if (EmptyString(deny->message)) send_reply(cptr, SND_EXPLICIT | ERR_YOUREBANNEDCREEP, ":Connection from your host is refused on this server."); @@ -1047,19 +1036,17 @@ int find_kill(struct Client *cptr) else send_reply(cptr, SND_EXPLICIT | ERR_YOUREBANNEDCREEP, ":%s.", deny->message); } + return -1; } - else if ((agline = gline_lookup(cptr, 0))) { + + if ((agline = gline_lookup(cptr, 0))) { /* * find active glines * added a check against the user's IP address to find_gline() -Kev */ send_reply(cptr, SND_EXPLICIT | ERR_YOUREBANNEDCREEP, ":%s.", GlineReason(agline)); - } - - if (deny) - return -1; - if (agline) return -2; + } return 0; } diff --git a/ircd/s_err.c b/ircd/s_err.c index 45a34da..4b03b3d 100644 --- a/ircd/s_err.c +++ b/ircd/s_err.c @@ -464,7 +464,7 @@ static Numeric replyTable[] = { /* 215 */ { RPL_STATSILINE, "I %s %d %s%s %d %s", "215" }, /* 216 */ - { RPL_STATSKLINE, "%c %s \"%s\" %s 0 0", "216" }, + { RPL_STATSKLINE, "%c %s@%s \"%s\" \"%s\" 0 0", "216" }, /* 217 */ { RPL_STATSPLINE, "P %d %d %s %s", "217" }, /* 218 */ diff --git a/ircd/s_stats.c b/ircd/s_stats.c index 3555376..9714157 100644 --- a/ircd/s_stats.c +++ b/ircd/s_stats.c @@ -194,8 +194,11 @@ report_deny_list(struct Client* to) { const struct DenyConf* p = conf_get_deny_list(); for ( ; p; p = p->next) - send_reply(to, RPL_STATSKLINE, (p->flags & DENY_FLAGS_IP) ? 'k' : 'K', - p->hostmask, p->message, p->usermask); + send_reply(to, RPL_STATSKLINE, p->bits > 0 ? 'k' : 'K', + p->usermask ? p->usermask : "*", + p->hostmask ? p->hostmask : "*", + p->message ? p->message : "(none)", + p->realmask ? p->realmask : "*"); } /** Report K/k-lines to a user. @@ -246,9 +249,11 @@ stats_klines(struct Client *sptr, const struct StatDesc *sd, char *mask) (wilds && !mmatch(host, conf->hostmask) && (!user || !mmatch(user, conf->usermask)))) { - send_reply(sptr, RPL_STATSKLINE, - (conf->flags & DENY_FLAGS_IP) ? 'k' : 'K', - conf->hostmask, conf->message, conf->usermask); + send_reply(sptr, RPL_STATSKLINE, conf->bits > 0 ? 'k' : 'K', + conf->usermask ? conf->usermask : "*", + conf->hostmask ? conf->hostmask : "*", + conf->message ? conf->message : "(none)", + conf->realmask ? conf->realmask : "*"); if (--count == 0) return; }