]> jfr.im git - irc/quakenet/snircd-patchqueue.git/blame - glinesnomask.patch
split.patch - fixed for conflict with staffpriv.patch
[irc/quakenet/snircd-patchqueue.git] / glinesnomask.patch
CommitLineData
715c825d 1SNO_GLINE and SNO_AUTO
12e82c05 2
c5aca5d6 3Add = mask prefix to glines to be used by services
4so their gline actions end up in SNO_AUTO,
5freeing SNO_GLINE from spam
12e82c05 6
c5aca5d6 7Services can do add this prefix before the mask for
8automated hits, but not add them for glines manually
9set by an oper on the service.
715c825d 10
c5aca5d6 11<source> GL <target> [=][!][+-<>]<mask> ..
12
13Oper is not allowed to use = prefix in /GLINE,
14as that would be cheating :-)
15
16*** important ***
17This prefix must not be used until the entire network
18and services are upgraded to handle it!
19
8ffede71 20diff -r a9d96ac08a2c include/gline.h
21--- a/include/gline.h Fri Jan 30 18:28:17 2009 +0100
22+++ b/include/gline.h Fri Jan 30 18:52:10 2009 +0100
c5aca5d6 23@@ -88,8 +88,10 @@
24 #define GLINE_LIFETIME 0x2000 /**< Record lifetime update */
25 #define GLINE_REASON 0x4000 /**< Reason update */
26
27+#define GLINE_AUTO 0x8000 /**< G-line set auto by service */
28+
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)
34
35@@ -110,6 +112,8 @@
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)
41
42 /** Return nick mask of a G-line. */
43 #define GlineNick(g) ((g)->gl_nick)
8ffede71 44diff -r a9d96ac08a2c ircd/gline.c
45--- a/ircd/gline.c Fri Jan 30 18:28:17 2009 +0100
46+++ b/ircd/gline.c Fri Jan 30 18:52:10 2009 +0100
715c825d
CP
47@@ -278,7 +278,7 @@
48 gline->gl_reason);
49
50 /* let the ops know about it */
51- sendto_opmask_butone(0, SNO_GLINE, "G-line active for %s",
c5aca5d6 52+ sendto_opmask_butone(0, GlineIsAuto(gline) ? SNO_AUTO : SNO_GLINE, "G-line active for %s",
715c825d
CP
53 get_client_name(acptr, SHOW_IP));
54
55 /* and get rid of him */
c5aca5d6 56@@ -378,7 +378,8 @@
57 return 0;
715c825d 58
c5aca5d6 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) ? "" : "!",
66@@ -555,8 +556,8 @@
715c825d
CP
67 /* lifetime is already an absolute timestamp */
68
715c825d
CP
69 /* Inform ops... */
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 "
c5aca5d6 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 "
715c825d
CP
74 "%Tu: %s",
75 (feature_bool(FEAT_HIS_SNOTICES) || IsServer(sptr)) ?
76 cli_name(sptr) :
c5aca5d6 77@@ -630,7 +631,8 @@
78 return 0; /* was active to begin with */
79
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)) ?
86 cli_name(sptr) :
87@@ -756,7 +758,8 @@
88 lifetime = expire;
89
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);
97@@ -765,7 +768,8 @@
98 "%#C %s GLINE for %s, expiring at %Tu", sptr, msg, userhost,
99 expire);
100
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);
105
106 return 0;
107@@ -912,6 +916,12 @@
108 break;
109 }
110
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 */
116+
117 /* Handle expiration changes... */
118 if (flags & GLINE_EXPIRE) {
119 gline->gl_expire = expire; /* save new expiration time */
120@@ -944,7 +954,8 @@
121 }
122
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",
130@@ -965,7 +976,8 @@
131 */
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 @@
141
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 ? "!" : "",
151 gline->gl_user,
152@@ -1192,7 +1205,8 @@
153
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)
164 return 0;
165
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);
8ffede71 196@@ -1308,6 +1326,7 @@
c5aca5d6 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) ? '+' : '-',
8ffede71 204@@ -1318,6 +1337,7 @@
c5aca5d6 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);
8ffede71 212diff -r a9d96ac08a2c ircd/m_gline.c
213--- a/ircd/m_gline.c Fri Jan 30 18:28:17 2009 +0100
214+++ b/ircd/m_gline.c Fri Jan 30 18:52:10 2009 +0100
c5aca5d6 215@@ -140,6 +140,11 @@
216 if (IsServer(sptr))
217 flags |= GLINE_FORCE;
218
219+ if (*mask == '=') {
220+ mask++;
221+ flags |= GLINE_AUTO; /* auto G-line action by service */
222+ }
223+
224 if (*mask == '!') {
225 mask++;
226 flags |= GLINE_OPERFORCE; /* assume oper had WIDE_GLINE */
227@@ -183,11 +188,14 @@
228 if ((action == GLINE_LOCAL_ACTIVATE || action == GLINE_LOCAL_DEACTIVATE) &&
229 !IsMe(acptr)) {
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",
8ffede71 233+ "to a remote server; target %s, mask %s, auto %s, operforce %s, action %c",
c5aca5d6 234+ target, mask,
c5aca5d6 235+ flags & GLINE_AUTO ? "YES" : "NO",
8ffede71 236+ flags & GLINE_OPERFORCE ? "YES" : "NO",
c5aca5d6 237 action == GLINE_LOCAL_ACTIVATE ? '>' : '<'));
238
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);
244
245@@ -226,8 +234,10 @@
246
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",
8ffede71 251+ "mask %s, auto %s, operforce %s, action %s, expire %Tu, reason: %s",
c5aca5d6 252+ target, mask,
c5aca5d6 253+ flags & GLINE_AUTO ? "YES" : "NO",
8ffede71 254+ flags & GLINE_OPERFORCE ? "YES" : "NO",
c5aca5d6 255 action == GLINE_ACTIVATE ? "+" : "-", expire, reason));
256
257 return gline_add(cptr, sptr, mask, reason, expire, lastmod,
8ffede71 258@@ -239,7 +249,8 @@
c5aca5d6 259
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,
8ffede71 263+ "mask %s, auto %s, operforce %s, action %s", target, mask,
c5aca5d6 264+ flags & GLINE_AUTO ? "YES" : "NO",
8ffede71 265 flags & GLINE_OPERFORCE ? "YES" : "NO",
c5aca5d6 266 action == GLINE_ACTIVATE ? "+" : "-"));
267
c5aca5d6 268@@ -255,14 +266,17 @@
269 assert(!IsMe(acptr));
270
271 Debug((DEBUG_DEBUG, "I am forwarding a local G-line to a remote server; "
272- "target %s, mask %s, operforce %s, action %c, expire %Tu, "
8ffede71 273+ "target %s, mask %s, auto %s, operforce %s, action %c, expire %Tu, "
c5aca5d6 274 "lastmod %Tu, reason: %s", target, mask,
c5aca5d6 275+ flags & GLINE_AUTO ? "YES" : "NO",
8ffede71 276 flags & GLINE_OPERFORCE ? "YES" : "NO",
c5aca5d6 277 action == GLINE_ACTIVATE ? '+' : '-', expire, CurrentTime,
278 reason));
279
280- sendcmdto_one(sptr, CMD_GLINE, acptr, "%C %s%c%s %Tu %Tu :%s",
281- acptr, flags & GLINE_OPERFORCE ? "!" : "",
282+ sendcmdto_one(sptr, CMD_GLINE, acptr, "%C %s%s%c%s %Tu %Tu :%s",
283+ acptr,
284+ flags & GLINE_AUTO ? "=" : "",
285+ flags & GLINE_OPERFORCE ? "!" : "",
286 action == GLINE_ACTIVATE ? '+' : '-', mask,
287 expire - CurrentTime, CurrentTime, reason);
288
8ffede71 289@@ -323,9 +337,10 @@
c5aca5d6 290 return need_more_params(sptr, "GLINE");
291
292 Debug((DEBUG_DEBUG, "I have a global G-line I am acting upon now; "
293- "target %s, mask %s, operforce %s, action %s, expire %Tu, "
8ffede71 294+ "target %s, mask %s, auto %s, operforce %s, action %s, expire %Tu, "
c5aca5d6 295 "lastmod %Tu, lifetime %Tu, reason: %s; gline %s! (fields "
296 "present: %s %s %s)", target, mask,
c5aca5d6 297+ flags & GLINE_AUTO ? "YES" : "NO",
8ffede71 298 flags & GLINE_OPERFORCE ? "YES" : "NO",
c5aca5d6 299 action == GLINE_ACTIVATE ? "+" :
300 (action == GLINE_DEACTIVATE ? "-" :
c5aca5d6 301@@ -353,7 +368,8 @@
302 action == GLINE_ACTIVATE ? "activation" : "deactivation"));
303
304 /* propagate the G-line, even though we don't have it */
305- sendcmdto_serv_butone(sptr, CMD_GLINE, cptr, "* %c%s %Tu",
306+ sendcmdto_serv_butone(sptr, CMD_GLINE, cptr, "* %s%c%s %Tu",
307+ flags & GLINE_AUTO ? "=" : "",
308 action == GLINE_ACTIVATE ? '+' : '-',
309 mask, lastmod);
310
8ffede71 311@@ -389,6 +405,10 @@
c5aca5d6 312 return gline_list(sptr, 0);
c5aca5d6 313 }
314
8ffede71 315+ /* ignore auto prefix from oper */
316+ if (*mask == '=')
317+ mask++;
318+
c5aca5d6 319 if (*mask == '!') {
8ffede71 320 mask++;
715c825d 321
8ffede71 322diff -r a9d96ac08a2c ircd/s_err.c
323--- a/ircd/s_err.c Fri Jan 30 18:28:17 2009 +0100
324+++ b/ircd/s_err.c Fri Jan 30 18:52:10 2009 +0100
c5aca5d6 325@@ -526,7 +526,7 @@
326 /* 246 */
327 { RPL_STATSTLINE, "%c %s %s", "246" },
328 /* 247 */
329- { RPL_STATSGLINE, "%c %s%s%s%s%s %Tu %Tu %Tu %s%c :%s", "247" },
330+ { RPL_STATSGLINE, "%c %s%s%s%s%s %Tu %Tu %Tu %s%s%c :%s", "247" },
331 /* 248 */
332 { RPL_STATSULINE, "U %s", "248" },
333 /* 249 */
334@@ -592,7 +592,7 @@
335 /* 279 */
336 { 0 },
337 /* 280 */
338- { RPL_GLIST, "%s%s%s%s%s %Tu %Tu %Tu %s %s%c :%s", "280" },
339+ { RPL_GLIST, "%s%s%s%s%s %Tu %Tu %Tu %s %s%s%c :%s", "280" },
340 /* 281 */
341 { RPL_ENDOFGLIST, ":End of G-line List", "281" },
342 /* 282 */