2 # Parent f49987f27c65a72ee0611e57c25a0c5309e5cec1
4 diff -r f49987f27c65 include/gline.h
5 --- a/include/gline.h Sun Jul 14 18:24:36 2013 +0100
6 +++ b/include/gline.h Sun Jul 14 18:25:15 2013 +0100
9 extern struct Gline *gline_find(char *userhost, unsigned int flags);
10 extern struct Gline *gline_lookup(struct Client *cptr, unsigned int flags);
11 +extern struct Gline *gline_lookup_badchan(char *userhost, unsigned int flags);
12 extern void gline_free(struct Gline *gline);
13 extern void gline_burst(struct Client *cptr);
14 extern int gline_resend(struct Client *cptr, struct Gline *gline);
15 diff -r f49987f27c65 ircd/gline.c
16 --- a/ircd/gline.c Sun Jul 14 18:24:36 2013 +0100
17 +++ b/ircd/gline.c Sun Jul 14 18:25:15 2013 +0100
26 #include "ircd_alloc.h"
27 #include "ircd_features.h"
31 /** Check local clients against a new G-line.
32 - * If the G-line is inactive or a badchan, return immediately.
33 - * Otherwise, if any users match it, disconnect them.
34 + * If the G-line is inactive, return immediately.
35 + * Otherwise, if any users match it, disconnect them or kick them if the G-line is a BADCHAN.
36 * @param[in] cptr Peer connect that sent the G-line.
37 * @param[in] sptr Client that originated the G-line.
38 * @param[in] gline New G-line to check.
40 if (feature_bool(FEAT_DISABLE_GLINES))
41 return 0; /* G-lines are disabled */
43 - if (GlineIsBadChan(gline)) /* no action taken on badchan glines */
45 if (!GlineIsActive(gline)) /* no action taken on inactive glines */
48 - for (fd = HighestFd; fd >= 0; --fd) {
52 - if ((acptr = LocalClientArray[fd])) {
53 - if (!cli_user(acptr))
55 + if (GlineIsBadChan(gline)) {
56 + /* Handle BADCHAN gline */
57 + struct Channel *chptr,*nchptr;
58 + struct Membership *member,*nmember;
60 - if (GlineIsRealName(gline)) { /* Realname Gline */
61 - Debug((DEBUG_DEBUG,"Realname Gline: %s %s",(cli_info(acptr)),
63 - if (match(gline->gl_user+2, cli_info(acptr)) != 0)
65 - Debug((DEBUG_DEBUG,"Matched!"));
66 - } else { /* Host/IP gline */
67 - if (cli_user(acptr)->username &&
68 - match(gline->gl_user, (cli_user(acptr))->realusername) != 0)
69 + for(chptr=GlobalChannelList;chptr;chptr=nchptr) {
71 + if (match(gline->gl_user, chptr->chname))
73 + for (member=chptr->members;member;member=nmember) {
74 + nmember=member->next_member;
75 + if (!MyUser(member->user) || IsZombie(member) || IsAnOper(member->user))
77 + sendcmdto_serv_butone(&me, CMD_KICK, NULL, "%H %C :Badchanneled (%s)", chptr, member->user, gline->gl_reason);
78 + sendcmdto_channel_butserv_butone(&his, CMD_KICK, chptr, NULL, 0, "%H %C :Badchanneled (%s)", chptr, member->user, gline->gl_reason);
79 + make_zombie(member, member->user, &me, &me, chptr);
84 + for (fd = HighestFd; fd >= 0; --fd) {
88 + if ((acptr = LocalClientArray[fd])) {
89 + if (!cli_user(acptr))
92 - if (GlineIsIpMask(gline)) {
93 - if (!ipmask_check(&cli_ip(acptr), &gline->gl_addr, gline->gl_bits))
94 + if (GlineIsRealName(gline)) { /* Realname Gline */
95 + Debug((DEBUG_DEBUG,"Realname Gline: %s %s",(cli_info(acptr)),
97 + if (match(gline->gl_user+2, cli_info(acptr)) != 0)
99 + Debug((DEBUG_DEBUG,"Matched!"));
100 + } else { /* Host/IP gline */
101 + if (cli_user(acptr)->username &&
102 + match(gline->gl_user, (cli_user(acptr))->realusername) != 0)
105 + if (GlineIsIpMask(gline)) {
106 + if (!ipmask_check(&cli_ip(acptr), &gline->gl_addr, gline->gl_bits))
110 + if (match(gline->gl_host, cli_sockhost(acptr)) != 0)
115 - if (match(gline->gl_host, cli_sockhost(acptr)) != 0)
119 + /* ok, here's one that got G-lined */
120 + send_reply(acptr, SND_EXPLICIT | ERR_YOUREBANNEDCREEP, ":%s",
123 + /* let the ops know about it */
124 + sendto_opmask_butone(0, SNO_GLINE, "G-line active for %s",
125 + get_client_name(acptr, SHOW_IP));
127 + /* and get rid of him */
128 + /* Asuka - Reimplement HEAD_IN_SAND_GLINE from Lain */
129 + if ((tval = exit_client_msg(cptr, acptr, &me,
130 + feature_bool(FEAT_HIS_GLINE) ? "G-lined" : "G-lined (%s)", gline->gl_reason)))
131 + retval = tval; /* retain killed status */
134 - /* ok, here's one that got G-lined */
135 - send_reply(acptr, SND_EXPLICIT | ERR_YOUREBANNEDCREEP, ":%s",
138 - /* let the ops know about it */
139 - sendto_opmask_butone(0, SNO_GLINE, "G-line active for %s",
140 - get_client_name(acptr, SHOW_IP));
142 - /* and get rid of him */
143 - /* Asuka - Reimplement HEAD_IN_SAND_GLINE from Lain */
144 - if ((tval = exit_client_msg(cptr, acptr, &me,
145 - feature_bool(FEAT_HIS_GLINE) ? "G-lined" : "G-lined (%s)", gline->gl_reason)))
146 - retval = tval; /* retain killed status */
155 +gline_lookup_badchan(char *userhost, unsigned int flags)
157 + struct Gline *gline;
158 + struct Gline *sgline;
160 + if (flags & (GLINE_BADCHAN | GLINE_ANY)) {
161 + gliter(BadChanGlineList, gline, sgline) {
162 + if ((flags & GLINE_GLOBAL && gline->gl_flags & GLINE_LOCAL) ||
163 + (flags & GLINE_LASTMOD && !gline->gl_lastmod))
166 + if ((flags & GLINE_EXACT ? ircd_strcmp(gline->gl_user, userhost) :
167 + match(gline->gl_user, userhost)) == 0) {
168 + if (GlineIsActive(gline))
177 /** Find a matching G-line for a user.
178 * @param[in] cptr Client to compare against.
179 * @param[in] flags Bitwise combination of GLINE_GLOBAL and/or
180 @@ -1162,6 +1206,16 @@
181 GlineIsRemActive(gline) ? '+' : '-',
185 + gliter(BadChanGlineList, gline, sgline) {
186 + send_reply(sptr, RPL_STATSGLINE, 'G', gline->gl_user, "", "", "", "",
187 + gline->gl_expire + TSoffset, gline->gl_lastmod,
188 + gline->gl_lifetime + TSoffset,
189 + gline->gl_state == GLOCAL_ACTIVATED ? ">" :
190 + (gline->gl_state == GLOCAL_DEACTIVATED ? "<" : ""),
191 + GlineIsRemActive(gline) ? '+' : '-', gline->gl_reason);
196 /** Calculate memory used by G-lines.
197 diff -r f49987f27c65 ircd/m_join.c
198 --- a/ircd/m_join.c Sun Jul 14 18:24:36 2013 +0100
199 +++ b/ircd/m_join.c Sun Jul 14 18:25:15 2013 +0100
203 /* BADCHANed channel */
204 - if ((gline = gline_find(name, GLINE_BADCHAN | GLINE_EXACT)) &&
205 - GlineIsActive(gline) && !IsAnOper(sptr)) {
206 - send_reply(sptr, ERR_BANNEDFROMCHAN, name);
207 + if (!IsAnOper(sptr)
208 + && (gline = gline_lookup_badchan(name, GLINE_BADCHAN))) {
209 + send_reply(sptr, ERR_BADCHANNAME, name, gline->gl_reason);
213 diff -r f49987f27c65 ircd/s_err.c
214 --- a/ircd/s_err.c Sun Jul 14 18:24:36 2013 +0100
215 +++ b/ircd/s_err.c Sun Jul 14 18:25:15 2013 +0100
218 { ERR_BANLISTFULL, "%s %s :Channel ban/ignore list is full", "478" },
220 - { ERR_BADCHANNAME, "%s :Cannot join channel (access denied on this server)", "479" },
221 + { ERR_BADCHANNAME, "%s :Cannot join channel (G-lined: %s)", "479" },