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 2182 by michael, Tue Jun 4 12:19:04 2013 UTC vs.
Revision 3860 by michael, Thu Jun 5 19:55:07 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"
28   #include "list.h"
29   #include "ircd_defs.h"
30   #include "conf.h"
31 < #include "s_serv.h"
31 > #include "server.h"
32   #include "resv.h"
33   #include "channel.h"
34   #include "client.h"
35   #include "event.h"
34 #include "hook.h"
36   #include "irc_string.h"
37   #include "s_bsd.h"
38   #include "ircd.h"
# Line 42 | Line 43
43   #include "fdlist.h"
44   #include "log.h"
45   #include "send.h"
45 #include "s_gline.h"
46   #include "memory.h"
47   #include "mempool.h"
48 < #include "irc_res.h"
48 > #include "res.h"
49   #include "userhost.h"
50 < #include "s_user.h"
50 > #include "user.h"
51   #include "channel_mode.h"
52   #include "parse.h"
53 < #include "s_misc.h"
53 > #include "misc.h"
54   #include "conf_db.h"
55   #include "conf_class.h"
56   #include "motd.h"
57  
58 +
59 + struct config_channel_entry ConfigChannel;
60   struct config_server_hide ConfigServerHide;
61 + struct config_file_entry ConfigFileEntry;
62 + struct logging_entry ConfigLoggingEntry = { .use_logging = 1 };
63 + struct server_info ServerInfo;
64 + struct admin_info AdminInfo;
65  
66   /* general conf items link list root, other than k lines etc. */
67   dlink_list service_items = { NULL, NULL, 0 };
# Line 123 | Line 129 | conf_dns_callback(void *vptr, const stru
129  
130    conf->dns_pending = 0;
131  
132 <  if (addr != NULL)
132 >  if (addr)
133      memcpy(&conf->addr, addr, sizeof(conf->addr));
134    else
135      conf->dns_failed = 1;
# Line 148 | Line 154 | conf_dns_lookup(struct MaskItem *conf)
154   struct MaskItem *
155   conf_make(enum maskitem_type type)
156   {
157 <  struct MaskItem *conf = MyMalloc(sizeof(*conf));
157 >  struct MaskItem *conf = MyCalloc(sizeof(*conf));
158    dlink_list *list = NULL;
159  
160    conf->type   = type;
# Line 174 | Line 180 | conf_free(struct MaskItem *conf)
180  
181    if (conf->dns_pending)
182      delete_resolver_queries(conf);
183 <  if (conf->passwd != NULL)
183 >  if (conf->passwd)
184      memset(conf->passwd, 0, strlen(conf->passwd));
185 <  if (conf->spasswd != NULL)
185 >  if (conf->spasswd)
186      memset(conf->spasswd, 0, strlen(conf->spasswd));
187  
188    conf->class = NULL;
# Line 184 | Line 190 | conf_free(struct MaskItem *conf)
190    MyFree(conf->passwd);
191    MyFree(conf->spasswd);
192    MyFree(conf->reason);
193 +  MyFree(conf->certfp);
194    MyFree(conf->user);
195    MyFree(conf->host);
196   #ifdef HAVE_LIBCRYPTO
# Line 195 | Line 202 | conf_free(struct MaskItem *conf)
202    DLINK_FOREACH_SAFE(ptr, ptr_next, conf->hub_list.head)
203    {
204      MyFree(ptr->data);
205 +    dlinkDelete(ptr, &conf->hub_list);
206      free_dlink_node(ptr);
207    }
208  
209    DLINK_FOREACH_SAFE(ptr, ptr_next, conf->leaf_list.head)
210    {
211      MyFree(ptr->data);
212 +    dlinkDelete(ptr, &conf->leaf_list);
213      free_dlink_node(ptr);
214    }
215  
# Line 208 | Line 217 | conf_free(struct MaskItem *conf)
217    {
218      struct exempt *exptr = ptr->data;
219  
220 +    dlinkDelete(ptr, &conf->exempt_list);
221      MyFree(exptr->name);
222      MyFree(exptr->user);
223      MyFree(exptr->host);
# Line 234 | Line 244 | int
244   check_client(struct Client *source_p)
245   {
246    int i;
247 <
247 >
248    if ((i = verify_access(source_p)))
249 <    ilog(LOG_TYPE_IRCD, "Access denied: %s[%s]",
249 >    ilog(LOG_TYPE_IRCD, "Access denied: %s[%s]",
250           source_p->name, source_p->sockhost);
251  
252    switch (i)
# Line 249 | Line 259 | check_client(struct Client *source_p)
259        ilog(LOG_TYPE_IRCD, "Too many connections on IP from %s.",
260             get_client_name(source_p, SHOW_IP));
261        ++ServerStats.is_ref;
262 <      exit_client(source_p, &me, "No more connections allowed on that IP");
262 >      exit_client(source_p, "No more connections allowed on that IP");
263        break;
264  
265      case I_LINE_FULL:
# Line 260 | Line 270 | check_client(struct Client *source_p)
270        ilog(LOG_TYPE_IRCD, "Too many connections from %s.",
271             get_client_name(source_p, SHOW_IP));
272        ++ServerStats.is_ref;
273 <      exit_client(source_p, &me,
264 <                  "No more connections allowed in your connection class");
273 >      exit_client(source_p, "No more connections allowed in your connection class");
274        break;
275  
276      case NOT_AUTHORIZED:
# Line 280 | Line 289 | check_client(struct Client *source_p)
289             source_p->localClient->listener->name,
290             source_p->localClient->listener->port);
291  
292 <      exit_client(source_p, &me, "You are not authorized to use this server");
292 >      exit_client(source_p, "You are not authorized to use this server");
293        break;
294  
295     case BANNED_CLIENT:
296 <     exit_client(source_p, &me, "Banned");
296 >     exit_client(source_p, "Banned");
297       ++ServerStats.is_ref;
298       break;
299  
# Line 306 | Line 315 | static int
315   verify_access(struct Client *client_p)
316   {
317    struct MaskItem *conf = NULL;
318 <  char non_ident[USERLEN + 1] = { '~', '\0' };
318 >  char non_ident[USERLEN + 1] = "~";
319  
320    if (IsGotId(client_p))
321    {
# Line 324 | Line 333 | verify_access(struct Client *client_p)
333                               client_p->localClient->passwd);
334    }
335  
336 <  if (conf != NULL)
336 >  if (conf)
337    {
338      if (IsConfClient(conf))
339      {
340        if (IsConfRedir(conf))
341        {
342 <        sendto_one(client_p, form_str(RPL_REDIR),
343 <                   me.name, client_p->name,
344 <                   conf->name ? conf->name : "",
336 <                   conf->port);
342 >        sendto_one_numeric(client_p, &me, RPL_REDIR,
343 >                           conf->name ? conf->name : "",
344 >                           conf->port);
345          return NOT_AUTHORIZED;
346        }
347  
# Line 356 | Line 364 | verify_access(struct Client *client_p)
364      else if (IsConfKill(conf) || (ConfigFileEntry.glines && IsConfGline(conf)))
365      {
366        if (IsConfGline(conf))
367 <        sendto_one(client_p, ":%s NOTICE %s :*** G-lined", me.name,
368 <                   client_p->name);
361 <      sendto_one(client_p, ":%s NOTICE %s :*** Banned: %s",
362 <                 me.name, client_p->name, conf->reason);
367 >        sendto_one_notice(client_p, &me, ":*** G-lined");
368 >      sendto_one_notice(client_p, &me, ":*** Banned: %s", conf->reason);
369        return BANNED_CLIENT;
370      }
371    }
# Line 382 | Line 388 | attach_iline(struct Client *client_p, st
388    int a_limit_reached = 0;
389    unsigned int local = 0, global = 0, ident = 0;
390  
391 +  assert(conf->class);
392 +
393    ip_found = find_or_add_ip(&client_p->localClient->ip);
394    ip_found->count++;
395    SetIpHash(client_p);
396  
389  if (conf->class == NULL)
390    return NOT_AUTHORIZED;  /* If class is missing, this is best */
391
397    class = conf->class;
398  
399    count_user_host(client_p->username, client_p->host,
# Line 398 | Line 403 | attach_iline(struct Client *client_p, st
403     * setting a_limit_reached if any limit is reached.
404     * - Dianora
405     */
406 <  if (class->max_total != 0 && class->ref_count >= class->max_total)
406 >  if (class->max_total && class->ref_count >= class->max_total)
407      a_limit_reached = 1;
408 <  else if (class->max_perip != 0 && ip_found->count > class->max_perip)
408 >  else if (class->max_perip && ip_found->count > class->max_perip)
409      a_limit_reached = 1;
410 <  else if (class->max_local != 0 && local >= class->max_local)
410 >  else if (class->max_local && local >= class->max_local)
411      a_limit_reached = 1;
412 <  else if (class->max_global != 0 && global >= class->max_global)
412 >  else if (class->max_global && global >= class->max_global)
413      a_limit_reached = 1;
414 <  else if (class->max_ident != 0 && ident >= class->max_ident &&
414 >  else if (class->max_ident && ident >= class->max_ident &&
415             client_p->username[0] != '~')
416      a_limit_reached = 1;
417  
# Line 415 | Line 420 | attach_iline(struct Client *client_p, st
420      if (!IsConfExemptLimits(conf))
421        return TOO_MANY;   /* Already at maximum allowed */
422  
423 <    sendto_one(client_p,
424 <               ":%s NOTICE %s :*** Your connection class is full, "
420 <               "but you have exceed_limit = yes;", me.name, client_p->name);
423 >    sendto_one_notice(client_p, &me, ":*** Your connection class is full, "
424 >                      "but you have exceed_limit = yes;");
425    }
426  
427    return attach_conf(client_p, conf);
# Line 576 | Line 580 | hash_ip(struct irc_ssaddr *addr)
580      uint32_t *ip = (uint32_t *)&v6->sin6_addr.s6_addr;
581  
582      hash  = ip[0] ^ ip[3];
583 <    hash ^= hash >> 16;  
584 <    hash ^= hash >> 8;  
583 >    hash ^= hash >> 16;
584 >    hash ^= hash >> 8;
585      hash  = hash & (IP_HASH_SIZE - 1);
586      return hash;
587    }
# Line 588 | Line 592 | hash_ip(struct irc_ssaddr *addr)
592  
593   /* count_ip_hash()
594   *
595 < * inputs        - pointer to counter of number of ips hashed
595 > * inputs        - pointer to counter of number of ips hashed
596   *               - pointer to memory used for ip hash
597   * output        - returned via pointers input
598   * side effects  - NONE
# Line 600 | Line 604 | void
604   count_ip_hash(unsigned int *number_ips_stored, uint64_t *mem_ips_stored)
605   {
606    struct ip_entry *ptr;
603  int i;
607  
608    *number_ips_stored = 0;
609    *mem_ips_stored    = 0;
610  
611 <  for (i = 0; i < IP_HASH_SIZE; i++)
611 >  for (unsigned int i = 0; i < IP_HASH_SIZE; ++i)
612    {
613      for (ptr = ip_hash_table[i]; ptr; ptr = ptr->next)
614      {
# Line 627 | Line 630 | garbage_collect_ip_entries(void)
630    struct ip_entry *ptr;
631    struct ip_entry *last_ptr;
632    struct ip_entry *next_ptr;
630  int i;
633  
634 <  for (i = 0; i < IP_HASH_SIZE; i++)
634 >  for (unsigned int i = 0; i < IP_HASH_SIZE; ++i)
635    {
636      last_ptr = NULL;
637  
# Line 664 | Line 666 | garbage_collect_ip_entries(void)
666   void
667   detach_conf(struct Client *client_p, enum maskitem_type type)
668   {
669 <  dlink_node *ptr = NULL, *next_ptr = NULL;
669 >  dlink_node *ptr = NULL, *ptr_next = NULL;
670  
671 <  DLINK_FOREACH_SAFE(ptr, next_ptr, client_p->localClient->confs.head)
671 >  DLINK_FOREACH_SAFE(ptr, ptr_next, client_p->localClient->confs.head)
672    {
673      struct MaskItem *conf = ptr->data;
674  
# Line 707 | Line 709 | detach_conf(struct Client *client_p, enu
709   int
710   attach_conf(struct Client *client_p, struct MaskItem *conf)
711   {
712 <  if (dlinkFind(&client_p->localClient->confs, conf) != NULL)
712 >  if (dlinkFind(&client_p->localClient->confs, conf))
713      return 1;
714  
715    if (conf->type == CONF_CLIENT)
# Line 776 | Line 778 | find_conf_name(dlink_list *list, const c
778    DLINK_FOREACH(ptr, list->head)
779    {
780      conf = ptr->data;
781 <    
781 >
782      if (conf->type == type)
783      {
784 <      if (conf->name && (irccmp(conf->name, name) == 0 ||
784 >      if (conf->name && (!irccmp(conf->name, name) ||
785                           !match(conf->name, name)))
786        return conf;
787      }
# Line 894 | Line 896 | find_matching_name_conf(enum maskitem_ty
896          return conf;
897      }
898      break;
899 <  
899 >
900    default:
901      break;
902    }
# Line 931 | Line 933 | find_exact_name_conf(enum maskitem_type
933  
934        if (EmptyString(conf->name))
935          continue;
936 <    
936 >
937        if (irccmp(conf->name, name) == 0)
938        {
939          if ((user == NULL && (host == NULL)))
# Line 997 | Line 999 | find_exact_name_conf(enum maskitem_type
999  
1000        if (EmptyString(conf->name))
1001          continue;
1002 <    
1002 >
1003        if (name == NULL)
1004        {
1005          if (EmptyString(conf->host))
# Line 1027 | Line 1029 | find_exact_name_conf(enum maskitem_type
1029   int
1030   rehash(int sig)
1031   {
1032 <  if (sig != 0)
1032 >  if (sig)
1033      sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1034 <                         "Got signal SIGHUP, reloading ircd.conf file");
1034 >                         "Got signal SIGHUP, reloading configuration file(s)");
1035  
1036    restart_resolver();
1037  
# Line 1040 | Line 1042 | rehash(int sig)
1042  
1043    read_conf_files(0);
1044  
1045 <  if (ServerInfo.description != NULL)
1045 >  if (ServerInfo.description)
1046      strlcpy(me.info, ServerInfo.description, sizeof(me.info));
1047  
1048    load_conf_modules();
# Line 1099 | Line 1101 | set_default_conf(void)
1101    ConfigLoggingEntry.use_logging = 1;
1102  
1103    ConfigChannel.disable_fake_channels = 0;
1104 <  ConfigChannel.knock_delay = 300;
1104 >  ConfigChannel.invite_client_count = 10;
1105 >  ConfigChannel.invite_client_time = 300;
1106 >  ConfigChannel.knock_client_count = 1;
1107 >  ConfigChannel.knock_client_time = 300;
1108    ConfigChannel.knock_delay_channel = 60;
1109    ConfigChannel.max_chans_per_user = 25;
1110    ConfigChannel.max_chans_per_oper = 50;
# Line 1116 | Line 1121 | set_default_conf(void)
1121    ConfigServerHide.hide_services = 0;
1122    ConfigServerHide.hidden_name = xstrdup(NETWORK_NAME_DEFAULT);
1123    ConfigServerHide.hide_server_ips = 0;
1124 +  ConfigServerHide.disable_remote_commands = 0;
1125  
1120  
1126    ConfigFileEntry.service_name = xstrdup(SERVICE_NAME_DEFAULT);
1127    ConfigFileEntry.max_watch = WATCHSIZE_DEFAULT;
1128 +  ConfigFileEntry.cycle_on_host_change = 1;
1129    ConfigFileEntry.glines = 0;
1130    ConfigFileEntry.gline_time = 12 * 3600;
1131    ConfigFileEntry.gline_request_time = GLINE_REQUEST_EXPIRE_DEFAULT;
# Line 1130 | Line 1136 | set_default_conf(void)
1136    ConfigFileEntry.hide_spoof_ips = 1;
1137    ConfigFileEntry.ignore_bogus_ts = 0;
1138    ConfigFileEntry.disable_auth = 0;
1133  ConfigFileEntry.disable_remote = 0;
1139    ConfigFileEntry.kill_chase_time_limit = 90;
1140    ConfigFileEntry.default_floodcount = 8;
1141    ConfigFileEntry.failed_oper_notice = 1;
# Line 1144 | Line 1149 | set_default_conf(void)
1149    ConfigFileEntry.anti_spam_exit_message_time = 0;
1150    ConfigFileEntry.ts_warn_delta = TS_WARN_DELTA_DEFAULT;
1151    ConfigFileEntry.ts_max_delta = TS_MAX_DELTA_DEFAULT;
1152 <  ConfigFileEntry.warn_no_nline = 1;
1152 >  ConfigFileEntry.warn_no_connect_block = 1;
1153 >  ConfigFileEntry.stats_e_disabled = 0;
1154    ConfigFileEntry.stats_o_oper_only = 0;
1155 <  ConfigFileEntry.stats_k_oper_only = 1;  /* masked */
1156 <  ConfigFileEntry.stats_i_oper_only = 1;  /* masked */
1155 >  ConfigFileEntry.stats_k_oper_only = 1;  /* 1 = masked */
1156 >  ConfigFileEntry.stats_i_oper_only = 1;  /* 1 = masked */
1157    ConfigFileEntry.stats_P_oper_only = 0;
1158 +  ConfigFileEntry.stats_u_oper_only = 0;
1159    ConfigFileEntry.caller_id_wait = 60;
1160    ConfigFileEntry.opers_bypass_callerid = 0;
1161    ConfigFileEntry.pace_wait = 10;
# Line 1188 | 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 1199 | Line 1206 | read_conf(FILE *file)
1206   {
1207    lineno = 0;
1208  
1209 <  set_default_conf(); /* Set default values prior to conf parsing */
1209 >  set_default_conf();  /* Set default values prior to conf parsing */
1210    conf_parser_ctx.pass = 1;
1211 <  yyparse();          /* pick up the classes first */
1211 >  yyparse();  /* Pick up the classes first */
1212  
1213    rewind(file);
1214  
1215    conf_parser_ctx.pass = 2;
1216 <  yyparse();          /* Load the values from the conf */
1217 <  validate_conf();    /* Check to make sure some values are still okay. */
1218 <                      /* Some global values are also loaded here. */
1219 <  class_delete_marked();      /* Make sure classes are valid */
1216 >  yyparse();  /* Load the values from the conf */
1217 >  validate_conf();  /* Check to make sure some values are still okay. */
1218 >                    /* Some global values are also loaded here. */
1219 >  class_delete_marked();  /* Delete unused classes that are marked for deletion */
1220   }
1221  
1222   /* lookup_confhost()
# Line 1222 | Line 1229 | lookup_confhost(struct MaskItem *conf)
1229   {
1230    struct addrinfo hints, *res;
1231  
1232 <  /* Do name lookup now on hostnames given and store the
1232 >  /*
1233 >   * Do name lookup now on hostnames given and store the
1234     * ip numbers in conf structure.
1235     */
1236    memset(&hints, 0, sizeof(hints));
# Line 1239 | Line 1247 | lookup_confhost(struct MaskItem *conf)
1247      return;
1248    }
1249  
1250 <  assert(res != NULL);
1250 >  assert(res);
1251  
1252    memcpy(&conf->addr, res->ai_addr, res->ai_addrlen);
1253    conf->addr.ss_len = res->ai_addrlen;
# Line 1265 | Line 1273 | conf_connect_allowed(struct irc_ssaddr *
1273    if (conf && (conf->type == CONF_EXEMPT))
1274      return 0;
1275  
1276 <  if (conf != NULL)
1276 >  if (conf)
1277      return BANNED_CLIENT;
1278  
1279    ip_found = find_or_add_ip(addr);
# Line 1281 | Line 1289 | conf_connect_allowed(struct irc_ssaddr *
1289    return 0;
1290   }
1291  
1284 /* find_kill()
1285 *
1286 * inputs       - pointer to client structure
1287 * output       - pointer to struct MaskItem if found
1288 * side effects - See if this user is klined already,
1289 *                and if so, return struct MaskItem pointer
1290 */
1291 struct MaskItem *
1292 find_kill(struct Client *client_p)
1293 {
1294  struct MaskItem *conf = NULL;
1295
1296  assert(client_p != NULL);
1297
1298  conf = find_conf_by_address(client_p->host, &client_p->localClient->ip,
1299                              CONF_KLINE, client_p->localClient->aftype,
1300                              client_p->username, NULL, 1);
1301  return conf;
1302 }
1303
1304 struct MaskItem *
1305 find_gline(struct Client *client_p)
1306 {
1307  struct MaskItem *conf;
1308
1309  assert(client_p != NULL);
1310
1311  conf = find_conf_by_address(client_p->host, &client_p->localClient->ip,
1312                              CONF_GLINE, client_p->localClient->aftype,
1313                              client_p->username, NULL, 1);
1314  return conf;
1315 }
1316
1292   /* cleanup_tklines()
1293   *
1294   * inputs       - NONE
# Line 1325 | Line 1300 | void
1300   cleanup_tklines(void *notused)
1301   {
1302    hostmask_expire_temporary();
1303 <  expire_tklines(&xconf_items);
1303 >  expire_tklines(&xconf_items);
1304    expire_tklines(&nresv_items);
1305    expire_tklines(&cresv_items);
1306   }
# Line 1339 | Line 1314 | cleanup_tklines(void *notused)
1314   static void
1315   expire_tklines(dlink_list *tklist)
1316   {
1317 <  dlink_node *ptr;
1318 <  dlink_node *next_ptr;
1344 <  struct MaskItem *conf;
1317 >  dlink_node *ptr = NULL, *ptr_next = NULL;
1318 >  struct MaskItem *conf = NULL;
1319  
1320 <  DLINK_FOREACH_SAFE(ptr, next_ptr, tklist->head)
1320 >  DLINK_FOREACH_SAFE(ptr, ptr_next, tklist->head)
1321    {
1322      conf = ptr->data;
1323  
# Line 1392 | Line 1366 | static const struct oper_privs
1366    { OPER_FLAG_SQUIT,          'R' },
1367    { OPER_FLAG_SQUIT_REMOTE,   'S' },
1368    { OPER_FLAG_UNKLINE,        'U' },
1369 <  { OPER_FLAG_X,              'X' },
1369 >  { OPER_FLAG_XLINE,          'X' },
1370    { 0, '\0' }
1371   };
1372  
1373   char *
1374   oper_privs_as_string(const unsigned int port)
1375   {
1376 <  static char privs_out[16];
1376 >  static char privs_out[IRCD_BUFSIZE];
1377    char *privs_ptr = privs_out;
1404  const struct oper_privs *opriv = flag_list;
1378  
1379 <  for (; opriv->flag; ++opriv)
1379 >  for (const struct oper_privs *opriv = flag_list; opriv->flag; ++opriv)
1380    {
1381      if (port & opriv->flag)
1382        *privs_ptr++ = opriv->c;
# Line 1425 | Line 1398 | oper_privs_as_string(const unsigned int
1398   const char *
1399   get_oper_name(const struct Client *client_p)
1400   {
1401 <  dlink_node *cnode = NULL;
1401 >  const dlink_node *cnode = NULL;
1402    /* +5 for !,@,{,} and null */
1403    static char buffer[NICKLEN + USERLEN + HOSTLEN + HOSTLEN + 5];
1404  
# Line 1433 | Line 1406 | get_oper_name(const struct Client *clien
1406    {
1407      if ((cnode = client_p->localClient->confs.head))
1408      {
1409 <      struct MaskItem *conf = cnode->data;
1409 >      const struct MaskItem *conf = cnode->data;
1410  
1411        if (IsConfOperator(conf))
1412        {
# Line 1443 | Line 1416 | get_oper_name(const struct Client *clien
1416        }
1417      }
1418  
1419 <    /* Probably should assert here for now. If there is an oper out there
1419 >    /* Probably should assert here for now. If there is an oper out there
1420       * with no oper{} conf attached, it would be good for us to know...
1421       */
1422      assert(0); /* Oper without oper conf! */
# Line 1463 | Line 1436 | get_oper_name(const struct Client *clien
1436   void
1437   read_conf_files(int cold)
1438   {
1439 <  const char *filename;
1440 <  char chanmodes[32];
1441 <  char chanlimit[32];
1439 >  const char *filename = NULL;
1440 >  char chanmodes[IRCD_BUFSIZE] = "";
1441 >  char chanlimit[IRCD_BUFSIZE] = "";
1442  
1443    conf_parser_ctx.boot = cold;
1444    filename = ConfigFileEntry.configfile;
# Line 1474 | Line 1447 | read_conf_files(int cold)
1447       FIXME: The full path is in conffilenamebuf first time since we
1448               dont know anything else
1449  
1450 <     - Gozem 2002-07-21
1450 >     - Gozem 2002-07-21
1451    */
1452    strlcpy(conffilebuf, filename, sizeof(conffilebuf));
1453  
# Line 1515 | Line 1488 | read_conf_files(int cold)
1488             ConfigChannel.max_chans_per_user);
1489    add_isupport("CHANLIMIT", chanlimit, -1);
1490    snprintf(chanmodes, sizeof(chanmodes), "%s", "beI,k,l,imnprstORS");
1491 <  add_isupport("CHANNELLEN", NULL, LOCAL_CHANNELLEN);
1491 >  add_isupport("CHANNELLEN", NULL, CHANNELLEN);
1492    add_isupport("TOPICLEN", NULL, ServerInfo.max_topic_length);
1493    add_isupport("CHANMODES", chanmodes, -1);
1494  
# Line 1548 | Line 1521 | clear_out_old_conf(void)
1521    /* We only need to free anything allocated by yyparse() here.
1522     * Resetting structs, etc, is taken care of by set_default_conf().
1523     */
1524 <  
1524 >
1525    for (; *iterator != NULL; iterator++)
1526    {
1527      DLINK_FOREACH_SAFE(ptr, next_ptr, (*iterator)->head)
# Line 1596 | Line 1569 | clear_out_old_conf(void)
1569    MyFree(ConfigFileEntry.egdpool_path);
1570    ConfigFileEntry.egdpool_path = NULL;
1571   #ifdef HAVE_LIBCRYPTO
1572 <  if (ServerInfo.rsa_private_key != NULL)
1572 >  if (ServerInfo.rsa_private_key)
1573    {
1574      RSA_free(ServerInfo.rsa_private_key);
1575      ServerInfo.rsa_private_key = NULL;
# Line 1635 | Line 1608 | clear_out_old_conf(void)
1608   *
1609   * inputs       - pointer to config item
1610   * output       - NONE
1611 < * side effects - Add a class pointer to a conf
1611 > * side effects - Add a class pointer to a conf
1612   */
1613   void
1614   conf_add_class_to_conf(struct MaskItem *conf, const char *class_name)
1615   {
1616 <  if (class_name == NULL)
1616 >  if (class_name == NULL)
1617    {
1618      conf->class = class_default;
1619  
# Line 1707 | Line 1680 | conf_error_report(const char *msg)
1680  
1681   /*
1682   * valid_tkline()
1683 < *
1683 > *
1684   * inputs       - pointer to ascii string to check
1685   *              - whether the specified time is in seconds or minutes
1686   * output       - -1 not enough parameters
# Line 1716 | Line 1689 | conf_error_report(const char *msg)
1689   * Originally written by Dianora (Diane, db@db.net)
1690   */
1691   time_t
1692 < valid_tkline(const char *p, int minutes)
1692 > valid_tkline(const char *data, const int minutes)
1693   {
1694 +  const unsigned char *p = (const unsigned char *)data;
1695 +  unsigned char tmpch = '\0';
1696    time_t result = 0;
1697  
1698 <  for (; *p; ++p)
1698 >  while ((tmpch = *p++))
1699    {
1700 <    if (!IsDigit(*p))
1700 >    if (!IsDigit(tmpch))
1701        return 0;
1702  
1703      result *= 10;
1704 <    result += (*p & 0xF);
1704 >    result += (tmpch & 0xF);
1705    }
1706  
1707    /*
1708 <   * In the degenerate case where oper does a /quote kline 0 user@host :reason
1708 >   * In the degenerate case where oper does a /quote kline 0 user@host :reason
1709     * i.e. they specifically use 0, I am going to return 1 instead
1710     * as a return value of non-zero is used to flag it as a temporary kline
1711     */
1712    if (result == 0)
1713      result = 1;
1714  
1715 <  /*
1715 >  /*
1716     * If the incoming time is in seconds convert it to minutes for the purpose
1717     * of this calculation
1718     */
1719    if (!minutes)
1720 <    result = result / (time_t)60;
1720 >    result = result / 60;
1721  
1722    if (result > MAX_TDKLINE_TIME)
1723      result = MAX_TDKLINE_TIME;
1724  
1725 <  result = result * (time_t)60;  /* turn it into seconds */
1725 >  result = result * 60;  /* turn it into seconds */
1726  
1727    return result;
1728   }
# Line 1827 | Line 1802 | valid_wild_card(struct Client *source_p,
1802           * break - no point in searching further.
1803           */
1804          if (++nonwild >= ConfigFileEntry.min_nonwildcard)
1805 +        {
1806 +          va_end(args);
1807            return 1;
1808 +        }
1809        }
1810      }
1811    }
1812  
1813    if (warn)
1814 <    sendto_one(source_p, ":%s NOTICE %s :Please include at least %d non-wildcard characters with the mask",
1815 <               me.name, source_p->name, ConfigFileEntry.min_nonwildcard);
1814 >    sendto_one_notice(source_p, &me,
1815 >                      ":Please include at least %d non-wildcard characters with the mask",
1816 >                      ConfigFileEntry.min_nonwildcard);
1817 >  va_end(args);
1818    return 0;
1819   }
1820  
# Line 1848 | Line 1828 | valid_wild_card(struct Client *source_p,
1828   *              - parse_flags bit map of things to test
1829   *              - pointer to user or string to parse into
1830   *              - pointer to host or NULL to parse into if non NULL
1831 < *              - pointer to optional tkline time or NULL
1831 > *              - pointer to optional tkline time or NULL
1832   *              - pointer to target_server to parse into if non NULL
1833   *              - pointer to reason to parse into
1834   *
# Line 1875 | Line 1855 | parse_aline(const char *cmd, struct Clie
1855              char **target_server, char **reason)
1856   {
1857    int found_tkline_time=0;
1858 <  static char def_reason[] = "No Reason";
1858 >  static char def_reason[] = CONF_NOREASON;
1859    static char user[USERLEN*4+1];
1860    static char host[HOSTLEN*4+1];
1861  
# Line 1893 | Line 1873 | parse_aline(const char *cmd, struct Clie
1873        *tkline_time = found_tkline_time;
1874      else
1875      {
1876 <      sendto_one(source_p, ":%s NOTICE %s :temp_line not supported by %s",
1897 <                 me.name, source_p->name, cmd);
1876 >      sendto_one_notice(source_p, &me, ":temp_line not supported by %s", cmd);
1877        return -1;
1878      }
1879    }
1880  
1881    if (parc == 0)
1882    {
1883 <    sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
1905 <               me.name, source_p->name, cmd);
1883 >    sendto_one_numeric(source_p, &me, ERR_NEEDMOREPARAMS, cmd);
1884      return -1;
1885    }
1886  
# Line 1916 | Line 1894 | parse_aline(const char *cmd, struct Clie
1894      *up_p = user;
1895      *h_p = host;
1896    }
1897 <
1897 >
1898    parc--;
1899    parv++;
1900  
# Line 1929 | Line 1907 | parse_aline(const char *cmd, struct Clie
1907  
1908        if (target_server == NULL)
1909        {
1910 <        sendto_one(source_p, ":%s NOTICE %s :ON server not supported by %s",
1933 <                   me.name, source_p->name, cmd);
1910 >        sendto_one_notice(source_p, &me, ":ON server not supported by %s", cmd);
1911          return -1;
1912        }
1913  
1914        if (!HasOFlag(source_p, OPER_FLAG_REMOTEBAN))
1915        {
1916 <        sendto_one(source_p, form_str(ERR_NOPRIVS),
1940 <                   me.name, source_p->name, "remoteban");
1916 >        sendto_one_numeric(source_p, &me, ERR_NOPRIVS, "remoteban");
1917          return -1;
1918        }
1919  
1920        if (parc == 0 || EmptyString(*parv))
1921        {
1922 <        sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
1947 <                   me.name, source_p->name, cmd);
1922 >        sendto_one_numeric(source_p, &me, ERR_NEEDMOREPARAMS, cmd);
1923          return -1;
1924        }
1925  
# Line 1966 | Line 1941 | parse_aline(const char *cmd, struct Clie
1941    {
1942      if (strchr(user, '!') != NULL)
1943      {
1944 <      sendto_one(source_p, ":%s NOTICE %s :Invalid character '!' in kline",
1970 <                 me.name, source_p->name);
1944 >      sendto_one_notice(source_p, &me, ":Invalid character '!' in kline");
1945        return -1;
1946      }
1947  
# Line 2038 | Line 2012 | find_user_host(struct Client *source_p,
2012        luser[1] = '\0';
2013        strlcpy(lhost, user_host_or_nick, HOSTLEN*4 + 1);
2014      }
2015 <    
2015 >
2016      return 1;
2017    }
2018    else
2019    {
2020      /* Try to find user@host mask from nick */
2021      /* Okay to use source_p as the first param, because source_p == client_p */
2022 <    if ((target_p =
2023 <        find_chasing(source_p, source_p, user_host_or_nick, NULL)) == NULL)
2024 <      return 0;
2022 >    if ((target_p =
2023 >        find_chasing(source_p, user_host_or_nick)) == NULL)
2024 >      return 0;  /* find_chasing sends ERR_NOSUCHNICK */
2025  
2026      if (IsExemptKline(target_p))
2027      {
2028        if (!IsServer(source_p))
2029 <        sendto_one(source_p,
2056 <                   ":%s NOTICE %s :%s is E-lined",
2057 <                   me.name, source_p->name, target_p->name);
2029 >        sendto_one_notice(source_p, &me, ":%s is E-lined", target_p->name);
2030        return 0;
2031      }
2032  
# Line 2115 | Line 2087 | match_conf_password(const char *password
2087    else
2088      encr = password;
2089  
2090 <  return !strcmp(encr, conf->passwd);
2090 >  return encr && !strcmp(encr, conf->passwd);
2091   }
2092  
2093   /*
# Line 2123 | Line 2095 | match_conf_password(const char *password
2095   *
2096   * inputs       - client sending the cluster
2097   *              - command name "KLINE" "XLINE" etc.
2098 < *              - capab -- CAP_KLN etc. from s_serv.h
2098 > *              - capab -- CAP_KLN etc. from server.h
2099   *              - cluster type -- CLUSTER_KLINE etc. from conf.h
2100   *              - pattern and args to send along
2101   * output       - none
# Line 2135 | Line 2107 | cluster_a_line(struct Client *source_p,
2107                 int capab, int cluster_type, const char *pattern, ...)
2108   {
2109    va_list args;
2110 <  char buffer[IRCD_BUFSIZE];
2110 >  char buffer[IRCD_BUFSIZE] = "";
2111    const dlink_node *ptr = NULL;
2112  
2113    va_start(args, pattern);
# Line 2196 | Line 2168 | split_nuh(struct split_nuh_item *const i
2168    {
2169      *p = '\0';
2170  
2171 <    if (iptr->nickptr && *iptr->nuhmask != '\0')
2171 >    if (iptr->nickptr && *iptr->nuhmask)
2172        strlcpy(iptr->nickptr, iptr->nuhmask, iptr->nicksize);
2173  
2174 <    if ((q = strchr(++p, '@'))) {
2174 >    if ((q = strchr(++p, '@')))
2175 >    {
2176        *q++ = '\0';
2177  
2178 <      if (*p != '\0')
2178 >      if (*p)
2179          strlcpy(iptr->userptr, p, iptr->usersize);
2180  
2181 <      if (*q != '\0')
2181 >      if (*q)
2182          strlcpy(iptr->hostptr, q, iptr->hostsize);
2183      }
2184      else
2185      {
2186 <      if (*p != '\0')
2186 >      if (*p)
2187          strlcpy(iptr->userptr, p, iptr->usersize);
2188      }
2189    }
# Line 2222 | Line 2195 | split_nuh(struct split_nuh_item *const i
2195        /* if found a @ */
2196        *p++ = '\0';
2197  
2198 <      if (*iptr->nuhmask != '\0')
2198 >      if (*iptr->nuhmask)
2199          strlcpy(iptr->userptr, iptr->nuhmask, iptr->usersize);
2200  
2201 <      if (*p != '\0')
2201 >      if (*p)
2202          strlcpy(iptr->hostptr, p, iptr->hostsize);
2203      }
2204      else

Diff Legend

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