]> jfr.im git - solanum.git/blob - ircd/hostmask.c
Add description parameter to auth blocks (#327)
[solanum.git] / ircd / hostmask.c
1 /*
2 * Solanum: a slightly advanced ircd
3 * hostmask.c: Code to efficiently find IP & hostmask based configs.
4 *
5 * Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center
6 * Copyright (C) 1996-2002 Hybrid Development Team
7 * Copyright (C) 2002-2005 ircd-ratbox development team
8 * Copyright (C) 2005-2008 charybdis development team
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
23 * USA
24 */
25
26 #include "stdinc.h"
27 #include "ircd_defs.h"
28 #include "s_conf.h"
29 #include "s_newconf.h"
30 #include "hostmask.h"
31 #include "numeric.h"
32 #include "send.h"
33 #include "match.h"
34
35 static unsigned long hash_ipv6(struct sockaddr *, int);
36 static unsigned long hash_ipv4(struct sockaddr *, int);
37
38
39 static int
40 _parse_netmask(const char *text, struct rb_sockaddr_storage *naddr, int *nb, bool strict)
41 {
42 char *ip = LOCAL_COPY(text);
43 char *ptr;
44 char *endp;
45 struct rb_sockaddr_storage *addr, xaddr;
46 int *b, xb;
47 if(nb == NULL)
48 b = &xb;
49 else
50 b = nb;
51
52 if(naddr == NULL)
53 addr = &xaddr;
54 else
55 addr = naddr;
56
57 if(strpbrk(ip, "*?") != NULL)
58 {
59 return HM_HOST;
60 }
61 if(strchr(ip, ':'))
62 {
63 if((ptr = strchr(ip, '/')))
64 {
65 *ptr = '\0';
66 ptr++;
67 long n = strtol(ptr, &endp, 10);
68 if (endp == ptr || n < 0)
69 return HM_HOST;
70 if (n > 128 || *endp != '\0')
71 {
72 if (strict)
73 return HM_ERROR;
74 else
75 n = 128;
76 }
77 *b = n;
78 } else
79 *b = 128;
80 if(rb_inet_pton_sock(ip, addr) > 0)
81 return HM_IPV6;
82 else
83 return HM_HOST;
84 } else
85 if(strchr(text, '.'))
86 {
87 if((ptr = strchr(ip, '/')))
88 {
89 *ptr = '\0';
90 ptr++;
91 long n = strtol(ptr, &endp, 10);
92 if (endp == ptr || n < 0)
93 return HM_HOST;
94 if (n > 32 || *endp != '\0')
95 {
96 if (strict)
97 return HM_ERROR;
98 else
99 n = 32;
100 }
101 *b = n;
102 } else
103 *b = 32;
104 if(rb_inet_pton_sock(ip, addr) > 0)
105 return HM_IPV4;
106 else
107 return HM_HOST;
108 }
109 return HM_HOST;
110 }
111
112 /* int parse_netmask(const char *, struct rb_sockaddr_storage *, int *);
113 * Input: A hostmask, or an IPV4/6 address.
114 * Output: An integer describing whether it is an IPV4, IPV6 address or a
115 * hostmask, an address(if it is an IP mask),
116 * a bitlength(if it is IP mask).
117 * Side effects: None
118 */
119 int parse_netmask(const char *mask, struct rb_sockaddr_storage *addr, int *blen)
120 {
121 return _parse_netmask(mask, addr, blen, false);
122 }
123
124 int parse_netmask_strict(const char *mask, struct rb_sockaddr_storage *addr, int *blen)
125 {
126 return _parse_netmask(mask, addr, blen, true);
127 }
128
129 /* Hashtable stuff...now external as its used in m_stats.c */
130 struct AddressRec *atable[ATABLE_SIZE];
131
132 void
133 init_host_hash(void)
134 {
135 memset(&atable, 0, sizeof(atable));
136 }
137
138 /* unsigned long hash_ipv4(struct rb_sockaddr_storage*)
139 * Input: An IP address.
140 * Output: A hash value of the IP address.
141 * Side effects: None
142 */
143 static unsigned long
144 hash_ipv4(struct sockaddr *saddr, int bits)
145 {
146 struct sockaddr_in *addr = (struct sockaddr_in *)(void *)saddr;
147
148 if(bits != 0)
149 {
150 unsigned long av = ntohl(addr->sin_addr.s_addr) & ~((1 << (32 - bits)) - 1);
151 return (av ^ (av >> 12) ^ (av >> 24)) & (ATABLE_SIZE - 1);
152 }
153
154 return 0;
155 }
156
157 /* unsigned long hash_ipv6(struct rb_sockaddr_storage*)
158 * Input: An IP address.
159 * Output: A hash value of the IP address.
160 * Side effects: None
161 */
162 static unsigned long
163 hash_ipv6(struct sockaddr *saddr, int bits)
164 {
165 struct sockaddr_in6 *addr = (struct sockaddr_in6 *)(void *)saddr;
166 unsigned long v = 0, n;
167 for (n = 0; n < 16; n++)
168 {
169 if(bits >= 8)
170 {
171 v ^= addr->sin6_addr.s6_addr[n];
172 bits -= 8;
173 }
174 else if(bits)
175 {
176 v ^= addr->sin6_addr.s6_addr[n] & ~((1 << (8 - bits)) - 1);
177 return v & (ATABLE_SIZE - 1);
178 }
179 else
180 return v & (ATABLE_SIZE - 1);
181 }
182 return v & (ATABLE_SIZE - 1);
183 }
184
185 /* int hash_text(const char *start)
186 * Input: The start of the text to hash.
187 * Output: The hash of the string between 1 and (TH_MAX-1)
188 * Side-effects: None.
189 */
190 static int
191 hash_text(const char *start)
192 {
193 const char *p = start;
194 unsigned long h = 0;
195
196 while(*p)
197 {
198 h = (h << 4) - (h + (unsigned char) irctolower(*p++));
199 }
200
201 return (h & (ATABLE_SIZE - 1));
202 }
203
204 /* unsigned long get_hash_mask(const char *)
205 * Input: The text to hash.
206 * Output: The hash of the string right of the first '.' past the last
207 * wildcard in the string.
208 * Side-effects: None.
209 */
210 static unsigned long
211 get_mask_hash(const char *text)
212 {
213 const char *hp = "", *p;
214
215 for (p = text + strlen(text) - 1; p >= text; p--)
216 if(*p == '*' || *p == '?')
217 return hash_text(hp);
218 else if(*p == '.')
219 hp = p + 1;
220 return hash_text(text);
221 }
222
223 /* struct ConfItem* find_conf_by_address(const char*, struct rb_sockaddr_storage*,
224 * int type, int fam, const char *username)
225 *
226 * This process needs to be kept in sync with check_one_kline().
227 *
228 * Input: The hostname, the address, the type of mask to find, the address
229 * family, the username.
230 * Output: The matching value with the highest precedence.
231 * Side-effects: None
232 * Note: Setting bit 0 of the type means that the username is ignored.
233 */
234 struct ConfItem *
235 find_conf_by_address(const char *name, const char *sockhost,
236 const char *orighost,
237 struct sockaddr *addr, int type, int fam,
238 const char *username, const char *auth_user)
239 {
240 unsigned long hprecv = 0;
241 struct ConfItem *hprec = NULL;
242 struct AddressRec *arec;
243 struct sockaddr_in ip4;
244 struct sockaddr *pip4 = NULL;
245 int b;
246
247 if(username == NULL)
248 username = "";
249
250 if(addr)
251 {
252 if (fam == AF_INET)
253 pip4 = addr;
254
255 if (fam == AF_INET6)
256 {
257 if (type == CONF_KILL && rb_ipv4_from_ipv6((struct sockaddr_in6 *)addr, &ip4))
258 pip4 = (struct sockaddr *)&ip4;
259
260 for (b = 128; b >= 0; b -= 16)
261 {
262 for (arec = atable[hash_ipv6(addr, b)]; arec; arec = arec->next)
263 if(arec->type == (type & ~0x1) &&
264 arec->masktype == HM_IPV6 &&
265 comp_with_mask_sock(addr, (struct sockaddr *)&arec->Mask.ipa.addr,
266 arec->Mask.ipa.bits) &&
267 (type & 0x1 || match(arec-> username, username)) &&
268 (type != CONF_CLIENT || !arec->auth_user ||
269 (auth_user && match(arec->auth_user, auth_user))) &&
270 arec->precedence > hprecv)
271 {
272 hprecv = arec->precedence;
273 hprec = arec->aconf;
274 }
275 }
276 }
277
278 if (pip4 != NULL)
279 {
280 for (b = 32; b >= 0; b -= 8)
281 {
282 for (arec = atable[hash_ipv4(pip4, b)]; arec; arec = arec->next)
283 if(arec->type == (type & ~0x1) &&
284 arec->masktype == HM_IPV4 &&
285 comp_with_mask_sock(pip4, (struct sockaddr *)&arec->Mask.ipa.addr,
286 arec->Mask.ipa.bits) &&
287 (type & 0x1 || match(arec->username, username)) &&
288 (type != CONF_CLIENT || !arec->auth_user ||
289 (auth_user && match(arec->auth_user, auth_user))) &&
290 arec->precedence > hprecv)
291 {
292 hprecv = arec->precedence;
293 hprec = arec->aconf;
294 }
295 }
296 }
297 }
298
299 if(orighost != NULL)
300 {
301 const char *p;
302
303 for (p = orighost; p != NULL;)
304 {
305 for (arec = atable[hash_text(p)]; arec; arec = arec->next)
306
307 if((arec->type == (type & ~0x1)) &&
308 (arec->masktype == HM_HOST) &&
309 arec->precedence > hprecv &&
310 match(arec->Mask.hostname, orighost) &&
311 (type != CONF_CLIENT || !arec->auth_user ||
312 (auth_user && match(arec->auth_user, auth_user))) &&
313 (type & 0x1 || match(arec->username, username)))
314 {
315 hprecv = arec->precedence;
316 hprec = arec->aconf;
317 }
318 p = strchr(p, '.');
319 if(p != NULL)
320 p++;
321 else
322 break;
323 }
324 for (arec = atable[0]; arec; arec = arec->next)
325 {
326 if(arec->type == (type & ~0x1) &&
327 arec->masktype == HM_HOST &&
328 arec->precedence > hprecv &&
329 (match(arec->Mask.hostname, orighost) ||
330 (sockhost && match(arec->Mask.hostname, sockhost))) &&
331 (type != CONF_CLIENT || !arec->auth_user ||
332 (auth_user && match(arec->auth_user, auth_user))) &&
333 (type & 0x1 || match(arec->username, username)))
334 {
335 hprecv = arec->precedence;
336 hprec = arec->aconf;
337 }
338 }
339 }
340
341 if(name != NULL)
342 {
343 const char *p;
344 /* And yes - we have to check p after strchr and p after increment for
345 * NULL -kre */
346 for (p = name; p != NULL;)
347 {
348 for (arec = atable[hash_text(p)]; arec; arec = arec->next)
349 if((arec->type == (type & ~0x1)) &&
350 (arec->masktype == HM_HOST) &&
351 arec->precedence > hprecv &&
352 match(arec->Mask.hostname, name) &&
353 (type != CONF_CLIENT || !arec->auth_user ||
354 (auth_user && match(arec->auth_user, auth_user))) &&
355 (type & 0x1 || match(arec->username, username)))
356 {
357 hprecv = arec->precedence;
358 hprec = arec->aconf;
359 }
360 p = strchr(p, '.');
361 if(p != NULL)
362 p++;
363 else
364 break;
365 }
366 for (arec = atable[0]; arec; arec = arec->next)
367 {
368 if(arec->type == (type & ~0x1) &&
369 arec->masktype == HM_HOST &&
370 arec->precedence > hprecv &&
371 (match(arec->Mask.hostname, name) ||
372 (sockhost && match(arec->Mask.hostname, sockhost))) &&
373 (type != CONF_CLIENT || !arec->auth_user ||
374 (auth_user && match(arec->auth_user, auth_user))) &&
375 (type & 0x1 || match(arec->username, username)))
376 {
377 hprecv = arec->precedence;
378 hprec = arec->aconf;
379 }
380 }
381 }
382 return hprec;
383 }
384
385 /* struct ConfItem* find_address_conf(const char*, const char*,
386 * struct rb_sockaddr_storage*, int);
387 * Input: The hostname, username, address, address family.
388 * Output: The applicable ConfItem.
389 * Side-effects: None
390 */
391 struct ConfItem *
392 find_address_conf(const char *host, const char *sockhost, const char *user,
393 const char *notildeuser, struct sockaddr *ip, int aftype, char *auth_user)
394 {
395 struct ConfItem *iconf, *kconf;
396 const char *vuser;
397
398 /* Find the best I-line... If none, return NULL -A1kmm */
399 if(!(iconf = find_conf_by_address(host, sockhost, NULL, ip, CONF_CLIENT, aftype, user, auth_user)))
400 return NULL;
401 /* Find what their visible username will be.
402 * Note that the username without tilde may contain one char more.
403 * -- jilles */
404 vuser = IsNoTilde(iconf) ? notildeuser : user;
405
406 /* If they are exempt from K-lines, return the best I-line. -A1kmm */
407 if(IsConfExemptKline(iconf))
408 return iconf;
409
410 /* if theres a spoof, check it against klines.. */
411 if(IsConfDoSpoofIp(iconf))
412 {
413 char *p = strchr(iconf->info.name, '@');
414
415 /* note, we dont need to pass sockhost here, as its
416 * guaranteed to not match by whats below.. --anfl
417 */
418 if(p)
419 {
420 *p = '\0';
421 kconf = find_conf_by_address(p+1, NULL, NULL, NULL, CONF_KILL, aftype, iconf->info.name, NULL);
422 *p = '@';
423 }
424 else
425 kconf = find_conf_by_address(iconf->info.name, NULL, NULL, NULL, CONF_KILL, aftype, vuser, NULL);
426
427 if(kconf)
428 return kconf;
429
430 /* everything else checks real hosts, if they're kline_spoof_ip we're done */
431 if(IsConfKlineSpoof(iconf))
432 return iconf;
433 }
434
435 /* Find the best K-line... -A1kmm */
436 kconf = find_conf_by_address(host, sockhost, NULL, ip, CONF_KILL, aftype, user, NULL);
437
438 /* If they are K-lined, return the K-line */
439 if(kconf)
440 return kconf;
441
442 /* if no_tilde, check the username without tilde against klines too
443 * -- jilles */
444 if(user != vuser)
445 {
446 kconf = find_conf_by_address(host, sockhost, NULL, ip, CONF_KILL, aftype, vuser, NULL);
447 if(kconf)
448 return kconf;
449 }
450
451 return iconf;
452 }
453
454 /* struct ConfItem* find_dline(struct rb_sockaddr_storage*, int)
455 * Input: An address, an address family.
456 * Output: The best matching D-line or exempt line.
457 * Side effects: None.
458 */
459 struct ConfItem *
460 find_dline(struct sockaddr *addr, int aftype)
461 {
462 struct ConfItem *aconf;
463 struct sockaddr_in addr2;
464
465 aconf = find_conf_by_address(NULL, NULL, NULL, addr, CONF_EXEMPTDLINE | 1, aftype, NULL, NULL);
466 if(aconf)
467 return aconf;
468 aconf = find_conf_by_address(NULL, NULL, NULL, addr, CONF_DLINE | 1, aftype, NULL, NULL);
469 if(aconf)
470 return aconf;
471 if(addr->sa_family == AF_INET6 &&
472 rb_ipv4_from_ipv6((const struct sockaddr_in6 *)(const void *)addr, &addr2))
473 {
474 aconf = find_conf_by_address(NULL, NULL, NULL, (struct sockaddr *)&addr2, CONF_DLINE | 1, AF_INET, NULL, NULL);
475 if(aconf)
476 return aconf;
477 }
478 return NULL;
479 }
480
481 struct ConfItem *
482 find_exact_conf_by_address_filtered(const char *address, int type, const char *username, bool (*filter)(struct ConfItem *))
483 {
484 int masktype, bits;
485 unsigned long hv;
486 struct AddressRec *arec;
487 struct rb_sockaddr_storage addr;
488
489 if(address == NULL)
490 address = "/NOMATCH!/";
491 masktype = parse_netmask(address, &addr, &bits);
492 if(masktype == HM_IPV6)
493 {
494 /* We have to do this, since we do not re-hash for every bit -A1kmm. */
495 hv = hash_ipv6((struct sockaddr *)&addr, bits - bits % 16);
496 }
497 else if(masktype == HM_IPV4)
498 {
499 /* We have to do this, since we do not re-hash for every bit -A1kmm. */
500 hv = hash_ipv4((struct sockaddr *)&addr, bits - bits % 8);
501 }
502 else
503 {
504 hv = get_mask_hash(address);
505 }
506 for (arec = atable[hv]; arec; arec = arec->next)
507 {
508 if (arec->type == type &&
509 arec->masktype == masktype &&
510 (arec->username == NULL || username == NULL ? arec->username == username : !irccmp(arec->username, username)))
511 {
512 if (filter && !filter(arec->aconf))
513 continue;
514
515 if (masktype == HM_HOST)
516 {
517 if (!irccmp(arec->Mask.hostname, address))
518 return arec->aconf;
519 }
520 else
521 {
522 if (arec->Mask.ipa.bits == bits &&
523 comp_with_mask_sock((struct sockaddr *)&arec->Mask.ipa.addr, (struct sockaddr *)&addr, bits))
524 return arec->aconf;
525 }
526 }
527 }
528 return NULL;
529 }
530
531 /* void find_exact_conf_by_address(const char*, int, const char *)
532 * Input:
533 * Output: ConfItem if found
534 * Side-effects: None
535 */
536 struct ConfItem *
537 find_exact_conf_by_address(const char *address, int type, const char *username)
538 {
539 return find_exact_conf_by_address_filtered(address, type, username, NULL);
540 }
541
542 /* void add_conf_by_address(const char*, int, const char *,
543 * struct ConfItem *aconf)
544 * Input:
545 * Output: None
546 * Side-effects: Adds this entry to the hash table.
547 */
548 void
549 add_conf_by_address(const char *address, int type, const char *username, const char *auth_user, struct ConfItem *aconf)
550 {
551 static unsigned long prec_value = 0xFFFFFFFF;
552 int bits;
553 unsigned long hv;
554 struct AddressRec *arec;
555
556 if(address == NULL)
557 address = "/NOMATCH!/";
558 arec = rb_malloc(sizeof(struct AddressRec));
559 arec->masktype = parse_netmask(address, &arec->Mask.ipa.addr, &bits);
560 if(arec->masktype == HM_IPV6)
561 {
562 arec->Mask.ipa.bits = bits;
563 /* We have to do this, since we do not re-hash for every bit -A1kmm. */
564 bits -= bits % 16;
565 arec->next = atable[(hv = hash_ipv6((struct sockaddr *)&arec->Mask.ipa.addr, bits))];
566 atable[hv] = arec;
567 }
568 else if(arec->masktype == HM_IPV4)
569 {
570 arec->Mask.ipa.bits = bits;
571 /* We have to do this, since we do not re-hash for every bit -A1kmm. */
572 bits -= bits % 8;
573 arec->next = atable[(hv = hash_ipv4((struct sockaddr *)&arec->Mask.ipa.addr, bits))];
574 atable[hv] = arec;
575 }
576 else
577 {
578 arec->Mask.hostname = address;
579 arec->next = atable[(hv = get_mask_hash(address))];
580 atable[hv] = arec;
581 }
582 arec->username = username;
583 arec->auth_user = auth_user;
584 arec->aconf = aconf;
585 arec->precedence = prec_value--;
586 arec->type = type;
587 }
588
589 /* void delete_one_address(const char*, struct ConfItem*)
590 * Input: An address string, the associated ConfItem.
591 * Output: None
592 * Side effects: Deletes an address record. Frees the ConfItem if there
593 * is nothing referencing it, sets it as illegal otherwise.
594 */
595 void
596 delete_one_address_conf(const char *address, struct ConfItem *aconf)
597 {
598 int masktype, bits;
599 unsigned long hv;
600 struct AddressRec *arec, *arecl = NULL;
601 struct rb_sockaddr_storage addr;
602 masktype = parse_netmask(address, &addr, &bits);
603 if(masktype == HM_IPV6)
604 {
605 /* We have to do this, since we do not re-hash for every bit -A1kmm. */
606 bits -= bits % 16;
607 hv = hash_ipv6((struct sockaddr *)&addr, bits);
608 }
609 else if(masktype == HM_IPV4)
610 {
611 /* We have to do this, since we do not re-hash for every bit -A1kmm. */
612 bits -= bits % 8;
613 hv = hash_ipv4((struct sockaddr *)&addr, bits);
614 }
615 else
616 hv = get_mask_hash(address);
617 for (arec = atable[hv]; arec; arec = arec->next)
618 {
619 if(arec->aconf == aconf)
620 {
621 if(arecl)
622 arecl->next = arec->next;
623 else
624 atable[hv] = arec->next;
625 aconf->status |= CONF_ILLEGAL;
626 if(!aconf->clients)
627 free_conf(aconf);
628 rb_free(arec);
629 return;
630 }
631 arecl = arec;
632 }
633 }
634
635 /* void clear_out_address_conf(void)
636 * Input: None
637 * Output: None
638 * Side effects: Clears out all address records in the hash table,
639 * frees them, and frees the ConfItems if nothing references
640 * them, otherwise sets them as illegal.
641 */
642 void
643 clear_out_address_conf(enum aconf_category clear_type)
644 {
645 int i;
646 struct AddressRec **store_next;
647 struct AddressRec *arec, *arecn;
648
649 for (i = 0; i < ATABLE_SIZE; i++)
650 {
651 store_next = &atable[i];
652 for (arec = atable[i]; arec; arec = arecn)
653 {
654 enum aconf_category cur_type;
655 arecn = arec->next;
656
657 if (arec->type == CONF_CLIENT || arec->type == CONF_EXEMPTDLINE || arec->type == CONF_SECURE)
658 cur_type = AC_CONFIG;
659 else
660 cur_type = AC_BANDB;
661
662 /* We keep the temporary K-lines and destroy the
663 * permanent ones, just to be confusing :) -A1kmm */
664 if (arec->aconf->flags & CONF_FLAGS_TEMPORARY || cur_type != clear_type)
665 {
666 *store_next = arec;
667 store_next = &arec->next;
668 }
669 else
670 {
671 arec->aconf->status |= CONF_ILLEGAL;
672 if(!arec->aconf->clients)
673 free_conf(arec->aconf);
674 rb_free(arec);
675 }
676 }
677 *store_next = NULL;
678 }
679 }
680
681 /*
682 * show_iline_prefix()
683 *
684 * inputs - pointer to struct Client requesting output
685 * - pointer to struct ConfItem
686 * - name to which iline prefix will be prefixed to
687 * output - pointer to static string with prefixes listed in ascii form
688 * side effects - NONE
689 */
690 char *
691 show_iline_prefix(struct Client *sptr, struct ConfItem *aconf, char *name)
692 {
693 static char prefix_of_host[USERLEN + 15];
694 char *prefix_ptr;
695
696 prefix_ptr = prefix_of_host;
697 if(IsNoTilde(aconf))
698 *prefix_ptr++ = '-';
699 if(IsNeedIdentd(aconf))
700 *prefix_ptr++ = '+';
701 if(IsConfDoSpoofIp(aconf))
702 *prefix_ptr++ = '=';
703 if(IsNeedSasl(aconf))
704 *prefix_ptr++ = '%';
705 if(IsOper(sptr) && IsConfExemptFlood(aconf))
706 *prefix_ptr++ = '|';
707 if(IsOper(sptr) && IsConfExemptDNSBL(aconf) && !IsConfExemptKline(aconf))
708 *prefix_ptr++ = '$';
709 if(IsOper(sptr) && IsConfExemptKline(aconf))
710 *prefix_ptr++ = '^';
711 if(IsOper(sptr) && IsConfExemptLimits(aconf))
712 *prefix_ptr++ = '>';
713 rb_strlcpy(prefix_ptr, name, USERLEN + 1);
714 return (prefix_of_host);
715 }
716
717 /* report_auth()
718 *
719 * Inputs: pointer to client to report to
720 * Output: None
721 * Side effects: Reports configured auth{} blocks to client_p
722 */
723 void
724 report_auth(struct Client *client_p)
725 {
726 char *name, *host, *user, *classname, *desc;
727 const char *pass;
728 struct AddressRec *arec;
729 struct ConfItem *aconf;
730 int i, port;
731
732 for (i = 0; i < ATABLE_SIZE; i++)
733 for (arec = atable[i]; arec; arec = arec->next)
734 if(arec->type == CONF_CLIENT)
735 {
736 aconf = arec->aconf;
737
738 if(!IsOperGeneral(client_p) && IsConfDoSpoofIp(aconf))
739 continue;
740
741 get_printable_conf(aconf, &name, &host, &pass, &user, &port,
742 &classname, &desc);
743
744 if(!EmptyString(aconf->spasswd))
745 pass = aconf->spasswd;
746
747 sendto_one_numeric(client_p, RPL_STATSILINE,
748 form_str(RPL_STATSILINE),
749 name, pass, show_iline_prefix(client_p, aconf, user),
750 show_ip_conf(aconf, client_p) ? host : "255.255.255.255",
751 port, classname, desc);
752 }
753 }
754