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 5039 by michael, Sat Dec 13 16:08:37 2014 UTC vs.
Revision 6842 by michael, Tue Nov 24 17:46:18 2015 UTC

# Line 1 | Line 1
1   /*
2   *  ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3   *
4 < *  Copyright (c) 1997-2014 ircd-hybrid development team
4 > *  Copyright (c) 1997-2015 ircd-hybrid development team
5   *
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
# Line 55 | Line 55
55   #include "conf_class.h"
56   #include "motd.h"
57   #include "ipcache.h"
58 + #include "isupport.h"
59  
60  
61 + struct config_channel_entry ConfigChannel;
62 + struct config_serverhide_entry ConfigServerHide;
63 + struct config_general_entry ConfigGeneral;
64 + struct config_log_entry ConfigLog = { .use_logging = 1 };
65 + struct config_serverinfo_entry ConfigServerInfo;
66 + struct config_admin_entry ConfigAdminInfo;
67 + struct conf_parser_context conf_parser_ctx;
68 +
69   /* general conf items link list root, other than k lines etc. */
70   dlink_list service_items;
71   dlink_list server_items;
72   dlink_list cluster_items;
73 < dlink_list oconf_items;
74 < dlink_list uconf_items;
75 < dlink_list xconf_items;
73 > dlink_list operator_items;
74 > dlink_list shared_items;
75 > dlink_list gecos_items;
76   dlink_list nresv_items;
77   dlink_list cresv_items;
78  
# Line 128 | Line 137 | map_to_list(enum maskitem_type type)
137    switch (type)
138    {
139      case CONF_XLINE:
140 <      return &xconf_items;
140 >      return &gecos_items;
141        break;
142 <    case CONF_ULINE:
143 <      return &uconf_items;
142 >    case CONF_SHARED:
143 >      return &shared_items;
144        break;
145      case CONF_NRESV:
146        return &nresv_items;
# Line 140 | Line 149 | map_to_list(enum maskitem_type type)
149        return &cresv_items;
150        break;
151      case CONF_OPER:
152 <      return &oconf_items;
152 >      return &operator_items;
153        break;
154      case CONF_SERVER:
155        return &server_items;
# Line 195 | Line 204 | conf_free(struct MaskItem *conf)
204    MyFree(conf->spasswd);
205    MyFree(conf->reason);
206    MyFree(conf->certfp);
207 +  MyFree(conf->whois);
208    MyFree(conf->user);
209    MyFree(conf->host);
210   #ifdef HAVE_LIBCRYPTO
# Line 250 | Line 260 | attach_iline(struct Client *client_p, st
260    ip_found->count++;
261    AddFlag(client_p, FLAGS_IPHASH);
262  
263 <  count_user_host(client_p->username, client_p->host,
264 <                  &global, &local, &ident);
263 >  userhost_count(client_p->username, client_p->host,
264 >                 &global, &local, &ident);
265  
266    /* XXX blah. go down checking the various silly limits
267     * setting a_limit_reached if any limit is reached.
# Line 291 | Line 301 | static int
301   verify_access(struct Client *client_p)
302   {
303    struct MaskItem *conf = NULL;
294  char non_ident[USERLEN + 1] = "~";
304  
305 <  if (IsGotId(client_p))
305 >  if (HasFlag(client_p, FLAGS_GOTID))
306    {
307      conf = find_address_conf(client_p->host, client_p->username,
308                               &client_p->connection->ip,
# Line 302 | Line 311 | verify_access(struct Client *client_p)
311    }
312    else
313    {
314 +    char non_ident[USERLEN + 1] = "~";
315 +
316      strlcpy(non_ident + 1, client_p->username, sizeof(non_ident) - 1);
317      conf = find_address_conf(client_p->host, non_ident,
318                               &client_p->connection->ip,
# Line 309 | Line 320 | verify_access(struct Client *client_p)
320                               client_p->connection->password);
321    }
322  
323 <  if (conf)
324 <  {
314 <    if (IsConfClient(conf))
315 <    {
316 <      if (IsConfRedir(conf))
317 <      {
318 <        sendto_one_numeric(client_p, &me, RPL_REDIR,
319 <                           conf->name ? conf->name : "",
320 <                           conf->port);
321 <        return NOT_AUTHORIZED;
322 <      }
323 >  if (!conf)
324 >    return NOT_AUTHORIZED;
325  
326 <      /* Thanks for spoof idea amm */
325 <      if (IsConfDoSpoofIp(conf))
326 <      {
327 <        if (IsConfSpoofNotice(conf))
328 <          sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE, "%s spoofing: %s as %s",
329 <                               client_p->name, client_p->host, conf->name);
326 >  assert(IsConfClient(conf) || IsConfKill(conf));
327  
328 <        strlcpy(client_p->host, conf->name, sizeof(client_p->host));
329 <      }
330 <
331 <      return attach_iline(client_p, conf);
328 >  if (IsConfClient(conf))
329 >  {
330 >    if (IsConfRedir(conf))
331 >    {
332 >      sendto_one_numeric(client_p, &me, RPL_REDIR,
333 >                         conf->name ? conf->name : "",
334 >                         conf->port);
335 >      return NOT_AUTHORIZED;
336      }
337 <    else if (IsConfKill(conf) || (ConfigGeneral.glines && IsConfGline(conf)))
337 >
338 >    if (IsConfDoSpoofIp(conf))
339      {
340 <      if (IsConfGline(conf))
341 <        sendto_one_notice(client_p, &me, ":*** G-lined");
340 >      if (IsConfSpoofNotice(conf))
341 >        sendto_realops_flags(UMODE_SERVNOTICE, L_ADMIN, SEND_NOTICE, "%s spoofing: %s as %s",
342 >                             client_p->name, client_p->host, conf->name);
343  
344 <      sendto_one_notice(client_p, &me, ":*** Banned: %s", conf->reason);
342 <      return BANNED_CLIENT;
344 >      strlcpy(client_p->host, conf->name, sizeof(client_p->host));
345      }
346 +
347 +    return attach_iline(client_p, conf);
348    }
349  
350 <  return NOT_AUTHORIZED;
350 >  sendto_one_notice(client_p, &me, ":*** Banned: %s", conf->reason);
351 >  return BANNED_CLIENT;
352   }
353  
354   /* check_client()
# Line 517 | Line 522 | attach_connect_block(struct Client *clie
522        continue;
523  
524      attach_conf(client_p, conf);
525 <    return -1;
525 >    return 1;
526    }
527  
528    return 0;
# Line 584 | Line 589 | find_matching_name_conf(enum maskitem_ty
589      break;
590  
591    case CONF_XLINE:
592 <  case CONF_ULINE:
592 >  case CONF_SHARED:
593    case CONF_NRESV:
594    case CONF_CRESV:
595      DLINK_FOREACH(node, list->head)
# Line 645 | Line 650 | find_exact_name_conf(enum maskitem_type
650    switch(type)
651    {
652    case CONF_XLINE:
653 <  case CONF_ULINE:
653 >  case CONF_SHARED:
654    case CONF_NRESV:
655    case CONF_CRESV:
656  
# Line 774 | Line 779 | set_default_conf(void)
779  
780    SSL_CTX_set_cipher_list(ConfigServerInfo.server_ctx, "EECDH+HIGH:EDH+HIGH:HIGH:!aNULL");
781    ConfigServerInfo.message_digest_algorithm = EVP_sha256();
777  ConfigServerInfo.rsa_private_key = NULL;
778  ConfigServerInfo.rsa_private_key_file = NULL;
782   #endif
783  
781  /* ConfigServerInfo.name is not rehashable */
782  /* ConfigServerInfo.name = ConfigServerInfo.name; */
783  ConfigServerInfo.description = NULL;
784    ConfigServerInfo.network_name = xstrdup(NETWORK_NAME_DEFAULT);
785    ConfigServerInfo.network_desc = xstrdup(NETWORK_DESC_DEFAULT);
786  
# Line 789 | Line 789 | set_default_conf(void)
789    memset(&ConfigServerInfo.ip6, 0, sizeof(ConfigServerInfo.ip6));
790    ConfigServerInfo.specific_ipv6_vhost = 0;
791  
792 <  ConfigServerInfo.max_clients = MAXCLIENTS_MAX;
792 >  ConfigServerInfo.default_max_clients = MAXCLIENTS_MAX;
793    ConfigServerInfo.max_nick_length = 9;
794    ConfigServerInfo.max_topic_length = 80;
795    ConfigServerInfo.hub = 0;
796  
797  ConfigAdminInfo.name = NULL;
798  ConfigAdminInfo.email = NULL;
799  ConfigAdminInfo.description = NULL;
800
797    log_del_all();
798  
799    ConfigLog.use_logging = 1;
# Line 805 | Line 801 | set_default_conf(void)
801    ConfigChannel.disable_fake_channels = 0;
802    ConfigChannel.invite_client_count = 10;
803    ConfigChannel.invite_client_time = 300;
804 +  ConfigChannel.invite_delay_channel = 5;
805    ConfigChannel.knock_client_count = 1;
806    ConfigChannel.knock_client_time = 300;
807    ConfigChannel.knock_delay_channel = 60;
808    ConfigChannel.max_channels = 25;
809    ConfigChannel.max_bans = 25;
810 <  ConfigChannel.default_split_user_count = 0;
811 <  ConfigChannel.default_split_server_count = 0;
815 <  ConfigChannel.no_join_on_split = 0;
816 <  ConfigChannel.no_create_on_split = 0;
810 >  ConfigChannel.default_join_flood_count = 18;
811 >  ConfigChannel.default_join_flood_time = 6;
812  
813    ConfigServerHide.flatten_links = 0;
814 <  ConfigServerHide.links_delay = 300;
814 >  ConfigServerHide.flatten_links_delay = 300;
815    ConfigServerHide.hidden = 0;
816    ConfigServerHide.hide_servers = 0;
817    ConfigServerHide.hide_services = 0;
# Line 826 | Line 821 | set_default_conf(void)
821  
822    ConfigGeneral.away_count = 2;
823    ConfigGeneral.away_time = 10;
824 <  ConfigGeneral.max_watch = WATCHSIZE_DEFAULT;
824 >  ConfigGeneral.max_watch = 50;
825    ConfigGeneral.cycle_on_host_change = 1;
826 <  ConfigGeneral.glines = 0;
827 <  ConfigGeneral.gline_time = 12 * 3600;
828 <  ConfigGeneral.gline_request_time = GLINE_REQUEST_EXPIRE_DEFAULT;
829 <  ConfigGeneral.gline_min_cidr = 16;
835 <  ConfigGeneral.gline_min_cidr6 = 48;
826 >  ConfigGeneral.dline_min_cidr = 16;
827 >  ConfigGeneral.dline_min_cidr6 = 48;
828 >  ConfigGeneral.kline_min_cidr = 16;
829 >  ConfigGeneral.kline_min_cidr6 = 48;
830    ConfigGeneral.invisible_on_connect = 1;
831    ConfigGeneral.tkline_expire_notices = 1;
832    ConfigGeneral.ignore_bogus_ts = 0;
# Line 843 | Line 837 | set_default_conf(void)
837    ConfigGeneral.dots_in_ident = 0;
838    ConfigGeneral.min_nonwildcard = 4;
839    ConfigGeneral.min_nonwildcard_simple = 3;
840 <  ConfigGeneral.max_accept = 20;
840 >  ConfigGeneral.max_accept = 50;
841    ConfigGeneral.anti_nick_flood = 0;
842    ConfigGeneral.max_nick_time = 20;
843    ConfigGeneral.max_nick_changes = 5;
# Line 865 | Line 859 | set_default_conf(void)
859    ConfigGeneral.short_motd = 0;
860    ConfigGeneral.ping_cookie = 0;
861    ConfigGeneral.no_oper_flood = 0;
868  ConfigGeneral.oper_pass_resv = 1;
862    ConfigGeneral.max_targets = MAX_TARGETS_DEFAULT;
863 <  ConfigGeneral.oper_only_umodes = UMODE_DEBUG;
863 >  ConfigGeneral.oper_only_umodes = UMODE_DEBUG | UMODE_LOCOPS | UMODE_HIDDEN | UMODE_FARCONNECT |
864 >                                   UMODE_UNAUTH | UMODE_EXTERNAL | UMODE_BOTS | UMODE_NCHANGE |
865 >                                   UMODE_SPY | UMODE_FULL | UMODE_SKILL | UMODE_REJ | UMODE_CCONN;
866    ConfigGeneral.oper_umodes = UMODE_BOTS | UMODE_LOCOPS | UMODE_SERVNOTICE | UMODE_WALLOP;
867    ConfigGeneral.throttle_count = 1;
868    ConfigGeneral.throttle_time = 1;
# Line 887 | Line 882 | validate_conf(void)
882  
883    if (EmptyString(ConfigServerInfo.network_desc))
884      ConfigServerInfo.network_desc = xstrdup(NETWORK_DESC_DEFAULT);
890
891  ConfigGeneral.max_watch = IRCD_MAX(ConfigGeneral.max_watch, WATCHSIZE_MIN);
885   }
886  
887   /* read_conf()
# Line 921 | Line 914 | read_conf(FILE *file)
914   * as a result of an operator issuing this command, else assume it has been
915   * called as a result of the server receiving a HUP signal.
916   */
917 < int
917 > void
918   conf_rehash(int sig)
919   {
920    if (sig)
921 <    sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
921 >    sendto_realops_flags(UMODE_SERVNOTICE, L_ALL, SEND_NOTICE,
922                           "Got signal SIGHUP, reloading configuration file(s)");
923  
924    restart_resolver();
# Line 936 | Line 929 | conf_rehash(int sig)
929  
930    load_conf_modules();
931    check_conf_klines();
939
940  return 0;
932   }
933  
934   /* lookup_confhost()
# Line 988 | Line 979 | int
979   conf_connect_allowed(struct irc_ssaddr *addr, int aftype)
980   {
981    struct ip_entry *ip_found = NULL;
982 <  struct MaskItem *const conf = find_dline_conf(addr, aftype);
992 <
993 <  /* DLINE exempt also gets you out of static limits/pacing... */
994 <  if (conf && (conf->type == CONF_EXEMPT))
995 <    return 0;
982 >  const struct MaskItem *conf = find_dline_conf(addr, aftype);
983  
984    if (conf)
985 +  {
986 +    /* DLINE exempt also gets you out of static limits/pacing... */
987 +    if (conf->type == CONF_EXEMPT)
988 +      return 0;
989      return BANNED_CLIENT;
990 +  }
991  
992    ip_found = ipcache_find_or_add_address(addr);
993  
# Line 1031 | Line 1023 | expire_tklines(dlink_list *list)
1023      if (!conf->until || conf->until > CurrentTime)
1024        continue;
1025  
1026 <    if (conf->type == CONF_XLINE)
1027 <    {
1028 <      if (ConfigGeneral.tkline_expire_notices)
1029 <        sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1038 <                               "Temporary X-line for [%s] expired", conf->name);
1039 <      conf_free(conf);
1040 <    }
1041 <    else if (conf->type == CONF_NRESV || conf->type == CONF_CRESV)
1042 <    {
1043 <      if (ConfigGeneral.tkline_expire_notices)
1044 <        sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1045 <                               "Temporary RESV for [%s] expired", conf->name);
1046 <      conf_free(conf);
1047 <    }
1026 >    if (ConfigGeneral.tkline_expire_notices)
1027 >      sendto_realops_flags(UMODE_SERVNOTICE, L_ALL, SEND_NOTICE, "Temporary %s for [%s] expired",
1028 >                           (conf->type == CONF_XLINE) ? "X-line" : "RESV", conf->name);
1029 >    conf_free(conf);
1030    }
1031   }
1032  
# Line 1059 | Line 1041 | void
1041   cleanup_tklines(void *unused)
1042   {
1043    hostmask_expire_temporary();
1044 <  expire_tklines(&xconf_items);
1044 >  expire_tklines(&gecos_items);
1045    expire_tklines(&nresv_items);
1046    expire_tklines(&cresv_items);
1047   }
# Line 1076 | Line 1058 | static const struct oper_privs
1058    const unsigned char c;
1059   } flag_list[] = {
1060    { OPER_FLAG_ADMIN,          'A' },
1061 <  { OPER_FLAG_REMOTEBAN,      'B' },
1062 <  { OPER_FLAG_DIE,            'D' },
1063 <  { OPER_FLAG_GLINE,          'G' },
1064 <  { OPER_FLAG_REHASH,         'H' },
1061 >  { OPER_FLAG_CLOSE,          'B' },
1062 >  { OPER_FLAG_CONNECT,        'C' },
1063 >  { OPER_FLAG_CONNECT_REMOTE, 'D' },
1064 >  { OPER_FLAG_DIE,            'E' },
1065 >  { OPER_FLAG_DLINE,          'F' },
1066 >  { OPER_FLAG_GLOBOPS,        'G' },
1067 >  { OPER_FLAG_JOIN_RESV,      'H' },
1068 >  { OPER_FLAG_KILL,           'I' },
1069 >  { OPER_FLAG_KILL_REMOTE,    'J' },
1070    { OPER_FLAG_KLINE,          'K' },
1071 <  { OPER_FLAG_KILL,           'N' },
1072 <  { OPER_FLAG_KILL_REMOTE,    'O' },
1073 <  { OPER_FLAG_CONNECT,        'P' },
1074 <  { OPER_FLAG_CONNECT_REMOTE, 'Q' },
1075 <  { OPER_FLAG_SQUIT,          'R' },
1076 <  { OPER_FLAG_SQUIT_REMOTE,   'S' },
1077 <  { OPER_FLAG_UNKLINE,        'U' },
1078 <  { OPER_FLAG_XLINE,          'X' },
1071 >  { OPER_FLAG_LOCOPS,         'L' },
1072 >  { OPER_FLAG_MODULE,         'M' },
1073 >  { OPER_FLAG_NICK_RESV,      'N' },
1074 >  { OPER_FLAG_OPME,           'O' },
1075 >  { OPER_FLAG_REHASH,         'P' },
1076 >  { OPER_FLAG_REMOTEBAN,      'Q' },
1077 >  { OPER_FLAG_RESTART,        'R' },
1078 >  { OPER_FLAG_RESV,           'S' },
1079 >  { OPER_FLAG_SET,            'T' },
1080 >  { OPER_FLAG_SQUIT,          'U' },
1081 >  { OPER_FLAG_SQUIT_REMOTE,   'V' },
1082 >  { OPER_FLAG_UNDLINE,        'W' },
1083 >  { OPER_FLAG_UNKLINE,        'X' },
1084 >  { OPER_FLAG_UNRESV,         'Y' },
1085 >  { OPER_FLAG_UNXLINE,        'Z' },
1086 >  { OPER_FLAG_WALLOPS,        'a' },
1087 >  { OPER_FLAG_XLINE,          'b' },
1088    { 0, '\0' }
1089   };
1090  
1091 < char *
1091 > const char *
1092   oper_privs_as_string(const unsigned int port)
1093   {
1094    static char privs_out[IRCD_BUFSIZE];
1095    char *privs_ptr = privs_out;
1096  
1097    for (const struct oper_privs *opriv = flag_list; opriv->flag; ++opriv)
1102  {
1098      if (port & opriv->flag)
1099        *privs_ptr++ = opriv->c;
1100 <    else
1101 <      *privs_ptr++ = ToLower(opriv->c);
1102 <  }
1100 >
1101 >  if (privs_ptr == privs_out)
1102 >    *privs_ptr++ = '0';
1103  
1104    *privs_ptr = '\0';
1105  
# Line 1120 | Line 1115 | oper_privs_as_string(const unsigned int
1115   const char *
1116   get_oper_name(const struct Client *client_p)
1117   {
1118 <  /* +5 for !,@,{,} and null */
1124 <  static char buffer[NICKLEN + USERLEN + HOSTLEN + HOSTLEN + 5];
1118 >  static char buffer[IRCD_BUFSIZE];
1119  
1120    if (IsServer(client_p))
1121      return client_p->name;
# Line 1165 | Line 1159 | clear_out_old_conf(void)
1159   {
1160    dlink_node *node = NULL, *node_next = NULL;
1161    dlink_list *free_items [] = {
1162 <    &server_items,   &oconf_items,
1163 <     &uconf_items,   &xconf_items,
1162 >    &server_items,   &operator_items,
1163 >     &shared_items,   &gecos_items,
1164       &nresv_items, &cluster_items,  &service_items, &cresv_items, NULL
1165    };
1166  
# Line 1183 | Line 1177 | clear_out_old_conf(void)
1177        struct MaskItem *conf = node->data;
1178  
1179        conf->active = 0;
1186      dlinkDelete(&conf->node, *iterator);
1180  
1181 <      /* XXX This is less than pretty */
1189 <      if (conf->type == CONF_SERVER || conf->type == CONF_OPER)
1181 >      if (!IsConfDatabase(conf))
1182        {
1183 +        dlinkDelete(&conf->node, *iterator);
1184 +
1185          if (!conf->ref_count)
1186            conf_free(conf);
1187        }
1194      else if (conf->type == CONF_XLINE)
1195      {
1196        if (!conf->until)
1197          conf_free(conf);
1198      }
1199      else
1200        conf_free(conf);
1188      }
1189    }
1190  
1191    motd_clear();
1192  
1193    /*
1194 <   * don't delete the class table, rather mark all entries
1195 <   * for deletion. The table is cleaned up by class_delete_marked. - avalon
1194 >   * Don't delete the class table, rather mark all entries for deletion.
1195 >   * The table is cleaned up by class_delete_marked. - avalon
1196     */
1197    class_mark_for_deletion();
1198  
1199    clear_out_address_conf();
1200  
1201 <  /* clean out module paths */
1201 >  /* Clean out module paths */
1202    mod_clear_paths();
1203  
1204    pseudo_clear();
1205  
1206 <  /* clean out ConfigServerInfo */
1206 >  /* Clean out ConfigServerInfo */
1207    MyFree(ConfigServerInfo.description);
1208    ConfigServerInfo.description = NULL;
1209    MyFree(ConfigServerInfo.network_name);
# Line 1234 | Line 1221 | clear_out_old_conf(void)
1221    ConfigServerInfo.rsa_private_key_file = NULL;
1222   #endif
1223  
1224 <  /* clean out ConfigAdminInfo */
1224 >  /* Clean out ConfigAdminInfo */
1225    MyFree(ConfigAdminInfo.name);
1226    ConfigAdminInfo.name = NULL;
1227    MyFree(ConfigAdminInfo.email);
# Line 1242 | Line 1229 | clear_out_old_conf(void)
1229    MyFree(ConfigAdminInfo.description);
1230    ConfigAdminInfo.description = NULL;
1231  
1232 <  /* clean out listeners */
1233 <  close_listeners();
1232 >  MyFree(ConfigServerHide.flatten_links_file);
1233 >  ConfigServerHide.flatten_links_file = NULL;
1234 >
1235 >  /* Clean out listeners */
1236 >  listener_close_marked();
1237   }
1238  
1239   /* read_conf_files()
# Line 1276 | Line 1266 | read_conf_files(int cold)
1266      {
1267        ilog(LOG_TYPE_IRCD, "Unable to read configuration file '%s': %s",
1268             filename, strerror(errno));
1269 <      exit(-1);
1269 >      exit(EXIT_FAILURE);
1270      }
1271      else
1272      {
1273 <      sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1273 >      sendto_realops_flags(UMODE_SERVNOTICE, L_ADMIN, SEND_NOTICE,
1274                             "Unable to read configuration file '%s': %s",
1275                             filename, strerror(errno));
1276        return;
# Line 1295 | Line 1285 | read_conf_files(int cold)
1285  
1286    log_reopen_all();
1287  
1288 <  add_isupport("NICKLEN", NULL, ConfigServerInfo.max_nick_length);
1289 <  add_isupport("NETWORK", ConfigServerInfo.network_name, -1);
1288 >  isupport_add("NICKLEN", NULL, ConfigServerInfo.max_nick_length);
1289 >  isupport_add("NETWORK", ConfigServerInfo.network_name, -1);
1290  
1291 <  snprintf(chanmodes, sizeof(chanmodes), "beI:%d", ConfigChannel.max_bans);
1292 <  add_isupport("MAXLIST", chanmodes, -1);
1293 <  add_isupport("MAXTARGETS", NULL, ConfigGeneral.max_targets);
1294 <  add_isupport("CHANTYPES", "#", -1);
1291 >  snprintf(chanmodes, sizeof(chanmodes), "beI:%u", ConfigChannel.max_bans);
1292 >  isupport_add("MAXLIST", chanmodes, -1);
1293 >  isupport_add("MAXTARGETS", NULL, ConfigGeneral.max_targets);
1294 >  isupport_add("CHANTYPES", "#", -1);
1295  
1296 <  snprintf(chanlimit, sizeof(chanlimit), "#:%d",
1296 >  snprintf(chanlimit, sizeof(chanlimit), "#:%u",
1297             ConfigChannel.max_channels);
1298 <  add_isupport("CHANLIMIT", chanlimit, -1);
1299 <  snprintf(chanmodes, sizeof(chanmodes), "%s", "beI,k,l,cimnprstMORS");
1300 <  add_isupport("CHANNELLEN", NULL, CHANNELLEN);
1301 <  add_isupport("TOPICLEN", NULL, ConfigServerInfo.max_topic_length);
1302 <  add_isupport("CHANMODES", chanmodes, -1);
1298 >  isupport_add("CHANLIMIT", chanlimit, -1);
1299 >  snprintf(chanmodes, sizeof(chanmodes), "%s", "beI,k,l,cimnprstCMORS");
1300 >  isupport_add("CHANNELLEN", NULL, CHANNELLEN);
1301 >  isupport_add("TOPICLEN", NULL, ConfigServerInfo.max_topic_length);
1302 >  isupport_add("CHANMODES", chanmodes, -1);
1303  
1304    /*
1305     * message_locale may have changed.  rebuild isupport since it relies
1306     * on strlen(form_str(RPL_ISUPPORT))
1307     */
1308 <  rebuild_isupport_message_line();
1308 >  isupport_rebuild();
1309   }
1310  
1311   /* conf_add_class_to_conf()
# Line 1325 | Line 1315 | read_conf_files(int cold)
1315   * side effects - Add a class pointer to a conf
1316   */
1317   void
1318 < conf_add_class_to_conf(struct MaskItem *conf, const char *class_name)
1318 > conf_add_class_to_conf(struct MaskItem *conf, const char *name)
1319   {
1320 <  if (class_name == NULL)
1320 >  if (EmptyString(name) || (conf->class = class_find(name, 1)) == NULL)
1321    {
1322      conf->class = class_default;
1323  
1324      if (conf->type == CONF_CLIENT || conf->type == CONF_OPER)
1325 <      sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1325 >      sendto_realops_flags(UMODE_SERVNOTICE, L_ADMIN, SEND_NOTICE,
1326                             "Warning *** Defaulting to default class for %s@%s",
1327                             conf->user, conf->host);
1328      else
1329 <      sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1329 >      sendto_realops_flags(UMODE_SERVNOTICE, L_ADMIN, SEND_NOTICE,
1330                             "Warning *** Defaulting to default class for %s",
1331                             conf->name);
1332    }
1343  else
1344    conf->class = class_find(class_name, 1);
1345
1346  if (conf->class == NULL)
1347  {
1348    if (conf->type == CONF_CLIENT || conf->type == CONF_OPER)
1349      sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1350                           "Warning *** Defaulting to default class for %s@%s",
1351                           conf->user, conf->host);
1352    else
1353      sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1354                           "Warning *** Defaulting to default class for %s",
1355                           conf->name);
1356    conf->class = class_default;
1357  }
1333   }
1334  
1335   /* yyerror()
# Line 1372 | Line 1347 | yyerror(const char *msg)
1347      return;
1348  
1349    strip_tabs(newlinebuf, linebuf, sizeof(newlinebuf));
1350 <  sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1350 >  sendto_realops_flags(UMODE_SERVNOTICE, L_ADMIN, SEND_NOTICE,
1351                         "\"%s\", line %u: %s: %s",
1352                         conffilebuf, lineno + 1, msg, newlinebuf);
1353    ilog(LOG_TYPE_IRCD, "\"%s\", line %u: %s: %s",
# Line 1385 | Line 1360 | conf_error_report(const char *msg)
1360    char newlinebuf[IRCD_BUFSIZE];
1361  
1362    strip_tabs(newlinebuf, linebuf, sizeof(newlinebuf));
1363 <  sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1363 >  sendto_realops_flags(UMODE_SERVNOTICE, L_ADMIN, SEND_NOTICE,
1364                         "\"%s\", line %u: %s: %s",
1365                         conffilebuf, lineno + 1, msg, newlinebuf);
1366    ilog(LOG_TYPE_IRCD, "\"%s\", line %u: %s: %s",
# Line 1420 | Line 1395 | valid_tkline(const char *data, const int
1395  
1396    /*
1397     * In the degenerate case where oper does a /quote kline 0 user@host :reason
1398 <   * i.e. they specifically use 0, I am going to return 1 instead
1399 <   * as a return value of non-zero is used to flag it as a temporary kline
1398 >   * i.e. they specifically use 0, I am going to return 1 instead as a return
1399 >   * value of non-zero is used to flag it as a temporary kline
1400     */
1401    if (result == 0)
1402      result = 1;
# Line 1436 | Line 1411 | valid_tkline(const char *data, const int
1411    if (result > MAX_TDKLINE_TIME)
1412      result = MAX_TDKLINE_TIME;
1413  
1414 <  result = result * 60;  /* turn it into seconds */
1414 >  result = result * 60;  /* Turn it into seconds */
1415  
1416    return result;
1417   }
# Line 1452 | Line 1427 | valid_wild_card_simple(const char *data)
1427   {
1428    const unsigned char *p = (const unsigned char *)data;
1429    unsigned char tmpch = '\0';
1430 <  unsigned int nonwild = 0;
1430 >  unsigned int nonwild = 0, wild = 0;
1431  
1432    while ((tmpch = *p++))
1433    {
# Line 1467 | Line 1442 | valid_wild_card_simple(const char *data)
1442        if (++nonwild >= ConfigGeneral.min_nonwildcard_simple)
1443          return 1;
1444      }
1445 +    else
1446 +      ++wild;
1447    }
1448  
1449 <  return 0;
1449 >  return !wild;
1450   }
1451  
1452   /* valid_wild_card()
# Line 1481 | Line 1458 | valid_wild_card_simple(const char *data)
1458   * side effects - NOTICE is given to source_p if warn is 1
1459   */
1460   int
1461 < valid_wild_card(struct Client *source_p, int warn, int count, ...)
1461 > valid_wild_card(struct Client *source_p, int count, ...)
1462   {
1463    unsigned char tmpch = '\0';
1464    unsigned int nonwild = 0;
# Line 1524 | Line 1501 | valid_wild_card(struct Client *source_p,
1501      }
1502    }
1503  
1504 <  if (warn)
1504 >  if (IsClient(source_p))
1505      sendto_one_notice(source_p, &me,
1506                        ":Please include at least %u non-wildcard characters with the mask",
1507                        ConfigGeneral.min_nonwildcard);
# Line 1543 | Line 1520 | valid_wild_card(struct Client *source_p,
1520   */
1521   static int
1522   find_user_host(struct Client *source_p, char *user_host_or_nick,
1523 <               char *luser, char *lhost, unsigned int flags)
1523 >               char *luser, char *lhost)
1524   {
1525    struct Client *target_p = NULL;
1526    char *hostp = NULL;
# Line 1588 | Line 1565 | find_user_host(struct Client *source_p,
1565          find_chasing(source_p, user_host_or_nick)) == NULL)
1566        return 0;  /* find_chasing sends ERR_NOSUCHNICK */
1567  
1568 <    if (IsExemptKline(target_p))
1568 >    if (HasFlag(target_p, FLAGS_EXEMPTKLINE))
1569      {
1570        if (IsClient(source_p))
1571          sendto_one_notice(source_p, &me, ":%s is E-lined", target_p->name);
# Line 1596 | Line 1573 | find_user_host(struct Client *source_p,
1573      }
1574  
1575      /*
1576 <     * turn the "user" bit into "*user", blow away '~'
1576 >     * Turn the "user" bit into "*user", blow away '~'
1577       * if found in original user name (non-idented)
1578       */
1579      strlcpy(luser, target_p->username, USERLEN*4 + 1);
# Line 1604 | Line 1581 | find_user_host(struct Client *source_p,
1581      if (target_p->username[0] == '~')
1582        luser[0] = '*';
1583  
1584 <    if (!strcmp(target_p->sockhost, "0"))
1608 <      strlcpy(lhost, target_p->host, HOSTLEN*4 + 1);
1609 <    else
1610 <      strlcpy(lhost, target_p->sockhost, HOSTLEN*4 + 1);
1584 >    strlcpy(lhost, target_p->sockhost, HOSTLEN*4 + 1);
1585      return 1;
1586    }
1587  
# Line 1628 | Line 1602 | find_user_host(struct Client *source_p,
1602   *              - pointer to target_server to parse into if non NULL
1603   *              - pointer to reason to parse into
1604   *
1605 < * output       - 1 if valid, -1 if not valid
1605 > * output       - 1 if valid, 0 if not valid
1606   * side effects - A generalised k/d/x etc. line parser,
1607   *               "ALINE [time] user@host|string [ON] target :reason"
1608   *                will parse returning a parsed user, host if
# Line 1651 | Line 1625 | parse_aline(const char *cmd, struct Clie
1625              char **target_server, char **reason)
1626   {
1627    int found_tkline_time=0;
1628 <  static char def_reason[] = CONF_NOREASON;
1628 >  static char default_reason[] = CONF_NOREASON;
1629    static char user[USERLEN*4+1];
1630    static char host[HOSTLEN*4+1];
1631  
# Line 1670 | Line 1644 | parse_aline(const char *cmd, struct Clie
1644      else
1645      {
1646        sendto_one_notice(source_p, &me, ":temp_line not supported by %s", cmd);
1647 <      return -1;
1647 >      return 0;
1648      }
1649    }
1650  
1651    if (parc == 0)
1652    {
1653      sendto_one_numeric(source_p, &me, ERR_NEEDMOREPARAMS, cmd);
1654 <    return -1;
1654 >    return 0;
1655    }
1656  
1657    if (h_p == NULL)
1658      *up_p = *parv;
1659    else
1660    {
1661 <    if (find_user_host(source_p, *parv, user, host, parse_flags) == 0)
1662 <      return -1;
1661 >    if (find_user_host(source_p, *parv, user, host) == 0)
1662 >      return 0;
1663  
1664      *up_p = user;
1665      *h_p = host;
# Line 1701 | Line 1675 | parse_aline(const char *cmd, struct Clie
1675        parc--;
1676        parv++;
1677  
1704      if (target_server == NULL)
1705      {
1706        sendto_one_notice(source_p, &me, ":ON server not supported by %s", cmd);
1707        return -1;
1708      }
1709
1678        if (!HasOFlag(source_p, OPER_FLAG_REMOTEBAN))
1679        {
1680          sendto_one_numeric(source_p, &me, ERR_NOPRIVS, "remoteban");
1681 <        return -1;
1681 >        return 0;
1682        }
1683  
1684        if (parc == 0 || EmptyString(*parv))
1685        {
1686          sendto_one_numeric(source_p, &me, ERR_NEEDMOREPARAMS, cmd);
1687 <        return -1;
1687 >        return 0;
1688        }
1689  
1690        *target_server = *parv;
# Line 1738 | Line 1706 | parse_aline(const char *cmd, struct Clie
1706      if (strchr(user, '!'))
1707      {
1708        sendto_one_notice(source_p, &me, ":Invalid character '!' in kline");
1709 <      return -1;
1709 >      return 0;
1710      }
1711  
1712 <    if ((parse_flags & AWILD) && !valid_wild_card(source_p, 1, 2, *up_p, *h_p))
1713 <      return -1;
1712 >    if ((parse_flags & AWILD) && !valid_wild_card(source_p, 2, *up_p, *h_p))
1713 >      return 0;
1714    }
1715    else
1716 <    if ((parse_flags & AWILD) && !valid_wild_card(source_p, 1, 1, *up_p))
1717 <      return -1;
1716 >    if ((parse_flags & AWILD) && !valid_wild_card(source_p, 1, *up_p))
1717 >      return 0;
1718  
1719    if (reason)
1720    {
1721      if (parc && !EmptyString(*parv))
1754    {
1722        *reason = *parv;
1756
1757      if (!valid_comment(source_p, *reason, 1))
1758        return -1;
1759    }
1723      else
1724 <      *reason = def_reason;
1724 >      *reason = default_reason;
1725    }
1726  
1727    return 1;
1728   }
1729  
1767 /* valid_comment()
1768 *
1769 * inputs       - pointer to client
1770 *              - pointer to comment
1771 * output       - 0 if no valid comment,
1772 *              - 1 if valid
1773 * side effects - truncates reason where necessary
1774 */
1775 int
1776 valid_comment(struct Client *source_p, char *comment, int warn)
1777 {
1778  if (strlen(comment) > REASONLEN)
1779    comment[REASONLEN-1] = '\0';
1780
1781  return 1;
1782 }
1783
1730   /* match_conf_password()
1731   *
1732   * inputs       - pointer to given password
# Line 1809 | Line 1755 | match_conf_password(const char *password
1755   *
1756   * inputs       - client sending the cluster
1757   *              - command name "KLINE" "XLINE" etc.
1758 < *              - capab -- CAP_KLN etc. from server.h
1758 > *              - capab -- CAPAB_KLN etc. from server.h
1759   *              - cluster type -- CLUSTER_KLINE etc. from conf.h
1760   *              - pattern and args to send along
1761   * output       - none
# Line 1817 | Line 1763 | match_conf_password(const char *password
1763   *                along to all servers that match capab and cluster type
1764   */
1765   void
1766 < cluster_a_line(struct Client *source_p, const char *command,
1767 <               int capab, int cluster_type, const char *pattern, ...)
1766 > cluster_a_line(struct Client *source_p, const char *command, unsigned int capab,
1767 >               unsigned int cluster_type, const char *pattern, ...)
1768   {
1769    va_list args;
1770    char buffer[IRCD_BUFSIZE] = "";
# Line 1833 | Line 1779 | cluster_a_line(struct Client *source_p,
1779      const struct MaskItem *conf = node->data;
1780  
1781      if (conf->flags & cluster_type)
1782 <      sendto_match_servs(source_p, conf->name, CAP_CLUSTER|capab,
1782 >      sendto_match_servs(source_p, conf->name, CAPAB_CLUSTER | capab,
1783                           "%s %s %s", command, conf->name, buffer);
1784    }
1785   }
# Line 1919 | Line 1865 | split_nuh(struct split_nuh_item *const i
1865      }
1866      else
1867      {
1868 <      /* no @ found */
1868 >      /* No @ found */
1869        if (!iptr->nickptr || strpbrk(iptr->nuhmask, ".:"))
1870          strlcpy(iptr->hostptr, iptr->nuhmask, iptr->hostsize);
1871        else

Diff Legend

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