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/trunk/src/conf.c (file contents):
Revision 7159 by michael, Thu Jan 28 11:26:51 2016 UTC vs.
Revision 7304 by michael, Wed Feb 10 10:45:46 2016 UTC

# Line 28 | Line 28
28   #include "list.h"
29   #include "ircd_defs.h"
30   #include "conf.h"
31 + #include "conf_cluster.h"
32 + #include "conf_gecos.h"
33   #include "conf_pseudo.h"
34 + #include "conf_resv.h"
35 + #include "conf_service.h"
36 + #include "conf_shared.h"
37   #include "server.h"
33 #include "resv.h"
38   #include "channel.h"
39   #include "client.h"
40   #include "event.h"
# Line 67 | Line 71 | struct config_admin_entry ConfigAdminInf
71   struct conf_parser_context conf_parser_ctx;
72  
73   /* general conf items link list root, other than k lines etc. */
70 dlink_list service_items;
74   dlink_list server_items;
72 dlink_list cluster_items;
75   dlink_list operator_items;
74 dlink_list shared_items;
75 dlink_list gecos_items;
76 dlink_list nresv_items;
77 dlink_list cresv_items;
76  
77   extern unsigned int lineno;
78   extern char linebuf[];
# Line 136 | Line 134 | map_to_list(enum maskitem_type type)
134   {
135    switch (type)
136    {
139    case CONF_XLINE:
140      return &gecos_items;
141      break;
142    case CONF_SHARED:
143      return &shared_items;
144      break;
145    case CONF_NRESV:
146      return &nresv_items;
147      break;
148    case CONF_CRESV:
149      return &cresv_items;
150      break;
137      case CONF_OPER:
138        return &operator_items;
139        break;
140      case CONF_SERVER:
141        return &server_items;
142        break;
157    case CONF_SERVICE:
158      return &service_items;
159      break;
160    case CONF_CLUSTER:
161      return &cluster_items;
162      break;
143      default:
144        return NULL;
145    }
# Line 223 | Line 203 | conf_free(struct MaskItem *conf)
203      free_dlink_node(node);
204    }
205  
226  DLINK_FOREACH_SAFE(node, node_next, conf->exempt_list.head)
227  {
228    struct exempt *exptr = node->data;
229
230    dlinkDelete(node, &conf->exempt_list);
231    xfree(exptr->name);
232    xfree(exptr->user);
233    xfree(exptr->host);
234    xfree(exptr);
235  }
236
206    xfree(conf);
207   }
208  
# Line 572 | Line 541 | find_matching_name_conf(enum maskitem_ty
541  
542    switch (type)
543    {
575  case CONF_SERVICE:
576    DLINK_FOREACH(node, list->head)
577    {
578      conf = node->data;
579
580      if (EmptyString(conf->name))
581        continue;
582      if (name && !irccmp(name, conf->name))
583        return conf;
584    }
585    break;
586
587  case CONF_XLINE:
588  case CONF_SHARED:
589  case CONF_NRESV:
590  case CONF_CRESV:
591    DLINK_FOREACH(node, list->head)
592    {
593      conf = node->data;
594
595      if (EmptyString(conf->name))
596        continue;
597      if (name && !match(conf->name, name))
598      {
599        if ((user == NULL && (host == NULL)))
600          return conf;
601        if ((conf->modes & flags) != flags)
602          continue;
603        if (EmptyString(conf->user) || EmptyString(conf->host))
604          return conf;
605        if (!match(conf->user, user) && !match(conf->host, host))
606          return conf;
607      }
608    }
609      break;
610
544    case CONF_SERVER:
545      DLINK_FOREACH(node, list->head)
546      {
# Line 645 | Line 578 | find_exact_name_conf(enum maskitem_type
578  
579    switch(type)
580    {
648  case CONF_XLINE:
649  case CONF_SHARED:
650  case CONF_NRESV:
651  case CONF_CRESV:
652
653    DLINK_FOREACH(node, list->head)
654    {
655      conf = node->data;
656
657      if (EmptyString(conf->name))
658        continue;
659
660      if (irccmp(conf->name, name) == 0)
661      {
662        if ((user == NULL && (host == NULL)))
663          return conf;
664        if (EmptyString(conf->user) || EmptyString(conf->host))
665          return conf;
666        if (!match(conf->user, user) && !match(conf->host, host))
667          return conf;
668      }
669    }
670    break;
671
581    case CONF_OPER:
582      DLINK_FOREACH(node, list->head)
583      {
# Line 770 | Line 679 | set_default_conf(void)
679    ConfigServerInfo.max_nick_length = 9;
680    ConfigServerInfo.max_topic_length = 80;
681    ConfigServerInfo.hub = 0;
682 +  ConfigServerInfo.libgeoip_database_options = 0;
683  
684    log_del_all();
685  
# Line 976 | Line 886 | conf_connect_allowed(struct irc_ssaddr *
886    return 0;
887   }
888  
979 /* expire_tklines()
980 *
981 * inputs       - tkline list pointer
982 * output       - NONE
983 * side effects - expire tklines
984 */
985 static void
986 expire_tklines(dlink_list *list)
987 {
988  dlink_node *node = NULL, *node_next = NULL;
989
990  DLINK_FOREACH_SAFE(node, node_next, list->head)
991  {
992    struct MaskItem *conf = node->data;
993
994    if (!conf->until || conf->until > CurrentTime)
995      continue;
996
997    if (ConfigGeneral.tkline_expire_notices)
998      sendto_realops_flags(UMODE_SERVNOTICE, L_ALL, SEND_NOTICE, "Temporary %s for [%s] expired",
999                           (conf->type == CONF_XLINE) ? "X-line" : "RESV", conf->name);
1000    conf_free(conf);
1001  }
1002 }
1003
889   /* cleanup_tklines()
890   *
891   * inputs       - NONE
# Line 1012 | Line 897 | void
897   cleanup_tklines(void *unused)
898   {
899    hostmask_expire_temporary();
900 <  expire_tklines(&gecos_items);
901 <  expire_tklines(&nresv_items);
1017 <  expire_tklines(&cresv_items);
900 >  gecos_expire();
901 >  resv_expire();
902   }
903  
904   /* oper_privs_as_string()
# Line 1023 | Line 907 | cleanup_tklines(void *unused)
907   * output        - pointer to static string showing oper privs
908   * side effects  - return as string, the oper privs as derived from port
909   */
910 < static const struct oper_privs
910 > static const struct oper_flags
911   {
912    const unsigned int flag;
913    const unsigned char c;
914 < } flag_list[] = {
914 > } flag_table[] = {
915    { OPER_FLAG_ADMIN,          'A' },
916    { OPER_FLAG_CLOSE,          'B' },
917    { OPER_FLAG_CONNECT,        'C' },
# Line 1060 | Line 944 | static const struct oper_privs
944   };
945  
946   const char *
947 < oper_privs_as_string(const unsigned int port)
947 > oper_privs_as_string(const unsigned int flags)
948   {
949 <  static char privs_out[IRCD_BUFSIZE];
950 <  char *privs_ptr = privs_out;
949 >  static char buf[sizeof(flag_table) / sizeof(struct oper_flags)];
950 >  char *p = buf;
951  
952 <  for (const struct oper_privs *opriv = flag_list; opriv->flag; ++opriv)
953 <    if (port & opriv->flag)
954 <      *privs_ptr++ = opriv->c;
952 >  for (const struct oper_flags *tab = flag_table; tab->flag; ++tab)
953 >    if (flags & tab->flag)
954 >      *p++ = tab->c;
955  
956 <  if (privs_ptr == privs_out)
957 <    *privs_ptr++ = '0';
956 >  if (p == buf)
957 >    *p++ = '0';
958  
959 <  *privs_ptr = '\0';
959 >  *p = '\0';
960  
961 <  return privs_out;
961 >  return buf;
962   }
963  
964   /*
# Line 1130 | Line 1014 | clear_out_old_conf(void)
1014   {
1015    dlink_node *node = NULL, *node_next = NULL;
1016    dlink_list *free_items [] = {
1017 <    &server_items,   &operator_items,
1134 <     &shared_items,   &gecos_items,
1135 <     &nresv_items, &cluster_items,  &service_items, &cresv_items, NULL
1017 >    &server_items, &operator_items, NULL
1018    };
1019  
1020    dlink_list ** iterator = free_items; /* C is dumb */
# Line 1148 | Line 1030 | clear_out_old_conf(void)
1030        struct MaskItem *conf = node->data;
1031  
1032        conf->active = 0;
1033 +      dlinkDelete(&conf->node, *iterator);
1034  
1035 <      if (!IsConfDatabase(conf))
1036 <      {
1154 <        dlinkDelete(&conf->node, *iterator);
1155 <
1156 <        if (!conf->ref_count)
1157 <          conf_free(conf);
1158 <      }
1035 >      if (!conf->ref_count)
1036 >        conf_free(conf);
1037      }
1038    }
1039  
1040 <  motd_clear();
1040 >  motd_clear();  /* Clear motd {} items and re-cache default motd */
1041  
1042    /*
1043     * Don't delete the class table, rather mark all entries for deletion.
# Line 1169 | Line 1047 | clear_out_old_conf(void)
1047  
1048    clear_out_address_conf();
1049  
1050 <  /* Clean out module paths */
1173 <  mod_clear_paths();
1050 >  modules_conf_clear();  /* Clear modules {} items */
1051  
1052 <  pseudo_clear();
1052 >  motd_clear();  /* Clear motd {} items and re-cache default motd */
1053 >
1054 >  cluster_clear();  /* Clear cluster {} items */
1055 >
1056 >  gecos_clear();  /* Clear gecos {} items */
1057 >
1058 >  resv_clear();  /* Clear resv {} items */
1059 >
1060 >  service_clear();  /* Clear service {} items */
1061 >
1062 >  shared_clear();  /* Clear shared {} items */
1063 >
1064 >  pseudo_clear();  /* Clear pseudo {} items */
1065 >
1066 > #ifdef HAVE_LIBGEOIP
1067 >  GeoIP_delete(GeoIPv4_ctx);
1068 >  GeoIPv4_ctx = NULL;
1069 >  GeoIP_delete(GeoIPv6_ctx);
1070 >  GeoIPv6_ctx = NULL;
1071 > #endif
1072  
1073    /* Clean out ConfigServerInfo */
1074    xfree(ConfigServerInfo.description);
# Line 1181 | Line 1077 | clear_out_old_conf(void)
1077    ConfigServerInfo.network_name = NULL;
1078    xfree(ConfigServerInfo.network_desc);
1079    ConfigServerInfo.network_desc = NULL;
1080 <
1080 >  xfree(ConfigServerInfo.libgeoip_ipv6_database_file);
1081 >  ConfigServerInfo.libgeoip_ipv6_database_file = NULL;
1082 >  xfree(ConfigServerInfo.libgeoip_ipv4_database_file);
1083 >  ConfigServerInfo.libgeoip_ipv4_database_file = NULL;
1084    xfree(ConfigServerInfo.rsa_private_key_file);
1085    ConfigServerInfo.rsa_private_key_file = NULL;
1086    xfree(ConfigServerInfo.ssl_certificate_file);
# Line 1218 | Line 1117 | conf_handle_tls(int cold)
1117      if (cold)
1118      {
1119        ilog(LOG_TYPE_IRCD, "Error while initializing TLS");
1120 <      exit(-1);
1120 >      exit(EXIT_FAILURE);
1121      }
1122      else
1123      {
# Line 1745 | Line 1644 | match_conf_password(const char *password
1644   }
1645  
1646   /*
1748 * cluster_a_line
1749 *
1750 * inputs       - client sending the cluster
1751 *              - command name "KLINE" "XLINE" etc.
1752 *              - capab -- CAPAB_KLN etc. from server.h
1753 *              - cluster type -- CLUSTER_KLINE etc. from conf.h
1754 *              - pattern and args to send along
1755 * output       - none
1756 * side effects - Take source_p send the pattern with args given
1757 *                along to all servers that match capab and cluster type
1758 */
1759 void
1760 cluster_a_line(struct Client *source_p, const char *command, unsigned int capab,
1761               unsigned int cluster_type, const char *pattern, ...)
1762 {
1763  va_list args;
1764  char buffer[IRCD_BUFSIZE] = "";
1765  const dlink_node *node = NULL;
1766
1767  va_start(args, pattern);
1768  vsnprintf(buffer, sizeof(buffer), pattern, args);
1769  va_end(args);
1770
1771  DLINK_FOREACH(node, cluster_items.head)
1772  {
1773    const struct MaskItem *conf = node->data;
1774
1775    if (conf->flags & cluster_type)
1776      sendto_match_servs(source_p, conf->name, CAPAB_CLUSTER | capab,
1777                         "%s %s %s", command, conf->name, buffer);
1778  }
1779 }
1780
1781 /*
1647   * split_nuh
1648   *
1649   * inputs       - pointer to original mask (modified in place)

Diff Legend

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