]> jfr.im git - irc/quakenet/snircd-patchqueue.git/blob - nickgline
nickgline: include nick! bit in gline loggin
[irc/quakenet/snircd-patchqueue.git] / nickgline
1 # HG changeset patch
2 # Parent c65dae2425be8a5d63d557fb9c55073e1b018e8b
3
4 diff -r c65dae2425be include/gline.h
5 --- a/include/gline.h Sat Jul 20 14:50:22 2013 +0100
6 +++ b/include/gline.h Sat Jul 20 15:06:19 2013 +0100
7 @@ -49,6 +49,7 @@
8 struct Gline {
9 struct Gline *gl_next; /**< Next G-line in linked list. */
10 struct Gline**gl_prev_p; /**< Previous pointer to this G-line. */
11 + char *gl_nick; /**< Nickname mask. */
12 char *gl_user; /**< Username mask (or channel/realname mask). */
13 char *gl_host; /**< Host portion of mask. */
14 char *gl_reason; /**< Reason for G-line. */
15 @@ -110,6 +111,8 @@
16 /** Test whether \a g is local to this server. */
17 #define GlineIsLocal(g) ((g)->gl_flags & GLINE_LOCAL)
18
19 +/** Return nick mask of a G-line. */
20 +#define GlineNick(g) ((g)->gl_nick)
21 /** Return user mask of a G-line. */
22 #define GlineUser(g) ((g)->gl_user)
23 /** Return host mask of a G-line. */
24 @@ -144,5 +147,6 @@
25 extern void gline_stats(struct Client *sptr, const struct StatDesc *sd,
26 char *param);
27 extern int gline_memory_count(size_t *gl_size);
28 +extern struct Gline *IsNickGlined(struct Client *cptr, char *nick);
29
30 #endif /* INCLUDED_gline_h */
31 diff -r c65dae2425be ircd/gline.c
32 --- a/ircd/gline.c Sat Jul 20 14:50:22 2013 +0100
33 +++ b/ircd/gline.c Sat Jul 20 15:06:19 2013 +0100
34 @@ -26,7 +26,6 @@
35 #include "gline.h"
36 #include "channel.h"
37 #include "client.h"
38 -#include "hash.h"
39 #include "ircd.h"
40 #include "ircd_alloc.h"
41 #include "ircd_features.h"
42 @@ -46,6 +45,7 @@
43 #include "msg.h"
44 #include "numnicks.h"
45 #include "numeric.h"
46 +#include "hash.h"
47
48 /* #include <assert.h> -- Now using assert in ircd_log.h */
49 #include <string.h>
50 @@ -104,32 +104,43 @@
51 * Otherwise, assign \a def_user to *user_p and \a userhost to *host_p.
52 *
53 * @param[in] userhost Input string from user.
54 + * @param[out] nick_p Gets pointer to nick part of hostmask.
55 * @param[out] user_p Gets pointer to user (or channel/realname) part of hostmask.
56 * @param[out] host_p Gets point to host part of hostmask (may be assigned NULL).
57 * @param[in] def_user Default value for user part.
58 */
59 static void
60 -canon_userhost(char *userhost, char **user_p, char **host_p, char *def_user)
61 +canon_userhost(char *userhost, char **nick_p, char **user_p, char **host_p, char *def_user)
62 {
63 - char *tmp;
64 + char *tmp, *s;
65
66 if (*userhost == '$') {
67 *user_p = userhost;
68 *host_p = NULL;
69 + *nick_p = NULL;
70 return;
71 }
72
73 - if (!(tmp = strchr(userhost, '@'))) {
74 + if ((tmp = strchr(userhost, '!'))) {
75 + *nick_p = userhost;
76 + *(tmp++) = '\0';
77 + } else {
78 + *nick_p = def_user;
79 + tmp = userhost;
80 + }
81 +
82 + if (!(s = strchr(tmp, '@'))) {
83 *user_p = def_user;
84 - *host_p = userhost;
85 + *host_p = tmp;
86 } else {
87 - *user_p = userhost;
88 - *(tmp++) = '\0';
89 - *host_p = tmp;
90 + *user_p = tmp;
91 + *(s++) = '\0';
92 + *host_p = s;
93 }
94 }
95
96 /** Create a Gline structure.
97 + * @param[in] nick Nick part of mask.
98 * @param[in] user User part of mask.
99 * @param[in] host Host part of mask (NULL if not applicable).
100 * @param[in] reason Reason for G-line.
101 @@ -139,7 +150,7 @@
102 * @return Newly allocated G-line.
103 */
104 static struct Gline *
105 -make_gline(char *user, char *host, char *reason, time_t expire, time_t lastmod,
106 +make_gline(char *nick, char *user, char *host, char *reason, time_t expire, time_t lastmod,
107 time_t lifetime, unsigned int flags)
108 {
109 struct Gline *gline;
110 @@ -166,7 +177,11 @@
111 BadChanGlineList->gl_prev_p = &gline->gl_next;
112 BadChanGlineList = gline;
113 } else {
114 - DupString(gline->gl_user, user); /* remember them... */
115 + if (*user!='$')
116 + DupString(gline->gl_nick, nick); /* remember them... */
117 + else
118 + gline->gl_nick = 0;
119 + DupString(gline->gl_user, user);
120 if (*user != '$')
121 DupString(gline->gl_host, host);
122 else
123 @@ -240,6 +255,10 @@
124 continue;
125 Debug((DEBUG_DEBUG,"Matched!"));
126 } else { /* Host/IP gline */
127 + if (cli_name(acptr) &&
128 + match(gline->gl_nick, cli_name(acptr)) !=0)
129 + continue;
130 +
131 if (cli_user(acptr)->username &&
132 match(gline->gl_user, (cli_user(acptr))->realusername) != 0)
133 continue;
134 @@ -359,8 +378,11 @@
135
136 assert(gline->gl_lastmod);
137
138 - sendcmdto_serv_butone(sptr, CMD_GLINE, cptr, "* %c%s%s%s %Tu %Tu %Tu :%s",
139 - GlineIsRemActive(gline) ? '+' : '-', gline->gl_user,
140 + sendcmdto_serv_butone(sptr, CMD_GLINE, cptr, "* %c%s%s%s%s%s %Tu %Tu %Tu :%s",
141 + GlineIsRemActive(gline) ? '+' : '-',
142 + GlineIsBadChan(gline)|GlineIsRealName(gline) ? "" : gline->gl_nick,
143 + GlineIsBadChan(gline)|GlineIsRealName(gline) ? "" : "!",
144 + gline->gl_user,
145 gline->gl_host ? "@" : "",
146 gline->gl_host ? gline->gl_host : "",
147 gline->gl_expire - TStime(), gline->gl_lastmod,
148 @@ -454,8 +476,8 @@
149 unsigned int flags)
150 {
151 struct Gline *agline;
152 - char uhmask[USERLEN + HOSTLEN + 2];
153 - char *user, *host;
154 + char uhmask[NICKLEN + USERLEN + HOSTLEN + 3];
155 + char *nick, *user, *host;
156 int tmp;
157
158 assert(0 != userhost);
159 @@ -503,7 +525,7 @@
160 return send_reply(sptr, ERR_TOOMANYUSERS, tmp);
161 }
162 } else {
163 - canon_userhost(userhost, &user, &host, "*");
164 + canon_userhost(userhost, &nick, &user, &host, "*");
165 if (sizeof(uhmask) <
166 ircd_snprintf(0, uhmask, sizeof(uhmask), "%s@%s", user, host))
167 return send_reply(sptr, ERR_LONGMASK);
168 @@ -545,29 +567,35 @@
169
170 /* Inform ops... */
171 sendto_opmask_butone(0, ircd_strncmp(reason, "AUTO", 4) ? SNO_GLINE :
172 - SNO_AUTO, "%s adding %s%s %s for %s%s%s, expiring at "
173 + SNO_AUTO, "%s adding %s%s %s for %s%s%s%s%s, expiring at "
174 "%Tu: %s",
175 (feature_bool(FEAT_HIS_SNOTICES) || IsServer(sptr)) ?
176 cli_name(sptr) :
177 cli_name((cli_user(sptr))->server),
178 (flags & GLINE_ACTIVE) ? "" : "deactivated ",
179 (flags & GLINE_LOCAL) ? "local" : "global",
180 - (flags & GLINE_BADCHAN) ? "BADCHAN" : "GLINE", user,
181 + (flags & GLINE_BADCHAN) ? "BADCHAN" : "GLINE",
182 + (flags & (GLINE_BADCHAN|GLINE_REALNAME)) ? "" : nick,
183 + (flags & (GLINE_BADCHAN|GLINE_REALNAME)) ? "" : "!",
184 + user,
185 (flags & (GLINE_BADCHAN|GLINE_REALNAME)) ? "" : "@",
186 (flags & (GLINE_BADCHAN|GLINE_REALNAME)) ? "" : host,
187 expire, reason);
188
189 /* and log it */
190 log_write(LS_GLINE, L_INFO, LOG_NOSNOTICE,
191 - "%#C adding %s %s for %s%s%s, expiring at %Tu: %s", sptr,
192 + "%#C adding %s %s for %s%s%s%s%s, expiring at %Tu: %s", sptr,
193 flags & GLINE_LOCAL ? "local" : "global",
194 - flags & GLINE_BADCHAN ? "BADCHAN" : "GLINE", user,
195 + flags & GLINE_BADCHAN ? "BADCHAN" : "GLINE",
196 + flags & (GLINE_BADCHAN|GLINE_REALNAME) ? "" : nick,
197 + flags & (GLINE_BADCHAN|GLINE_REALNAME) ? "" : "!",
198 + user,
199 flags & (GLINE_BADCHAN|GLINE_REALNAME) ? "" : "@",
200 flags & (GLINE_BADCHAN|GLINE_REALNAME) ? "" : host,
201 expire, reason);
202
203 /* make the gline */
204 - agline = make_gline(user, host, reason, expire, lastmod, lifetime, flags);
205 + agline = make_gline(nick, user, host, reason, expire, lastmod, lifetime, flags);
206
207 /* since we've disabled overlapped G-line checking, agline should
208 * never be NULL...
209 @@ -614,19 +642,24 @@
210 return 0; /* was active to begin with */
211
212 /* Inform ops and log it */
213 - sendto_opmask_butone(0, SNO_GLINE, "%s activating global %s for %s%s%s, "
214 + sendto_opmask_butone(0, SNO_GLINE, "%s activating global %s for %s%s%s%s%s, "
215 "expiring at %Tu: %s",
216 (feature_bool(FEAT_HIS_SNOTICES) || IsServer(sptr)) ?
217 cli_name(sptr) :
218 cli_name((cli_user(sptr))->server),
219 GlineIsBadChan(gline) ? "BADCHAN" : "GLINE",
220 + GlineIsBadChan(gline)|GlineIsRealName(gline) ? "" : gline->gl_nick,
221 + GlineIsBadChan(gline)|GlineIsRealName(gline) ? "" : "!",
222 gline->gl_user, gline->gl_host ? "@" : "",
223 gline->gl_host ? gline->gl_host : "",
224 gline->gl_expire, gline->gl_reason);
225
226 log_write(LS_GLINE, L_INFO, LOG_NOSNOTICE,
227 - "%#C activating global %s for %s%s%s, expiring at %Tu: %s", sptr,
228 - GlineIsBadChan(gline) ? "BADCHAN" : "GLINE", gline->gl_user,
229 + "%#C activating global %s for %s%s%s%s%s, expiring at %Tu: %s", sptr,
230 + GlineIsBadChan(gline) ? "BADCHAN" : "GLINE",
231 + GlineIsBadChan(gline)|GlineIsRealName(gline) ? "" : gline->gl_nick,
232 + GlineIsBadChan(gline)|GlineIsRealName(gline) ? "" : "!",
233 + gline->gl_user,
234 gline->gl_host ? "@" : "",
235 gline->gl_host ? gline->gl_host : "",
236 gline->gl_expire, gline->gl_reason);
237 @@ -682,19 +715,24 @@
238 }
239
240 /* Inform ops and log it */
241 - sendto_opmask_butone(0, SNO_GLINE, "%s %s %s for %s%s%s, expiring at %Tu: "
242 + sendto_opmask_butone(0, SNO_GLINE, "%s %s %s for %s%s%s%s%s, expiring at %Tu: "
243 "%s",
244 (feature_bool(FEAT_HIS_SNOTICES) || IsServer(sptr)) ?
245 cli_name(sptr) :
246 cli_name((cli_user(sptr))->server),
247 msg, GlineIsBadChan(gline) ? "BADCHAN" : "GLINE",
248 + GlineIsBadChan(gline)|GlineIsRealName(gline) ? "" : gline->gl_nick,
249 + GlineIsBadChan(gline)|GlineIsRealName(gline) ? "" : "!",
250 gline->gl_user, gline->gl_host ? "@" : "",
251 gline->gl_host ? gline->gl_host : "",
252 gline->gl_expire, gline->gl_reason);
253
254 log_write(LS_GLINE, L_INFO, LOG_NOSNOTICE,
255 - "%#C %s %s for %s%s%s, expiring at %Tu: %s", sptr, msg,
256 - GlineIsBadChan(gline) ? "BADCHAN" : "GLINE", gline->gl_user,
257 + "%#C %s %s for %s%s%s%s%s, expiring at %Tu: %s", sptr, msg,
258 + GlineIsBadChan(gline) ? "BADCHAN" : "GLINE",
259 + GlineIsBadChan(gline)|GlineIsRealName(gline) ? "" : gline->gl_nick,
260 + GlineIsBadChan(gline)|GlineIsRealName(gline) ? "" : "!",
261 + gline->gl_user,
262 gline->gl_host ? "@" : "",
263 gline->gl_host ? gline->gl_host : "",
264 gline->gl_expire, gline->gl_reason);
265 @@ -732,8 +770,10 @@
266 assert(gline);
267 assert(!GlineIsLocal(gline));
268
269 - Debug((DEBUG_DEBUG, "gline_modify(\"%s\", \"%s\", \"%s%s%s\", %s, \"%s\", "
270 + Debug((DEBUG_DEBUG, "gline_modify(\"%s\", \"%s\", \"%s%s%s%s%s\", %s, \"%s\", "
271 "%Tu, %Tu, %Tu, 0x%04x)", cli_name(cptr), cli_name(sptr),
272 + GlineIsBadChan(gline)|GlineIsRealName(gline) ? "" : gline->gl_nick,
273 + GlineIsBadChan(gline)|GlineIsRealName(gline) ? "" : "!",
274 gline->gl_user, gline->gl_host ? "@" : "",
275 gline->gl_host ? gline->gl_host : "",
276 action == GLINE_ACTIVATE ? "GLINE_ACTIVATE" :
277 @@ -883,17 +923,22 @@
278 /* All right, inform ops... */
279 non_auto = non_auto || ircd_strncmp(gline->gl_reason, "AUTO", 4);
280 sendto_opmask_butone(0, non_auto ? SNO_GLINE : SNO_AUTO,
281 - "%s modifying global %s for %s%s%s:%s",
282 + "%s modifying global %s for %s%s%s%s%s:%s",
283 (feature_bool(FEAT_HIS_SNOTICES) || IsServer(sptr)) ?
284 cli_name(sptr) : cli_name((cli_user(sptr))->server),
285 GlineIsBadChan(gline) ? "BADCHAN" : "GLINE",
286 + GlineIsBadChan(gline)|GlineIsRealName(gline) ? "" : gline->gl_nick,
287 + GlineIsBadChan(gline)|GlineIsRealName(gline) ? "" : "!",
288 gline->gl_user, gline->gl_host ? "@" : "",
289 gline->gl_host ? gline->gl_host : "", buf);
290
291 /* and log the change */
292 log_write(LS_GLINE, L_INFO, LOG_NOSNOTICE,
293 - "%#C modifying global %s for %s%s%s:%s", sptr,
294 - GlineIsBadChan(gline) ? "BADCHAN" : "GLINE", gline->gl_user,
295 + "%#C modifying global %s for %s%s%s%s%s:%s", sptr,
296 + GlineIsBadChan(gline) ? "BADCHAN" : "GLINE",
297 + GlineIsBadChan(gline)|GlineIsRealName(gline) ? "" : gline->gl_nick,
298 + GlineIsBadChan(gline)|GlineIsRealName(gline) ? "" : "!",
299 + gline->gl_user,
300 gline->gl_host ? "@" : "", gline->gl_host ? gline->gl_host : "",
301 buf);
302
303 @@ -902,8 +947,10 @@
304 */
305 if (action != GLINE_LOCAL_ACTIVATE && action != GLINE_LOCAL_DEACTIVATE)
306 sendcmdto_serv_butone(sptr, CMD_GLINE, cptr,
307 - "* %s%s%s%s%s %Tu %Tu %Tu :%s",
308 + "* %s%s%s%s%s%s%s %Tu %Tu %Tu :%s",
309 flags & GLINE_OPERFORCE ? "!" : "", op,
310 + GlineIsBadChan(gline)|GlineIsRealName(gline) ? "" : gline->gl_nick,
311 + GlineIsBadChan(gline)|GlineIsRealName(gline) ? "" : "!",
312 gline->gl_user, gline->gl_host ? "@" : "",
313 gline->gl_host ? gline->gl_host : "",
314 gline->gl_expire - TStime(), gline->gl_lastmod,
315 @@ -926,15 +973,20 @@
316 assert(GlineIsLocal(gline));
317
318 /* Inform ops and log it */
319 - sendto_opmask_butone(0, SNO_GLINE, "%s removing local %s for %s%s%s",
320 + sendto_opmask_butone(0, SNO_GLINE, "%s removing local %s for %s%s%s%s%s",
321 (feature_bool(FEAT_HIS_SNOTICES) || IsServer(sptr)) ?
322 cli_name(sptr) : cli_name((cli_user(sptr))->server),
323 GlineIsBadChan(gline) ? "BADCHAN" : "GLINE",
324 + GlineIsBadChan(gline)|GlineIsRealName(gline) ? "" : gline->gl_nick,
325 + GlineIsBadChan(gline)|GlineIsRealName(gline) ? "" : "!",
326 gline->gl_user, gline->gl_host ? "@" : "",
327 gline->gl_host ? gline->gl_host : "");
328 log_write(LS_GLINE, L_INFO, LOG_NOSNOTICE,
329 - "%#C removing local %s for %s%s%s", sptr,
330 - GlineIsBadChan(gline) ? "BADCHAN" : "GLINE", gline->gl_user,
331 + "%#C removing local %s for %s%s%s%s%s", sptr,
332 + GlineIsBadChan(gline) ? "BADCHAN" : "GLINE",
333 + GlineIsBadChan(gline)|GlineIsRealName(gline) ? "" : gline->gl_nick,
334 + GlineIsBadChan(gline)|GlineIsRealName(gline) ? "" : "!",
335 + gline->gl_user,
336 gline->gl_host ? "@" : "", gline->gl_host ? gline->gl_host : "");
337
338 gline_free(gline); /* get rid of the G-line */
339 @@ -962,7 +1014,7 @@
340 {
341 struct Gline *gline = 0;
342 struct Gline *sgline;
343 - char *user, *host, *t_uh;
344 + char *nick, *user, *host, *t_uh;
345
346 if (flags & (GLINE_BADCHAN | GLINE_ANY)) {
347 gliter(BadChanGlineList, gline, sgline) {
348 @@ -980,7 +1032,7 @@
349 return 0;
350
351 DupString(t_uh, userhost);
352 - canon_userhost(t_uh, &user, &host, "*");
353 + canon_userhost(t_uh, &nick, &user, &host, "*");
354
355 gliter(GlobalGlineList, gline, sgline) {
356 if ((flags & (GlineIsLocal(gline) ? GLINE_GLOBAL : GLINE_LOCAL)) ||
357 @@ -989,12 +1041,18 @@
358 else if (flags & GLINE_EXACT) {
359 if (((gline->gl_host && host && ircd_strcmp(gline->gl_host, host) == 0)
360 || (!gline->gl_host && !host)) &&
361 - (ircd_strcmp(gline->gl_user, user) == 0))
362 + ((!user && ircd_strcmp(gline->gl_user, "*") == 0) ||
363 + (user && ircd_strcmp(gline->gl_user, user) == 0)) &&
364 + ((!nick && gline->gl_nick && ircd_strcmp(gline->gl_nick, "*") == 0) ||
365 + (nick && gline->gl_nick && ircd_strcmp(gline->gl_nick, nick) == 0) || (!gline->gl_nick && !nick)))
366 break;
367 } else {
368 if (((gline->gl_host && host && match(gline->gl_host, host) == 0)
369 || (!gline->gl_host && !host)) &&
370 - (match(gline->gl_user, user) == 0))
371 + ((!user && ircd_strcmp(gline->gl_user, "*") == 0) ||
372 + (user && match(gline->gl_user, user) == 0)) &&
373 + ((!nick && gline->gl_nick && ircd_strcmp(gline->gl_nick, "*") == 0) ||
374 + (nick && gline->gl_nick && (match(gline->gl_nick, nick) == 0)) || (!gline->gl_nick && !nick)))
375 break;
376 }
377 }
378 @@ -1050,7 +1108,9 @@
379 continue;
380 }
381 else {
382 - if (match(gline->gl_user, (cli_user(cptr))->username) != 0)
383 + if (match(gline->gl_nick, cli_name(cptr)) != 0)
384 + continue;
385 + if (match(gline->gl_user, (cli_user(cptr))->realusername) != 0)
386 continue;
387
388 if (GlineIsIpMask(gline)) {
389 @@ -1101,8 +1161,11 @@
390
391 gliter(GlobalGlineList, gline, sgline) {
392 if (!GlineIsLocal(gline) && gline->gl_lastmod)
393 - sendcmdto_one(&me, CMD_GLINE, cptr, "* %c%s%s%s %Tu %Tu %Tu :%s",
394 - GlineIsRemActive(gline) ? '+' : '-', gline->gl_user,
395 + sendcmdto_one(&me, CMD_GLINE, cptr, "* %c%s%s%s%s%s %Tu %Tu %Tu :%s",
396 + GlineIsRemActive(gline) ? '+' : '-',
397 + gline->gl_nick ? gline->gl_nick : "",
398 + gline->gl_nick ? "!" : "",
399 + gline->gl_user,
400 gline->gl_host ? "@" : "",
401 gline->gl_host ? gline->gl_host : "",
402 gline->gl_expire - TStime(), gline->gl_lastmod,
403 @@ -1129,8 +1192,11 @@
404 if (GlineIsLocal(gline) || !gline->gl_lastmod)
405 return 0;
406
407 - sendcmdto_one(&me, CMD_GLINE, cptr, "* %c%s%s%s %Tu %Tu %Tu :%s",
408 - GlineIsRemActive(gline) ? '+' : '-', gline->gl_user,
409 + sendcmdto_one(&me, CMD_GLINE, cptr, "* %c%s%s%s%s%s %Tu %Tu %Tu :%s",
410 + GlineIsRemActive(gline) ? '+' : '-',
411 + GlineIsBadChan(gline)|GlineIsRealName(gline) ? "" : gline->gl_nick,
412 + GlineIsBadChan(gline)|GlineIsRealName(gline) ? "" : "!",
413 + gline->gl_user,
414 gline->gl_host ? "@" : "",
415 gline->gl_host ? gline->gl_host : "",
416 gline->gl_expire - TStime(), gline->gl_lastmod,
417 @@ -1157,8 +1223,10 @@
418 return send_reply(sptr, ERR_NOSUCHGLINE, userhost);
419
420 /* send gline information along */
421 - send_reply(sptr, RPL_GLIST, gline->gl_user,
422 - gline->gl_host ? "@" : "",
423 + send_reply(sptr, RPL_GLIST,
424 + GlineIsBadChan(gline) | GlineIsRealName(gline) ? "" : gline->gl_nick,
425 + GlineIsBadChan(gline) | GlineIsRealName(gline) ? "" : "!",
426 + gline->gl_user, GlineIsBadChan(gline) || GlineIsRealName(gline) ? "" : "@",
427 gline->gl_host ? gline->gl_host : "",
428 gline->gl_expire, gline->gl_lastmod,
429 gline->gl_lifetime,
430 @@ -1168,7 +1236,10 @@
431 GlineIsRemActive(gline) ? '+' : '-', gline->gl_reason);
432 } else {
433 gliter(GlobalGlineList, gline, sgline) {
434 - send_reply(sptr, RPL_GLIST, gline->gl_user,
435 + send_reply(sptr, RPL_GLIST,
436 + gline->gl_nick ? gline->gl_nick : "",
437 + gline->gl_nick ? "!" : "",
438 + gline->gl_user,
439 gline->gl_host ? "@" : "",
440 gline->gl_host ? gline->gl_host : "",
441 gline->gl_expire, gline->gl_lastmod,
442 @@ -1180,7 +1251,7 @@
443 }
444
445 gliter(BadChanGlineList, gline, sgline) {
446 - send_reply(sptr, RPL_GLIST, gline->gl_user, "", "",
447 + send_reply(sptr, RPL_GLIST, gline->gl_user, "", "", "", "",
448 gline->gl_expire, gline->gl_lastmod,
449 gline->gl_lifetime,
450 GlineIsLocal(gline) ? cli_name(&me) : "*",
451 @@ -1207,7 +1278,10 @@
452 struct Gline *sgline;
453
454 gliter(GlobalGlineList, gline, sgline) {
455 - send_reply(sptr, RPL_STATSGLINE, 'G', gline->gl_user,
456 + send_reply(sptr, RPL_STATSGLINE, 'G',
457 + gline->gl_nick ? gline->gl_nick : "",
458 + gline->gl_nick ? "!" : "",
459 + gline->gl_user,
460 gline->gl_host ? "@" : "",
461 gline->gl_host ? gline->gl_host : "",
462 gline->gl_expire, gline->gl_lastmod,
463 @@ -1242,6 +1316,7 @@
464 for (gline = GlobalGlineList; gline; gline = gline->gl_next) {
465 gl++;
466 *gl_size += sizeof(struct Gline);
467 + *gl_size += gline->gl_nick ? (strlen(gline->gl_nick) +1) : 0;
468 *gl_size += gline->gl_user ? (strlen(gline->gl_user) + 1) : 0;
469 *gl_size += gline->gl_host ? (strlen(gline->gl_host) + 1) : 0;
470 *gl_size += gline->gl_reason ? (strlen(gline->gl_reason) + 1) : 0;
471 @@ -1257,3 +1332,46 @@
472
473 return gl;
474 }
475 +
476 +struct Gline *
477 +IsNickGlined(struct Client *cptr, char *nick)
478 +{
479 + struct Gline *gline;
480 + struct Gline *sgline;
481 +
482 + for (gline = GlobalGlineList; gline; gline = sgline) {
483 + sgline = gline->gl_next;
484 +
485 + if (gline->gl_expire <= CurrentTime) {
486 + gline_free(gline);
487 + continue;
488 + }
489 +
490 + if (GlineIsRealName(gline)) /* skip realname glines */
491 + continue;
492 +
493 + if (!ircd_strcmp(gline->gl_nick, "*")) /* skip glines w. wildcarded nick */
494 + continue;
495 +
496 + if (match(gline->gl_nick, nick) != 0)
497 + continue;
498 +
499 + if (match(gline->gl_user, (cli_user(cptr))->username) != 0)
500 + continue;
501 +
502 + if (GlineIsIpMask(gline)) {
503 + if (!ipmask_check(&(cli_ip(cptr)), &gline->gl_addr, gline->gl_bits))
504 + continue;
505 + }
506 + else {
507 + if (match(gline->gl_host, (cli_user(cptr))->realhost) != 0)
508 + continue;
509 + }
510 + return gline;
511 + }
512 + /*
513 + * No Glines matched
514 + */
515 + return 0;
516 +}
517 +
518 diff -r c65dae2425be ircd/m_nick.c
519 --- a/ircd/m_nick.c Sat Jul 20 14:50:22 2013 +0100
520 +++ b/ircd/m_nick.c Sat Jul 20 15:06:19 2013 +0100
521 @@ -98,6 +98,7 @@
522 #include "s_user.h"
523 #include "send.h"
524 #include "sys.h"
525 +#include "gline.h"
526
527 /* #include <assert.h> -- Now using assert in ircd_log.h */
528 #include <stdlib.h>
529 @@ -179,6 +180,11 @@
530 return 0;
531 }
532
533 + if (IsRegistered(sptr) && !IsAnOper(sptr) && IsNickGlined(sptr, nick)) {
534 + send_reply(sptr, ERR_ERRONEUSNICKNAME, nick);
535 + return 0;
536 + }
537 +
538 /*
539 * Check if this is a LOCAL user trying to use a reserved (Juped)
540 * nick, if so tell him that it's a nick in use...
541 diff -r c65dae2425be ircd/s_err.c
542 --- a/ircd/s_err.c Sat Jul 20 14:50:22 2013 +0100
543 +++ b/ircd/s_err.c Sat Jul 20 15:06:19 2013 +0100
544 @@ -526,7 +526,7 @@
545 /* 246 */
546 { RPL_STATSTLINE, "%c %s %s", "246" },
547 /* 247 */
548 - { RPL_STATSGLINE, "%c %s%s%s %Tu %Tu %Tu %s%c :%s", "247" },
549 + { RPL_STATSGLINE, "%c %s%s%s%s%s %Tu %Tu %Tu %s%c :%s", "247" },
550 /* 248 */
551 { RPL_STATSULINE, "U %s", "248" },
552 /* 249 */
553 @@ -592,7 +592,7 @@
554 /* 279 */
555 { 0 },
556 /* 280 */
557 - { RPL_GLIST, "%s%s%s %Tu %Tu %Tu %s %s%c :%s", "280" },
558 + { RPL_GLIST, "%s%s%s%s%s %Tu %Tu %Tu %s %s%c :%s", "280" },
559 /* 281 */
560 { RPL_ENDOFGLIST, ":End of G-line List", "281" },
561 /* 282 */