]>
Commit | Line | Data |
---|---|---|
edb26b39 | 1 | # HG changeset patch |
6fe1b135 | 2 | # Parent b303d3fb110ec90c10a105cc533a8a0b9b2baefb |
edb26b39 | 3 | |
6fe1b135 P |
4 | diff -r b303d3fb110e include/gline.h |
5 | --- a/include/gline.h Sat Jul 20 14:49:32 2013 +0100 | |
6 | +++ b/include/gline.h Sat Jul 20 14:50:19 2013 +0100 | |
edb26b39 P |
7 | @@ -136,6 +136,7 @@ |
8 | struct Gline *gline); | |
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); | |
6fe1b135 P |
15 | diff -r b303d3fb110e ircd/gline.c |
16 | --- a/ircd/gline.c Sat Jul 20 14:49:32 2013 +0100 | |
17 | +++ b/ircd/gline.c Sat Jul 20 14:50:19 2013 +0100 | |
18 | @@ -26,6 +26,7 @@ | |
edb26b39 | 19 | #include "gline.h" |
6fe1b135 | 20 | #include "channel.h" |
edb26b39 P |
21 | #include "client.h" |
22 | +#include "hash.h" | |
23 | #include "ircd.h" | |
24 | #include "ircd_alloc.h" | |
25 | #include "ircd_features.h" | |
6fe1b135 | 26 | @@ -185,8 +186,8 @@ |
edb26b39 P |
27 | } |
28 | ||
29 | /** Check local clients against a new G-line. | |
30 | - * If the G-line is inactive or a badchan, return immediately. | |
31 | - * Otherwise, if any users match it, disconnect them. | |
32 | + * If the G-line is inactive, return immediately. | |
33 | + * Otherwise, if any users match it, disconnect them or kick them if the G-line is a BADCHAN. | |
34 | * @param[in] cptr Peer connect that sent the G-line. | |
35 | * @param[in] sptr Client that originated the G-line. | |
36 | * @param[in] gline New G-line to check. | |
6fe1b135 | 37 | @@ -201,53 +202,72 @@ |
edb26b39 P |
38 | if (feature_bool(FEAT_DISABLE_GLINES)) |
39 | return 0; /* G-lines are disabled */ | |
40 | ||
41 | - if (GlineIsBadChan(gline)) /* no action taken on badchan glines */ | |
42 | - return 0; | |
43 | if (!GlineIsActive(gline)) /* no action taken on inactive glines */ | |
44 | return 0; | |
45 | ||
46 | - for (fd = HighestFd; fd >= 0; --fd) { | |
47 | - /* | |
48 | - * get the users! | |
49 | - */ | |
50 | - if ((acptr = LocalClientArray[fd])) { | |
51 | - if (!cli_user(acptr)) | |
52 | - continue; | |
53 | + if (GlineIsBadChan(gline)) { | |
54 | + /* Handle BADCHAN gline */ | |
55 | + struct Channel *chptr,*nchptr; | |
56 | + struct Membership *member,*nmember; | |
57 | ||
58 | - if (GlineIsRealName(gline)) { /* Realname Gline */ | |
59 | - Debug((DEBUG_DEBUG,"Realname Gline: %s %s",(cli_info(acptr)), | |
60 | - gline->gl_user+2)); | |
61 | - if (match(gline->gl_user+2, cli_info(acptr)) != 0) | |
62 | - continue; | |
63 | - Debug((DEBUG_DEBUG,"Matched!")); | |
64 | - } else { /* Host/IP gline */ | |
65 | - if (cli_user(acptr)->username && | |
66 | - match(gline->gl_user, (cli_user(acptr))->realusername) != 0) | |
67 | + for(chptr=GlobalChannelList;chptr;chptr=nchptr) { | |
68 | + nchptr=chptr->next; | |
69 | + if (match(gline->gl_user, chptr->chname)) | |
70 | + continue; | |
71 | + for (member=chptr->members;member;member=nmember) { | |
72 | + nmember=member->next_member; | |
73 | + if (!MyUser(member->user) || IsZombie(member) || IsAnOper(member->user)) | |
74 | + continue; | |
75 | + sendcmdto_serv_butone(&me, CMD_KICK, NULL, "%H %C :Badchanneled (%s)", chptr, member->user, gline->gl_reason); | |
76 | + sendcmdto_channel_butserv_butone(&his, CMD_KICK, chptr, NULL, 0, "%H %C :Badchanneled (%s)", chptr, member->user, gline->gl_reason); | |
77 | + make_zombie(member, member->user, &me, &me, chptr); | |
78 | + retval=1; | |
79 | + } | |
80 | + } | |
81 | + } else { | |
82 | + for (fd = HighestFd; fd >= 0; --fd) { | |
83 | + /* | |
84 | + * get the users! | |
85 | + */ | |
86 | + if ((acptr = LocalClientArray[fd])) { | |
87 | + if (!cli_user(acptr)) | |
88 | continue; | |
89 | ||
90 | - if (GlineIsIpMask(gline)) { | |
91 | - if (!ipmask_check(&cli_ip(acptr), &gline->gl_addr, gline->gl_bits)) | |
92 | + if (GlineIsRealName(gline)) { /* Realname Gline */ | |
93 | + Debug((DEBUG_DEBUG,"Realname Gline: %s %s",(cli_info(acptr)), | |
94 | + gline->gl_user+2)); | |
95 | + if (match(gline->gl_user+2, cli_info(acptr)) != 0) | |
96 | + continue; | |
97 | + Debug((DEBUG_DEBUG,"Matched!")); | |
98 | + } else { /* Host/IP gline */ | |
99 | + if (cli_user(acptr)->username && | |
100 | + match(gline->gl_user, (cli_user(acptr))->realusername) != 0) | |
101 | continue; | |
102 | + | |
103 | + if (GlineIsIpMask(gline)) { | |
104 | + if (!ipmask_check(&cli_ip(acptr), &gline->gl_addr, gline->gl_bits)) | |
105 | + continue; | |
106 | + } | |
107 | + else { | |
108 | + if (match(gline->gl_host, cli_sockhost(acptr)) != 0) | |
109 | + continue; | |
110 | + } | |
111 | } | |
112 | - else { | |
113 | - if (match(gline->gl_host, cli_sockhost(acptr)) != 0) | |
114 | - continue; | |
115 | - } | |
116 | + | |
117 | + /* ok, here's one that got G-lined */ | |
118 | + send_reply(acptr, SND_EXPLICIT | ERR_YOUREBANNEDCREEP, ":%s", | |
119 | + gline->gl_reason); | |
120 | + | |
121 | + /* let the ops know about it */ | |
122 | + sendto_opmask_butone(0, SNO_GLINE, "G-line active for %s", | |
123 | + get_client_name(acptr, SHOW_IP)); | |
124 | + | |
125 | + /* and get rid of him */ | |
126 | + /* Asuka - Reimplement HEAD_IN_SAND_GLINE from Lain */ | |
127 | + if ((tval = exit_client_msg(cptr, acptr, &me, | |
128 | + feature_bool(FEAT_HIS_GLINE) ? "G-lined" : "G-lined (%s)", gline->gl_reason))) | |
129 | + retval = tval; /* retain killed status */ | |
130 | } | |
131 | - | |
132 | - /* ok, here's one that got G-lined */ | |
133 | - send_reply(acptr, SND_EXPLICIT | ERR_YOUREBANNEDCREEP, ":%s", | |
134 | - gline->gl_reason); | |
135 | - | |
136 | - /* let the ops know about it */ | |
137 | - sendto_opmask_butone(0, SNO_GLINE, "G-line active for %s", | |
138 | - get_client_name(acptr, SHOW_IP)); | |
139 | - | |
140 | - /* and get rid of him */ | |
141 | - /* Asuka - Reimplement HEAD_IN_SAND_GLINE from Lain */ | |
142 | - if ((tval = exit_client_msg(cptr, acptr, &me, | |
143 | - feature_bool(FEAT_HIS_GLINE) ? "G-lined" : "G-lined (%s)", gline->gl_reason))) | |
144 | - retval = tval; /* retain killed status */ | |
145 | } | |
146 | } | |
147 | return retval; | |
6fe1b135 | 148 | @@ -984,6 +1004,29 @@ |
edb26b39 P |
149 | return gline; |
150 | } | |
151 | ||
152 | +struct Gline * | |
153 | +gline_lookup_badchan(char *userhost, unsigned int flags) | |
154 | +{ | |
155 | + struct Gline *gline; | |
156 | + struct Gline *sgline; | |
157 | + | |
158 | + if (flags & (GLINE_BADCHAN | GLINE_ANY)) { | |
159 | + gliter(BadChanGlineList, gline, sgline) { | |
160 | + if ((flags & GLINE_GLOBAL && gline->gl_flags & GLINE_LOCAL) || | |
161 | + (flags & GLINE_LASTMOD && !gline->gl_lastmod)) | |
162 | + continue; | |
163 | + | |
164 | + if ((flags & GLINE_EXACT ? ircd_strcmp(gline->gl_user, userhost) : | |
165 | + match(gline->gl_user, userhost)) == 0) { | |
166 | + if (GlineIsActive(gline)) | |
167 | + return gline; | |
168 | + } | |
169 | + } | |
170 | + } | |
171 | + | |
172 | + return 0; | |
173 | +} | |
174 | + | |
175 | /** Find a matching G-line for a user. | |
176 | * @param[in] cptr Client to compare against. | |
177 | * @param[in] flags Bitwise combination of GLINE_GLOBAL and/or | |
6fe1b135 | 178 | @@ -1174,6 +1217,16 @@ |
edb26b39 P |
179 | GlineIsRemActive(gline) ? '+' : '-', |
180 | gline->gl_reason); | |
181 | } | |
182 | + | |
183 | + gliter(BadChanGlineList, gline, sgline) { | |
184 | + send_reply(sptr, RPL_STATSGLINE, 'G', gline->gl_user, "", "", "", "", | |
185 | + gline->gl_expire + TSoffset, gline->gl_lastmod, | |
186 | + gline->gl_lifetime + TSoffset, | |
187 | + gline->gl_state == GLOCAL_ACTIVATED ? ">" : | |
188 | + (gline->gl_state == GLOCAL_DEACTIVATED ? "<" : ""), | |
189 | + GlineIsRemActive(gline) ? '+' : '-', gline->gl_reason); | |
190 | + } | |
191 | + | |
192 | } | |
193 | ||
194 | /** Calculate memory used by G-lines. | |
6fe1b135 P |
195 | diff -r b303d3fb110e ircd/m_join.c |
196 | --- a/ircd/m_join.c Sat Jul 20 14:49:32 2013 +0100 | |
197 | +++ b/ircd/m_join.c Sat Jul 20 14:50:19 2013 +0100 | |
edb26b39 P |
198 | @@ -150,9 +150,9 @@ |
199 | } | |
200 | ||
201 | /* BADCHANed channel */ | |
202 | - if ((gline = gline_find(name, GLINE_BADCHAN | GLINE_EXACT)) && | |
203 | - GlineIsActive(gline) && !IsAnOper(sptr)) { | |
204 | - send_reply(sptr, ERR_BANNEDFROMCHAN, name); | |
205 | + if (!IsAnOper(sptr) | |
206 | + && (gline = gline_lookup_badchan(name, GLINE_BADCHAN))) { | |
207 | + send_reply(sptr, ERR_BADCHANNAME, name, gline->gl_reason); | |
208 | continue; | |
209 | } | |
210 | ||
6fe1b135 P |
211 | diff -r b303d3fb110e ircd/s_err.c |
212 | --- a/ircd/s_err.c Sat Jul 20 14:49:32 2013 +0100 | |
213 | +++ b/ircd/s_err.c Sat Jul 20 14:50:19 2013 +0100 | |
edb26b39 P |
214 | @@ -990,7 +990,7 @@ |
215 | /* 478 */ | |
216 | { ERR_BANLISTFULL, "%s %s :Channel ban/ignore list is full", "478" }, | |
217 | /* 479 */ | |
218 | - { ERR_BADCHANNAME, "%s :Cannot join channel (access denied on this server)", "479" }, | |
219 | + { ERR_BADCHANNAME, "%s :Cannot join channel (G-lined: %s)", "479" }, | |
220 | /* 480 */ | |
221 | { 0 }, | |
222 | /* 481 */ |