3 Add = mask prefix to glines to be used by services
4 so their gline actions end up in SNO_AUTO,
5 freeing SNO_GLINE from spam
7 Services can do add this prefix before the mask for
8 automated hits, but not add them for glines manually
9 set by an oper on the service.
11 <source> GL <target> [=][!][+-<>]<mask> ..
13 Oper is not allowed to use = prefix in /GLINE,
14 as that would be cheating :-)
17 This prefix must not be used until the entire network
18 and services are upgraded to handle it!
20 diff -r a4507a57b7cd include/gline.h
21 --- a/include/gline.h Sun Jan 18 21:11:24 2009 +0100
22 +++ b/include/gline.h Sun Jan 18 23:19:34 2009 +0100
24 #define GLINE_LIFETIME 0x2000 /**< Record lifetime update */
25 #define GLINE_REASON 0x4000 /**< Reason update */
27 +#define GLINE_AUTO 0x8000 /**< G-line set auto by service */
29 /** Controllable flags that can be set on an actual G-line. */
30 -#define GLINE_MASK (GLINE_ACTIVE | GLINE_BADCHAN | GLINE_LOCAL | GLINE_REALNAME)
31 +#define GLINE_MASK (GLINE_ACTIVE | GLINE_BADCHAN | GLINE_LOCAL | GLINE_REALNAME | GLINE_AUTO)
32 /** Mask for G-line activity flags. */
33 #define GLINE_ACTMASK (GLINE_ACTIVE | GLINE_LDEACT)
36 #define GlineIsBadChan(g) ((g)->gl_flags & GLINE_BADCHAN)
37 /** Test whether \a g is local to this server. */
38 #define GlineIsLocal(g) ((g)->gl_flags & GLINE_LOCAL)
39 +/** Test whether \a g is auto set by service */
40 +#define GlineIsAuto(g) ((g)->gl_flags & GLINE_AUTO)
42 /** Return nick mask of a G-line. */
43 #define GlineNick(g) ((g)->gl_nick)
44 diff -r a4507a57b7cd ircd/gline.c
45 --- a/ircd/gline.c Sun Jan 18 21:11:24 2009 +0100
46 +++ b/ircd/gline.c Sun Jan 18 23:19:35 2009 +0100
50 /* let the ops know about it */
51 - sendto_opmask_butone(0, SNO_GLINE, "G-line active for %s",
52 + sendto_opmask_butone(0, GlineIsAuto(gline) ? SNO_AUTO : SNO_GLINE, "G-line active for %s",
53 get_client_name(acptr, SHOW_IP));
55 /* and get rid of him */
59 assert(gline->gl_lastmod);
60 - sendcmdto_serv_butone(sptr, CMD_GLINE, cptr, "* %c%s%s%s%s%s %Tu %Tu %Tu :%s",
61 + sendcmdto_serv_butone(sptr, CMD_GLINE, cptr, "* %s%c%s%s%s%s%s %Tu %Tu %Tu :%s",
62 + GlineIsAuto(gline) ? "=" : "",
63 GlineIsRemActive(gline) ? '+' : '-',
64 GlineIsBadChan(gline)|GlineIsRealName(gline) ? "" : gline->gl_nick,
65 GlineIsBadChan(gline)|GlineIsRealName(gline) ? "" : "!",
67 /* lifetime is already an absolute timestamp */
70 - sendto_opmask_butone(0, ircd_strncmp(reason, "AUTO", 4) ? SNO_GLINE :
71 - SNO_AUTO, "%s adding %s %s for %s%s%s%s%s, expiring at "
72 + sendto_opmask_butone(0, (flags & GLINE_AUTO) ? SNO_AUTO : SNO_GLINE,
73 + "%s adding %s %s for %s%s%s%s%s, expiring at "
75 (feature_bool(FEAT_HIS_SNOTICES) || IsServer(sptr)) ?
78 return 0; /* was active to begin with */
80 /* Inform ops and log it */
81 - sendto_opmask_butone(0, SNO_GLINE, "%s activating global %s for %s%s%s%s%s, "
82 + sendto_opmask_butone(0, GlineIsAuto(gline) ? SNO_AUTO : SNO_GLINE,
83 + "%s activating global %s for %s%s%s%s%s, "
84 "expiring at %Tu: %s",
85 (feature_bool(FEAT_HIS_SNOTICES) || IsServer(sptr)) ?
90 /* Inform ops and log it */
91 - sendto_opmask_butone(0, SNO_GLINE, "%s %s GLINE for %s, expiring at %Tu",
92 + sendto_opmask_butone(0, (flags & GLINE_AUTO) ? SNO_AUTO : SNO_GLINE,
93 + "%s %s GLINE for %s, expiring at %Tu",
94 (feature_bool(FEAT_HIS_SNOTICES) || IsServer(sptr)) ?
95 cli_name(sptr) : cli_name((cli_user(sptr))->server),
96 msg, userhost, expire + TSoffset);
98 "%#C %s GLINE for %s, expiring at %Tu", sptr, msg, userhost,
101 - sendcmdto_serv_butone(sptr, CMD_GLINE, cptr, "* -%s %Tu %Tu %Tu",
102 + sendcmdto_serv_butone(sptr, CMD_GLINE, cptr, "* %s-%s %Tu %Tu %Tu",
103 + (flags & GLINE_AUTO) ? "=" : "",
104 userhost, expire, lastmod, lifetime);
111 + /* Handle the change of auto or manual G-line */
112 + if ((flags & GLINE_AUTO) && !GlineIsAuto(gline))
113 + gline->gl_flags |= GLINE_AUTO; /* mark as auto */
114 + else if (!(flags & GLINE_AUTO) && GlineIsAuto(gline))
115 + gline->gl_flags &= ~GLINE_AUTO; /* mark as manual */
117 /* Handle expiration changes... */
118 if (flags & GLINE_EXPIRE) {
119 gline->gl_expire = expire; /* save new expiration time */
123 /* All right, inform ops... */
124 - sendto_opmask_butone(0, SNO_GLINE, "%s modifying global %s for %s%s%s%s%s:%s",
125 + sendto_opmask_butone(0, flags & GLINE_AUTO ? SNO_GLINE : SNO_GLINE,
126 + "%s modifying global %s for %s%s%s%s%s:%s",
127 (feature_bool(FEAT_HIS_SNOTICES) || IsServer(sptr)) ?
128 cli_name(sptr) : cli_name((cli_user(sptr))->server),
129 GlineIsBadChan(gline) ? "BADCHAN" : "GLINE",
132 if (action != GLINE_LOCAL_ACTIVATE && action != GLINE_LOCAL_DEACTIVATE)
133 sendcmdto_serv_butone(sptr, CMD_GLINE, cptr,
134 - "* %s%s%s%s%s%s%s %Tu %Tu %Tu :%s",
135 + "* %s%s%s%s%s%s%s%s %Tu %Tu %Tu :%s",
136 + (flags & GLINE_AUTO) ? "=" : "",
137 flags & GLINE_OPERFORCE ? "!" : "", op,
138 GlineIsBadChan(gline)|GlineIsRealName(gline) ? "" : gline->gl_nick,
139 GlineIsBadChan(gline)|GlineIsRealName(gline) ? "" : "!",
140 @@ -1179,8 +1191,9 @@
142 gliter(GlobalGlineList, gline, sgline) {
143 if (!GlineIsLocal(gline) && gline->gl_lastmod)
144 - sendcmdto_one(&me, CMD_GLINE, cptr, "* %c%s%s%s%s%s %Tu %Tu %Tu :%s",
145 - GlineIsRemActive(gline) ? '+' : '-',
146 + sendcmdto_one(&me, CMD_GLINE, cptr, "* %s%c%s%s%s%s%s %Tu %Tu %Tu :%s",
147 + GlineIsAuto(gline) ? "=" : "",
148 + GlineIsRemActive(gline) ? '+' : '-',
149 gline->gl_nick ? gline->gl_nick : "",
150 gline->gl_nick ? "!" : "",
152 @@ -1192,7 +1205,8 @@
154 gliter(BadChanGlineList, gline, sgline) {
155 if (!GlineIsLocal(gline) && gline->gl_lastmod)
156 - sendcmdto_one(&me, CMD_GLINE, cptr, "* %c%s %Tu %Tu %Tu :%s",
157 + sendcmdto_one(&me, CMD_GLINE, cptr, "* %s%c%s %Tu %Tu %Tu :%s",
158 + GlineIsAuto(gline) ? "=" : "",
159 GlineIsRemActive(gline) ? '+' : '-', gline->gl_user,
160 gline->gl_expire - CurrentTime, gline->gl_lastmod,
161 gline->gl_lifetime, gline->gl_reason);
162 @@ -1210,7 +1224,8 @@
163 if (GlineIsLocal(gline) || !gline->gl_lastmod)
166 - sendcmdto_one(&me, CMD_GLINE, cptr, "* %c%s%s%s%s%s %Tu %Tu %Tu :%s",
167 + sendcmdto_one(&me, CMD_GLINE, cptr, "* %s%c%s%s%s%s%s %Tu %Tu %Tu :%s",
168 + GlineIsAuto(gline) ? "=" : "",
169 GlineIsRemActive(gline) ? '+' : '-',
170 GlineIsBadChan(gline)|GlineIsRealName(gline) ? "" : gline->gl_nick,
171 GlineIsBadChan(gline)|GlineIsRealName(gline) ? "" : "!",
172 @@ -1249,6 +1264,7 @@
173 gline->gl_expire + TSoffset, gline->gl_lastmod,
174 gline->gl_lifetime + TSoffset,
175 GlineIsLocal(gline) ? cli_name(&me) : "*",
176 + GlineIsAuto(gline) && IsAnOper(sptr) ? "=" : "",
177 gline->gl_state == GLOCAL_ACTIVATED ? ">" :
178 (gline->gl_state == GLOCAL_DEACTIVATED ? "<" : ""),
179 GlineIsRemActive(gline) ? '+' : '-', gline->gl_reason);
180 @@ -1263,6 +1279,7 @@
181 gline->gl_expire + TSoffset, gline->gl_lastmod,
182 gline->gl_lifetime + TSoffset,
183 GlineIsLocal(gline) ? cli_name(&me) : "*",
184 + GlineIsAuto(gline) && IsAnOper(sptr) ? "=" : "",
185 gline->gl_state == GLOCAL_ACTIVATED ? ">" :
186 (gline->gl_state == GLOCAL_DEACTIVATED ? "<" : ""),
187 GlineIsRemActive(gline) ? '+' : '-', gline->gl_reason);
188 @@ -1273,6 +1290,7 @@
189 gline->gl_expire + TSoffset, gline->gl_lastmod,
190 gline->gl_lifetime + TSoffset,
191 GlineIsLocal(gline) ? cli_name(&me) : "*",
192 + GlineIsAuto(gline) && IsAnOper(sptr) ? "=" : "",
193 gline->gl_state == GLOCAL_ACTIVATED ? ">" :
194 (gline->gl_state == GLOCAL_DEACTIVATED ? "<" : ""),
195 GlineIsRemActive(gline) ? '+' : '-', gline->gl_reason);
196 @@ -1304,6 +1322,7 @@
197 gline->gl_host ? gline->gl_host : "",
198 gline->gl_expire + TSoffset, gline->gl_lastmod,
199 gline->gl_lifetime + TSoffset,
200 + GlineIsAuto(gline) && IsAnOper(sptr) ? "=" : "",
201 gline->gl_state == GLOCAL_ACTIVATED ? ">" :
202 (gline->gl_state == GLOCAL_DEACTIVATED ? "<" : ""),
203 GlineIsRemActive(gline) ? '+' : '-',
204 @@ -1314,6 +1333,7 @@
205 send_reply(sptr, RPL_STATSGLINE, 'G', gline->gl_user, "", "", "", "",
206 gline->gl_expire + TSoffset, gline->gl_lastmod,
207 gline->gl_lifetime + TSoffset,
208 + GlineIsAuto(gline) && IsAnOper(sptr) ? "=" : "",
209 gline->gl_state == GLOCAL_ACTIVATED ? ">" :
210 (gline->gl_state == GLOCAL_DEACTIVATED ? "<" : ""),
211 GlineIsRemActive(gline) ? '+' : '-', gline->gl_reason);
212 diff -r a4507a57b7cd ircd/m_gline.c
213 --- a/ircd/m_gline.c Sun Jan 18 21:11:24 2009 +0100
214 +++ b/ircd/m_gline.c Sun Jan 18 23:19:35 2009 +0100
217 flags |= GLINE_FORCE;
219 + if (*mask == '=') {
221 + flags |= GLINE_AUTO; /* auto G-line action by service */
226 flags |= GLINE_OPERFORCE; /* assume oper had WIDE_GLINE */
227 @@ -183,11 +188,14 @@
228 if ((action == GLINE_LOCAL_ACTIVATE || action == GLINE_LOCAL_DEACTIVATE) &&
230 Debug((DEBUG_DEBUG, "I am forwarding a local change to a global gline "
231 - "to a remote server; target %s, mask %s, operforce %s, action %c",
232 - target, mask, flags & GLINE_OPERFORCE ? "YES" : "NO",
233 + "to a remote server; target %s, mask %s, operforce %s, auto %s, action %c",
235 + flags & GLINE_OPERFORCE ? "YES" : "NO",
236 + flags & GLINE_AUTO ? "YES" : "NO",
237 action == GLINE_LOCAL_ACTIVATE ? '>' : '<'));
239 - sendcmdto_one(sptr, CMD_GLINE, acptr, "%C %s%c%s", acptr,
240 + sendcmdto_one(sptr, CMD_GLINE, acptr, "%C %s%s%c%s", acptr,
241 + flags & GLINE_AUTO ? "=" : "",
242 flags & GLINE_OPERFORCE ? "!" : "",
243 action == GLINE_LOCAL_ACTIVATE ? '>' : '<', mask);
247 /* OK, create the local G-line */
248 Debug((DEBUG_DEBUG, "I am creating a local G-line here; target %s, "
249 - "mask %s, operforce %s, action %s, expire %Tu, reason: %s",
250 - target, mask, flags & GLINE_OPERFORCE ? "YES" : "NO",
251 + "mask %s, operforce %s, auto %s, action %s, expire %Tu, reason: %s",
253 + flags & GLINE_OPERFORCE ? "YES" : "NO",
254 + flags & GLINE_AUTO ? "YES" : "NO",
255 action == GLINE_ACTIVATE ? "+" : "-", expire, reason));
257 return gline_add(cptr, sptr, mask, reason, expire, lastmod,
260 /* Let's now destroy the G-line */;
261 Debug((DEBUG_DEBUG, "I am destroying a local G-line here; target %s, "
262 - "mask %s, operforce %s, action %s", target, mask,
263 + "mask %s, operforce %s, auto %s, action %s", target, mask,
264 flags & GLINE_OPERFORCE ? "YES" : "NO",
265 + flags & GLINE_AUTO ? "YES" : "NO",
266 action == GLINE_ACTIVATE ? "+" : "-"));
268 return gline_destroy(cptr, sptr, agline);
269 @@ -255,14 +266,17 @@
270 assert(!IsMe(acptr));
272 Debug((DEBUG_DEBUG, "I am forwarding a local G-line to a remote server; "
273 - "target %s, mask %s, operforce %s, action %c, expire %Tu, "
274 + "target %s, mask %s, operforce %s, auto %s, action %c, expire %Tu, "
275 "lastmod %Tu, reason: %s", target, mask,
276 flags & GLINE_OPERFORCE ? "YES" : "NO",
277 + flags & GLINE_AUTO ? "YES" : "NO",
278 action == GLINE_ACTIVATE ? '+' : '-', expire, CurrentTime,
281 - sendcmdto_one(sptr, CMD_GLINE, acptr, "%C %s%c%s %Tu %Tu :%s",
282 - acptr, flags & GLINE_OPERFORCE ? "!" : "",
283 + sendcmdto_one(sptr, CMD_GLINE, acptr, "%C %s%s%c%s %Tu %Tu :%s",
285 + flags & GLINE_AUTO ? "=" : "",
286 + flags & GLINE_OPERFORCE ? "!" : "",
287 action == GLINE_ACTIVATE ? '+' : '-', mask,
288 expire - CurrentTime, CurrentTime, reason);
290 @@ -323,10 +337,11 @@
291 return need_more_params(sptr, "GLINE");
293 Debug((DEBUG_DEBUG, "I have a global G-line I am acting upon now; "
294 - "target %s, mask %s, operforce %s, action %s, expire %Tu, "
295 + "target %s, mask %s, operforce %s, auto %s, action %s, expire %Tu, "
296 "lastmod %Tu, lifetime %Tu, reason: %s; gline %s! (fields "
297 "present: %s %s %s)", target, mask,
298 flags & GLINE_OPERFORCE ? "YES" : "NO",
299 + flags & GLINE_AUTO ? "YES" : "NO",
300 action == GLINE_ACTIVATE ? "+" :
301 (action == GLINE_DEACTIVATE ? "-" :
302 (action == GLINE_LOCAL_ACTIVATE ? ">" :
304 action == GLINE_ACTIVATE ? "activation" : "deactivation"));
306 /* propagate the G-line, even though we don't have it */
307 - sendcmdto_serv_butone(sptr, CMD_GLINE, cptr, "* %c%s %Tu",
308 + sendcmdto_serv_butone(sptr, CMD_GLINE, cptr, "* %s%c%s %Tu",
309 + flags & GLINE_AUTO ? "=" : "",
310 action == GLINE_ACTIVATE ? '+' : '-',
314 return send_reply(sptr, ERR_NOPRIVILEGES);
316 return gline_list(sptr, 0);
319 + if (*mask == '=') { /* ignore auto prefix from oper */
324 @@ -506,11 +526,14 @@
325 return send_reply(sptr, ERR_NOPRIVILEGES);
327 Debug((DEBUG_DEBUG, "I am forwarding a local change to a global gline "
328 - "to a remote server; target %s, mask %s, operforce %s, action %c",
329 - cli_name(acptr), mask, flags & GLINE_OPERFORCE ? "YES" : "NO",
330 + "to a remote server; target %s, mask %s, operforce %s, auto %s, action %c",
331 + cli_name(acptr), mask,
332 + flags & GLINE_OPERFORCE ? "YES" : "NO",
333 + flags & GLINE_AUTO ? "YES" : "NO",
334 action == GLINE_LOCAL_ACTIVATE ? '>' : '<'));
336 sendcmdto_one(sptr, CMD_GLINE, acptr, "%C %s%c%s", acptr,
337 + flags & GLINE_AUTO ? "=" : "",
338 flags & GLINE_OPERFORCE ? "!" : "",
339 action == GLINE_LOCAL_ACTIVATE ? '>' : '<', mask);
341 @@ -544,13 +567,16 @@
342 return send_reply(sptr, ERR_NOPRIVILEGES);
344 Debug((DEBUG_DEBUG, "I am forwarding a local G-line to a remote "
345 - "server; target %s, mask %s, operforce %s, action %c, "
346 + "server; target %s, mask %s, operforce %s, auto %s, action %c, "
347 "expire %Tu, reason %s", target, mask,
348 flags & GLINE_OPERFORCE ? "YES" : "NO",
349 + flags & GLINE_AUTO ? "YES" : "NO",
350 action == GLINE_ACTIVATE ? '+' : '-', expire, reason));
352 - sendcmdto_one(sptr, CMD_GLINE, acptr, "%C %s%c%s %Tu %Tu :%s",
353 - acptr, flags & GLINE_OPERFORCE ? "!" : "",
354 + sendcmdto_one(sptr, CMD_GLINE, acptr, "%C %s%s%c%s %Tu %Tu :%s",
356 + flags & GLINE_AUTO ? "=" : "",
357 + flags & GLINE_OPERFORCE ? "!" : "",
358 action == GLINE_ACTIVATE ? '+' : '-', mask,
359 expire - CurrentTime, CurrentTime, reason);
363 /* OK, create the local G-line */
364 Debug((DEBUG_DEBUG, "I am creating a local G-line here; target %s, "
365 - "mask %s, operforce %s, action %s, expire %Tu, reason: %s",
366 - target, mask, flags & GLINE_OPERFORCE ? "YES" : "NO",
367 + "mask %s, operforce %s, auto %s, action %s, expire %Tu, reason: %s",
369 + flags & GLINE_OPERFORCE ? "YES" : "NO",
370 + flags & GLINE_AUTO ? "YES" : "NO",
371 action == GLINE_ACTIVATE ? "+" : "-", expire, reason));
373 return gline_add(cptr, sptr, mask, reason, expire, 0, 0,
376 /* Let's now destroy the G-line */
377 Debug((DEBUG_DEBUG, "I am destroying a local G-line here; target %s, "
378 - "mask %s, operforce %s, action %s", target, mask,
379 + "mask %s, operforce %s, auto %s, action %s", target, mask,
380 flags & GLINE_OPERFORCE ? "YES" : "NO",
381 + flags & GLINE_AUTO ? "YES" : "NO",
382 action == GLINE_ACTIVATE ? "+" : "-"));
384 return gline_destroy(cptr, sptr, agline);
388 Debug((DEBUG_DEBUG, "I have a global G-line I am acting upon now; "
389 - "target %s, mask %s, operforce %s, action %s, expire %Tu, "
390 + "target %s, mask %s, operforce %s, auto %s, action %s, expire %Tu, "
391 "reason: %s; gline %s! (fields present: %s %s)", target,
392 - mask, flags & GLINE_OPERFORCE ? "YES" : "NO",
394 + flags & GLINE_OPERFORCE ? "YES" : "NO",
395 + flags & GLINE_AUTO ? "YES" : "NO",
396 action == GLINE_ACTIVATE ? "+" :
397 (action == GLINE_DEACTIVATE ? "-" :
398 (action == GLINE_LOCAL_ACTIVATE ? ">" :
399 diff -r a4507a57b7cd ircd/s_err.c
400 --- a/ircd/s_err.c Sun Jan 18 21:11:24 2009 +0100
401 +++ b/ircd/s_err.c Sun Jan 18 23:19:35 2009 +0100
404 { RPL_STATSTLINE, "%c %s %s", "246" },
406 - { RPL_STATSGLINE, "%c %s%s%s%s%s %Tu %Tu %Tu %s%c :%s", "247" },
407 + { RPL_STATSGLINE, "%c %s%s%s%s%s %Tu %Tu %Tu %s%s%c :%s", "247" },
409 { RPL_STATSULINE, "U %s", "248" },
415 - { RPL_GLIST, "%s%s%s%s%s %Tu %Tu %Tu %s %s%c :%s", "280" },
416 + { RPL_GLIST, "%s%s%s%s%s %Tu %Tu %Tu %s %s%s%c :%s", "280" },
418 { RPL_ENDOFGLIST, ":End of G-line List", "281" },