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 5797 by michael, Fri Apr 17 16:19:21 2015 UTC vs.
Revision 6367 by michael, Wed Aug 19 10:25:00 2015 UTC

# 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;
# Line 301 | Line 302 | verify_access(struct Client *client_p)
302   {
303    struct MaskItem *conf = NULL;
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 319 | Line 320 | verify_access(struct Client *client_p)
320                               client_p->connection->password);
321    }
322  
323 <  if (conf)
324 <  {
324 <    if (IsConfClient(conf))
325 <    {
326 <      if (IsConfRedir(conf))
327 <      {
328 <        sendto_one_numeric(client_p, &me, RPL_REDIR,
329 <                           conf->name ? conf->name : "",
330 <                           conf->port);
331 <        return NOT_AUTHORIZED;
332 <      }
323 >  if (!conf)
324 >    return NOT_AUTHORIZED;
325  
326 <      /* Thanks for spoof idea amm */
335 <      if (IsConfDoSpoofIp(conf))
336 <      {
337 <        if (IsConfSpoofNotice(conf))
338 <          sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE, "%s spoofing: %s as %s",
339 <                               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);
352 <      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 840 | Line 835 | set_default_conf(void)
835    ConfigGeneral.away_time = 10;
836    ConfigGeneral.max_watch = WATCHSIZE_DEFAULT;
837    ConfigGeneral.cycle_on_host_change = 1;
838 <  ConfigGeneral.glines = 0;
839 <  ConfigGeneral.gline_time = 12 * 3600;
840 <  ConfigGeneral.gline_request_time = GLINE_REQUEST_EXPIRE_DEFAULT;
841 <  ConfigGeneral.gline_min_cidr = 16;
847 <  ConfigGeneral.gline_min_cidr6 = 48;
838 >  ConfigGeneral.dline_min_cidr = 16;
839 >  ConfigGeneral.dline_min_cidr6 = 48;
840 >  ConfigGeneral.kline_min_cidr = 16;
841 >  ConfigGeneral.kline_min_cidr6 = 48;
842    ConfigGeneral.invisible_on_connect = 1;
843    ConfigGeneral.tkline_expire_notices = 1;
844    ConfigGeneral.ignore_bogus_ts = 0;
# Line 939 | Line 933 | void
933   conf_rehash(int sig)
934   {
935    if (sig)
936 <    sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
936 >    sendto_realops_flags(UMODE_SERVNOTICE, L_ALL, SEND_NOTICE,
937                           "Got signal SIGHUP, reloading configuration file(s)");
938  
939    restart_resolver();
# Line 1043 | Line 1037 | expire_tklines(dlink_list *list)
1037      if (!conf->until || conf->until > CurrentTime)
1038        continue;
1039  
1040 <    if (conf->type == CONF_XLINE)
1041 <    {
1042 <      if (ConfigGeneral.tkline_expire_notices)
1043 <        sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1050 <                             "Temporary X-line for [%s] expired", conf->name);
1051 <      conf_free(conf);
1052 <    }
1053 <    else if (conf->type == CONF_NRESV || conf->type == CONF_CRESV)
1054 <    {
1055 <      if (ConfigGeneral.tkline_expire_notices)
1056 <        sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1057 <                             "Temporary RESV for [%s] expired", conf->name);
1058 <      conf_free(conf);
1059 <    }
1040 >    if (ConfigGeneral.tkline_expire_notices)
1041 >      sendto_realops_flags(UMODE_SERVNOTICE, L_ALL, SEND_NOTICE, "Temporary %s for [%s] expired",
1042 >                           (conf->type == CONF_XLINE) ? "X-line" : "RESV", conf->name);
1043 >    conf_free(conf);
1044    }
1045   }
1046  
# Line 1090 | Line 1074 | static const struct oper_privs
1074    { OPER_FLAG_ADMIN,          'A' },
1075    { OPER_FLAG_REMOTEBAN,      'B' },
1076    { OPER_FLAG_DIE,            'D' },
1093  { OPER_FLAG_GLINE,          'G' },
1077    { OPER_FLAG_REHASH,         'H' },
1078    { OPER_FLAG_KLINE,          'K' },
1079    { OPER_FLAG_KILL,           'N' },
# Line 1194 | Line 1177 | clear_out_old_conf(void)
1177        struct MaskItem *conf = node->data;
1178  
1179        conf->active = 0;
1197      dlinkDelete(&conf->node, *iterator);
1180  
1181 <      /* XXX This is less than pretty */
1200 <      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        }
1205      else if (conf->type == CONF_XLINE)
1206      {
1207        if (!conf->until)
1208          conf_free(conf);
1209      }
1210      else
1211        conf_free(conf);
1188      }
1189    }
1190  
# Line 1254 | Line 1230 | clear_out_old_conf(void)
1230    ConfigAdminInfo.description = NULL;
1231  
1232    /* Clean out listeners */
1233 <  close_listeners();
1233 >  listener_close_marked();
1234   }
1235  
1236   /* read_conf_files()
# Line 1291 | Line 1267 | read_conf_files(int cold)
1267      }
1268      else
1269      {
1270 <      sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1270 >      sendto_realops_flags(UMODE_SERVNOTICE, L_ADMIN, SEND_NOTICE,
1271                             "Unable to read configuration file '%s': %s",
1272                             filename, strerror(errno));
1273        return;
# Line 1306 | Line 1282 | read_conf_files(int cold)
1282  
1283    log_reopen_all();
1284  
1285 <  add_isupport("NICKLEN", NULL, ConfigServerInfo.max_nick_length);
1286 <  add_isupport("NETWORK", ConfigServerInfo.network_name, -1);
1285 >  isupport_add("NICKLEN", NULL, ConfigServerInfo.max_nick_length);
1286 >  isupport_add("NETWORK", ConfigServerInfo.network_name, -1);
1287  
1288    snprintf(chanmodes, sizeof(chanmodes), "beI:%d", ConfigChannel.max_bans);
1289 <  add_isupport("MAXLIST", chanmodes, -1);
1290 <  add_isupport("MAXTARGETS", NULL, ConfigGeneral.max_targets);
1291 <  add_isupport("CHANTYPES", "#", -1);
1289 >  isupport_add("MAXLIST", chanmodes, -1);
1290 >  isupport_add("MAXTARGETS", NULL, ConfigGeneral.max_targets);
1291 >  isupport_add("CHANTYPES", "#", -1);
1292  
1293    snprintf(chanlimit, sizeof(chanlimit), "#:%d",
1294             ConfigChannel.max_channels);
1295 <  add_isupport("CHANLIMIT", chanlimit, -1);
1295 >  isupport_add("CHANLIMIT", chanlimit, -1);
1296    snprintf(chanmodes, sizeof(chanmodes), "%s", "beI,k,l,cimnprstCMORS");
1297 <  add_isupport("CHANNELLEN", NULL, CHANNELLEN);
1298 <  add_isupport("TOPICLEN", NULL, ConfigServerInfo.max_topic_length);
1299 <  add_isupport("CHANMODES", chanmodes, -1);
1297 >  isupport_add("CHANNELLEN", NULL, CHANNELLEN);
1298 >  isupport_add("TOPICLEN", NULL, ConfigServerInfo.max_topic_length);
1299 >  isupport_add("CHANMODES", chanmodes, -1);
1300  
1301    /*
1302     * message_locale may have changed.  rebuild isupport since it relies
1303     * on strlen(form_str(RPL_ISUPPORT))
1304     */
1305 <  rebuild_isupport_message_line();
1305 >  isupport_rebuild();
1306   }
1307  
1308   /* conf_add_class_to_conf()
# Line 1343 | Line 1319 | conf_add_class_to_conf(struct MaskItem *
1319      conf->class = class_default;
1320  
1321      if (conf->type == CONF_CLIENT || conf->type == CONF_OPER)
1322 <      sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1322 >      sendto_realops_flags(UMODE_SERVNOTICE, L_ADMIN, SEND_NOTICE,
1323                             "Warning *** Defaulting to default class for %s@%s",
1324                             conf->user, conf->host);
1325      else
1326 <      sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1326 >      sendto_realops_flags(UMODE_SERVNOTICE, L_ADMIN, SEND_NOTICE,
1327                             "Warning *** Defaulting to default class for %s",
1328                             conf->name);
1329    }
# Line 1368 | Line 1344 | yyerror(const char *msg)
1344      return;
1345  
1346    strip_tabs(newlinebuf, linebuf, sizeof(newlinebuf));
1347 <  sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1347 >  sendto_realops_flags(UMODE_SERVNOTICE, L_ADMIN, SEND_NOTICE,
1348                         "\"%s\", line %u: %s: %s",
1349                         conffilebuf, lineno + 1, msg, newlinebuf);
1350    ilog(LOG_TYPE_IRCD, "\"%s\", line %u: %s: %s",
# Line 1381 | Line 1357 | conf_error_report(const char *msg)
1357    char newlinebuf[IRCD_BUFSIZE];
1358  
1359    strip_tabs(newlinebuf, linebuf, sizeof(newlinebuf));
1360 <  sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1360 >  sendto_realops_flags(UMODE_SERVNOTICE, L_ADMIN, SEND_NOTICE,
1361                         "\"%s\", line %u: %s: %s",
1362                         conffilebuf, lineno + 1, msg, newlinebuf);
1363    ilog(LOG_TYPE_IRCD, "\"%s\", line %u: %s: %s",
# Line 1448 | Line 1424 | valid_wild_card_simple(const char *data)
1424   {
1425    const unsigned char *p = (const unsigned char *)data;
1426    unsigned char tmpch = '\0';
1427 <  unsigned int nonwild = 0;
1427 >  unsigned int nonwild = 0, wild = 0;
1428  
1429    while ((tmpch = *p++))
1430    {
# Line 1463 | Line 1439 | valid_wild_card_simple(const char *data)
1439        if (++nonwild >= ConfigGeneral.min_nonwildcard_simple)
1440          return 1;
1441      }
1442 +    else
1443 +      ++wild;
1444    }
1445  
1446 <  return 0;
1446 >  return !wild;
1447   }
1448  
1449   /* valid_wild_card()
# Line 1584 | Line 1562 | find_user_host(struct Client *source_p,
1562          find_chasing(source_p, user_host_or_nick)) == NULL)
1563        return 0;  /* find_chasing sends ERR_NOSUCHNICK */
1564  
1565 <    if (IsExemptKline(target_p))
1565 >    if (HasFlag(target_p, FLAGS_EXEMPTKLINE))
1566      {
1567        if (IsClient(source_p))
1568          sendto_one_notice(source_p, &me, ":%s is E-lined", target_p->name);
# Line 1647 | 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 1697 | Line 1675 | parse_aline(const char *cmd, struct Clie
1675        parc--;
1676        parv++;
1677  
1700      if (target_server == NULL)
1701      {
1702        sendto_one_notice(source_p, &me, ":ON server not supported by %s", cmd);
1703        return 0;
1704      }
1705
1678        if (!HasOFlag(source_p, OPER_FLAG_REMOTEBAN))
1679        {
1680          sendto_one_numeric(source_p, &me, ERR_NOPRIVS, "remoteban");
# Line 1747 | Line 1719 | parse_aline(const char *cmd, struct Clie
1719    if (reason)
1720    {
1721      if (parc && !EmptyString(*parv))
1750    {
1722        *reason = *parv;
1752
1753      if (!valid_comment(source_p, *reason, 1))
1754        return 0;
1755    }
1723      else
1724 <      *reason = def_reason;
1724 >      *reason = default_reason;
1725    }
1726  
1727    return 1;
1728   }
1729  
1763 /* valid_comment()
1764 *
1765 * inputs       - pointer to client
1766 *              - pointer to comment
1767 * output       - 0 if no valid comment,
1768 *              - 1 if valid
1769 * side effects - truncates reason where necessary
1770 */
1771 int
1772 valid_comment(struct Client *source_p, char *comment, int warn)
1773 {
1774  if (strlen(comment) > REASONLEN)
1775    comment[REASONLEN-1] = '\0';
1776
1777  return 1;
1778 }
1779
1730   /* match_conf_password()
1731   *
1732   * inputs       - pointer to given password
# Line 1805 | 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 1829 | 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   }

Diff Legend

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