ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/branches/8.2.x/src/conf.c
Revision: 5810
Committed: Thu Apr 23 17:27:17 2015 UTC (8 years, 11 months ago) by michael
Content type: text/x-csrc
File size: 50852 byte(s)
Log Message:
- Removed glines
- Added kline_min_cidr, kline_min_cidr6, dline_min_cidr and
  dline_min_cidr6 configuration options
- m_dline.c: allow d-lines to be added even if an exempt {} exists

File Contents

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

Properties

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