ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/src/conf.c
(Generate patch)

Comparing:
ircd-hybrid-7.2/src/s_conf.c (file contents), Revision 948 by michael, Tue Jul 21 17:34:06 2009 UTC vs.
ircd-hybrid-8/src/conf.c (file contents), Revision 1388 by michael, Tue May 1 11:59:09 2012 UTC

# Line 1 | Line 1
1   /*
2   *  ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3 < *  s_conf.c: Configuration file functions.
3 > *  conf.c: Configuration file functions.
4   *
5   *  Copyright (C) 2002 by the past and present ircd coders, and others.
6   *
# Line 23 | Line 23
23   */
24  
25   #include "stdinc.h"
26 + #include "list.h"
27   #include "ircd_defs.h"
28 < #include "tools.h"
29 < #include "s_conf.h"
28 > #include "balloc.h"
29 > #include "conf.h"
30   #include "s_serv.h"
31   #include "resv.h"
32   #include "channel.h"
33   #include "client.h"
33 #include "common.h"
34   #include "event.h"
35 #include "hash.h"
35   #include "hook.h"
36   #include "irc_string.h"
38 #include "sprintf_irc.h"
37   #include "s_bsd.h"
40 #include "irc_getaddrinfo.h"
38   #include "ircd.h"
42 #include "list.h"
39   #include "listener.h"
40   #include "hostmask.h"
41   #include "modules.h"
42   #include "numeric.h"
43   #include "fdlist.h"
44 < #include "s_log.h"
44 > #include "log.h"
45   #include "send.h"
46   #include "s_gline.h"
51 #include "fileio.h"
47   #include "memory.h"
48   #include "irc_res.h"
49   #include "userhost.h"
50   #include "s_user.h"
51   #include "channel_mode.h"
52 + #include "parse.h"
53 + #include "s_misc.h"
54  
55   struct Callback *client_check_cb = NULL;
56   struct config_server_hide ConfigServerHide;
57  
58   /* general conf items link list root, other than k lines etc. */
59 + dlink_list service_items = { NULL, NULL, 0 };
60   dlink_list server_items  = { NULL, NULL, 0 };
61   dlink_list cluster_items = { NULL, NULL, 0 };
64 dlink_list hub_items     = { NULL, NULL, 0 };
65 dlink_list leaf_items    = { NULL, NULL, 0 };
62   dlink_list oconf_items   = { NULL, NULL, 0 };
63   dlink_list uconf_items   = { NULL, NULL, 0 };
64   dlink_list xconf_items   = { NULL, NULL, 0 };
# Line 72 | Line 68 | dlink_list nresv_items   = { NULL, NULL,
68   dlink_list class_items   = { NULL, NULL, 0 };
69   dlink_list gdeny_items   = { NULL, NULL, 0 };
70  
75 dlink_list temporary_klines  = { NULL, NULL, 0 };
76 dlink_list temporary_dlines  = { NULL, NULL, 0 };
71   dlink_list temporary_xlines  = { NULL, NULL, 0 };
78 dlink_list temporary_rklines = { NULL, NULL, 0 };
79 dlink_list temporary_glines  = { NULL, NULL, 0 };
80 dlink_list temporary_rxlines = { NULL, NULL, 0 };
72   dlink_list temporary_resv = { NULL, NULL, 0 };
73  
74   extern unsigned int lineno;
75   extern char linebuf[];
76   extern char conffilebuf[IRCD_BUFSIZE];
86 extern char yytext[];
77   extern int yyparse(); /* defined in y.tab.c */
78 < int ypass = 1; /* used by yyparse()      */
78 >
79 > struct conf_parser_context conf_parser_ctx = { 0, 0, NULL };
80  
81   /* internally defined functions */
82 < static void lookup_confhost(struct ConfItem *);
92 < static void set_default_conf(void);
93 < static void validate_conf(void);
94 < static void read_conf(FBFILE *);
82 > static void read_conf(FILE *);
83   static void clear_out_old_conf(void);
84   static void flush_deleted_I_P(void);
85   static void expire_tklines(dlink_list *);
# Line 114 | Line 102 | static void destroy_cidr_class(struct Cl
102  
103   static void flags_to_ascii(unsigned int, const unsigned int[], char *, int);
104  
117 FBFILE *conf_fbfile_in = NULL;
118
105   /* address of default class conf */
106   static struct ConfItem *class_default;
107  
# Line 138 | Line 124 | static BlockHeap *ip_entry_heap = NULL;
124   static int ip_entries_count = 0;
125  
126  
127 < inline void *
127 > void *
128   map_to_conf(struct ConfItem *aconf)
129   {
130    void *conf;
131 <  conf = (void *)((unsigned long)aconf +
132 <                  (unsigned long)sizeof(struct ConfItem));
131 >  conf = (void *)((uintptr_t)aconf +
132 >                  (uintptr_t)sizeof(struct ConfItem));
133    return(conf);
134   }
135  
136 < inline struct ConfItem *
136 > struct ConfItem *
137   unmap_conf_item(void *aconf)
138   {
139    struct ConfItem *conf;
140  
141 <  conf = (struct ConfItem *)((unsigned long)aconf -
142 <                             (unsigned long)sizeof(struct ConfItem));
141 >  conf = (struct ConfItem *)((uintptr_t)aconf -
142 >                             (uintptr_t)sizeof(struct ConfItem));
143    return(conf);
144   }
145  
# Line 168 | Line 154 | unmap_conf_item(void *aconf)
154   * if successful save hp in the conf item it was called with
155   */
156   static void
157 < conf_dns_callback(void *vptr, struct DNSReply *reply)
157 > conf_dns_callback(void *vptr, const struct irc_ssaddr *addr, const char *name)
158   {
159 <  struct AccessItem *aconf = (struct AccessItem *)vptr;
174 <  struct ConfItem *conf;
159 >  struct AccessItem *aconf = vptr;
160  
161 <  MyFree(aconf->dns_query);
177 <  aconf->dns_query = NULL;
161 >  aconf->dns_pending = 0;
162  
163 <  if (reply != NULL)
164 <    memcpy(&aconf->ipnum, &reply->addr, sizeof(reply->addr));
165 <  else {
166 <    ilog(L_NOTICE, "Host not found: %s, ignoring connect{} block",
183 <         aconf->host);
184 <    conf = unmap_conf_item(aconf);
185 <    sendto_realops_flags(UMODE_ALL, L_ALL,
186 <                         "Ignoring connect{} block for %s - host not found",
187 <                         conf->name);
188 <    delete_conf_item(conf);
189 <  }
163 >  if (addr != NULL)
164 >    memcpy(&aconf->ipnum, addr, sizeof(aconf->ipnum));
165 >  else
166 >    aconf->dns_failed = 1;
167   }
168  
169   /* conf_dns_lookup()
# Line 198 | Line 175 | conf_dns_callback(void *vptr, struct DNS
175   static void
176   conf_dns_lookup(struct AccessItem *aconf)
177   {
178 <  if (aconf->dns_query == NULL)
178 >  if (!aconf->dns_pending)
179    {
180 <    aconf->dns_query = MyMalloc(sizeof(struct DNSQuery));
181 <    aconf->dns_query->ptr = aconf;
205 <    aconf->dns_query->callback = conf_dns_callback;
206 <    gethost_byname(aconf->host, aconf->dns_query);
180 >    aconf->dns_pending = 1;
181 >    gethost_byname(conf_dns_callback, aconf, aconf->host);
182    }
183   }
184  
# Line 274 | Line 249 | make_conf_item(ConfType type)
249      aconf->status = status;
250      break;
251  
277  case LEAF_TYPE:
278    conf = (struct ConfItem *)MyMalloc(sizeof(struct ConfItem) +
279                                       sizeof(struct MatchItem));
280    dlinkAdd(conf, &conf->node, &leaf_items);
281    break;
282
283  case HUB_TYPE:
284    conf = (struct ConfItem *)MyMalloc(sizeof(struct ConfItem) +
285                                       sizeof(struct MatchItem));
286    dlinkAdd(conf, &conf->node, &hub_items);
287    break;
288
252    case ULINE_TYPE:
253      conf = (struct ConfItem *)MyMalloc(sizeof(struct ConfItem) +
254                                         sizeof(struct MatchItem));
# Line 303 | Line 266 | make_conf_item(ConfType type)
266                                         sizeof(struct MatchItem));
267      dlinkAdd(conf, &conf->node, &xconf_items);
268      break;
269 <
269 > #ifdef HAVE_LIBPCRE
270    case RXLINE_TYPE:
271      conf = (struct ConfItem *)MyMalloc(sizeof(struct ConfItem) +
272                                         sizeof(struct MatchItem));
# Line 317 | Line 280 | make_conf_item(ConfType type)
280      aconf->status = CONF_KLINE;
281      dlinkAdd(conf, &conf->node, &rkconf_items);
282      break;
283 <
283 > #endif
284    case CLUSTER_TYPE:
285      conf = (struct ConfItem *)MyMalloc(sizeof(struct ConfItem));
286      dlinkAdd(conf, &conf->node, &cluster_items);
# Line 334 | Line 297 | make_conf_item(ConfType type)
297      dlinkAdd(conf, &conf->node, &nresv_items);
298      break;
299  
300 +  case SERVICE_TYPE:
301 +    status = CONF_SERVICE;
302 +    conf = MyMalloc(sizeof(struct ConfItem));
303 +    dlinkAdd(conf, &conf->node, &service_items);
304 +    break;
305 +
306    case CLASS_TYPE:
307      conf = MyMalloc(sizeof(struct ConfItem) +
308                             sizeof(struct ClassItem));
# Line 341 | Line 310 | make_conf_item(ConfType type)
310  
311      aclass = map_to_conf(conf);
312      aclass->active = 1;
313 <    ConFreq(aclass) = DEFAULT_CONNECTFREQUENCY;
314 <    PingFreq(aclass) = DEFAULT_PINGFREQUENCY;
315 <    MaxTotal(aclass) = MAXIMUM_LINKS_DEFAULT;
316 <    MaxSendq(aclass) = DEFAULT_SENDQ;
313 >    aclass->con_freq = DEFAULT_CONNECTFREQUENCY;
314 >    aclass->ping_freq = DEFAULT_PINGFREQUENCY;
315 >    aclass->max_total = MAXIMUM_LINKS_DEFAULT;
316 >    aclass->max_sendq = DEFAULT_SENDQ;
317  
318      break;
319  
# Line 362 | Line 331 | make_conf_item(ConfType type)
331   void
332   delete_conf_item(struct ConfItem *conf)
333   {
334 <  dlink_node *m = NULL;
334 >  dlink_node *m = NULL, *m_next = NULL;
335    struct MatchItem *match_item;
336    struct AccessItem *aconf;
337    ConfType type = conf->type;
# Line 381 | Line 350 | delete_conf_item(struct ConfItem *conf)
350    case SERVER_TYPE:
351      aconf = map_to_conf(conf);
352  
353 <    if (aconf->dns_query != NULL)
354 <    {
386 <      delete_resolver_queries(aconf->dns_query);
387 <      MyFree(aconf->dns_query);
388 <    }
353 >    if (aconf->dns_pending)
354 >      delete_resolver_queries(aconf);
355      if (aconf->passwd != NULL)
356        memset(aconf->passwd, 0, strlen(aconf->passwd));
357      if (aconf->spasswd != NULL)
# Line 398 | Line 364 | delete_conf_item(struct ConfItem *conf)
364      MyFree(aconf->oper_reason);
365      MyFree(aconf->user);
366      MyFree(aconf->host);
367 <    MyFree(aconf->fakename);
367 >    MyFree(aconf->cipher_list);
368   #ifdef HAVE_LIBCRYPTO
369      if (aconf->rsa_public_key)
370        RSA_free(aconf->rsa_public_key);
# Line 425 | Line 391 | delete_conf_item(struct ConfItem *conf)
391  
392      case SERVER_TYPE:
393        aconf = map_to_conf(conf);
394 +
395 +      DLINK_FOREACH_SAFE(m, m_next, aconf->hub_list.head)
396 +      {
397 +        MyFree(m->data);
398 +        free_dlink_node(m);
399 +      }
400 +
401 +      DLINK_FOREACH_SAFE(m, m_next, aconf->leaf_list.head)
402 +      {
403 +        MyFree(m->data);
404 +        free_dlink_node(m);  
405 +      }
406 +
407        if (!IsConfIllegal(aconf))
408          dlinkDelete(&conf->node, &server_items);
409        MyFree(conf);
# Line 435 | Line 414 | delete_conf_item(struct ConfItem *conf)
414      }
415      break;
416  
438  case HUB_TYPE:
439    match_item = map_to_conf(conf);
440    MyFree(match_item->user);
441    MyFree(match_item->host);
442    MyFree(match_item->reason);
443    MyFree(match_item->oper_reason);
444    /* If marked illegal, its already been pulled off of the hub_items list */
445    if (!match_item->illegal)
446      dlinkDelete(&conf->node, &hub_items);
447    MyFree(conf);
448    break;
449
450  case LEAF_TYPE:
451    match_item = map_to_conf(conf);
452    MyFree(match_item->user);
453    MyFree(match_item->host);
454    MyFree(match_item->reason);
455    MyFree(match_item->oper_reason);
456    /* If marked illegal, its already been pulled off of the leaf_items list */
457    if (!match_item->illegal)
458      dlinkDelete(&conf->node, &leaf_items);
459    MyFree(conf);
460    break;
461
417    case ULINE_TYPE:
418      match_item = map_to_conf(conf);
419      MyFree(match_item->user);
# Line 478 | Line 433 | delete_conf_item(struct ConfItem *conf)
433      dlinkDelete(&conf->node, &xconf_items);
434      MyFree(conf);
435      break;
436 <
436 > #ifdef HAVE_LIBPCRE
437    case RKLINE_TYPE:
438      aconf = map_to_conf(conf);
439      MyFree(aconf->regexuser);
# Line 501 | Line 456 | delete_conf_item(struct ConfItem *conf)
456      dlinkDelete(&conf->node, &rxconf_items);
457      MyFree(conf);
458      break;
459 <
459 > #endif
460    case NRESV_TYPE:
461      match_item = map_to_conf(conf);
462      MyFree(match_item->user);
# Line 543 | Line 498 | delete_conf_item(struct ConfItem *conf)
498      MyFree(conf);
499      break;
500  
501 +  case SERVICE_TYPE:
502 +    dlinkDelete(&conf->node, &service_items);
503 +    MyFree(conf);
504 +    break;
505 +
506    default:
507      break;
508    }
# Line 576 | Line 536 | static const unsigned int shared_bit_tab
536   * side effects -
537   */
538   void
539 < report_confitem_types(struct Client *source_p, ConfType type, int temp)
539 > report_confitem_types(struct Client *source_p, ConfType type)
540   {
541 <  dlink_node *ptr = NULL;
541 >  dlink_node *ptr = NULL, *dptr = NULL;
542    struct ConfItem *conf = NULL;
543    struct AccessItem *aconf = NULL;
544    struct MatchItem *matchitem = NULL;
545    struct ClassItem *classitem = NULL;
546    char buf[12];
547    char *p = NULL;
588  const char *pfx = NULL;
548  
549    switch (type)
550    {
# Line 628 | Line 587 | report_confitem_types(struct Client *sou
587      }
588      break;
589  
590 + #ifdef HAVE_LIBPCRE
591    case RXLINE_TYPE:
592      DLINK_FOREACH(ptr, rxconf_items.head)
593      {
# Line 636 | Line 596 | report_confitem_types(struct Client *sou
596  
597        sendto_one(source_p, form_str(RPL_STATSXLINE),
598                   me.name, source_p->name,
599 <                 matchitem->hold ? "xR": "XR", matchitem->count,
599 >                 "XR", matchitem->count,
600                   conf->name, matchitem->reason);
601      }
602      break;
603  
604    case RKLINE_TYPE:
645    pfx = temp ? "kR" : "KR";
646
605      DLINK_FOREACH(ptr, rkconf_items.head)
606      {
607        aconf = map_to_conf((conf = ptr->data));
608  
651      if (temp && !(conf->flags & CONF_FLAGS_TEMPORARY))
652        continue;
653
609        sendto_one(source_p, form_str(RPL_STATSKLINE), me.name,
610 <                 source_p->name, pfx, aconf->host, aconf->user,
610 >                 source_p->name, "KR", aconf->host, aconf->user,
611                   aconf->reason, aconf->oper_reason ? aconf->oper_reason : "");
612      }
613      break;
614 + #endif
615  
616    case ULINE_TYPE:
617      DLINK_FOREACH(ptr, uconf_items.head)
# Line 700 | Line 656 | report_confitem_types(struct Client *sou
656        aconf = map_to_conf(conf);
657  
658        /* Don't allow non opers to see oper privs */
659 <      if (IsOper(source_p))
659 >      if (HasUMode(source_p, UMODE_OPER))
660          sendto_one(source_p, form_str(RPL_STATSOLINE),
661                     me.name, source_p->name, 'O', aconf->user, aconf->host,
662                     conf->name, oper_privs_as_string(aconf->port),
# Line 720 | Line 676 | report_confitem_types(struct Client *sou
676        classitem = map_to_conf(conf);
677        sendto_one(source_p, form_str(RPL_STATSYLINE),
678                   me.name, source_p->name, 'Y',
679 <                 conf->name, PingFreq(classitem),
680 <                 ConFreq(classitem),
681 <                 MaxTotal(classitem), MaxSendq(classitem),
682 <                 CurrUserCount(classitem),
679 >                 conf->name, classitem->ping_freq,
680 >                 classitem->con_freq,
681 >                 classitem->max_total, classitem->max_sendq,
682 >                 classitem->curr_user_count,
683                   classitem->active ? "active" : "disabled");
684      }
685      break;
# Line 732 | Line 688 | report_confitem_types(struct Client *sou
688    case CLIENT_TYPE:
689      break;
690  
691 +  case SERVICE_TYPE:
692 +    DLINK_FOREACH(ptr, service_items.head)
693 +    {
694 +      conf = ptr->data;
695 +      sendto_one(source_p, form_str(RPL_STATSSERVICE),
696 +                 me.name, source_p->name, 'S', "*", conf->name, 0, 0);
697 +    }
698 +    break;
699 +
700    case SERVER_TYPE:
701      DLINK_FOREACH(ptr, server_items.head)
702      {
# Line 744 | Line 709 | report_confitem_types(struct Client *sou
709  
710        if (IsConfAllowAutoConn(aconf))
711          *p++ = 'A';
712 <      if (IsConfCryptLink(aconf))
713 <        *p++ = 'C';
749 <      if (aconf->fakename)
750 <        *p++ = 'M';
712 >      if (IsConfSSL(aconf))
713 >        *p++ = 'S';
714        if (IsConfTopicBurst(aconf))
715          *p++ = 'T';
753      if (IsConfCompressed(aconf))
754        *p++ = 'Z';
716        if (buf[0] == '\0')
717          *p++ = '*';
718  
# Line 760 | Line 721 | report_confitem_types(struct Client *sou
721        /*
722         * Allow admins to see actual ips unless hide_server_ips is enabled
723         */
724 <      if (!ConfigServerHide.hide_server_ips && IsAdmin(source_p))
724 >      if (!ConfigServerHide.hide_server_ips && HasUMode(source_p, UMODE_ADMIN))
725          sendto_one(source_p, form_str(RPL_STATSCLINE),
726                     me.name, source_p->name, 'C', aconf->host,
727                     buf, conf->name, aconf->port,
# Line 774 | Line 735 | report_confitem_types(struct Client *sou
735      break;
736  
737    case HUB_TYPE:
738 <    DLINK_FOREACH(ptr, hub_items.head)
738 >    DLINK_FOREACH(ptr, server_items.head)
739      {
740        conf = ptr->data;
741 <      matchitem = map_to_conf(conf);
742 <      sendto_one(source_p, form_str(RPL_STATSHLINE), me.name,
743 <                 source_p->name, 'H', matchitem->host, conf->name, 0, "*");
741 >      aconf = map_to_conf(conf);
742 >
743 >      DLINK_FOREACH(dptr, aconf->hub_list.head)
744 >        sendto_one(source_p, form_str(RPL_STATSHLINE), me.name,
745 >                   source_p->name, 'H', dptr->data, conf->name, 0, "*");
746      }
747      break;
748  
749    case LEAF_TYPE:
750 <    DLINK_FOREACH(ptr, leaf_items.head)
750 >    DLINK_FOREACH(ptr, server_items.head)
751      {
752        conf = ptr->data;
753 <      matchitem = map_to_conf(conf);
754 <      sendto_one(source_p, form_str(RPL_STATSLLINE), me.name,
755 <                 source_p->name, 'L', matchitem->host, conf->name, 0, "*");
753 >      aconf = map_to_conf(conf);
754 >
755 >      DLINK_FOREACH(dptr, aconf->leaf_list.head)
756 >        sendto_one(source_p, form_str(RPL_STATSLLINE), me.name,
757 >                   source_p->name, 'L', dptr->data, conf->name, 0, "*");
758      }
759      break;
760  
# Line 800 | Line 765 | report_confitem_types(struct Client *sou
765    case CRESV_TYPE:
766    case NRESV_TYPE:
767    case CLUSTER_TYPE:
768 +  default:
769      break;
770    }
771   }
# Line 826 | Line 792 | check_client(va_list args)
792  
793    /* I'm already in big trouble if source_p->localClient is NULL -db */
794    if ((i = verify_access(source_p, username)))
795 <    ilog(L_INFO, "Access denied: %s[%s]",
795 >    ilog(LOG_TYPE_IRCD, "Access denied: %s[%s]",
796           source_p->name, source_p->sockhost);
797  
798    switch (i)
# Line 836 | Line 802 | check_client(va_list args)
802                             "Too many on IP for %s (%s).",
803                             get_client_name(source_p, SHOW_IP),
804                             source_p->sockhost);
805 <      ilog(L_INFO,"Too many connections on IP from %s.",
805 >      ilog(LOG_TYPE_IRCD, "Too many connections on IP from %s.",
806             get_client_name(source_p, SHOW_IP));
807        ++ServerStats.is_ref;
808        exit_client(source_p, &me, "No more connections allowed on that IP");
# Line 847 | Line 813 | check_client(va_list args)
813                             "I-line is full for %s (%s).",
814                             get_client_name(source_p, SHOW_IP),
815                             source_p->sockhost);
816 <      ilog(L_INFO,"Too many connections from %s.",
816 >      ilog(LOG_TYPE_IRCD, "Too many connections from %s.",
817             get_client_name(source_p, SHOW_IP));
818        ++ServerStats.is_ref;
819        exit_client(source_p, &me,
# Line 864 | Line 830 | check_client(va_list args)
830                             source_p->sockhost,
831                             source_p->localClient->listener->name,
832                             source_p->localClient->listener->port);
833 <      ilog(L_INFO,
833 >      ilog(LOG_TYPE_IRCD,
834            "Unauthorized client connection from %s on [%s/%u].",
835            get_client_name(source_p, SHOW_IP),
836            source_p->localClient->listener->name,
# Line 1027 | Line 993 | attach_iline(struct Client *client_p, st
993     * setting a_limit_reached if any limit is reached.
994     * - Dianora
995     */
996 <  if (MaxTotal(aclass) != 0 && CurrUserCount(aclass) >= MaxTotal(aclass))
996 >  if (aclass->max_total != 0 && aclass->curr_user_count >= aclass->max_total)
997      a_limit_reached = 1;
998 <  else if (MaxPerIp(aclass) != 0 && ip_found->count > MaxPerIp(aclass))
998 >  else if (aclass->max_perip != 0 && ip_found->count > aclass->max_perip)
999      a_limit_reached = 1;
1000 <  else if (MaxLocal(aclass) != 0 && local >= MaxLocal(aclass))
1000 >  else if (aclass->max_local != 0 && local >= aclass->max_local)
1001      a_limit_reached = 1;
1002 <  else if (MaxGlobal(aclass) != 0 && global >= MaxGlobal(aclass))
1002 >  else if (aclass->max_global != 0 && global >= aclass->max_global)
1003      a_limit_reached = 1;
1004 <  else if (MaxIdent(aclass) != 0 && ident >= MaxIdent(aclass) &&
1004 >  else if (aclass->max_ident != 0 && ident >= aclass->max_ident &&
1005             client_p->username[0] != '~')
1006      a_limit_reached = 1;
1007  
# Line 1191 | Line 1157 | hash_ip(struct irc_ssaddr *addr)
1157    {
1158      struct sockaddr_in *v4 = (struct sockaddr_in *)addr;
1159      int hash;
1160 <    u_int32_t ip;
1160 >    uint32_t ip;
1161  
1162      ip   = ntohl(v4->sin_addr.s_addr);
1163      hash = ((ip >> 12) + ip) & (IP_HASH_SIZE-1);
# Line 1202 | Line 1168 | hash_ip(struct irc_ssaddr *addr)
1168    {
1169      int hash;
1170      struct sockaddr_in6 *v6 = (struct sockaddr_in6 *)addr;
1171 <    u_int32_t *ip = (u_int32_t *)&v6->sin6_addr.s6_addr;
1171 >    uint32_t *ip = (uint32_t *)&v6->sin6_addr.s6_addr;
1172  
1173      hash  = ip[0] ^ ip[3];
1174      hash ^= hash >> 16;  
# Line 1318 | Line 1284 | detach_conf(struct Client *client_p, Con
1284  
1285          assert(aconf->clients > 0);
1286  
1287 <        if ((aclass_conf = ClassPtr(aconf)) != NULL)
1287 >        if ((aclass_conf = aconf->class_ptr) != NULL)
1288          {
1289            aclass = map_to_conf(aclass_conf);
1290  
# Line 1334 | Line 1300 | detach_conf(struct Client *client_p, Con
1300            delete_conf_item(conf);
1301  
1302          break;
1337
1338      case LEAF_TYPE:
1339      case HUB_TYPE:
1340        match_item = map_to_conf(conf);
1341        if (match_item->ref_count == 0 && match_item->illegal)
1342          delete_conf_item(conf);
1343        break;
1303        default:
1304          break;
1305        }
# Line 1384 | Line 1343 | attach_conf(struct Client *client_p, str
1343                               &client_p->localClient->ip, aclass))
1344          return TOO_MANY;    /* Already at maximum allowed */
1345  
1346 <    CurrUserCount(aclass)++;
1346 >    aclass->curr_user_count++;
1347      aconf->clients++;
1348    }
1390  else if (conf->type == HUB_TYPE || conf->type == LEAF_TYPE)
1391  {
1392    struct MatchItem *match_item = map_to_conf(conf);
1393    match_item->ref_count++;
1394  }
1349  
1350    dlinkAdd(conf, make_dlink_node(), &client_p->localClient->confs);
1351  
# Line 1480 | Line 1434 | find_conf_exact(ConfType type, const cha
1434      {
1435        struct ClassItem *aclass = map_to_conf(aconf->class_ptr);
1436  
1437 <      if (aconf->clients >= MaxTotal(aclass))
1437 >      if (aconf->clients >= aclass->max_total)
1438          continue;
1439      }
1440  
# Line 1552 | Line 1506 | map_to_list(ConfType type)
1506    case SERVER_TYPE:
1507      return(&server_items);
1508      break;
1509 +  case SERVICE_TYPE:
1510 +    return(&service_items);
1511 +    break;
1512    case CLUSTER_TYPE:
1513      return(&cluster_items);
1514      break;
# Line 1587 | Line 1544 | find_matching_name_conf(ConfType type, c
1544  
1545    switch (type)
1546    {
1547 <    case RXLINE_TYPE:
1547 > #ifdef HAVE_LIBPCRE
1548 >  case RXLINE_TYPE:
1549        DLINK_FOREACH(ptr, list_p->head)
1550        {
1551          conf = ptr->data;
# Line 1597 | Line 1555 | find_matching_name_conf(ConfType type, c
1555            return conf;
1556        }
1557        break;
1558 + #endif
1559 +  case SERVICE_TYPE:
1560 +    DLINK_FOREACH(ptr, list_p->head)
1561 +    {
1562 +      conf = ptr->data;
1563 +
1564 +      if (EmptyString(conf->name))
1565 +        continue;
1566 +      if ((name != NULL) && !irccmp(name, conf->name))
1567 +        return conf;
1568 +    }
1569 +    break;
1570  
1571    case XLINE_TYPE:
1572    case ULINE_TYPE:
# Line 1651 | Line 1621 | find_matching_name_conf(ConfType type, c
1621   * side effects - looks for an exact match on name field
1622   */
1623   struct ConfItem *
1624 < find_exact_name_conf(ConfType type, const char *name,
1624 > find_exact_name_conf(ConfType type, const struct Client *who, const char *name,
1625                       const char *user, const char *host)
1626   {
1627    dlink_node *ptr = NULL;
# Line 1692 | Line 1662 | find_exact_name_conf(ConfType type, cons
1662      DLINK_FOREACH(ptr, list_p->head)
1663      {
1664        conf = ptr->data;
1665 <      aconf = (struct AccessItem *)map_to_conf(conf);
1665 >      aconf = map_to_conf(conf);
1666 >
1667        if (EmptyString(conf->name))
1668 <        continue;
1669 <    
1670 <      if (irccmp(conf->name, name) == 0)
1668 >        continue;
1669 >
1670 >      if (!irccmp(conf->name, name))
1671        {
1672 <        if ((user == NULL && (host == NULL)))
1673 <          return (conf);
1674 <        if (EmptyString(aconf->user) || EmptyString(aconf->host))
1675 <          return (conf);
1676 <        if (match(aconf->user, user) && match(aconf->host, host))
1677 <          return (conf);
1672 >        if (!who)
1673 >          return conf;
1674 >        if (EmptyString(aconf->user) || EmptyString(aconf->host))
1675 >          return conf;
1676 >        if (match(aconf->user, who->username))
1677 >        {
1678 >          switch (aconf->type)
1679 >          {
1680 >            case HM_HOST:
1681 >              if (match(aconf->host, who->host) || match(aconf->host, who->sockhost))
1682 >                return conf;
1683 >              break;
1684 >            case HM_IPV4:
1685 >              if (who->localClient->aftype == AF_INET)
1686 >                if (match_ipv4(&who->localClient->ip, &aconf->ipnum, aconf->bits))
1687 >                  return conf;
1688 >              break;
1689 > #ifdef IPV6
1690 >            case HM_IPV6:
1691 >              if (who->localClient->aftype == AF_INET6)
1692 >                if (match_ipv6(&who->localClient->ip, &aconf->ipnum, aconf->bits))
1693 >                  return conf;
1694 >              break;
1695 > #endif
1696 >            default:
1697 >              assert(0);
1698 >          }
1699 >        }
1700        }
1701      }
1702 +
1703      break;
1704  
1705    case SERVER_TYPE:
# Line 1761 | Line 1755 | rehash(int sig)
1755      sendto_realops_flags(UMODE_ALL, L_ALL,
1756                           "Got signal SIGHUP, reloading ircd.conf file");
1757  
1764 #ifndef _WIN32
1758    restart_resolver();
1759 < #endif
1759 >
1760    /* don't close listeners until we know we can go ahead with the rehash */
1761  
1762    /* Check to see if we magically got(or lost) IPv6 support */
# Line 1774 | Line 1767 | rehash(int sig)
1767    if (ServerInfo.description != NULL)
1768      strlcpy(me.info, ServerInfo.description, sizeof(me.info));
1769  
1777 #ifndef STATIC_MODULES
1770    load_conf_modules();
1779 #endif
1771  
1772    flush_deleted_I_P();
1773  
1774    rehashed_klines = 1;
1775 <
1775 > /* XXX */
1776    if (ConfigLoggingEntry.use_logging)
1777 <    reopen_log(logFileName);
1777 >    log_close_all();
1778  
1779    return(0);
1780   }
# Line 1822 | Line 1813 | set_default_conf(void)
1813    ServerInfo.specific_ipv6_vhost = 0;
1814  
1815    ServerInfo.max_clients = MAXCLIENTS_MAX;
1816 <  /* Don't reset hub, as that will break lazylinks */
1817 <  /* ServerInfo.hub = NO; */
1816 >
1817 >  ServerInfo.hub = 0;
1818    ServerInfo.dns_host.sin_addr.s_addr = 0;
1819    ServerInfo.dns_host.sin_port = 0;
1820    AdminInfo.name = NULL;
1821    AdminInfo.email = NULL;
1822    AdminInfo.description = NULL;
1823  
1824 <  set_log_level(L_NOTICE);
1824 >  log_close_all();
1825 >
1826    ConfigLoggingEntry.use_logging = 1;
1827 <  ConfigLoggingEntry.operlog[0] = '\0';
1828 <  ConfigLoggingEntry.userlog[0] = '\0';
1829 <  ConfigLoggingEntry.klinelog[0] = '\0';
1830 <  ConfigLoggingEntry.glinelog[0] = '\0';
1831 <  ConfigLoggingEntry.killlog[0] = '\0';
1832 <  ConfigLoggingEntry.operspylog[0] = '\0';
1833 <  ConfigLoggingEntry.ioerrlog[0] = '\0';
1842 <  ConfigLoggingEntry.failed_operlog[0] = '\0';
1843 <
1844 <  ConfigChannel.disable_fake_channels = NO;
1845 <  ConfigChannel.restrict_channels = NO;
1846 <  ConfigChannel.disable_local_channels = NO;
1847 <  ConfigChannel.use_invex = YES;
1848 <  ConfigChannel.use_except = YES;
1849 <  ConfigChannel.use_knock = YES;
1827 >
1828 >  ConfigChannel.disable_fake_channels = 0;
1829 >  ConfigChannel.restrict_channels = 0;
1830 >  ConfigChannel.disable_local_channels = 0;
1831 >  ConfigChannel.use_invex = 1;
1832 >  ConfigChannel.use_except = 1;
1833 >  ConfigChannel.use_knock = 1;
1834    ConfigChannel.knock_delay = 300;
1835    ConfigChannel.knock_delay_channel = 60;
1836    ConfigChannel.max_chans_per_user = 15;
1837 <  ConfigChannel.quiet_on_ban = YES;
1837 >  ConfigChannel.quiet_on_ban = 1;
1838    ConfigChannel.max_bans = 25;
1839    ConfigChannel.default_split_user_count = 0;
1840    ConfigChannel.default_split_server_count = 0;
1841 <  ConfigChannel.no_join_on_split = NO;
1842 <  ConfigChannel.no_create_on_split = NO;
1843 <  ConfigChannel.burst_topicwho = YES;
1841 >  ConfigChannel.no_join_on_split = 0;
1842 >  ConfigChannel.no_create_on_split = 0;
1843 >  ConfigChannel.burst_topicwho = 1;
1844  
1845 <  ConfigServerHide.flatten_links = NO;
1845 >  ConfigServerHide.flatten_links = 0;
1846    ConfigServerHide.links_delay = 300;
1847 <  ConfigServerHide.hidden = NO;
1848 <  ConfigServerHide.disable_hidden = NO;
1849 <  ConfigServerHide.hide_servers = NO;
1847 >  ConfigServerHide.hidden = 0;
1848 >  ConfigServerHide.disable_hidden = 0;
1849 >  ConfigServerHide.hide_servers = 0;
1850    DupString(ConfigServerHide.hidden_name, NETWORK_NAME_DEFAULT);
1851 <  ConfigServerHide.hide_server_ips = NO;
1851 >  ConfigServerHide.hide_server_ips = 0;
1852  
1853    
1854 +  DupString(ConfigFileEntry.service_name, SERVICE_NAME_DEFAULT);
1855    ConfigFileEntry.max_watch = WATCHSIZE_DEFAULT;
1856    ConfigFileEntry.gline_min_cidr = 16;
1857    ConfigFileEntry.gline_min_cidr6 = 48;
1858 <  ConfigFileEntry.invisible_on_connect = YES;
1859 <  ConfigFileEntry.burst_away = NO;
1860 <  ConfigFileEntry.use_whois_actually = YES;
1861 <  ConfigFileEntry.tkline_expire_notices = YES;
1862 <  ConfigFileEntry.hide_spoof_ips = YES;
1863 <  ConfigFileEntry.ignore_bogus_ts = NO;
1864 <  ConfigFileEntry.disable_auth = NO;
1865 <  ConfigFileEntry.disable_remote = NO;
1858 >  ConfigFileEntry.invisible_on_connect = 1;
1859 >  ConfigFileEntry.burst_away = 0;
1860 >  ConfigFileEntry.use_whois_actually = 1;
1861 >  ConfigFileEntry.tkline_expire_notices = 1;
1862 >  ConfigFileEntry.hide_spoof_ips = 1;
1863 >  ConfigFileEntry.ignore_bogus_ts = 0;
1864 >  ConfigFileEntry.disable_auth = 0;
1865 >  ConfigFileEntry.disable_remote = 0;
1866    ConfigFileEntry.kill_chase_time_limit = 90;
1867 <  ConfigFileEntry.default_floodcount = 8; /* XXX */
1868 <  ConfigFileEntry.failed_oper_notice = YES;
1869 <  ConfigFileEntry.dots_in_ident = 0;      /* XXX */
1885 <  ConfigFileEntry.dot_in_ip6_addr = YES;
1867 >  ConfigFileEntry.default_floodcount = 8;
1868 >  ConfigFileEntry.failed_oper_notice = 1;
1869 >  ConfigFileEntry.dots_in_ident = 0;
1870    ConfigFileEntry.min_nonwildcard = 4;
1871    ConfigFileEntry.min_nonwildcard_simple = 3;
1872    ConfigFileEntry.max_accept = 20;
1873 <  ConfigFileEntry.anti_nick_flood = NO;   /* XXX */
1873 >  ConfigFileEntry.anti_nick_flood = 0;
1874    ConfigFileEntry.max_nick_time = 20;
1875    ConfigFileEntry.max_nick_changes = 5;
1876 <  ConfigFileEntry.anti_spam_exit_message_time = 0;  /* XXX */
1876 >  ConfigFileEntry.anti_spam_exit_message_time = 0;
1877    ConfigFileEntry.ts_warn_delta = TS_WARN_DELTA_DEFAULT;
1878 <  ConfigFileEntry.ts_max_delta = TS_MAX_DELTA_DEFAULT;  /* XXX */
1879 <  ConfigFileEntry.kline_with_reason = YES;
1878 >  ConfigFileEntry.ts_max_delta = TS_MAX_DELTA_DEFAULT;
1879 >  ConfigFileEntry.kline_with_reason = 1;
1880    ConfigFileEntry.kline_reason = NULL;
1881 <  ConfigFileEntry.warn_no_nline = YES;
1882 <  ConfigFileEntry.stats_o_oper_only = NO; /* XXX */
1881 >  ConfigFileEntry.warn_no_nline = 1;
1882 >  ConfigFileEntry.stats_o_oper_only = 0;
1883    ConfigFileEntry.stats_k_oper_only = 1;  /* masked */
1884    ConfigFileEntry.stats_i_oper_only = 1;  /* masked */
1885 <  ConfigFileEntry.stats_P_oper_only = NO;
1885 >  ConfigFileEntry.stats_P_oper_only = 0;
1886    ConfigFileEntry.caller_id_wait = 60;
1887 <  ConfigFileEntry.opers_bypass_callerid = NO;
1887 >  ConfigFileEntry.opers_bypass_callerid = 0;
1888    ConfigFileEntry.pace_wait = 10;
1889    ConfigFileEntry.pace_wait_simple = 1;
1890 <  ConfigFileEntry.short_motd = NO;
1891 <  ConfigFileEntry.ping_cookie = NO;
1892 <  ConfigFileEntry.no_oper_flood = NO;     /* XXX */
1893 <  ConfigFileEntry.true_no_oper_flood = NO;  /* XXX */
1894 <  ConfigFileEntry.oper_pass_resv = YES;
1895 <  ConfigFileEntry.glines = NO;            /* XXX */
1896 <  ConfigFileEntry.gline_time = 12 * 3600; /* XXX */
1913 <  ConfigFileEntry.idletime = 0;
1890 >  ConfigFileEntry.short_motd = 0;
1891 >  ConfigFileEntry.ping_cookie = 0;
1892 >  ConfigFileEntry.no_oper_flood = 0;
1893 >  ConfigFileEntry.true_no_oper_flood = 0;
1894 >  ConfigFileEntry.oper_pass_resv = 1;
1895 >  ConfigFileEntry.glines = 0;
1896 >  ConfigFileEntry.gline_time = 12 * 3600;
1897    ConfigFileEntry.max_targets = MAX_TARGETS_DEFAULT;
1898    ConfigFileEntry.client_flood = CLIENT_FLOOD_DEFAULT;
1899 <  ConfigFileEntry.oper_only_umodes = UMODE_DEBUG;  /* XXX */
1899 >  ConfigFileEntry.oper_only_umodes = UMODE_DEBUG;
1900    ConfigFileEntry.oper_umodes = UMODE_BOTS | UMODE_LOCOPS | UMODE_SERVNOTICE |
1901 <    UMODE_OPERWALL | UMODE_WALLOP;        /* XXX */
1902 <  DupString(ConfigFileEntry.servlink_path, SLPATH);
1920 < #ifdef HAVE_LIBCRYPTO
1921 <  /* jdc -- This is our default value for a cipher.  According to the
1922 <   *        CRYPTLINK document (doc/cryptlink.txt), BF/128 must be supported
1923 <   *        under all circumstances if cryptlinks are enabled.  So,
1924 <   *        this will be our default.
1925 <   *
1926 <   *        NOTE: I apologise for the hard-coded value of "1" (BF/128).
1927 <   *              This should be moved into a find_cipher() routine.
1928 <   */
1929 <  ConfigFileEntry.default_cipher_preference = &CipherTable[1];
1930 < #endif
1931 <  ConfigFileEntry.use_egd = NO;
1901 >    UMODE_OPERWALL | UMODE_WALLOP;
1902 >  ConfigFileEntry.use_egd = 0;
1903    ConfigFileEntry.egdpool_path = NULL;
1933 #ifdef HAVE_LIBZ
1934  ConfigFileEntry.compression_level = 0;
1935 #endif
1904    ConfigFileEntry.throttle_time = 10;
1905   }
1906  
1939 /* read_conf()
1940 *
1941 * inputs       - file descriptor pointing to config file to use
1942 * output       - None
1943 * side effects - Read configuration file.
1944 */
1945 static void
1946 read_conf(FBFILE *file)
1947 {
1948  lineno = 0;
1949
1950  set_default_conf(); /* Set default values prior to conf parsing */
1951  ypass = 1;
1952  yyparse();          /* pick up the classes first */
1953
1954  fbrewind(file);
1955
1956  ypass = 2;
1957  yyparse();          /* Load the values from the conf */
1958  validate_conf();    /* Check to make sure some values are still okay. */
1959                      /* Some global values are also loaded here. */
1960  check_class();      /* Make sure classes are valid */
1961 }
1962
1907   static void
1908   validate_conf(void)
1909   {
# Line 1969 | Line 1913 | validate_conf(void)
1913    if (ConfigFileEntry.ts_max_delta < TS_MAX_DELTA_MIN)
1914      ConfigFileEntry.ts_max_delta = TS_MAX_DELTA_DEFAULT;
1915  
1972  if (ConfigFileEntry.servlink_path == NULL)
1973    DupString(ConfigFileEntry.servlink_path, SLPATH);
1974
1916    if (ServerInfo.network_name == NULL)
1917      DupString(ServerInfo.network_name,NETWORK_NAME_DEFAULT);
1918  
1919    if (ServerInfo.network_desc == NULL)
1920      DupString(ServerInfo.network_desc,NETWORK_DESC_DEFAULT);
1921  
1922 +  if (ConfigFileEntry.service_name == NULL)
1923 +    DupString(ConfigFileEntry.service_name, SERVICE_NAME_DEFAULT);
1924 +
1925    if ((ConfigFileEntry.client_flood < CLIENT_FLOOD_MIN) ||
1926        (ConfigFileEntry.client_flood > CLIENT_FLOOD_MAX))
1927      ConfigFileEntry.client_flood = CLIENT_FLOOD_MAX;
# Line 1985 | Line 1929 | validate_conf(void)
1929    ConfigFileEntry.max_watch = IRCD_MAX(ConfigFileEntry.max_watch, WATCHSIZE_MIN);
1930   }
1931  
1932 + /* read_conf()
1933 + *
1934 + * inputs       - file descriptor pointing to config file to use
1935 + * output       - None
1936 + * side effects - Read configuration file.
1937 + */
1938 + static void
1939 + read_conf(FILE *file)
1940 + {
1941 +  lineno = 0;
1942 +
1943 +  set_default_conf(); /* Set default values prior to conf parsing */
1944 +  conf_parser_ctx.pass = 1;
1945 +  yyparse();          /* pick up the classes first */
1946 +
1947 +  rewind(file);
1948 +
1949 +  conf_parser_ctx.pass = 2;
1950 +  yyparse();          /* Load the values from the conf */
1951 +  validate_conf();    /* Check to make sure some values are still okay. */
1952 +                      /* Some global values are also loaded here. */
1953 +  check_class();      /* Make sure classes are valid */
1954 + }
1955 +
1956   /* lookup_confhost()
1957   *
1958   * start DNS lookups of all hostnames in the conf
# Line 2001 | Line 1969 | lookup_confhost(struct ConfItem *conf)
1969    if (EmptyString(aconf->host) ||
1970        EmptyString(aconf->user))
1971    {
1972 <    ilog(L_ERROR, "Host/server name error: (%s) (%s)",
1972 >    ilog(LOG_TYPE_IRCD, "Host/server name error: (%s) (%s)",
1973           aconf->host, conf->name);
1974      return;
1975    }
# Line 2021 | Line 1989 | lookup_confhost(struct ConfItem *conf)
1989    /* Get us ready for a bind() and don't bother doing dns lookup */
1990    hints.ai_flags = AI_PASSIVE | AI_NUMERICHOST;
1991  
1992 <  if (irc_getaddrinfo(aconf->host, NULL, &hints, &res))
1992 >  if (getaddrinfo(aconf->host, NULL, &hints, &res))
1993    {
1994      conf_dns_lookup(aconf);
1995      return;
# Line 2032 | Line 2000 | lookup_confhost(struct ConfItem *conf)
2000    memcpy(&aconf->ipnum, res->ai_addr, res->ai_addrlen);
2001    aconf->ipnum.ss_len = res->ai_addrlen;
2002    aconf->ipnum.ss.ss_family = res->ai_family;
2003 <  irc_freeaddrinfo(res);
2003 >  freeaddrinfo(res);
2004   }
2005  
2006   /* conf_connect_allowed()
# Line 2071 | Line 2039 | conf_connect_allowed(struct irc_ssaddr *
2039   static struct AccessItem *
2040   find_regexp_kline(const char *uhi[])
2041   {
2042 + #ifdef HAVE_LIBPCRE
2043    const dlink_node *ptr = NULL;
2044  
2045    DLINK_FOREACH(ptr, rkconf_items.head)
# Line 2085 | Line 2054 | find_regexp_kline(const char *uhi[])
2054           !ircd_pcre_exec(aptr->regexhost, uhi[2])))
2055        return aptr;
2056    }
2057 <
2057 > #endif
2058    return NULL;
2059   }
2060  
# Line 2147 | Line 2116 | find_gline(struct Client *client_p)
2116   void
2117   add_temp_line(struct ConfItem *conf)
2118   {
2119 <  struct AccessItem *aconf;
2151 <
2152 <  if (conf->type == DLINE_TYPE)
2153 <  {
2154 <    aconf = map_to_conf(conf);
2155 <    SetConfTemporary(aconf);
2156 <    dlinkAdd(conf, &conf->node, &temporary_dlines);
2157 <    MyFree(aconf->user);
2158 <    aconf->user = NULL;
2159 <    add_conf_by_address(CONF_DLINE, aconf);
2160 <  }
2161 <  else if (conf->type == KLINE_TYPE)
2162 <  {
2163 <    aconf = map_to_conf(conf);
2164 <    SetConfTemporary(aconf);
2165 <    dlinkAdd(conf, &conf->node, &temporary_klines);
2166 <    add_conf_by_address(CONF_KILL, aconf);
2167 <  }
2168 <  else if (conf->type == GLINE_TYPE)
2169 <  {
2170 <    aconf = map_to_conf(conf);
2171 <    SetConfTemporary(aconf);
2172 <    dlinkAdd(conf, &conf->node, &temporary_glines);
2173 <    add_conf_by_address(CONF_GLINE, aconf);
2174 <  }
2175 <  else if (conf->type == XLINE_TYPE)
2119 >  if (conf->type == XLINE_TYPE)
2120    {
2121      conf->flags |= CONF_FLAGS_TEMPORARY;
2122      dlinkAdd(conf, make_dlink_node(), &temporary_xlines);
2123    }
2180  else if (conf->type == RXLINE_TYPE)
2181  {
2182    conf->flags |= CONF_FLAGS_TEMPORARY;
2183    dlinkAdd(conf, make_dlink_node(), &temporary_rxlines);
2184  }
2185  else if (conf->type == RKLINE_TYPE)
2186  {
2187    conf->flags |= CONF_FLAGS_TEMPORARY;
2188    dlinkAdd(conf, make_dlink_node(), &temporary_rklines);
2189  }
2124    else if ((conf->type == NRESV_TYPE) || (conf->type == CRESV_TYPE))
2125    {
2126      conf->flags |= CONF_FLAGS_TEMPORARY;
# Line 2204 | Line 2138 | add_temp_line(struct ConfItem *conf)
2138   void
2139   cleanup_tklines(void *notused)
2140   {
2141 <  expire_tklines(&temporary_glines);
2208 <  expire_tklines(&temporary_klines);
2209 <  expire_tklines(&temporary_dlines);
2141 >  hostmask_expire_temporary();
2142    expire_tklines(&temporary_xlines);
2211  expire_tklines(&temporary_rxlines);
2212  expire_tklines(&temporary_rklines);
2143    expire_tklines(&temporary_resv);
2144   }
2145  
# Line 2227 | Line 2157 | expire_tklines(dlink_list *tklist)
2157    struct ConfItem *conf;
2158    struct MatchItem *xconf;
2159    struct MatchItem *nconf;
2230  struct AccessItem *aconf;
2160    struct ResvChannel *cconf;
2161  
2162    DLINK_FOREACH_SAFE(ptr, next_ptr, tklist->head)
2163    {
2164      conf = ptr->data;
2236    if (conf->type == GLINE_TYPE ||
2237        conf->type == KLINE_TYPE ||
2238        conf->type == DLINE_TYPE)
2239    {
2240      aconf = (struct AccessItem *)map_to_conf(conf);
2241      if (aconf->hold <= CurrentTime)
2242      {
2243        /* XXX - Do we want GLINE expiry notices?? */
2244        /* Alert opers that a TKline expired - Hwy */
2245        if (ConfigFileEntry.tkline_expire_notices)
2246        {
2247          if (aconf->status & CONF_KILL)
2248          {
2249            sendto_realops_flags(UMODE_ALL, L_ALL,
2250                                 "Temporary K-line for [%s@%s] expired",
2251                                 (aconf->user) ? aconf->user : "*",
2252                                 (aconf->host) ? aconf->host : "*");
2253          }
2254          else if (conf->type == DLINE_TYPE)
2255          {
2256            sendto_realops_flags(UMODE_ALL, L_ALL,
2257                                 "Temporary D-line for [%s] expired",
2258                                 (aconf->host) ? aconf->host : "*");
2259          }
2260        }
2165  
2166 <        dlinkDelete(ptr, tklist);
2263 <        delete_one_address_conf(aconf->host, aconf);
2264 <      }
2265 <    }
2266 <    else if (conf->type == XLINE_TYPE ||
2267 <             conf->type == RXLINE_TYPE)
2166 >    if (conf->type == XLINE_TYPE)
2167      {
2168        xconf = (struct MatchItem *)map_to_conf(conf);
2169        if (xconf->hold <= CurrentTime)
2170        {
2171          if (ConfigFileEntry.tkline_expire_notices)
2172            sendto_realops_flags(UMODE_ALL, L_ALL,
2173 <                               "Temporary X-line for [%s] %sexpired", conf->name,
2275 <                               conf->type == RXLINE_TYPE ? "(REGEX) " : "");
2173 >                               "Temporary X-line for [%s] sexpired", conf->name);
2174          dlinkDelete(ptr, tklist);
2175          free_dlink_node(ptr);
2176          delete_conf_item(conf);
2177        }
2178      }
2281    else if (conf->type == RKLINE_TYPE)
2282    {
2283      aconf = map_to_conf(conf);
2284      if (aconf->hold <= CurrentTime)
2285      {
2286        if (ConfigFileEntry.tkline_expire_notices)
2287           sendto_realops_flags(UMODE_ALL, L_ALL,
2288                                "Temporary K-line for [%s@%s] (REGEX) expired",
2289                                (aconf->user) ? aconf->user : "*",
2290                                (aconf->host) ? aconf->host : "*");
2291        dlinkDelete(ptr, tklist);
2292        free_dlink_node(ptr);
2293        delete_conf_item(conf);
2294      }
2295    }
2179      else if (conf->type == NRESV_TYPE)
2180      {
2181        nconf = (struct MatchItem *)map_to_conf(conf);
# Line 2329 | Line 2212 | expire_tklines(dlink_list *tklist)
2212   static const struct oper_privs
2213   {
2214    const unsigned int oprivs;
2332  const unsigned int hidden;
2215    const unsigned char c;
2216   } flag_list[] = {
2217 <  { OPER_FLAG_ADMIN,       OPER_FLAG_HIDDEN_ADMIN,  'A' },
2218 <  { OPER_FLAG_REMOTEBAN,   0,                       'B' },
2219 <  { OPER_FLAG_DIE,         0,                       'D' },
2220 <  { OPER_FLAG_GLINE,       0,                       'G' },
2221 <  { OPER_FLAG_REHASH,      0,                       'H' },
2222 <  { OPER_FLAG_K,           0,                       'K' },
2223 <  { OPER_FLAG_OPERWALL,    0,                       'L' },
2224 <  { OPER_FLAG_N,           0,                       'N' },
2225 <  { OPER_FLAG_GLOBAL_KILL, 0,                       'O' },
2226 <  { OPER_FLAG_REMOTE,      0,                       'R' },
2227 <  { OPER_FLAG_OPER_SPY,    0,                       'S' },
2228 <  { OPER_FLAG_UNKLINE,     0,                       'U' },
2229 <  { OPER_FLAG_X,           0,                       'X' },
2230 <  { 0, 0, '\0' }
2217 >  { OPER_FLAG_ADMIN,       'A' },
2218 >  { OPER_FLAG_REMOTEBAN,   'B' },
2219 >  { OPER_FLAG_DIE,         'D' },
2220 >  { OPER_FLAG_GLINE,       'G' },
2221 >  { OPER_FLAG_REHASH,      'H' },
2222 >  { OPER_FLAG_K,           'K' },
2223 >  { OPER_FLAG_OPERWALL,    'L' },
2224 >  { OPER_FLAG_N,           'N' },
2225 >  { OPER_FLAG_GLOBAL_KILL, 'O' },
2226 >  { OPER_FLAG_REMOTE,      'R' },
2227 >  { OPER_FLAG_OPER_SPY,    'S' },
2228 >  { OPER_FLAG_UNKLINE,     'U' },
2229 >  { OPER_FLAG_X,           'X' },
2230 >  { 0, '\0' }
2231   };
2232  
2233   char *
# Line 2357 | Line 2239 | oper_privs_as_string(const unsigned int
2239  
2240    for (; flag_list[i].oprivs; ++i)
2241    {
2242 <    if ((port & flag_list[i].oprivs) &&
2361 <        (port & flag_list[i].hidden) == 0)
2242 >    if (port & flag_list[i].oprivs)
2243        *privs_ptr++ = flag_list[i].c;
2244      else
2245        *privs_ptr++ = ToLowerTab[flag_list[i].c];
# Line 2375 | Line 2256 | oper_privs_as_string(const unsigned int
2256   *         "oper" is server name for remote opers
2257   * Side effects: None.
2258   */
2259 < char *
2259 > const char *
2260   get_oper_name(const struct Client *client_p)
2261   {
2262 <  dlink_node *cnode;
2382 <  struct ConfItem *conf;
2383 <  struct AccessItem *aconf;
2384 <
2262 >  dlink_node *cnode = NULL;
2263    /* +5 for !,@,{,} and null */
2264 <  static char buffer[NICKLEN+USERLEN+HOSTLEN+HOSTLEN+5];
2264 >  static char buffer[NICKLEN + USERLEN + HOSTLEN + HOSTLEN + 5];
2265  
2266    if (MyConnect(client_p))
2267    {
2268 <    DLINK_FOREACH(cnode, client_p->localClient->confs.head)
2268 >    if ((cnode = client_p->localClient->confs.head))
2269      {
2270 <      conf = cnode->data;
2271 <      aconf = map_to_conf(conf);
2270 >      struct ConfItem *conf = cnode->data;
2271 >      const struct AccessItem *aconf = map_to_conf(conf);
2272  
2273        if (IsConfOperator(aconf))
2274        {
2275 <        ircsprintf(buffer, "%s!%s@%s{%s}", client_p->name,
2276 <                   client_p->username, client_p->host,
2399 <                   conf->name);
2275 >        snprintf(buffer, sizeof(buffer), "%s!%s@%s{%s}", client_p->name,
2276 >                 client_p->username, client_p->host, conf->name);
2277          return buffer;
2278        }
2279      }
# Line 2407 | Line 2284 | get_oper_name(const struct Client *clien
2284      assert(0); /* Oper without oper conf! */
2285    }
2286  
2287 <  ircsprintf(buffer, "%s!%s@%s{%s}", client_p->name,
2288 <             client_p->username, client_p->host, client_p->servptr->name);
2287 >  snprintf(buffer, sizeof(buffer), "%s!%s@%s{%s}", client_p->name,
2288 >           client_p->username, client_p->host, client_p->servptr->name);
2289    return buffer;
2290   }
2291  
# Line 2425 | Line 2302 | read_conf_files(int cold)
2302    char chanmodes[32];
2303    char chanlimit[32];
2304  
2305 +  conf_parser_ctx.boot = cold;
2306    filename = get_conf_name(CONF_TYPE);
2307  
2308    /* We need to know the initial filename for the yyerror() to report
# Line 2435 | Line 2313 | read_conf_files(int cold)
2313    */
2314    strlcpy(conffilebuf, filename, sizeof(conffilebuf));
2315  
2316 <  if ((conf_fbfile_in = fbopen(filename, "r")) == NULL)
2316 >  if ((conf_parser_ctx.conf_file = fopen(filename, "r")) == NULL)
2317    {
2318      if (cold)
2319      {
2320 <      ilog(L_CRIT, "Unable to read configuration file '%s': %s",
2320 >      ilog(LOG_TYPE_IRCD, "Unable to read configuration file '%s': %s",
2321             filename, strerror(errno));
2322        exit(-1);
2323      }
# Line 2455 | Line 2333 | read_conf_files(int cold)
2333    if (!cold)
2334      clear_out_old_conf();
2335  
2336 <  read_conf(conf_fbfile_in);
2337 <  fbclose(conf_fbfile_in);
2336 >  read_conf(conf_parser_ctx.conf_file);
2337 >  fclose(conf_parser_ctx.conf_file);
2338  
2339    add_isupport("NETWORK", ServerInfo.network_name, -1);
2340 <  ircsprintf(chanmodes, "b%s%s:%d", ConfigChannel.use_except ? "e" : "",
2341 <             ConfigChannel.use_invex ? "I" : "", ConfigChannel.max_bans);
2340 >  snprintf(chanmodes, sizeof(chanmodes), "b%s%s:%d",
2341 >           ConfigChannel.use_except ? "e" : "",
2342 >           ConfigChannel.use_invex ? "I" : "", ConfigChannel.max_bans);
2343    add_isupport("MAXLIST", chanmodes, -1);
2344    add_isupport("MAXTARGETS", NULL, ConfigFileEntry.max_targets);
2345 +
2346    if (ConfigChannel.disable_local_channels)
2347      add_isupport("CHANTYPES", "#", -1);
2348    else
2349      add_isupport("CHANTYPES", "#&", -1);
2350 <  ircsprintf(chanlimit, "%s:%d", ConfigChannel.disable_local_channels ? "#" : "#&",
2351 <             ConfigChannel.max_chans_per_user);
2350 >
2351 >  snprintf(chanlimit, sizeof(chanlimit), "%s:%d",
2352 >           ConfigChannel.disable_local_channels ? "#" : "#&",
2353 >           ConfigChannel.max_chans_per_user);
2354    add_isupport("CHANLIMIT", chanlimit, -1);
2355 <  ircsprintf(chanmodes, "%s%s%s", ConfigChannel.use_except ? "e" : "",
2356 <             ConfigChannel.use_invex ? "I" : "", "b,k,l,imnpst");
2355 >  snprintf(chanmodes, sizeof(chanmodes), "%s%s%s",
2356 >           ConfigChannel.use_except ? "e" : "",
2357 >           ConfigChannel.use_invex ? "I" : "", "b,k,l,imnprstORS");
2358    add_isupport("CHANNELLEN", NULL, LOCAL_CHANNELLEN);
2359 +
2360    if (ConfigChannel.use_except)
2361      add_isupport("EXCEPTS", "e", -1);
2362    if (ConfigChannel.use_invex)
# Line 2485 | Line 2369 | read_conf_files(int cold)
2369     */
2370    rebuild_isupport_message_line();
2371  
2372 <  parse_conf_file(KLINE_TYPE, cold);
2372 > #ifdef HAVE_LIBPCRE
2373    parse_conf_file(RKLINE_TYPE, cold);
2374 +  parse_conf_file(RXLINE_TYPE, cold);
2375 + #endif
2376 +  parse_conf_file(KLINE_TYPE, cold);
2377    parse_conf_file(DLINE_TYPE, cold);
2378    parse_conf_file(XLINE_TYPE, cold);
2492  parse_conf_file(RXLINE_TYPE, cold);
2379    parse_conf_file(NRESV_TYPE, cold);
2380    parse_conf_file(CRESV_TYPE, cold);
2381   }
# Line 2503 | Line 2389 | read_conf_files(int cold)
2389   static void
2390   parse_conf_file(int type, int cold)
2391   {
2392 <  FBFILE *file = NULL;
2392 >  FILE *file = NULL;
2393    const char *filename = get_conf_name(type);
2394  
2395 <  if ((file = fbopen(filename, "r")) == NULL)
2395 >  if ((file = fopen(filename, "r")) == NULL)
2396    {
2397      if (cold)
2398 <      ilog(L_ERROR, "Unable to read configuration file '%s': %s",
2398 >      ilog(LOG_TYPE_IRCD, "Unable to read configuration file '%s': %s",
2399             filename, strerror(errno));
2400      else
2401        sendto_realops_flags(UMODE_ALL, L_ALL,
# Line 2519 | Line 2405 | parse_conf_file(int type, int cold)
2405    else
2406    {
2407      parse_csv_file(file, type);
2408 <    fbclose(file);
2408 >    fclose(file);
2409    }
2410   }
2411  
# Line 2538 | Line 2424 | clear_out_old_conf(void)
2424    struct ClassItem *cltmp;
2425    struct MatchItem *match_item;
2426    dlink_list *free_items [] = {
2427 <    &server_items,   &oconf_items,    &hub_items, &leaf_items,
2427 >    &server_items,   &oconf_items,
2428       &uconf_items,   &xconf_items, &rxconf_items, &rkconf_items,
2429 <     &nresv_items, &cluster_items,  &gdeny_items, NULL
2429 >     &nresv_items, &cluster_items,  &gdeny_items, &service_items, NULL
2430    };
2431  
2432    dlink_list ** iterator = free_items; /* C is dumb */
# Line 2583 | Line 2469 | clear_out_old_conf(void)
2469            delete_conf_item(conf);
2470          }
2471        }
2586      else if (conf->type == CLIENT_TYPE)
2587      {
2588        aconf = map_to_conf(conf);
2589
2590        if (aconf->clients != 0)
2591        {
2592          SetConfIllegal(aconf);
2593        }
2594        else
2595        {
2596          delete_conf_item(conf);
2597        }
2598      }
2472        else if (conf->type == XLINE_TYPE  ||
2473                 conf->type == RXLINE_TYPE ||
2474                 conf->type == RKLINE_TYPE)
# Line 2609 | Line 2482 | clear_out_old_conf(void)
2482        }
2483        else
2484        {
2612        if ((conf->type == LEAF_TYPE) || (conf->type == HUB_TYPE))
2613        {
2614          match_item = map_to_conf(conf);
2615          if (match_item->ref_count <= 0)
2616            delete_conf_item(conf);
2617          else
2618          {
2619            match_item->illegal = 1;
2620            dlinkDelete(&conf->node, *iterator);
2621          }
2622        }
2623        else
2485            delete_conf_item(conf);
2486        }
2487      }
# Line 2641 | Line 2502 | clear_out_old_conf(void)
2502    clear_out_address_conf();
2503  
2504    /* clean out module paths */
2644 #ifndef STATIC_MODULES
2505    mod_clear_paths();
2646 #endif
2506  
2507    /* clean out ServerInfo */
2508    MyFree(ServerInfo.description);
# Line 2663 | Line 2522 | clear_out_old_conf(void)
2522  
2523    MyFree(ServerInfo.rsa_private_key_file);
2524    ServerInfo.rsa_private_key_file = NULL;
2525 +
2526 +  if (ServerInfo.server_ctx)
2527 +    SSL_CTX_set_options(ServerInfo.server_ctx, SSL_OP_NO_SSLv2|
2528 +                                               SSL_OP_NO_SSLv3|
2529 +                                               SSL_OP_NO_TLSv1);
2530 +  if (ServerInfo.client_ctx)
2531 +    SSL_CTX_set_options(ServerInfo.client_ctx, SSL_OP_NO_SSLv2|
2532 +                                               SSL_OP_NO_SSLv3|
2533 +                                               SSL_OP_NO_TLSv1);
2534   #endif
2535  
2536    /* clean out old resvs from the conf */
# Line 2685 | Line 2553 | clear_out_old_conf(void)
2553     */
2554  
2555    /* clean out general */
2556 <  MyFree(ConfigFileEntry.servlink_path);
2557 <  ConfigFileEntry.servlink_path = NULL;
2558 < #ifdef HAVE_LIBCRYPTO
2691 <  ConfigFileEntry.default_cipher_preference = NULL;
2692 < #endif /* HAVE_LIBCRYPTO */
2556 >  MyFree(ConfigFileEntry.service_name);
2557 >  ConfigFileEntry.service_name = NULL;
2558 >
2559    delete_isupport("INVEX");
2560    delete_isupport("EXCEPTS");
2561   }
# Line 2800 | Line 2666 | get_conf_ping(struct ConfItem *conf, int
2666      if (aconf->class_ptr != NULL)
2667      {
2668        aclass = (struct ClassItem *)map_to_conf(aconf->class_ptr);
2669 <      *pingwarn = PingWarning(aclass);
2670 <      return PingFreq(aclass);
2669 >      *pingwarn = aclass->ping_warning;
2670 >      return aclass->ping_freq;
2671      }
2672    }
2673  
# Line 2817 | Line 2683 | get_conf_ping(struct ConfItem *conf, int
2683   const char *
2684   get_client_class(struct Client *target_p)
2685   {
2686 <  dlink_node *ptr;
2687 <  struct ConfItem *conf;
2822 <  struct AccessItem *aconf;
2686 >  dlink_node *cnode = NULL;
2687 >  struct AccessItem *aconf = NULL;
2688  
2689 <  if (target_p != NULL && !IsMe(target_p) &&
2690 <      target_p->localClient->confs.head != NULL)
2689 >  assert(!IsMe(target_p));
2690 >
2691 >  if ((cnode = target_p->localClient->confs.head))
2692    {
2693 <    DLINK_FOREACH(ptr, target_p->localClient->confs.head)
2828 <    {
2829 <      conf = ptr->data;
2693 >    struct ConfItem *conf = cnode->data;
2694  
2695 <      if (conf->type == CLIENT_TYPE || conf->type == SERVER_TYPE ||
2696 <          conf->type == OPER_TYPE)
2697 <      {
2698 <        aconf = (struct AccessItem *) map_to_conf(conf);
2699 <        if (aconf->class_ptr != NULL)
2700 <          return aconf->class_ptr->name;
2837 <      }
2838 <    }
2695 >    assert((conf->type == CLIENT_TYPE) || (conf->type == SERVER_TYPE) ||
2696 >          (conf->type == OPER_TYPE));
2697 >
2698 >    aconf = map_to_conf(conf);
2699 >    if (aconf->class_ptr != NULL)
2700 >      return aconf->class_ptr->name;
2701    }
2702  
2703    return "default";
# Line 2851 | Line 2713 | get_client_class(struct Client *target_p
2713   int
2714   get_client_ping(struct Client *target_p, int *pingwarn)
2715   {
2716 <  int ping;
2717 <  struct ConfItem *conf;
2856 <  dlink_node *nlink;
2716 >  int ping = 0;
2717 >  dlink_node *cnode = NULL;
2718  
2719 <  if (target_p->localClient->confs.head != NULL)
2720 <    DLINK_FOREACH(nlink, target_p->localClient->confs.head)
2721 <    {
2861 <      conf = nlink->data;
2719 >  if ((cnode = target_p->localClient->confs.head))
2720 >  {
2721 >    struct ConfItem *conf = cnode->data;
2722  
2723 <      if ((conf->type == CLIENT_TYPE) || (conf->type == SERVER_TYPE) ||
2724 <          (conf->type == OPER_TYPE))
2725 <      {
2726 <        ping = get_conf_ping(conf, pingwarn);
2727 <        if (ping > 0)
2728 <          return ping;
2729 <      }
2870 <    }
2723 >    assert((conf->type == CLIENT_TYPE) || (conf->type == SERVER_TYPE) ||
2724 >          (conf->type == OPER_TYPE));
2725 >
2726 >    ping = get_conf_ping(conf, pingwarn);
2727 >    if (ping > 0)
2728 >      return ping;
2729 >  }
2730  
2731    *pingwarn = 0;
2732    return DEFAULT_PINGFREQUENCY;
# Line 2884 | Line 2743 | find_class(const char *classname)
2743   {
2744    struct ConfItem *conf;
2745  
2746 <  if ((conf = find_exact_name_conf(CLASS_TYPE, classname, NULL, NULL)) != NULL)
2746 >  if ((conf = find_exact_name_conf(CLASS_TYPE, NULL, classname, NULL, NULL)) != NULL)
2747      return conf;
2748  
2749    return class_default;
# Line 2905 | Line 2764 | check_class(void)
2764    {
2765      struct ClassItem *aclass = map_to_conf(ptr->data);
2766  
2767 <    if (!aclass->active && !CurrUserCount(aclass))
2767 >    if (!aclass->active && !aclass->curr_user_count)
2768      {
2769        destroy_cidr_class(aclass);
2770        delete_conf_item(ptr->data);
# Line 2929 | Line 2788 | init_class(void)
2788    aclass = map_to_conf(class_default);
2789    aclass->active = 1;
2790    DupString(class_default->name, "default");
2791 <  ConFreq(aclass)  = DEFAULT_CONNECTFREQUENCY;
2792 <  PingFreq(aclass) = DEFAULT_PINGFREQUENCY;
2793 <  MaxTotal(aclass) = MAXIMUM_LINKS_DEFAULT;
2794 <  MaxSendq(aclass) = DEFAULT_SENDQ;
2791 >  aclass->con_freq  = DEFAULT_CONNECTFREQUENCY;
2792 >  aclass->ping_freq = DEFAULT_PINGFREQUENCY;
2793 >  aclass->max_total = MAXIMUM_LINKS_DEFAULT;
2794 >  aclass->max_sendq = DEFAULT_SENDQ;
2795  
2796    client_check_cb = register_callback("check_client", check_client);
2797   }
# Line 2947 | Line 2806 | unsigned int
2806   get_sendq(struct Client *client_p)
2807   {
2808    unsigned int sendq = DEFAULT_SENDQ;
2809 <  dlink_node *ptr;
2951 <  struct ConfItem *conf;
2809 >  dlink_node *cnode;
2810    struct ConfItem *class_conf;
2811    struct ClassItem *aclass;
2812    struct AccessItem *aconf;
2813  
2814 <  if (client_p && !IsMe(client_p) && (client_p->localClient->confs.head))
2814 >  assert(!IsMe(client_p));
2815 >
2816 >  if ((cnode = client_p->localClient->confs.head))
2817    {
2818 <    DLINK_FOREACH(ptr, client_p->localClient->confs.head)
2819 <    {
2820 <      conf = ptr->data;
2821 <      if ((conf->type == SERVER_TYPE) || (conf->type == OPER_TYPE)
2822 <          || (conf->type == CLIENT_TYPE))
2823 <      {
2824 <        aconf = (struct AccessItem *)map_to_conf(conf);
2825 <        if ((class_conf = aconf->class_ptr) == NULL)
2826 <          continue;
2827 <        aclass = (struct ClassItem *)map_to_conf(class_conf);
2828 <        sendq = MaxSendq(aclass);
2829 <        return sendq;
2830 <      }
2971 <    }
2818 >    struct ConfItem *conf = cnode->data;
2819 >
2820 >    assert((conf->type == CLIENT_TYPE) || (conf->type == SERVER_TYPE) ||
2821 >          (conf->type == OPER_TYPE));
2822 >
2823 >    aconf = map_to_conf(conf);
2824 >
2825 >    if ((class_conf = aconf->class_ptr) == NULL)
2826 >      return DEFAULT_SENDQ; /* TBV: shouldn't be possible at all */
2827 >
2828 >    aclass = map_to_conf(class_conf);
2829 >    sendq = aclass->max_sendq;
2830 >    return sendq;
2831    }
2832 +
2833    /* XXX return a default?
2834     * if here, then there wasn't an attached conf with a sendq
2835     * that is very bad -Dianora
# Line 3032 | Line 2892 | conf_add_class_to_conf(struct ConfItem *
2892   int
2893   conf_add_server(struct ConfItem *conf, const char *class_name)
2894   {
2895 <  struct AccessItem *aconf;
3036 <  struct split_nuh_item nuh;
3037 <  char conf_user[USERLEN + 1];
3038 <  char conf_host[HOSTLEN + 1];
3039 <
3040 <  aconf = map_to_conf(conf);
2895 >  struct AccessItem *aconf = map_to_conf(conf);
2896  
2897    conf_add_class_to_conf(conf, class_name);
2898  
2899    if (!aconf->host || !conf->name)
2900    {
2901      sendto_realops_flags(UMODE_ALL, L_ALL, "Bad connect block");
2902 <    ilog(L_WARN, "Bad connect block");
2902 >    ilog(LOG_TYPE_IRCD, "Bad connect block");
2903      return -1;
2904    }
2905  
2906 <  if (EmptyString(aconf->passwd) && !IsConfCryptLink(aconf))
2906 >  if (EmptyString(aconf->passwd))
2907    {
2908      sendto_realops_flags(UMODE_ALL, L_ALL, "Bad connect block, name %s",
2909                           conf->name);
2910 <    ilog(L_WARN, "Bad connect block, host %s", conf->name);
2910 >    ilog(LOG_TYPE_IRCD, "Bad connect block, host %s", conf->name);
2911      return -1;
2912    }
2913  
3059  nuh.nuhmask  = aconf->host;
3060  nuh.nickptr  = NULL;
3061  nuh.userptr  = conf_user;
3062  nuh.hostptr  = conf_host;
3063
3064  nuh.nicksize = 0;
3065  nuh.usersize = sizeof(conf_user);
3066  nuh.hostsize = sizeof(conf_host);
3067
3068  split_nuh(&nuh);
3069
3070  MyFree(aconf->host);
3071  aconf->host = NULL;
3072
3073  DupString(aconf->user, conf_user); /* somehow username checking for servers
3074                                 got lost in H6/7, will have to be re-added */
3075  DupString(aconf->host, conf_host);
3076
2914    lookup_confhost(conf);
2915  
2916    return 0;
2917   }
2918  
3082 /* conf_add_d_conf()
3083 *
3084 * inputs       - pointer to config item
3085 * output       - NONE
3086 * side effects - Add a d/D line
3087 */
3088 void
3089 conf_add_d_conf(struct AccessItem *aconf)
3090 {
3091  if (aconf->host == NULL)
3092    return;
3093
3094  aconf->user = NULL;
3095
3096  /* XXX - Should 'd' ever be in the old conf? For new conf we don't
3097   *       need this anyway, so I will disable it for now... -A1kmm
3098   */
3099  if (parse_netmask(aconf->host, NULL, NULL) == HM_HOST)
3100  {
3101    ilog(L_WARN, "Invalid Dline %s ignored", aconf->host);
3102    free_access_item(aconf);
3103  }
3104  else
3105  {
3106    /* XXX ensure user is NULL */
3107    MyFree(aconf->user);
3108    aconf->user = NULL;
3109    add_conf_by_address(CONF_DLINE, aconf);
3110  }
3111 }
3112
2919   /* yyerror()
2920   *
2921   * inputs       - message from parser
# Line 3121 | Line 2927 | yyerror(const char *msg)
2927   {
2928    char newlinebuf[IRCD_BUFSIZE];
2929  
2930 <  if (ypass != 1)
2930 >  if (conf_parser_ctx.pass != 1)
2931      return;
2932  
2933    strip_tabs(newlinebuf, linebuf, sizeof(newlinebuf));
2934    sendto_realops_flags(UMODE_ALL, L_ALL, "\"%s\", line %u: %s: %s",
2935                         conffilebuf, lineno + 1, msg, newlinebuf);
2936 <  ilog(L_WARN, "\"%s\", line %u: %s: %s",
2936 >  ilog(LOG_TYPE_IRCD, "\"%s\", line %u: %s: %s",
2937         conffilebuf, lineno + 1, msg, newlinebuf);
2938   }
2939  
3134 int
3135 conf_fbgets(char *lbuf, unsigned int max_size, FBFILE *fb)
3136 {
3137  if (fbgets(lbuf, max_size, fb) == NULL)
3138    return 0;
3139
3140  return strlen(lbuf);
3141 }
3142
3143 int
3144 conf_yy_fatal_error(const char *msg)
3145 {
3146  return 0;
3147 }
3148
2940   /*
2941   * valid_tkline()
2942   *
# Line 3157 | Line 2948 | conf_yy_fatal_error(const char *msg)
2948   * Originally written by Dianora (Diane, db@db.net)
2949   */
2950   time_t
2951 < valid_tkline(char *p, int minutes)
2951 > valid_tkline(const char *p, int minutes)
2952   {
2953    time_t result = 0;
2954  
2955 <  while (*p)
2955 >  for (; *p; ++p)
2956    {
2957 <    if (IsDigit(*p))
3167 <    {
3168 <      result *= 10;
3169 <      result += ((*p) & 0xF);
3170 <      p++;
3171 <    }
3172 <    else
2957 >    if (!IsDigit(*p))
2958        return 0;
2959 +
2960 +    result *= 10;
2961 +    result += ((*p) & 0xF);
2962    }
2963  
2964 <  /* in the degenerate case where oper does a /quote kline 0 user@host :reason
2964 >  /*
2965 >   * In the degenerate case where oper does a /quote kline 0 user@host :reason
2966     * i.e. they specifically use 0, I am going to return 1 instead
2967     * as a return value of non-zero is used to flag it as a temporary kline
2968     */
3180
2969    if (result == 0)
2970      result = 1;
2971  
# Line 3348 | Line 3136 | parse_aline(const char *cmd, struct Clie
3136          return -1;
3137        }
3138  
3139 <      if (!IsOperRemoteBan(source_p))
3139 >      if (!HasOFlag(source_p, OPER_FLAG_REMOTEBAN))
3140        {
3141          sendto_one(source_p, form_str(ERR_NOPRIVS),
3142                     me.name, source_p->name, "remoteban");
# Line 3385 | Line 3173 | parse_aline(const char *cmd, struct Clie
3173        return -1;
3174      }
3175  
3176 <    if ((parse_flags & AWILD) && !valid_wild_card(source_p, YES, 2, *up_p, *h_p))
3176 >    if ((parse_flags & AWILD) && !valid_wild_card(source_p, 1, 2, *up_p, *h_p))
3177        return -1;
3178    }
3179    else
3180 <    if ((parse_flags & AWILD) && !valid_wild_card(source_p, YES, 1, *up_p))
3180 >    if ((parse_flags & AWILD) && !valid_wild_card(source_p, 1, 1, *up_p))
3181        return -1;
3182  
3183    if (reason != NULL)
# Line 3397 | Line 3185 | parse_aline(const char *cmd, struct Clie
3185      if (parc != 0 && !EmptyString(*parv))
3186      {
3187        *reason = *parv;
3188 <      if (!valid_comment(source_p, *reason, YES))
3188 >      if (!valid_comment(source_p, *reason, 1))
3189          return -1;
3190      }
3191      else
# Line 3556 | Line 3344 | match_conf_password(const char *password
3344   * inputs       - client sending the cluster
3345   *              - command name "KLINE" "XLINE" etc.
3346   *              - capab -- CAP_KLN etc. from s_serv.h
3347 < *              - cluster type -- CLUSTER_KLINE etc. from s_conf.h
3347 > *              - cluster type -- CLUSTER_KLINE etc. from conf.h
3348   *              - pattern and args to send along
3349   * output       - none
3350   * side effects - Take source_p send the pattern with args given
# Line 3716 | Line 3504 | cidr_limit_reached(int over_rule,
3504    dlink_node *ptr = NULL;
3505    struct CidrItem *cidr;
3506  
3507 <  if (NumberPerCidr(aclass) <= 0)
3507 >  if (aclass->number_per_cidr <= 0)
3508      return 0;
3509  
3510    if (ip->ss.ss_family == AF_INET)
3511    {
3512 <    if (CidrBitlenIPV4(aclass) <= 0)
3512 >    if (aclass->cidr_bitlen_ipv4 <= 0)
3513        return 0;
3514  
3515      DLINK_FOREACH(ptr, aclass->list_ipv4.head)
3516      {
3517        cidr = ptr->data;
3518 <      if (match_ipv4(ip, &cidr->mask, CidrBitlenIPV4(aclass)))
3518 >      if (match_ipv4(ip, &cidr->mask, aclass->cidr_bitlen_ipv4))
3519        {
3520 <        if (!over_rule && (cidr->number_on_this_cidr >= NumberPerCidr(aclass)))
3520 >        if (!over_rule && (cidr->number_on_this_cidr >= aclass->number_per_cidr))
3521            return -1;
3522          cidr->number_on_this_cidr++;
3523          return 0;
# Line 3738 | Line 3526 | cidr_limit_reached(int over_rule,
3526      cidr = MyMalloc(sizeof(struct CidrItem));
3527      cidr->number_on_this_cidr = 1;
3528      cidr->mask = *ip;
3529 <    mask_addr(&cidr->mask, CidrBitlenIPV4(aclass));
3529 >    mask_addr(&cidr->mask, aclass->cidr_bitlen_ipv4);
3530      dlinkAdd(cidr, &cidr->node, &aclass->list_ipv4);
3531    }
3532   #ifdef IPV6
3533 <  else if (CidrBitlenIPV6(aclass) > 0)
3533 >  else if (aclass->cidr_bitlen_ipv6 > 0)
3534    {
3535      DLINK_FOREACH(ptr, aclass->list_ipv6.head)
3536      {
3537        cidr = ptr->data;
3538 <      if (match_ipv6(ip, &cidr->mask, CidrBitlenIPV6(aclass)))
3538 >      if (match_ipv6(ip, &cidr->mask, aclass->cidr_bitlen_ipv6))
3539        {
3540 <        if (!over_rule && (cidr->number_on_this_cidr >= NumberPerCidr(aclass)))
3540 >        if (!over_rule && (cidr->number_on_this_cidr >= aclass->number_per_cidr))
3541            return -1;
3542          cidr->number_on_this_cidr++;
3543          return 0;
# Line 3758 | Line 3546 | cidr_limit_reached(int over_rule,
3546      cidr = MyMalloc(sizeof(struct CidrItem));
3547      cidr->number_on_this_cidr = 1;
3548      cidr->mask = *ip;
3549 <    mask_addr(&cidr->mask, CidrBitlenIPV6(aclass));
3549 >    mask_addr(&cidr->mask, aclass->cidr_bitlen_ipv6);
3550      dlinkAdd(cidr, &cidr->node, &aclass->list_ipv6);
3551    }
3552   #endif
# Line 3780 | Line 3568 | remove_from_cidr_check(struct irc_ssaddr
3568    dlink_node *next_ptr = NULL;
3569    struct CidrItem *cidr;
3570  
3571 <  if (NumberPerCidr(aclass) == 0)
3571 >  if (aclass->number_per_cidr == 0)
3572      return;
3573  
3574    if (ip->ss.ss_family == AF_INET)
3575    {
3576 <    if (CidrBitlenIPV4(aclass) <= 0)
3576 >    if (aclass->cidr_bitlen_ipv4 <= 0)
3577        return;
3578  
3579      DLINK_FOREACH_SAFE(ptr, next_ptr, aclass->list_ipv4.head)
3580      {
3581        cidr = ptr->data;
3582 <      if (match_ipv4(ip, &cidr->mask, CidrBitlenIPV4(aclass)))
3582 >      if (match_ipv4(ip, &cidr->mask, aclass->cidr_bitlen_ipv4))
3583        {
3584          cidr->number_on_this_cidr--;
3585          if (cidr->number_on_this_cidr == 0)
# Line 3804 | Line 3592 | remove_from_cidr_check(struct irc_ssaddr
3592      }
3593    }
3594   #ifdef IPV6
3595 <  else if (CidrBitlenIPV6(aclass) > 0)
3595 >  else if (aclass->cidr_bitlen_ipv6 > 0)
3596    {
3597      DLINK_FOREACH_SAFE(ptr, next_ptr, aclass->list_ipv6.head)
3598      {
3599        cidr = ptr->data;
3600 <      if (match_ipv6(ip, &cidr->mask, CidrBitlenIPV6(aclass)))
3600 >      if (match_ipv6(ip, &cidr->mask, aclass->cidr_bitlen_ipv6))
3601        {
3602          cidr->number_on_this_cidr--;
3603          if (cidr->number_on_this_cidr == 0)
# Line 3872 | Line 3660 | rebuild_cidr_class(struct ConfItem *conf
3660   {
3661    struct ClassItem *old_class = map_to_conf(conf);
3662  
3663 <  if (NumberPerCidr(old_class) > 0 && NumberPerCidr(new_class) > 0)
3663 >  if (old_class->number_per_cidr > 0 && new_class->number_per_cidr > 0)
3664    {
3665 <    if (CidrBitlenIPV4(old_class) > 0 && CidrBitlenIPV4(new_class) > 0)
3665 >    if (old_class->cidr_bitlen_ipv4 > 0 && new_class->cidr_bitlen_ipv4 > 0)
3666        rebuild_cidr_list(AF_INET, conf, new_class,
3667                          &old_class->list_ipv4, &new_class->list_ipv4,
3668 <                        CidrBitlenIPV4(old_class) != CidrBitlenIPV4(new_class));
3668 >                        old_class->cidr_bitlen_ipv4 != new_class->cidr_bitlen_ipv4);
3669  
3670   #ifdef IPV6
3671 <    if (CidrBitlenIPV6(old_class) > 0 && CidrBitlenIPV6(new_class) > 0)
3671 >    if (old_class->cidr_bitlen_ipv6 > 0 && new_class->cidr_bitlen_ipv6 > 0)
3672        rebuild_cidr_list(AF_INET6, conf, new_class,
3673                          &old_class->list_ipv6, &new_class->list_ipv6,
3674 <                        CidrBitlenIPV6(old_class) != CidrBitlenIPV6(new_class));
3674 >                        old_class->cidr_bitlen_ipv6 != new_class->cidr_bitlen_ipv6);
3675   #endif
3676    }
3677  

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)