ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/branches/newio/src/conf.c
Revision: 2658
Committed: Thu Dec 12 19:35:55 2013 UTC (11 years, 8 months ago) by michael
Content type: text/x-csrc
File size: 58415 byte(s)
Log Message:
- conf.c:valid_wild_card(): add missing va_end()

File Contents

# Content
1 /*
2 * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3 * conf.c: Configuration file functions.
4 *
5 * Copyright (C) 2002 by the past and present ircd coders, and others.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 * USA
21 *
22 * $Id$
23 */
24
25 #include "stdinc.h"
26 #include "list.h"
27 #include "ircd_defs.h"
28 #include "conf.h"
29 #include "s_serv.h"
30 #include "resv.h"
31 #include "channel.h"
32 #include "client.h"
33 #include "ioengine.h"
34 #include "hook.h"
35 #include "irc_string.h"
36 #include "s_bsd.h"
37 #include "ircd.h"
38 #include "listener.h"
39 #include "hostmask.h"
40 #include "modules.h"
41 #include "numeric.h"
42 #include "log.h"
43 #include "send.h"
44 #include "s_gline.h"
45 #include "memory.h"
46 #include "mempool.h"
47 #include "irc_res.h"
48 #include "userhost.h"
49 #include "s_user.h"
50 #include "channel_mode.h"
51 #include "parse.h"
52 #include "s_misc.h"
53 #include "conf_db.h"
54 #include "conf_class.h"
55 #include "motd.h"
56
57 struct config_server_hide ConfigServerHide;
58
59 /* general conf items link list root, other than k lines etc. */
60 dlink_list service_items = { NULL, NULL, 0 };
61 dlink_list server_items = { NULL, NULL, 0 };
62 dlink_list cluster_items = { NULL, NULL, 0 };
63 dlink_list oconf_items = { NULL, NULL, 0 };
64 dlink_list uconf_items = { NULL, NULL, 0 };
65 dlink_list xconf_items = { NULL, NULL, 0 };
66 dlink_list nresv_items = { NULL, NULL, 0 };
67 dlink_list cresv_items = { NULL, NULL, 0 };
68
69 extern unsigned int lineno;
70 extern char linebuf[];
71 extern char conffilebuf[IRCD_BUFSIZE];
72 extern int yyparse(); /* defined in y.tab.c */
73
74 struct conf_parser_context conf_parser_ctx = { 0, 0, NULL };
75
76 /* internally defined functions */
77 static void read_conf(FILE *);
78 static void clear_out_old_conf(void);
79 static void expire_tklines(dlink_list *);
80 static void garbage_collect_ip_entries(void);
81 static int hash_ip(struct irc_ssaddr *);
82 static int verify_access(struct Client *);
83 static int attach_iline(struct Client *, struct MaskItem *);
84 static struct ip_entry *find_or_add_ip(struct irc_ssaddr *);
85 static dlink_list *map_to_list(enum maskitem_type);
86 static int find_user_host(struct Client *, char *, char *, char *, unsigned int);
87
88
89 /* usually, with hash tables, you use a prime number...
90 * but in this case I am dealing with ip addresses,
91 * not ascii strings.
92 */
93 #define IP_HASH_SIZE 0x1000
94
95 struct ip_entry
96 {
97 struct irc_ssaddr ip;
98 unsigned int count;
99 time_t last_attempt;
100 struct ip_entry *next;
101 };
102
103 static struct ip_entry *ip_hash_table[IP_HASH_SIZE];
104 static mp_pool_t *ip_entry_pool = NULL;
105 static int ip_entries_count = 0;
106
107
108 /* conf_dns_callback()
109 *
110 * inputs - pointer to struct MaskItem
111 * - pointer to DNSReply reply
112 * output - none
113 * side effects - called when resolver query finishes
114 * if the query resulted in a successful search, hp will contain
115 * a non-null pointer, otherwise hp will be null.
116 * if successful save hp in the conf item it was called with
117 */
118 static void
119 conf_dns_callback(void *vptr, const struct irc_ssaddr *addr, const char *name)
120 {
121 struct MaskItem *conf = vptr;
122
123 conf->dns_pending = 0;
124
125 if (addr != NULL)
126 memcpy(&conf->addr, addr, sizeof(conf->addr));
127 }
128
129 /* conf_dns_lookup()
130 *
131 * do a nameserver lookup of the conf host
132 * if the conf entry is currently doing a ns lookup do nothing, otherwise
133 * allocate a dns_query and start ns lookup.
134 */
135 static void
136 conf_dns_lookup(struct MaskItem *conf)
137 {
138 if (!conf->dns_pending)
139 {
140 conf->dns_pending = 1;
141 gethost_byname(conf_dns_callback, conf, conf->host);
142 }
143 }
144
145 struct MaskItem *
146 conf_make(enum maskitem_type type)
147 {
148 struct MaskItem *conf = MyMalloc(sizeof(*conf));
149 dlink_list *list = NULL;
150
151 conf->type = type;
152 conf->active = 1;
153 conf->aftype = AF_INET;
154
155 if ((list = map_to_list(type)))
156 dlinkAdd(conf, &conf->node, list);
157 return conf;
158 }
159
160 void
161 conf_free(struct MaskItem *conf)
162 {
163 dlink_node *ptr = NULL, *ptr_next = NULL;
164 dlink_list *list = NULL;
165
166 if (conf->node.next)
167 if ((list = map_to_list(conf->type)))
168 dlinkDelete(&conf->node, list);
169
170 MyFree(conf->name);
171
172 if (conf->dns_pending)
173 delete_resolver_queries(conf);
174 if (conf->passwd != NULL)
175 memset(conf->passwd, 0, strlen(conf->passwd));
176 if (conf->spasswd != NULL)
177 memset(conf->spasswd, 0, strlen(conf->spasswd));
178
179 conf->class = NULL;
180
181 MyFree(conf->passwd);
182 MyFree(conf->spasswd);
183 MyFree(conf->reason);
184 MyFree(conf->certfp);
185 MyFree(conf->user);
186 MyFree(conf->host);
187 #ifdef HAVE_LIBCRYPTO
188 MyFree(conf->cipher_list);
189
190 if (conf->rsa_public_key)
191 RSA_free(conf->rsa_public_key);
192 #endif
193 DLINK_FOREACH_SAFE(ptr, ptr_next, conf->hub_list.head)
194 {
195 MyFree(ptr->data);
196 free_dlink_node(ptr);
197 }
198
199 DLINK_FOREACH_SAFE(ptr, ptr_next, conf->leaf_list.head)
200 {
201 MyFree(ptr->data);
202 free_dlink_node(ptr);
203 }
204
205 DLINK_FOREACH_SAFE(ptr, ptr_next, conf->exempt_list.head)
206 {
207 struct exempt *exptr = ptr->data;
208
209 MyFree(exptr->name);
210 MyFree(exptr->user);
211 MyFree(exptr->host);
212 MyFree(exptr);
213 }
214
215 MyFree(conf);
216 }
217
218 /* check_client()
219 *
220 * inputs - pointer to client
221 * output - 0 = Success
222 * NOT_AUTHORIZED (-1) = Access denied (no I line match)
223 * IRCD_SOCKET_ERROR (-2) = Bad socket.
224 * I_LINE_FULL (-3) = I-line is full
225 * TOO_MANY (-4) = Too many connections from hostname
226 * BANNED_CLIENT (-5) = K-lined
227 * side effects - Ordinary client access check.
228 * Look for conf lines which have the same
229 * status as the flags passed.
230 */
231 int
232 check_client(struct Client *source_p)
233 {
234 int i;
235
236 if ((i = verify_access(source_p)))
237 ilog(LOG_TYPE_IRCD, "Access denied: %s[%s]",
238 source_p->name, source_p->sockhost);
239
240 switch (i)
241 {
242 case TOO_MANY:
243 sendto_realops_flags(UMODE_FULL, L_ALL, SEND_NOTICE,
244 "Too many on IP for %s (%s).",
245 get_client_name(source_p, SHOW_IP),
246 source_p->sockhost);
247 ilog(LOG_TYPE_IRCD, "Too many connections on IP from %s.",
248 get_client_name(source_p, SHOW_IP));
249 ++ServerStats.is_ref;
250 exit_client(source_p, source_p, &me, "No more connections allowed on that IP");
251 break;
252
253 case I_LINE_FULL:
254 sendto_realops_flags(UMODE_FULL, L_ALL, SEND_NOTICE,
255 "auth{} block is full for %s (%s).",
256 get_client_name(source_p, SHOW_IP),
257 source_p->sockhost);
258 ilog(LOG_TYPE_IRCD, "Too many connections from %s.",
259 get_client_name(source_p, SHOW_IP));
260 ++ServerStats.is_ref;
261 exit_client(source_p, source_p, &me,
262 "No more connections allowed in your connection class");
263 break;
264
265 case NOT_AUTHORIZED:
266 ++ServerStats.is_ref;
267 /* jdc - lists server name & port connections are on */
268 /* a purely cosmetical change */
269 sendto_realops_flags(UMODE_UNAUTH, L_ALL, SEND_NOTICE,
270 "Unauthorized client connection from %s [%s] on [%s/%u].",
271 get_client_name(source_p, SHOW_IP),
272 source_p->sockhost,
273 source_p->localClient->listener->name,
274 source_p->localClient->listener->port);
275 ilog(LOG_TYPE_IRCD,
276 "Unauthorized client connection from %s on [%s/%u].",
277 get_client_name(source_p, SHOW_IP),
278 source_p->localClient->listener->name,
279 source_p->localClient->listener->port);
280
281 exit_client(source_p, source_p, &me, "You are not authorized to use this server");
282 break;
283
284 case BANNED_CLIENT:
285 exit_client(source_p, source_p, &me, "Banned");
286 ++ServerStats.is_ref;
287 break;
288
289 case 0:
290 default:
291 break;
292 }
293
294 return (i < 0 ? 0 : 1);
295 }
296
297 /* verify_access()
298 *
299 * inputs - pointer to client to verify
300 * output - 0 if success -'ve if not
301 * side effect - find the first (best) I line to attach.
302 */
303 static int
304 verify_access(struct Client *client_p)
305 {
306 struct MaskItem *conf = NULL;
307 char non_ident[USERLEN + 1] = { '~', '\0' };
308
309 if (IsGotId(client_p))
310 {
311 conf = find_address_conf(client_p->host, client_p->username,
312 &client_p->localClient->ip,
313 client_p->localClient->aftype,
314 client_p->localClient->passwd);
315 }
316 else
317 {
318 strlcpy(non_ident + 1, client_p->username, sizeof(non_ident) - 1);
319 conf = find_address_conf(client_p->host,non_ident,
320 &client_p->localClient->ip,
321 client_p->localClient->aftype,
322 client_p->localClient->passwd);
323 }
324
325 if (conf != NULL)
326 {
327 if (IsConfClient(conf))
328 {
329 if (IsConfRedir(conf))
330 {
331 sendto_one(client_p, form_str(RPL_REDIR),
332 me.name, client_p->name,
333 conf->name ? conf->name : "",
334 conf->port);
335 return NOT_AUTHORIZED;
336 }
337
338 if (IsConfDoIdentd(conf))
339 SetNeedId(client_p);
340
341 /* Thanks for spoof idea amm */
342 if (IsConfDoSpoofIp(conf))
343 {
344 if (!ConfigFileEntry.hide_spoof_ips && IsConfSpoofNotice(conf))
345 sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE,
346 "%s spoofing: %s as %s",
347 client_p->name, client_p->host, conf->name);
348 strlcpy(client_p->host, conf->name, sizeof(client_p->host));
349 AddFlag(client_p, FLAGS_IP_SPOOFING | FLAGS_AUTH_SPOOF);
350 }
351
352 return attach_iline(client_p, conf);
353 }
354 else if (IsConfKill(conf) || (ConfigFileEntry.glines && IsConfGline(conf)))
355 {
356 if (IsConfGline(conf))
357 sendto_one(client_p, ":%s NOTICE %s :*** G-lined", me.name,
358 client_p->name);
359 sendto_one(client_p, ":%s NOTICE %s :*** Banned: %s",
360 me.name, client_p->name, conf->reason);
361 return BANNED_CLIENT;
362 }
363 }
364
365 return NOT_AUTHORIZED;
366 }
367
368 /* attach_iline()
369 *
370 * inputs - client pointer
371 * - conf pointer
372 * output -
373 * side effects - do actual attach
374 */
375 static int
376 attach_iline(struct Client *client_p, struct MaskItem *conf)
377 {
378 struct ClassItem *class = NULL;
379 struct ip_entry *ip_found;
380 int a_limit_reached = 0;
381 unsigned int local = 0, global = 0, ident = 0;
382
383 assert(conf->class);
384
385 ip_found = find_or_add_ip(&client_p->localClient->ip);
386 ip_found->count++;
387 SetIpHash(client_p);
388
389 class = conf->class;
390
391 count_user_host(client_p->username, client_p->host,
392 &global, &local, &ident);
393
394 /* XXX blah. go down checking the various silly limits
395 * setting a_limit_reached if any limit is reached.
396 * - Dianora
397 */
398 if (class->max_total != 0 && class->ref_count >= class->max_total)
399 a_limit_reached = 1;
400 else if (class->max_perip != 0 && ip_found->count > class->max_perip)
401 a_limit_reached = 1;
402 else if (class->max_local != 0 && local >= class->max_local)
403 a_limit_reached = 1;
404 else if (class->max_global != 0 && global >= class->max_global)
405 a_limit_reached = 1;
406 else if (class->max_ident != 0 && ident >= class->max_ident &&
407 client_p->username[0] != '~')
408 a_limit_reached = 1;
409
410 if (a_limit_reached)
411 {
412 if (!IsConfExemptLimits(conf))
413 return TOO_MANY; /* Already at maximum allowed */
414
415 sendto_one(client_p,
416 ":%s NOTICE %s :*** Your connection class is full, "
417 "but you have exceed_limit = yes;", me.name, client_p->name);
418 }
419
420 return attach_conf(client_p, conf);
421 }
422
423 /* init_ip_hash_table()
424 *
425 * inputs - NONE
426 * output - NONE
427 * side effects - allocate memory for ip_entry(s)
428 * - clear the ip hash table
429 */
430 void
431 init_ip_hash_table(void)
432 {
433 ip_entry_pool = mp_pool_new(sizeof(struct ip_entry), MP_CHUNK_SIZE_IP_ENTRY);
434 memset(ip_hash_table, 0, sizeof(ip_hash_table));
435 }
436
437 /* find_or_add_ip()
438 *
439 * inputs - pointer to struct irc_ssaddr
440 * output - pointer to a struct ip_entry
441 * side effects -
442 *
443 * If the ip # was not found, a new struct ip_entry is created, and the ip
444 * count set to 0.
445 */
446 static struct ip_entry *
447 find_or_add_ip(struct irc_ssaddr *ip_in)
448 {
449 struct ip_entry *ptr, *newptr;
450 int hash_index = hash_ip(ip_in), res;
451 struct sockaddr_in *v4 = (struct sockaddr_in *)ip_in, *ptr_v4;
452 struct sockaddr_in6 *v6 = (struct sockaddr_in6 *)ip_in, *ptr_v6;
453
454 for (ptr = ip_hash_table[hash_index]; ptr; ptr = ptr->next)
455 {
456 if (ptr->ip.ss.ss_family != ip_in->ss.ss_family)
457 continue;
458 if (ip_in->ss.ss_family == AF_INET6)
459 {
460 ptr_v6 = (struct sockaddr_in6 *)&ptr->ip;
461 res = memcmp(&v6->sin6_addr, &ptr_v6->sin6_addr, sizeof(struct in6_addr));
462 }
463 else
464 {
465 ptr_v4 = (struct sockaddr_in *)&ptr->ip;
466 res = memcmp(&v4->sin_addr, &ptr_v4->sin_addr, sizeof(struct in_addr));
467 }
468 if (res == 0)
469 {
470 /* Found entry already in hash, return it. */
471 return ptr;
472 }
473 }
474
475 if (ip_entries_count >= 2 * 1024) /* XXX */
476 garbage_collect_ip_entries();
477
478 newptr = mp_pool_get(ip_entry_pool);
479 memset(newptr, 0, sizeof(*newptr));
480 ip_entries_count++;
481 memcpy(&newptr->ip, ip_in, sizeof(struct irc_ssaddr));
482
483 newptr->next = ip_hash_table[hash_index];
484 ip_hash_table[hash_index] = newptr;
485
486 return newptr;
487 }
488
489 /* remove_one_ip()
490 *
491 * inputs - unsigned long IP address value
492 * output - NONE
493 * side effects - The ip address given, is looked up in ip hash table
494 * and number of ip#'s for that ip decremented.
495 * If ip # count reaches 0 and has expired,
496 * the struct ip_entry is returned to the ip_entry_heap
497 */
498 void
499 remove_one_ip(struct irc_ssaddr *ip_in)
500 {
501 struct ip_entry *ptr;
502 struct ip_entry *last_ptr = NULL;
503 int hash_index = hash_ip(ip_in), res;
504 struct sockaddr_in *v4 = (struct sockaddr_in *)ip_in, *ptr_v4;
505 struct sockaddr_in6 *v6 = (struct sockaddr_in6 *)ip_in, *ptr_v6;
506
507 for (ptr = ip_hash_table[hash_index]; ptr; ptr = ptr->next)
508 {
509 if (ptr->ip.ss.ss_family != ip_in->ss.ss_family)
510 continue;
511 if (ip_in->ss.ss_family == AF_INET6)
512 {
513 ptr_v6 = (struct sockaddr_in6 *)&ptr->ip;
514 res = memcmp(&v6->sin6_addr, &ptr_v6->sin6_addr, sizeof(struct in6_addr));
515 }
516 else
517 {
518 ptr_v4 = (struct sockaddr_in *)&ptr->ip;
519 res = memcmp(&v4->sin_addr, &ptr_v4->sin_addr, sizeof(struct in_addr));
520 }
521 if (res)
522 continue;
523 if (ptr->count > 0)
524 ptr->count--;
525 if (ptr->count == 0 &&
526 (CurrentTime-ptr->last_attempt) >= ConfigFileEntry.throttle_time)
527 {
528 if (last_ptr != NULL)
529 last_ptr->next = ptr->next;
530 else
531 ip_hash_table[hash_index] = ptr->next;
532
533 mp_pool_release(ptr);
534 ip_entries_count--;
535 return;
536 }
537 last_ptr = ptr;
538 }
539 }
540
541 /* hash_ip()
542 *
543 * input - pointer to an irc_inaddr
544 * output - integer value used as index into hash table
545 * side effects - hopefully, none
546 */
547 static int
548 hash_ip(struct irc_ssaddr *addr)
549 {
550 if (addr->ss.ss_family == AF_INET)
551 {
552 struct sockaddr_in *v4 = (struct sockaddr_in *)addr;
553 int hash;
554 uint32_t ip;
555
556 ip = ntohl(v4->sin_addr.s_addr);
557 hash = ((ip >> 12) + ip) & (IP_HASH_SIZE-1);
558 return hash;
559 }
560 else
561 {
562 int hash;
563 struct sockaddr_in6 *v6 = (struct sockaddr_in6 *)addr;
564 uint32_t *ip = (uint32_t *)&v6->sin6_addr.s6_addr;
565
566 hash = ip[0] ^ ip[3];
567 hash ^= hash >> 16;
568 hash ^= hash >> 8;
569 hash = hash & (IP_HASH_SIZE - 1);
570 return hash;
571 }
572 }
573
574 /* count_ip_hash()
575 *
576 * inputs - pointer to counter of number of ips hashed
577 * - pointer to memory used for ip hash
578 * output - returned via pointers input
579 * side effects - NONE
580 *
581 * number of hashed ip #'s is counted up, plus the amount of memory
582 * used in the hash.
583 */
584 void
585 count_ip_hash(unsigned int *number_ips_stored, uint64_t *mem_ips_stored)
586 {
587 struct ip_entry *ptr;
588 int i;
589
590 *number_ips_stored = 0;
591 *mem_ips_stored = 0;
592
593 for (i = 0; i < IP_HASH_SIZE; i++)
594 {
595 for (ptr = ip_hash_table[i]; ptr; ptr = ptr->next)
596 {
597 *number_ips_stored += 1;
598 *mem_ips_stored += sizeof(struct ip_entry);
599 }
600 }
601 }
602
603 /* garbage_collect_ip_entries()
604 *
605 * input - NONE
606 * output - NONE
607 * side effects - free up all ip entries with no connections
608 */
609 static void
610 garbage_collect_ip_entries(void)
611 {
612 struct ip_entry *ptr;
613 struct ip_entry *last_ptr;
614 struct ip_entry *next_ptr;
615 int i;
616
617 for (i = 0; i < IP_HASH_SIZE; i++)
618 {
619 last_ptr = NULL;
620
621 for (ptr = ip_hash_table[i]; ptr; ptr = next_ptr)
622 {
623 next_ptr = ptr->next;
624
625 if (ptr->count == 0 &&
626 (CurrentTime - ptr->last_attempt) >= ConfigFileEntry.throttle_time)
627 {
628 if (last_ptr != NULL)
629 last_ptr->next = ptr->next;
630 else
631 ip_hash_table[i] = ptr->next;
632 mp_pool_release(ptr);
633 ip_entries_count--;
634 }
635 else
636 last_ptr = ptr;
637 }
638 }
639 }
640
641 /* detach_conf()
642 *
643 * inputs - pointer to client to detach
644 * - type of conf to detach
645 * output - 0 for success, -1 for failure
646 * side effects - Disassociate configuration from the client.
647 * Also removes a class from the list if marked for deleting.
648 */
649 void
650 detach_conf(struct Client *client_p, enum maskitem_type type)
651 {
652 dlink_node *ptr = NULL, *next_ptr = NULL;
653
654 DLINK_FOREACH_SAFE(ptr, next_ptr, client_p->localClient->confs.head)
655 {
656 struct MaskItem *conf = ptr->data;
657
658 assert(conf->type & (CONF_CLIENT | CONF_OPER | CONF_SERVER));
659 assert(conf->ref_count > 0);
660 assert(conf->class->ref_count > 0);
661
662 if (!(conf->type & type))
663 continue;
664
665 dlinkDelete(ptr, &client_p->localClient->confs);
666 free_dlink_node(ptr);
667
668 if (conf->type == CONF_CLIENT)
669 remove_from_cidr_check(&client_p->localClient->ip, conf->class);
670
671 if (--conf->class->ref_count == 0 && conf->class->active == 0)
672 {
673 class_free(conf->class);
674 conf->class = NULL;
675 }
676
677 if (--conf->ref_count == 0 && conf->active == 0)
678 conf_free(conf);
679 }
680 }
681
682 /* attach_conf()
683 *
684 * inputs - client pointer
685 * - conf pointer
686 * output -
687 * side effects - Associate a specific configuration entry to a *local*
688 * client (this is the one which used in accepting the
689 * connection). Note, that this automatically changes the
690 * attachment if there was an old one...
691 */
692 int
693 attach_conf(struct Client *client_p, struct MaskItem *conf)
694 {
695 if (dlinkFind(&client_p->localClient->confs, conf) != NULL)
696 return 1;
697
698 if (conf->type == CONF_CLIENT)
699 if (cidr_limit_reached(IsConfExemptLimits(conf),
700 &client_p->localClient->ip, conf->class))
701 return TOO_MANY; /* Already at maximum allowed */
702
703 conf->class->ref_count++;
704 conf->ref_count++;
705
706 dlinkAdd(conf, make_dlink_node(), &client_p->localClient->confs);
707
708 return 0;
709 }
710
711 /* attach_connect_block()
712 *
713 * inputs - pointer to server to attach
714 * - name of server
715 * - hostname of server
716 * output - true (1) if both are found, otherwise return false (0)
717 * side effects - find connect block and attach them to connecting client
718 */
719 int
720 attach_connect_block(struct Client *client_p, const char *name,
721 const char *host)
722 {
723 dlink_node *ptr;
724 struct MaskItem *conf = NULL;
725
726 assert(client_p != NULL);
727 assert(host != NULL);
728
729 if (client_p == NULL || host == NULL)
730 return 0;
731
732 DLINK_FOREACH(ptr, server_items.head)
733 {
734 conf = ptr->data;
735
736 if (match(conf->name, name) || match(conf->host, host))
737 continue;
738
739 attach_conf(client_p, conf);
740 return -1;
741 }
742
743 return 0;
744 }
745
746 /* find_conf_name()
747 *
748 * inputs - pointer to conf link list to search
749 * - pointer to name to find
750 * - int mask of type of conf to find
751 * output - NULL or pointer to conf found
752 * side effects - find a conf entry which matches the name
753 * and has the given mask.
754 */
755 struct MaskItem *
756 find_conf_name(dlink_list *list, const char *name, enum maskitem_type type)
757 {
758 dlink_node *ptr;
759 struct MaskItem* conf;
760
761 DLINK_FOREACH(ptr, list->head)
762 {
763 conf = ptr->data;
764
765 if (conf->type == type)
766 {
767 if (conf->name && (irccmp(conf->name, name) == 0 ||
768 !match(conf->name, name)))
769 return conf;
770 }
771 }
772
773 return NULL;
774 }
775
776 /* map_to_list()
777 *
778 * inputs - ConfType conf
779 * output - pointer to dlink_list to use
780 * side effects - none
781 */
782 static dlink_list *
783 map_to_list(enum maskitem_type type)
784 {
785 switch(type)
786 {
787 case CONF_XLINE:
788 return(&xconf_items);
789 break;
790 case CONF_ULINE:
791 return(&uconf_items);
792 break;
793 case CONF_NRESV:
794 return(&nresv_items);
795 break;
796 case CONF_CRESV:
797 return(&cresv_items);
798 case CONF_OPER:
799 return(&oconf_items);
800 break;
801 case CONF_SERVER:
802 return(&server_items);
803 break;
804 case CONF_SERVICE:
805 return(&service_items);
806 break;
807 case CONF_CLUSTER:
808 return(&cluster_items);
809 break;
810 default:
811 return NULL;
812 }
813 }
814
815 /* find_matching_name_conf()
816 *
817 * inputs - type of link list to look in
818 * - pointer to name string to find
819 * - pointer to user
820 * - pointer to host
821 * - optional flags to match on as well
822 * output - NULL or pointer to found struct MaskItem
823 * side effects - looks for a match on name field
824 */
825 struct MaskItem *
826 find_matching_name_conf(enum maskitem_type type, const char *name, const char *user,
827 const char *host, unsigned int flags)
828 {
829 dlink_node *ptr=NULL;
830 struct MaskItem *conf=NULL;
831 dlink_list *list_p = map_to_list(type);
832
833 switch (type)
834 {
835 case CONF_SERVICE:
836 DLINK_FOREACH(ptr, list_p->head)
837 {
838 conf = ptr->data;
839
840 if (EmptyString(conf->name))
841 continue;
842 if ((name != NULL) && !irccmp(name, conf->name))
843 return conf;
844 }
845 break;
846
847 case CONF_XLINE:
848 case CONF_ULINE:
849 case CONF_NRESV:
850 case CONF_CRESV:
851 DLINK_FOREACH(ptr, list_p->head)
852 {
853 conf = ptr->data;
854
855 if (EmptyString(conf->name))
856 continue;
857 if ((name != NULL) && !match(conf->name, name))
858 {
859 if ((user == NULL && (host == NULL)))
860 return conf;
861 if ((conf->flags & flags) != flags)
862 continue;
863 if (EmptyString(conf->user) || EmptyString(conf->host))
864 return conf;
865 if (!match(conf->user, user) && !match(conf->host, host))
866 return conf;
867 }
868 }
869 break;
870
871 case CONF_SERVER:
872 DLINK_FOREACH(ptr, list_p->head)
873 {
874 conf = ptr->data;
875
876 if ((name != NULL) && !match(name, conf->name))
877 return conf;
878 else if ((host != NULL) && !match(host, conf->host))
879 return conf;
880 }
881 break;
882
883 default:
884 break;
885 }
886 return NULL;
887 }
888
889 /* find_exact_name_conf()
890 *
891 * inputs - type of link list to look in
892 * - pointer to name string to find
893 * - pointer to user
894 * - pointer to host
895 * output - NULL or pointer to found struct MaskItem
896 * side effects - looks for an exact match on name field
897 */
898 struct MaskItem *
899 find_exact_name_conf(enum maskitem_type type, const struct Client *who, const char *name,
900 const char *user, const char *host)
901 {
902 dlink_node *ptr = NULL;
903 struct MaskItem *conf;
904 dlink_list *list_p = map_to_list(type);
905
906 switch(type)
907 {
908 case CONF_XLINE:
909 case CONF_ULINE:
910 case CONF_NRESV:
911 case CONF_CRESV:
912
913 DLINK_FOREACH(ptr, list_p->head)
914 {
915 conf = ptr->data;
916
917 if (EmptyString(conf->name))
918 continue;
919
920 if (irccmp(conf->name, name) == 0)
921 {
922 if ((user == NULL && (host == NULL)))
923 return conf;
924 if (EmptyString(conf->user) || EmptyString(conf->host))
925 return conf;
926 if (!match(conf->user, user) && !match(conf->host, host))
927 return conf;
928 }
929 }
930 break;
931
932 case CONF_OPER:
933 DLINK_FOREACH(ptr, list_p->head)
934 {
935 conf = ptr->data;
936
937 if (EmptyString(conf->name))
938 continue;
939
940 if (!irccmp(conf->name, name))
941 {
942 if (!who)
943 return conf;
944 if (EmptyString(conf->user) || EmptyString(conf->host))
945 return NULL;
946 if (!match(conf->user, who->username))
947 {
948 switch (conf->htype)
949 {
950 case HM_HOST:
951 if (!match(conf->host, who->host) || !match(conf->host, who->sockhost))
952 if (!conf->class->max_total || conf->class->ref_count < conf->class->max_total)
953 return conf;
954 break;
955 case HM_IPV4:
956 if (who->localClient->aftype == AF_INET)
957 if (match_ipv4(&who->localClient->ip, &conf->addr, conf->bits))
958 if (!conf->class->max_total || conf->class->ref_count < conf->class->max_total)
959 return conf;
960 break;
961 case HM_IPV6:
962 if (who->localClient->aftype == AF_INET6)
963 if (match_ipv6(&who->localClient->ip, &conf->addr, conf->bits))
964 if (!conf->class->max_total || conf->class->ref_count < conf->class->max_total)
965 return conf;
966 break;
967 default:
968 assert(0);
969 }
970 }
971 }
972 }
973
974 break;
975
976 case CONF_SERVER:
977 DLINK_FOREACH(ptr, list_p->head)
978 {
979 conf = ptr->data;
980
981 if (EmptyString(conf->name))
982 continue;
983
984 if (name == NULL)
985 {
986 if (EmptyString(conf->host))
987 continue;
988 if (irccmp(conf->host, host) == 0)
989 return conf;
990 }
991 else if (irccmp(conf->name, name) == 0)
992 return conf;
993 }
994
995 break;
996
997 default:
998 break;
999 }
1000
1001 return NULL;
1002 }
1003
1004 /* rehash()
1005 *
1006 * Actual REHASH service routine. Called with sig == 0 if it has been called
1007 * as a result of an operator issuing this command, else assume it has been
1008 * called as a result of the server receiving a HUP signal.
1009 */
1010 int
1011 rehash(int sig)
1012 {
1013 if (sig != 0)
1014 sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1015 "Got signal SIGHUP, reloading ircd.conf file");
1016
1017 restart_resolver();
1018
1019 /* don't close listeners until we know we can go ahead with the rehash */
1020
1021 read_conf_files(0);
1022
1023 if (ServerInfo.description != NULL)
1024 strlcpy(me.info, ServerInfo.description, sizeof(me.info));
1025
1026 load_conf_modules();
1027
1028 rehashed_klines = 1;
1029
1030 return 0;
1031 }
1032
1033 /* set_default_conf()
1034 *
1035 * inputs - NONE
1036 * output - NONE
1037 * side effects - Set default values here.
1038 * This is called **PRIOR** to parsing the
1039 * configuration file. If you want to do some validation
1040 * of values later, put them in validate_conf().
1041 */
1042 static void
1043 set_default_conf(void)
1044 {
1045 /* verify init_class() ran, this should be an unnecessary check
1046 * but its not much work.
1047 */
1048 assert(class_default == class_get_list()->tail->data);
1049
1050 #ifdef HAVE_LIBCRYPTO
1051 ServerInfo.rsa_private_key = NULL;
1052 ServerInfo.rsa_private_key_file = NULL;
1053 #endif
1054
1055 /* ServerInfo.name is not rehashable */
1056 /* ServerInfo.name = ServerInfo.name; */
1057 ServerInfo.description = NULL;
1058 ServerInfo.network_name = xstrdup(NETWORK_NAME_DEFAULT);
1059 ServerInfo.network_desc = xstrdup(NETWORK_DESC_DEFAULT);
1060
1061 memset(&ServerInfo.ip, 0, sizeof(ServerInfo.ip));
1062 ServerInfo.specific_ipv4_vhost = 0;
1063 memset(&ServerInfo.ip6, 0, sizeof(ServerInfo.ip6));
1064 ServerInfo.specific_ipv6_vhost = 0;
1065
1066 // XXX TBV ServerInfo.max_clients = MAXCLIENTS_MAX;
1067 ServerInfo.max_nick_length = 9;
1068 ServerInfo.max_topic_length = 80;
1069
1070 ServerInfo.hub = 0;
1071 ServerInfo.dns_host.sin_addr.s_addr = 0;
1072 ServerInfo.dns_host.sin_port = 0;
1073 AdminInfo.name = NULL;
1074 AdminInfo.email = NULL;
1075 AdminInfo.description = NULL;
1076
1077 log_del_all();
1078
1079 ConfigLoggingEntry.use_logging = 1;
1080
1081 ConfigChannel.disable_fake_channels = 0;
1082 ConfigChannel.knock_delay = 300;
1083 ConfigChannel.knock_delay_channel = 60;
1084 ConfigChannel.max_chans_per_user = 25;
1085 ConfigChannel.max_chans_per_oper = 50;
1086 ConfigChannel.max_bans = 25;
1087 ConfigChannel.default_split_user_count = 0;
1088 ConfigChannel.default_split_server_count = 0;
1089 ConfigChannel.no_join_on_split = 0;
1090 ConfigChannel.no_create_on_split = 0;
1091
1092 ConfigServerHide.flatten_links = 0;
1093 ConfigServerHide.links_delay = 300;
1094 ConfigServerHide.hidden = 0;
1095 ConfigServerHide.hide_servers = 0;
1096 ConfigServerHide.hide_services = 0;
1097 ConfigServerHide.hidden_name = xstrdup(NETWORK_NAME_DEFAULT);
1098 ConfigServerHide.hide_server_ips = 0;
1099 ConfigServerHide.disable_remote_commands = 0;
1100
1101
1102 ConfigFileEntry.service_name = xstrdup(SERVICE_NAME_DEFAULT);
1103 ConfigFileEntry.max_watch = WATCHSIZE_DEFAULT;
1104 ConfigFileEntry.cycle_on_host_change = 1;
1105 ConfigFileEntry.glines = 0;
1106 ConfigFileEntry.gline_time = 12 * 3600;
1107 ConfigFileEntry.gline_request_time = GLINE_REQUEST_EXPIRE_DEFAULT;
1108 ConfigFileEntry.gline_min_cidr = 16;
1109 ConfigFileEntry.gline_min_cidr6 = 48;
1110 ConfigFileEntry.invisible_on_connect = 1;
1111 ConfigFileEntry.tkline_expire_notices = 1;
1112 ConfigFileEntry.hide_spoof_ips = 1;
1113 ConfigFileEntry.ignore_bogus_ts = 0;
1114 ConfigFileEntry.disable_auth = 0;
1115 ConfigFileEntry.kill_chase_time_limit = 90;
1116 ConfigFileEntry.default_floodcount = 8;
1117 ConfigFileEntry.failed_oper_notice = 1;
1118 ConfigFileEntry.dots_in_ident = 0;
1119 ConfigFileEntry.min_nonwildcard = 4;
1120 ConfigFileEntry.min_nonwildcard_simple = 3;
1121 ConfigFileEntry.max_accept = 20;
1122 ConfigFileEntry.anti_nick_flood = 0;
1123 ConfigFileEntry.max_nick_time = 20;
1124 ConfigFileEntry.max_nick_changes = 5;
1125 ConfigFileEntry.anti_spam_exit_message_time = 0;
1126 ConfigFileEntry.ts_warn_delta = TS_WARN_DELTA_DEFAULT;
1127 ConfigFileEntry.ts_max_delta = TS_MAX_DELTA_DEFAULT;
1128 ConfigFileEntry.warn_no_nline = 1;
1129 ConfigFileEntry.stats_o_oper_only = 0;
1130 ConfigFileEntry.stats_k_oper_only = 1; /* masked */
1131 ConfigFileEntry.stats_i_oper_only = 1; /* masked */
1132 ConfigFileEntry.stats_P_oper_only = 0;
1133 ConfigFileEntry.stats_u_oper_only = 0;
1134 ConfigFileEntry.caller_id_wait = 60;
1135 ConfigFileEntry.opers_bypass_callerid = 0;
1136 ConfigFileEntry.pace_wait = 10;
1137 ConfigFileEntry.pace_wait_simple = 1;
1138 ConfigFileEntry.short_motd = 0;
1139 ConfigFileEntry.ping_cookie = 0;
1140 ConfigFileEntry.oper_pass_resv = 1;
1141 ConfigFileEntry.max_targets = MAX_TARGETS_DEFAULT;
1142 ConfigFileEntry.oper_only_umodes = UMODE_DEBUG;
1143 ConfigFileEntry.oper_umodes = UMODE_BOTS | UMODE_LOCOPS | UMODE_SERVNOTICE |
1144 UMODE_OPERWALL | UMODE_WALLOP;
1145 ConfigFileEntry.use_egd = 0;
1146 ConfigFileEntry.egdpool_path = NULL;
1147 ConfigFileEntry.throttle_time = 10;
1148 }
1149
1150 static void
1151 validate_conf(void)
1152 {
1153 if (ConfigFileEntry.ts_warn_delta < TS_WARN_DELTA_MIN)
1154 ConfigFileEntry.ts_warn_delta = TS_WARN_DELTA_DEFAULT;
1155
1156 if (ConfigFileEntry.ts_max_delta < TS_MAX_DELTA_MIN)
1157 ConfigFileEntry.ts_max_delta = TS_MAX_DELTA_DEFAULT;
1158
1159 if (ServerInfo.network_name == NULL)
1160 ServerInfo.network_name = xstrdup(NETWORK_NAME_DEFAULT);
1161
1162 if (ServerInfo.network_desc == NULL)
1163 ServerInfo.network_desc = xstrdup(NETWORK_DESC_DEFAULT);
1164
1165 if (ConfigFileEntry.service_name == NULL)
1166 ConfigFileEntry.service_name = xstrdup(SERVICE_NAME_DEFAULT);
1167
1168 ConfigFileEntry.max_watch = IRCD_MAX(ConfigFileEntry.max_watch, WATCHSIZE_MIN);
1169 }
1170
1171 /* read_conf()
1172 *
1173 * inputs - file descriptor pointing to config file to use
1174 * output - None
1175 * side effects - Read configuration file.
1176 */
1177 static void
1178 read_conf(FILE *file)
1179 {
1180 lineno = 0;
1181
1182 set_default_conf(); /* Set default values prior to conf parsing */
1183 conf_parser_ctx.pass = 1;
1184 yyparse(); /* pick up the classes first */
1185
1186 rewind(file);
1187
1188 conf_parser_ctx.pass = 2;
1189 yyparse(); /* Load the values from the conf */
1190 validate_conf(); /* Check to make sure some values are still okay. */
1191 /* Some global values are also loaded here. */
1192 listener_close_marked();
1193 class_delete_marked(); /* Make sure classes are valid */
1194 }
1195
1196 /* lookup_confhost()
1197 *
1198 * start DNS lookups of all hostnames in the conf
1199 * line and convert an IP addresses in a.b.c.d number for to IP#s.
1200 */
1201 void
1202 lookup_confhost(struct MaskItem *conf)
1203 {
1204 struct addrinfo hints, *res;
1205 char portname[PORTNAMELEN + 1];
1206
1207 /* Do name lookup now on hostnames given and store the
1208 * ip numbers in conf structure.
1209 */
1210 memset(&hints, 0, sizeof(hints));
1211
1212 hints.ai_family = AF_UNSPEC;
1213 hints.ai_socktype = SOCK_STREAM;
1214
1215 /* Get us ready for a bind() and don't bother doing dns lookup */
1216 hints.ai_flags = AI_PASSIVE | AI_NUMERICHOST;
1217
1218 snprintf(portname, sizeof(portname), "%d", conf->port);
1219
1220 if (getaddrinfo(conf->host, portname, &hints, &res))
1221 {
1222 conf_dns_lookup(conf);
1223 return;
1224 }
1225
1226 assert(res != NULL);
1227
1228 memcpy(&conf->addr, res->ai_addr, res->ai_addrlen);
1229 conf->addr.ss_len = res->ai_addrlen;
1230 conf->addr.ss.ss_family = res->ai_family;
1231
1232 freeaddrinfo(res);
1233 }
1234
1235 /* conf_connect_allowed()
1236 *
1237 * inputs - pointer to inaddr
1238 * - int type ipv4 or ipv6
1239 * output - BANNED or accepted
1240 * side effects - none
1241 */
1242 int
1243 conf_connect_allowed(struct irc_ssaddr *addr, int aftype)
1244 {
1245 struct ip_entry *ip_found;
1246 struct MaskItem *conf = find_dline_conf(addr, aftype);
1247
1248 /* DLINE exempt also gets you out of static limits/pacing... */
1249 if (conf && (conf->type == CONF_EXEMPT))
1250 return 0;
1251
1252 if (conf != NULL)
1253 return BANNED_CLIENT;
1254
1255 ip_found = find_or_add_ip(addr);
1256
1257 if ((CurrentTime - ip_found->last_attempt) <
1258 ConfigFileEntry.throttle_time)
1259 {
1260 ip_found->last_attempt = CurrentTime;
1261 return TOO_FAST;
1262 }
1263
1264 ip_found->last_attempt = CurrentTime;
1265 return 0;
1266 }
1267
1268 /* cleanup_tklines()
1269 *
1270 * inputs - NONE
1271 * output - NONE
1272 * side effects - call function to expire temporary k/d lines
1273 * This is an event started off in ircd.c
1274 */
1275 void
1276 cleanup_tklines(struct Event *ev)
1277 {
1278 hostmask_expire_temporary();
1279 expire_tklines(&xconf_items);
1280 expire_tklines(&nresv_items);
1281 expire_tklines(&cresv_items);
1282 }
1283
1284 /* expire_tklines()
1285 *
1286 * inputs - tkline list pointer
1287 * output - NONE
1288 * side effects - expire tklines
1289 */
1290 static void
1291 expire_tklines(dlink_list *tklist)
1292 {
1293 dlink_node *ptr;
1294 dlink_node *next_ptr;
1295 struct MaskItem *conf;
1296
1297 DLINK_FOREACH_SAFE(ptr, next_ptr, tklist->head)
1298 {
1299 conf = ptr->data;
1300
1301 if (!conf->until || conf->until > CurrentTime)
1302 continue;
1303
1304 if (conf->type == CONF_XLINE)
1305 {
1306 if (ConfigFileEntry.tkline_expire_notices)
1307 sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1308 "Temporary X-line for [%s] expired", conf->name);
1309 conf_free(conf);
1310 }
1311 else if (conf->type == CONF_NRESV || conf->type == CONF_CRESV)
1312 {
1313 if (ConfigFileEntry.tkline_expire_notices)
1314 sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1315 "Temporary RESV for [%s] expired", conf->name);
1316 conf_free(conf);
1317 }
1318 }
1319 }
1320
1321 /* oper_privs_as_string()
1322 *
1323 * inputs - pointer to client_p
1324 * output - pointer to static string showing oper privs
1325 * side effects - return as string, the oper privs as derived from port
1326 */
1327 static const struct oper_privs
1328 {
1329 const unsigned int flag;
1330 const unsigned char c;
1331 } flag_list[] = {
1332 { OPER_FLAG_ADMIN, 'A' },
1333 { OPER_FLAG_REMOTEBAN, 'B' },
1334 { OPER_FLAG_DIE, 'D' },
1335 { OPER_FLAG_GLINE, 'G' },
1336 { OPER_FLAG_REHASH, 'H' },
1337 { OPER_FLAG_K, 'K' },
1338 { OPER_FLAG_OPERWALL, 'L' },
1339 { OPER_FLAG_KILL, 'N' },
1340 { OPER_FLAG_KILL_REMOTE, 'O' },
1341 { OPER_FLAG_CONNECT, 'P' },
1342 { OPER_FLAG_CONNECT_REMOTE, 'Q' },
1343 { OPER_FLAG_SQUIT, 'R' },
1344 { OPER_FLAG_SQUIT_REMOTE, 'S' },
1345 { OPER_FLAG_UNKLINE, 'U' },
1346 { OPER_FLAG_X, 'X' },
1347 { 0, '\0' }
1348 };
1349
1350 char *
1351 oper_privs_as_string(const unsigned int port)
1352 {
1353 static char privs_out[16];
1354 char *privs_ptr = privs_out;
1355 const struct oper_privs *opriv = flag_list;
1356
1357 for (; opriv->flag; ++opriv)
1358 {
1359 if (port & opriv->flag)
1360 *privs_ptr++ = opriv->c;
1361 else
1362 *privs_ptr++ = ToLower(opriv->c);
1363 }
1364
1365 *privs_ptr = '\0';
1366
1367 return privs_out;
1368 }
1369
1370 /*
1371 * Input: A client to find the active oper{} name for.
1372 * Output: The nick!user@host{oper} of the oper.
1373 * "oper" is server name for remote opers
1374 * Side effects: None.
1375 */
1376 const char *
1377 get_oper_name(const struct Client *client_p)
1378 {
1379 dlink_node *cnode = NULL;
1380 /* +5 for !,@,{,} and null */
1381 static char buffer[NICKLEN + USERLEN + HOSTLEN + HOSTLEN + 5];
1382
1383 if (MyConnect(client_p))
1384 {
1385 if ((cnode = client_p->localClient->confs.head))
1386 {
1387 struct MaskItem *conf = cnode->data;
1388
1389 if (IsConfOperator(conf))
1390 {
1391 snprintf(buffer, sizeof(buffer), "%s!%s@%s{%s}", client_p->name,
1392 client_p->username, client_p->host, conf->name);
1393 return buffer;
1394 }
1395 }
1396
1397 /* Probably should assert here for now. If there is an oper out there
1398 * with no oper{} conf attached, it would be good for us to know...
1399 */
1400 assert(0); /* Oper without oper conf! */
1401 }
1402
1403 snprintf(buffer, sizeof(buffer), "%s!%s@%s{%s}", client_p->name,
1404 client_p->username, client_p->host, client_p->servptr->name);
1405 return buffer;
1406 }
1407
1408 /* read_conf_files()
1409 *
1410 * inputs - cold start YES or NO
1411 * output - none
1412 * side effects - read all conf files needed, ircd.conf kline.conf etc.
1413 */
1414 void
1415 read_conf_files(int cold)
1416 {
1417 const char *filename;
1418 char chanmodes[32];
1419 char chanlimit[32];
1420
1421 conf_parser_ctx.boot = cold;
1422 filename = ConfigFileEntry.configfile;
1423
1424 /* We need to know the initial filename for the yyerror() to report
1425 FIXME: The full path is in conffilenamebuf first time since we
1426 dont know anything else
1427
1428 - Gozem 2002-07-21
1429 */
1430 strlcpy(conffilebuf, filename, sizeof(conffilebuf));
1431
1432 if ((conf_parser_ctx.conf_file = fopen(filename, "r")) == NULL)
1433 {
1434 if (cold)
1435 {
1436 ilog(LOG_TYPE_IRCD, "Unable to read configuration file '%s': %s",
1437 filename, strerror(errno));
1438 exit(-1);
1439 }
1440 else
1441 {
1442 sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1443 "Unable to read configuration file '%s': %s",
1444 filename, strerror(errno));
1445 return;
1446 }
1447 }
1448
1449 if (!cold)
1450 clear_out_old_conf();
1451
1452 read_conf(conf_parser_ctx.conf_file);
1453 fclose(conf_parser_ctx.conf_file);
1454
1455 log_reopen_all();
1456
1457 add_isupport("NICKLEN", NULL, ServerInfo.max_nick_length);
1458 add_isupport("NETWORK", ServerInfo.network_name, -1);
1459
1460 snprintf(chanmodes, sizeof(chanmodes), "beI:%d", ConfigChannel.max_bans);
1461 add_isupport("MAXLIST", chanmodes, -1);
1462 add_isupport("MAXTARGETS", NULL, ConfigFileEntry.max_targets);
1463 add_isupport("CHANTYPES", "#", -1);
1464
1465 snprintf(chanlimit, sizeof(chanlimit), "#:%d",
1466 ConfigChannel.max_chans_per_user);
1467 add_isupport("CHANLIMIT", chanlimit, -1);
1468 snprintf(chanmodes, sizeof(chanmodes), "%s", "beI,k,l,imnprstORS");
1469 add_isupport("CHANNELLEN", NULL, LOCAL_CHANNELLEN);
1470 add_isupport("TOPICLEN", NULL, ServerInfo.max_topic_length);
1471 add_isupport("CHANMODES", chanmodes, -1);
1472
1473 /*
1474 * message_locale may have changed. rebuild isupport since it relies
1475 * on strlen(form_str(RPL_ISUPPORT))
1476 */
1477 rebuild_isupport_message_line();
1478 }
1479
1480 /* clear_out_old_conf()
1481 *
1482 * inputs - none
1483 * output - none
1484 * side effects - Clear out the old configuration
1485 */
1486 static void
1487 clear_out_old_conf(void)
1488 {
1489 dlink_node *ptr = NULL, *next_ptr = NULL;
1490 struct MaskItem *conf;
1491 dlink_list *free_items [] = {
1492 &server_items, &oconf_items,
1493 &uconf_items, &xconf_items,
1494 &nresv_items, &cluster_items, &service_items, &cresv_items, NULL
1495 };
1496
1497 dlink_list ** iterator = free_items; /* C is dumb */
1498
1499 /* We only need to free anything allocated by yyparse() here.
1500 * Resetting structs, etc, is taken care of by set_default_conf().
1501 */
1502
1503 for (; *iterator != NULL; iterator++)
1504 {
1505 DLINK_FOREACH_SAFE(ptr, next_ptr, (*iterator)->head)
1506 {
1507 conf = ptr->data;
1508
1509 dlinkDelete(&conf->node, map_to_list(conf->type));
1510
1511 /* XXX This is less than pretty */
1512 if (conf->type == CONF_SERVER || conf->type == CONF_OPER)
1513 {
1514 if (!conf->ref_count)
1515 conf_free(conf);
1516 }
1517 else if (conf->type == CONF_XLINE)
1518 {
1519 if (!conf->until)
1520 conf_free(conf);
1521 }
1522 else
1523 conf_free(conf);
1524 }
1525 }
1526
1527 motd_clear();
1528
1529 /*
1530 * don't delete the class table, rather mark all entries
1531 * for deletion. The table is cleaned up by class_delete_marked. - avalon
1532 */
1533 class_mark_for_deletion();
1534 listener_mark_closing();
1535
1536 clear_out_address_conf();
1537
1538 /* clean out module paths */
1539 mod_clear_paths();
1540
1541 /* clean out ServerInfo */
1542 MyFree(ServerInfo.description);
1543 ServerInfo.description = NULL;
1544 MyFree(ServerInfo.network_name);
1545 ServerInfo.network_name = NULL;
1546 MyFree(ServerInfo.network_desc);
1547 ServerInfo.network_desc = NULL;
1548 MyFree(ConfigFileEntry.egdpool_path);
1549 ConfigFileEntry.egdpool_path = NULL;
1550 #ifdef HAVE_LIBCRYPTO
1551 if (ServerInfo.rsa_private_key != NULL)
1552 {
1553 RSA_free(ServerInfo.rsa_private_key);
1554 ServerInfo.rsa_private_key = NULL;
1555 }
1556
1557 MyFree(ServerInfo.rsa_private_key_file);
1558 ServerInfo.rsa_private_key_file = NULL;
1559
1560 if (ServerInfo.server_ctx)
1561 SSL_CTX_set_options(ServerInfo.server_ctx, SSL_OP_NO_SSLv2|
1562 SSL_OP_NO_SSLv3|
1563 SSL_OP_NO_TLSv1);
1564 if (ServerInfo.client_ctx)
1565 SSL_CTX_set_options(ServerInfo.client_ctx, SSL_OP_NO_SSLv2|
1566 SSL_OP_NO_SSLv3|
1567 SSL_OP_NO_TLSv1);
1568 #endif
1569
1570 /* clean out AdminInfo */
1571 MyFree(AdminInfo.name);
1572 AdminInfo.name = NULL;
1573 MyFree(AdminInfo.email);
1574 AdminInfo.email = NULL;
1575 MyFree(AdminInfo.description);
1576 AdminInfo.description = NULL;
1577
1578 /* clean out general */
1579 MyFree(ConfigFileEntry.service_name);
1580 ConfigFileEntry.service_name = NULL;
1581 }
1582
1583 /* conf_add_class_to_conf()
1584 *
1585 * inputs - pointer to config item
1586 * output - NONE
1587 * side effects - Add a class pointer to a conf
1588 */
1589 void
1590 conf_add_class_to_conf(struct MaskItem *conf, const char *class_name)
1591 {
1592 if (class_name == NULL)
1593 {
1594 conf->class = class_default;
1595
1596 if (conf->type == CONF_CLIENT)
1597 sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1598 "Warning *** Defaulting to default class for %s@%s",
1599 conf->user, conf->host);
1600 else
1601 sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1602 "Warning *** Defaulting to default class for %s",
1603 conf->name);
1604 }
1605 else
1606 conf->class = class_find(class_name, 1);
1607
1608 if (conf->class == NULL)
1609 {
1610 if (conf->type == CONF_CLIENT)
1611 sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1612 "Warning *** Defaulting to default class for %s@%s",
1613 conf->user, conf->host);
1614 else
1615 sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1616 "Warning *** Defaulting to default class for %s",
1617 conf->name);
1618 conf->class = class_default;
1619 }
1620 }
1621
1622 /* yyerror()
1623 *
1624 * inputs - message from parser
1625 * output - NONE
1626 * side effects - message to opers and log file entry is made
1627 */
1628 void
1629 yyerror(const char *msg)
1630 {
1631 char newlinebuf[IRCD_BUFSIZE];
1632
1633 if (conf_parser_ctx.pass != 1)
1634 return;
1635
1636 strip_tabs(newlinebuf, linebuf, sizeof(newlinebuf));
1637 sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1638 "\"%s\", line %u: %s: %s",
1639 conffilebuf, lineno + 1, msg, newlinebuf);
1640 ilog(LOG_TYPE_IRCD, "\"%s\", line %u: %s: %s",
1641 conffilebuf, lineno + 1, msg, newlinebuf);
1642 }
1643
1644 void
1645 conf_error_report(const char *msg)
1646 {
1647 char newlinebuf[IRCD_BUFSIZE];
1648
1649 strip_tabs(newlinebuf, linebuf, sizeof(newlinebuf));
1650 sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1651 "\"%s\", line %u: %s: %s",
1652 conffilebuf, lineno + 1, msg, newlinebuf);
1653 ilog(LOG_TYPE_IRCD, "\"%s\", line %u: %s: %s",
1654 conffilebuf, lineno + 1, msg, newlinebuf);
1655 }
1656
1657 /*
1658 * valid_tkline()
1659 *
1660 * inputs - pointer to ascii string to check
1661 * - whether the specified time is in seconds or minutes
1662 * output - -1 not enough parameters
1663 * - 0 if not an integer number, else the number
1664 * side effects - none
1665 * Originally written by Dianora (Diane, db@db.net)
1666 */
1667 time_t
1668 valid_tkline(const char *data, const int minutes)
1669 {
1670 const unsigned char *p = (const unsigned char *)data;
1671 unsigned char tmpch = '\0';
1672 time_t result = 0;
1673
1674 while ((tmpch = *p++))
1675 {
1676 if (!IsDigit(tmpch))
1677 return 0;
1678
1679 result *= 10;
1680 result += (tmpch & 0xF);
1681 }
1682
1683 /*
1684 * In the degenerate case where oper does a /quote kline 0 user@host :reason
1685 * i.e. they specifically use 0, I am going to return 1 instead
1686 * as a return value of non-zero is used to flag it as a temporary kline
1687 */
1688 if (result == 0)
1689 result = 1;
1690
1691 /*
1692 * If the incoming time is in seconds convert it to minutes for the purpose
1693 * of this calculation
1694 */
1695 if (!minutes)
1696 result = result / 60;
1697
1698 if (result > MAX_TDKLINE_TIME)
1699 result = MAX_TDKLINE_TIME;
1700
1701 result = result * 60; /* turn it into seconds */
1702
1703 return result;
1704 }
1705
1706 /* valid_wild_card_simple()
1707 *
1708 * inputs - data to check for sufficient non-wildcard characters
1709 * outputs - 1 if valid, else 0
1710 * side effects - none
1711 */
1712 int
1713 valid_wild_card_simple(const char *data)
1714 {
1715 const unsigned char *p = (const unsigned char *)data;
1716 unsigned char tmpch = '\0';
1717 int nonwild = 0;
1718
1719 while ((tmpch = *p++))
1720 {
1721 if (tmpch == '\\')
1722 {
1723 ++p;
1724 if (++nonwild >= ConfigFileEntry.min_nonwildcard_simple)
1725 return 1;
1726 }
1727 else if (!IsMWildChar(tmpch))
1728 {
1729 if (++nonwild >= ConfigFileEntry.min_nonwildcard_simple)
1730 return 1;
1731 }
1732 }
1733
1734 return 0;
1735 }
1736
1737 /* valid_wild_card()
1738 *
1739 * input - pointer to client
1740 * - int flag, 0 for no warning oper 1 for warning oper
1741 * - count of following varargs to check
1742 * output - 0 if not valid, 1 if valid
1743 * side effects - NOTICE is given to source_p if warn is 1
1744 */
1745 int
1746 valid_wild_card(struct Client *source_p, int warn, int count, ...)
1747 {
1748 char tmpch;
1749 int nonwild = 0;
1750 va_list args;
1751
1752 /*
1753 * Now we must check the user and host to make sure there
1754 * are at least NONWILDCHARS non-wildcard characters in
1755 * them, otherwise assume they are attempting to kline
1756 * *@* or some variant of that. This code will also catch
1757 * people attempting to kline *@*.tld, as long as NONWILDCHARS
1758 * is greater than 3. In that case, there are only 3 non-wild
1759 * characters (tld), so if NONWILDCHARS is 4, the kline will
1760 * be disallowed.
1761 * -wnder
1762 */
1763
1764 va_start(args, count);
1765
1766 while (count--)
1767 {
1768 const char *p = va_arg(args, const char *);
1769 if (p == NULL)
1770 continue;
1771
1772 while ((tmpch = *p++))
1773 {
1774 if (!IsKWildChar(tmpch))
1775 {
1776 /*
1777 * If we find enough non-wild characters, we can
1778 * break - no point in searching further.
1779 */
1780 if (++nonwild >= ConfigFileEntry.min_nonwildcard)
1781 {
1782 va_end(args);
1783 return 1;
1784 }
1785 }
1786 }
1787 }
1788
1789 if (warn)
1790 sendto_one(source_p, ":%s NOTICE %s :Please include at least %d non-wildcard characters with the mask",
1791 me.name, source_p->name, ConfigFileEntry.min_nonwildcard);
1792 va_end(args);
1793 return 0;
1794 }
1795
1796 /* XXX should this go into a separate file ? -Dianora */
1797 /* parse_aline
1798 *
1799 * input - pointer to cmd name being used
1800 * - pointer to client using cmd
1801 * - parc parameter count
1802 * - parv[] list of parameters to parse
1803 * - parse_flags bit map of things to test
1804 * - pointer to user or string to parse into
1805 * - pointer to host or NULL to parse into if non NULL
1806 * - pointer to optional tkline time or NULL
1807 * - pointer to target_server to parse into if non NULL
1808 * - pointer to reason to parse into
1809 *
1810 * output - 1 if valid, -1 if not valid
1811 * side effects - A generalised k/d/x etc. line parser,
1812 * "ALINE [time] user@host|string [ON] target :reason"
1813 * will parse returning a parsed user, host if
1814 * h_p pointer is non NULL, string otherwise.
1815 * if tkline_time pointer is non NULL a tk line will be set
1816 * to non zero if found.
1817 * if tkline_time pointer is NULL and tk line is found,
1818 * error is reported.
1819 * if target_server is NULL and an "ON" is found error
1820 * is reported.
1821 * if reason pointer is NULL ignore pointer,
1822 * this allows use of parse_a_line in unkline etc.
1823 *
1824 * - Dianora
1825 */
1826 int
1827 parse_aline(const char *cmd, struct Client *source_p,
1828 int parc, char **parv,
1829 int parse_flags, char **up_p, char **h_p, time_t *tkline_time,
1830 char **target_server, char **reason)
1831 {
1832 int found_tkline_time=0;
1833 static char def_reason[] = "No Reason";
1834 static char user[USERLEN*4+1];
1835 static char host[HOSTLEN*4+1];
1836
1837 parv++;
1838 parc--;
1839
1840 found_tkline_time = valid_tkline(*parv, TK_MINUTES);
1841
1842 if (found_tkline_time != 0)
1843 {
1844 parv++;
1845 parc--;
1846
1847 if (tkline_time != NULL)
1848 *tkline_time = found_tkline_time;
1849 else
1850 {
1851 sendto_one(source_p, ":%s NOTICE %s :temp_line not supported by %s",
1852 me.name, source_p->name, cmd);
1853 return -1;
1854 }
1855 }
1856
1857 if (parc == 0)
1858 {
1859 sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
1860 me.name, source_p->name, cmd);
1861 return -1;
1862 }
1863
1864 if (h_p == NULL)
1865 *up_p = *parv;
1866 else
1867 {
1868 if (find_user_host(source_p, *parv, user, host, parse_flags) == 0)
1869 return -1;
1870
1871 *up_p = user;
1872 *h_p = host;
1873 }
1874
1875 parc--;
1876 parv++;
1877
1878 if (parc != 0)
1879 {
1880 if (irccmp(*parv, "ON") == 0)
1881 {
1882 parc--;
1883 parv++;
1884
1885 if (target_server == NULL)
1886 {
1887 sendto_one(source_p, ":%s NOTICE %s :ON server not supported by %s",
1888 me.name, source_p->name, cmd);
1889 return -1;
1890 }
1891
1892 if (!HasOFlag(source_p, OPER_FLAG_REMOTEBAN))
1893 {
1894 sendto_one(source_p, form_str(ERR_NOPRIVS),
1895 me.name, source_p->name, "remoteban");
1896 return -1;
1897 }
1898
1899 if (parc == 0 || EmptyString(*parv))
1900 {
1901 sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
1902 me.name, source_p->name, cmd);
1903 return -1;
1904 }
1905
1906 *target_server = *parv;
1907 parc--;
1908 parv++;
1909 }
1910 else
1911 {
1912 /* Make sure target_server *is* NULL if no ON server found
1913 * caller probably NULL'd it first, but no harm to do it again -db
1914 */
1915 if (target_server != NULL)
1916 *target_server = NULL;
1917 }
1918 }
1919
1920 if (h_p != NULL)
1921 {
1922 if (strchr(user, '!') != NULL)
1923 {
1924 sendto_one(source_p, ":%s NOTICE %s :Invalid character '!' in kline",
1925 me.name, source_p->name);
1926 return -1;
1927 }
1928
1929 if ((parse_flags & AWILD) && !valid_wild_card(source_p, 1, 2, *up_p, *h_p))
1930 return -1;
1931 }
1932 else
1933 if ((parse_flags & AWILD) && !valid_wild_card(source_p, 1, 1, *up_p))
1934 return -1;
1935
1936 if (reason != NULL)
1937 {
1938 if (parc != 0 && !EmptyString(*parv))
1939 {
1940 *reason = *parv;
1941 if (!valid_comment(source_p, *reason, 1))
1942 return -1;
1943 }
1944 else
1945 *reason = def_reason;
1946 }
1947
1948 return 1;
1949 }
1950
1951 /* find_user_host()
1952 *
1953 * inputs - pointer to client placing kline
1954 * - pointer to user_host_or_nick
1955 * - pointer to user buffer
1956 * - pointer to host buffer
1957 * output - 0 if not ok to kline, 1 to kline i.e. if valid user host
1958 * side effects -
1959 */
1960 static int
1961 find_user_host(struct Client *source_p, char *user_host_or_nick,
1962 char *luser, char *lhost, unsigned int flags)
1963 {
1964 struct Client *target_p = NULL;
1965 char *hostp = NULL;
1966
1967 if (lhost == NULL)
1968 {
1969 strlcpy(luser, user_host_or_nick, USERLEN*4 + 1);
1970 return 1;
1971 }
1972
1973 if ((hostp = strchr(user_host_or_nick, '@')) || *user_host_or_nick == '*')
1974 {
1975 /* Explicit user@host mask given */
1976
1977 if (hostp != NULL) /* I'm a little user@host */
1978 {
1979 *(hostp++) = '\0'; /* short and squat */
1980 if (*user_host_or_nick)
1981 strlcpy(luser, user_host_or_nick, USERLEN*4 + 1); /* here is my user */
1982 else
1983 strcpy(luser, "*");
1984
1985 if (*hostp)
1986 strlcpy(lhost, hostp, HOSTLEN + 1); /* here is my host */
1987 else
1988 strcpy(lhost, "*");
1989 }
1990 else
1991 {
1992 luser[0] = '*'; /* no @ found, assume its *@somehost */
1993 luser[1] = '\0';
1994 strlcpy(lhost, user_host_or_nick, HOSTLEN*4 + 1);
1995 }
1996
1997 return 1;
1998 }
1999 else
2000 {
2001 /* Try to find user@host mask from nick */
2002 /* Okay to use source_p as the first param, because source_p == client_p */
2003 if ((target_p =
2004 find_chasing(source_p, user_host_or_nick, NULL)) == NULL)
2005 return 0;
2006
2007 if (IsExemptKline(target_p))
2008 {
2009 if (!IsServer(source_p))
2010 sendto_one(source_p,
2011 ":%s NOTICE %s :%s is E-lined",
2012 me.name, source_p->name, target_p->name);
2013 return 0;
2014 }
2015
2016 /*
2017 * turn the "user" bit into "*user", blow away '~'
2018 * if found in original user name (non-idented)
2019 */
2020 strlcpy(luser, target_p->username, USERLEN*4 + 1);
2021
2022 if (target_p->username[0] == '~')
2023 luser[0] = '*';
2024
2025 if (target_p->sockhost[0] == '\0' ||
2026 (target_p->sockhost[0] == '0' && target_p->sockhost[1] == '\0'))
2027 strlcpy(lhost, target_p->host, HOSTLEN*4 + 1);
2028 else
2029 strlcpy(lhost, target_p->sockhost, HOSTLEN*4 + 1);
2030 return 1;
2031 }
2032
2033 return 0;
2034 }
2035
2036 /* valid_comment()
2037 *
2038 * inputs - pointer to client
2039 * - pointer to comment
2040 * output - 0 if no valid comment,
2041 * - 1 if valid
2042 * side effects - truncates reason where necessary
2043 */
2044 int
2045 valid_comment(struct Client *source_p, char *comment, int warn)
2046 {
2047 if (strlen(comment) > REASONLEN)
2048 comment[REASONLEN-1] = '\0';
2049
2050 return 1;
2051 }
2052
2053 /* match_conf_password()
2054 *
2055 * inputs - pointer to given password
2056 * - pointer to Conf
2057 * output - 1 or 0 if match
2058 * side effects - none
2059 */
2060 int
2061 match_conf_password(const char *password, const struct MaskItem *conf)
2062 {
2063 const char *encr = NULL;
2064
2065 if (EmptyString(password) || EmptyString(conf->passwd))
2066 return 0;
2067
2068 if (conf->flags & CONF_FLAGS_ENCRYPTED)
2069 encr = crypt(password, conf->passwd);
2070 else
2071 encr = password;
2072
2073 return !strcmp(encr, conf->passwd);
2074 }
2075
2076 /*
2077 * cluster_a_line
2078 *
2079 * inputs - client sending the cluster
2080 * - command name "KLINE" "XLINE" etc.
2081 * - capab -- CAP_KLN etc. from s_serv.h
2082 * - cluster type -- CLUSTER_KLINE etc. from conf.h
2083 * - pattern and args to send along
2084 * output - none
2085 * side effects - Take source_p send the pattern with args given
2086 * along to all servers that match capab and cluster type
2087 */
2088 void
2089 cluster_a_line(struct Client *source_p, const char *command,
2090 int capab, int cluster_type, const char *pattern, ...)
2091 {
2092 va_list args;
2093 char buffer[IRCD_BUFSIZE];
2094 const dlink_node *ptr = NULL;
2095
2096 va_start(args, pattern);
2097 vsnprintf(buffer, sizeof(buffer), pattern, args);
2098 va_end(args);
2099
2100 DLINK_FOREACH(ptr, cluster_items.head)
2101 {
2102 const struct MaskItem *conf = ptr->data;
2103
2104 if (conf->flags & cluster_type)
2105 sendto_match_servs(source_p, conf->name, CAP_CLUSTER|capab,
2106 "%s %s %s", command, conf->name, buffer);
2107 }
2108 }
2109
2110 /*
2111 * split_nuh
2112 *
2113 * inputs - pointer to original mask (modified in place)
2114 * - pointer to pointer where nick should go
2115 * - pointer to pointer where user should go
2116 * - pointer to pointer where host should go
2117 * output - NONE
2118 * side effects - mask is modified in place
2119 * If nick pointer is NULL, ignore writing to it
2120 * this allows us to use this function elsewhere.
2121 *
2122 * mask nick user host
2123 * ---------------------- ------- ------- ------
2124 * Dianora!db@db.net Dianora db db.net
2125 * Dianora Dianora * *
2126 * db.net * * db.net
2127 * OR if nick pointer is NULL
2128 * Dianora - * Dianora
2129 * Dianora! Dianora * *
2130 * Dianora!@ Dianora * *
2131 * Dianora!db Dianora db *
2132 * Dianora!@db.net Dianora * db.net
2133 * db@db.net * db db.net
2134 * !@ * * *
2135 * @ * * *
2136 * ! * * *
2137 */
2138 void
2139 split_nuh(struct split_nuh_item *const iptr)
2140 {
2141 char *p = NULL, *q = NULL;
2142
2143 if (iptr->nickptr)
2144 strlcpy(iptr->nickptr, "*", iptr->nicksize);
2145 if (iptr->userptr)
2146 strlcpy(iptr->userptr, "*", iptr->usersize);
2147 if (iptr->hostptr)
2148 strlcpy(iptr->hostptr, "*", iptr->hostsize);
2149
2150 if ((p = strchr(iptr->nuhmask, '!')))
2151 {
2152 *p = '\0';
2153
2154 if (iptr->nickptr && *iptr->nuhmask != '\0')
2155 strlcpy(iptr->nickptr, iptr->nuhmask, iptr->nicksize);
2156
2157 if ((q = strchr(++p, '@')))
2158 {
2159 *q++ = '\0';
2160
2161 if (*p != '\0')
2162 strlcpy(iptr->userptr, p, iptr->usersize);
2163
2164 if (*q != '\0')
2165 strlcpy(iptr->hostptr, q, iptr->hostsize);
2166 }
2167 else
2168 {
2169 if (*p != '\0')
2170 strlcpy(iptr->userptr, p, iptr->usersize);
2171 }
2172 }
2173 else
2174 {
2175 /* No ! found so lets look for a user@host */
2176 if ((p = strchr(iptr->nuhmask, '@')))
2177 {
2178 /* if found a @ */
2179 *p++ = '\0';
2180
2181 if (*iptr->nuhmask != '\0')
2182 strlcpy(iptr->userptr, iptr->nuhmask, iptr->usersize);
2183
2184 if (*p != '\0')
2185 strlcpy(iptr->hostptr, p, iptr->hostsize);
2186 }
2187 else
2188 {
2189 /* no @ found */
2190 if (!iptr->nickptr || strpbrk(iptr->nuhmask, ".:"))
2191 strlcpy(iptr->hostptr, iptr->nuhmask, iptr->hostsize);
2192 else
2193 strlcpy(iptr->nickptr, iptr->nuhmask, iptr->nicksize);
2194 }
2195 }
2196 }

Properties

Name Value
svn:eol-style native
svn:keywords Id Revision