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 2852 by michael, Sat Jan 18 16:30:48 2014 UTC vs.
Revision 3215 by michael, Tue Mar 25 19:23:15 2014 UTC

# Line 1 | Line 1
1   /*
2 < *  ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3 < *  conf.c: Configuration file functions.
2 > *  ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3   *
4 < *  Copyright (C) 2002 by the past and present ircd coders, and others.
4 > *  Copyright (c) 1997-2014 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 18 | Line 17
17   *  along with this program; if not, write to the Free Software
18   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
19   *  USA
20 < *
21 < *  $Id$
20 > */
21 >
22 > /*! \file conf.c
23 > * \brief Configuration file functions.
24 > * \version $Id$
25   */
26  
27   #include "stdinc.h"
# Line 55 | Line 57
57   #include "conf_class.h"
58   #include "motd.h"
59  
60 +
61 + struct config_channel_entry ConfigChannel;
62   struct config_server_hide ConfigServerHide;
63 + struct config_file_entry ConfigFileEntry;
64 + struct logging_entry ConfigLoggingEntry = { .use_logging = 1 };
65 + struct server_info ServerInfo;
66 + struct admin_info AdminInfo;
67  
68   /* general conf items link list root, other than k lines etc. */
69   dlink_list service_items = { NULL, NULL, 0 };
# Line 238 | Line 246 | int
246   check_client(struct Client *source_p)
247   {
248    int i;
249 <
249 >
250    if ((i = verify_access(source_p)))
251 <    ilog(LOG_TYPE_IRCD, "Access denied: %s[%s]",
251 >    ilog(LOG_TYPE_IRCD, "Access denied: %s[%s]",
252           source_p->name, source_p->sockhost);
253  
254    switch (i)
# Line 253 | Line 261 | check_client(struct Client *source_p)
261        ilog(LOG_TYPE_IRCD, "Too many connections on IP from %s.",
262             get_client_name(source_p, SHOW_IP));
263        ++ServerStats.is_ref;
264 <      exit_client(source_p, &me, "No more connections allowed on that IP");
264 >      exit_client(source_p, "No more connections allowed on that IP");
265        break;
266  
267      case I_LINE_FULL:
# Line 264 | Line 272 | check_client(struct Client *source_p)
272        ilog(LOG_TYPE_IRCD, "Too many connections from %s.",
273             get_client_name(source_p, SHOW_IP));
274        ++ServerStats.is_ref;
275 <      exit_client(source_p, &me,
268 <                  "No more connections allowed in your connection class");
275 >      exit_client(source_p, "No more connections allowed in your connection class");
276        break;
277  
278      case NOT_AUTHORIZED:
# Line 284 | Line 291 | check_client(struct Client *source_p)
291             source_p->localClient->listener->name,
292             source_p->localClient->listener->port);
293  
294 <      exit_client(source_p, &me, "You are not authorized to use this server");
294 >      exit_client(source_p, "You are not authorized to use this server");
295        break;
296  
297     case BANNED_CLIENT:
298 <     exit_client(source_p, &me, "Banned");
298 >     exit_client(source_p, "Banned");
299       ++ServerStats.is_ref;
300       break;
301  
# Line 310 | Line 317 | static int
317   verify_access(struct Client *client_p)
318   {
319    struct MaskItem *conf = NULL;
320 <  char non_ident[USERLEN + 1] = { '~', '\0' };
320 >  char non_ident[USERLEN + 1] = "~";
321  
322    if (IsGotId(client_p))
323    {
# Line 328 | Line 335 | verify_access(struct Client *client_p)
335                               client_p->localClient->passwd);
336    }
337  
338 <  if (conf != NULL)
338 >  if (conf)
339    {
340      if (IsConfClient(conf))
341      {
342        if (IsConfRedir(conf))
343        {
344 <        sendto_one(client_p, form_str(RPL_REDIR),
345 <                   me.name, client_p->name,
346 <                   conf->name ? conf->name : "",
340 <                   conf->port);
344 >        sendto_one_numeric(client_p, &me, RPL_REDIR,
345 >                           conf->name ? conf->name : "",
346 >                           conf->port);
347          return NOT_AUTHORIZED;
348        }
349  
# Line 360 | Line 366 | verify_access(struct Client *client_p)
366      else if (IsConfKill(conf) || (ConfigFileEntry.glines && IsConfGline(conf)))
367      {
368        if (IsConfGline(conf))
369 <        sendto_one(client_p, ":%s NOTICE %s :*** G-lined", me.name,
370 <                   client_p->name);
365 <      sendto_one(client_p, ":%s NOTICE %s :*** Banned: %s",
366 <                 me.name, client_p->name, conf->reason);
369 >        sendto_one_notice(client_p, &me, ":*** G-lined");
370 >      sendto_one_notice(client_p, &me, ":*** Banned: %s", conf->reason);
371        return BANNED_CLIENT;
372      }
373    }
# Line 418 | Line 422 | attach_iline(struct Client *client_p, st
422      if (!IsConfExemptLimits(conf))
423        return TOO_MANY;   /* Already at maximum allowed */
424  
425 <    sendto_one(client_p,
426 <               ":%s NOTICE %s :*** Your connection class is full, "
423 <               "but you have exceed_limit = yes;", me.name, client_p->name);
425 >    sendto_one_notice(client_p, &me, ":*** Your connection class is full, "
426 >                      "but you have exceed_limit = yes;");
427    }
428  
429    return attach_conf(client_p, conf);
# Line 579 | Line 582 | hash_ip(struct irc_ssaddr *addr)
582      uint32_t *ip = (uint32_t *)&v6->sin6_addr.s6_addr;
583  
584      hash  = ip[0] ^ ip[3];
585 <    hash ^= hash >> 16;  
586 <    hash ^= hash >> 8;  
585 >    hash ^= hash >> 16;
586 >    hash ^= hash >> 8;
587      hash  = hash & (IP_HASH_SIZE - 1);
588      return hash;
589    }
# Line 591 | Line 594 | hash_ip(struct irc_ssaddr *addr)
594  
595   /* count_ip_hash()
596   *
597 < * inputs        - pointer to counter of number of ips hashed
597 > * inputs        - pointer to counter of number of ips hashed
598   *               - pointer to memory used for ip hash
599   * output        - returned via pointers input
600   * side effects  - NONE
# Line 779 | Line 782 | find_conf_name(dlink_list *list, const c
782    DLINK_FOREACH(ptr, list->head)
783    {
784      conf = ptr->data;
785 <    
785 >
786      if (conf->type == type)
787      {
788        if (conf->name && (irccmp(conf->name, name) == 0 ||
# Line 897 | Line 900 | find_matching_name_conf(enum maskitem_ty
900          return conf;
901      }
902      break;
903 <  
903 >
904    default:
905      break;
906    }
# Line 934 | Line 937 | find_exact_name_conf(enum maskitem_type
937  
938        if (EmptyString(conf->name))
939          continue;
940 <    
940 >
941        if (irccmp(conf->name, name) == 0)
942        {
943          if ((user == NULL && (host == NULL)))
# Line 1000 | Line 1003 | find_exact_name_conf(enum maskitem_type
1003  
1004        if (EmptyString(conf->name))
1005          continue;
1006 <    
1006 >
1007        if (name == NULL)
1008        {
1009          if (EmptyString(conf->host))
# Line 1121 | Line 1124 | set_default_conf(void)
1124    ConfigServerHide.hide_server_ips = 0;
1125    ConfigServerHide.disable_remote_commands = 0;
1126  
1124  
1127    ConfigFileEntry.service_name = xstrdup(SERVICE_NAME_DEFAULT);
1128    ConfigFileEntry.max_watch = WATCHSIZE_DEFAULT;
1129    ConfigFileEntry.cycle_on_host_change = 1;
# Line 1193 | Line 1195 | validate_conf(void)
1195    ConfigFileEntry.max_watch = IRCD_MAX(ConfigFileEntry.max_watch, WATCHSIZE_MIN);
1196   }
1197  
1198 < /* read_conf()
1198 > /* read_conf()
1199   *
1200   * inputs       - file descriptor pointing to config file to use
1201   * output       - None
# Line 1297 | Line 1299 | void
1299   cleanup_tklines(void *notused)
1300   {
1301    hostmask_expire_temporary();
1302 <  expire_tklines(&xconf_items);
1302 >  expire_tklines(&xconf_items);
1303    expire_tklines(&nresv_items);
1304    expire_tklines(&cresv_items);
1305   }
# Line 1397 | Line 1399 | oper_privs_as_string(const unsigned int
1399   const char *
1400   get_oper_name(const struct Client *client_p)
1401   {
1402 <  dlink_node *cnode = NULL;
1402 >  const dlink_node *cnode = NULL;
1403    /* +5 for !,@,{,} and null */
1404    static char buffer[NICKLEN + USERLEN + HOSTLEN + HOSTLEN + 5];
1405  
# Line 1405 | Line 1407 | get_oper_name(const struct Client *clien
1407    {
1408      if ((cnode = client_p->localClient->confs.head))
1409      {
1410 <      struct MaskItem *conf = cnode->data;
1410 >      const struct MaskItem *conf = cnode->data;
1411  
1412        if (IsConfOperator(conf))
1413        {
# Line 1415 | Line 1417 | get_oper_name(const struct Client *clien
1417        }
1418      }
1419  
1420 <    /* Probably should assert here for now. If there is an oper out there
1420 >    /* Probably should assert here for now. If there is an oper out there
1421       * with no oper{} conf attached, it would be good for us to know...
1422       */
1423      assert(0); /* Oper without oper conf! */
# Line 1446 | Line 1448 | read_conf_files(int cold)
1448       FIXME: The full path is in conffilenamebuf first time since we
1449               dont know anything else
1450  
1451 <     - Gozem 2002-07-21
1451 >     - Gozem 2002-07-21
1452    */
1453    strlcpy(conffilebuf, filename, sizeof(conffilebuf));
1454  
# Line 1520 | Line 1522 | clear_out_old_conf(void)
1522    /* We only need to free anything allocated by yyparse() here.
1523     * Resetting structs, etc, is taken care of by set_default_conf().
1524     */
1525 <  
1525 >
1526    for (; *iterator != NULL; iterator++)
1527    {
1528      DLINK_FOREACH_SAFE(ptr, next_ptr, (*iterator)->head)
# Line 1607 | Line 1609 | clear_out_old_conf(void)
1609   *
1610   * inputs       - pointer to config item
1611   * output       - NONE
1612 < * side effects - Add a class pointer to a conf
1612 > * side effects - Add a class pointer to a conf
1613   */
1614   void
1615   conf_add_class_to_conf(struct MaskItem *conf, const char *class_name)
1616   {
1617 <  if (class_name == NULL)
1617 >  if (class_name == NULL)
1618    {
1619      conf->class = class_default;
1620  
# Line 1679 | Line 1681 | conf_error_report(const char *msg)
1681  
1682   /*
1683   * valid_tkline()
1684 < *
1684 > *
1685   * inputs       - pointer to ascii string to check
1686   *              - whether the specified time is in seconds or minutes
1687   * output       - -1 not enough parameters
# Line 1704 | Line 1706 | valid_tkline(const char *data, const int
1706    }
1707  
1708    /*
1709 <   * In the degenerate case where oper does a /quote kline 0 user@host :reason
1709 >   * In the degenerate case where oper does a /quote kline 0 user@host :reason
1710     * i.e. they specifically use 0, I am going to return 1 instead
1711     * as a return value of non-zero is used to flag it as a temporary kline
1712     */
1713    if (result == 0)
1714      result = 1;
1715  
1716 <  /*
1716 >  /*
1717     * If the incoming time is in seconds convert it to minutes for the purpose
1718     * of this calculation
1719     */
1720    if (!minutes)
1721 <    result = result / 60;
1721 >    result = result / 60;
1722  
1723    if (result > MAX_TDKLINE_TIME)
1724      result = MAX_TDKLINE_TIME;
# Line 1810 | Line 1812 | valid_wild_card(struct Client *source_p,
1812    }
1813  
1814    if (warn)
1815 <    sendto_one(source_p, ":%s NOTICE %s :Please include at least %d non-wildcard characters with the mask",
1816 <               me.name, source_p->name, ConfigFileEntry.min_nonwildcard);
1815 >    sendto_one_notice(source_p, &me,
1816 >                      ":Please include at least %d non-wildcard characters with the mask",
1817 >                      ConfigFileEntry.min_nonwildcard);
1818    va_end(args);
1819    return 0;
1820   }
# Line 1826 | Line 1829 | valid_wild_card(struct Client *source_p,
1829   *              - parse_flags bit map of things to test
1830   *              - pointer to user or string to parse into
1831   *              - pointer to host or NULL to parse into if non NULL
1832 < *              - pointer to optional tkline time or NULL
1832 > *              - pointer to optional tkline time or NULL
1833   *              - pointer to target_server to parse into if non NULL
1834   *              - pointer to reason to parse into
1835   *
# Line 1871 | Line 1874 | parse_aline(const char *cmd, struct Clie
1874        *tkline_time = found_tkline_time;
1875      else
1876      {
1877 <      sendto_one(source_p, ":%s NOTICE %s :temp_line not supported by %s",
1875 <                 me.name, source_p->name, cmd);
1877 >      sendto_one_notice(source_p, &me, ":temp_line not supported by %s", cmd);
1878        return -1;
1879      }
1880    }
1881  
1882    if (parc == 0)
1883    {
1884 <    sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
1883 <               me.name, source_p->name, cmd);
1884 >    sendto_one_numeric(source_p, &me, ERR_NEEDMOREPARAMS, cmd);
1885      return -1;
1886    }
1887  
# Line 1894 | Line 1895 | parse_aline(const char *cmd, struct Clie
1895      *up_p = user;
1896      *h_p = host;
1897    }
1898 <
1898 >
1899    parc--;
1900    parv++;
1901  
# Line 1907 | Line 1908 | parse_aline(const char *cmd, struct Clie
1908  
1909        if (target_server == NULL)
1910        {
1911 <        sendto_one(source_p, ":%s NOTICE %s :ON server not supported by %s",
1911 <                   me.name, source_p->name, cmd);
1911 >        sendto_one_notice(source_p, &me, ":ON server not supported by %s", cmd);
1912          return -1;
1913        }
1914  
1915        if (!HasOFlag(source_p, OPER_FLAG_REMOTEBAN))
1916        {
1917 <        sendto_one(source_p, form_str(ERR_NOPRIVS),
1918 <                   me.name, source_p->name, "remoteban");
1917 >        sendto_one_numeric(source_p, &me, ERR_NOPRIVS, "remoteban");
1918          return -1;
1919        }
1920  
1921        if (parc == 0 || EmptyString(*parv))
1922        {
1923 <        sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
1925 <                   me.name, source_p->name, cmd);
1923 >        sendto_one_numeric(source_p, &me, ERR_NEEDMOREPARAMS, cmd);
1924          return -1;
1925        }
1926  
# Line 1944 | Line 1942 | parse_aline(const char *cmd, struct Clie
1942    {
1943      if (strchr(user, '!') != NULL)
1944      {
1945 <      sendto_one(source_p, ":%s NOTICE %s :Invalid character '!' in kline",
1948 <                 me.name, source_p->name);
1945 >      sendto_one_notice(source_p, &me, ":Invalid character '!' in kline");
1946        return -1;
1947      }
1948  
# Line 2016 | Line 2013 | find_user_host(struct Client *source_p,
2013        luser[1] = '\0';
2014        strlcpy(lhost, user_host_or_nick, HOSTLEN*4 + 1);
2015      }
2016 <    
2016 >
2017      return 1;
2018    }
2019    else
2020    {
2021      /* Try to find user@host mask from nick */
2022      /* Okay to use source_p as the first param, because source_p == client_p */
2023 <    if ((target_p =
2024 <        find_chasing(source_p, user_host_or_nick, NULL)) == NULL)
2023 >    if ((target_p =
2024 >        find_chasing(source_p, user_host_or_nick)) == NULL)
2025        return 0;
2026  
2027      if (IsExemptKline(target_p))
2028      {
2029        if (!IsServer(source_p))
2030 <        sendto_one(source_p,
2034 <                   ":%s NOTICE %s :%s is E-lined",
2035 <                   me.name, source_p->name, target_p->name);
2030 >        sendto_one_notice(source_p, &me, ":%s is E-lined", target_p->name);
2031        return 0;
2032      }
2033  

Diff Legend

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