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 2175 by michael, Mon Jun 3 23:45:39 2013 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 184 | Line 192 | conf_free(struct MaskItem *conf)
192    MyFree(conf->passwd);
193    MyFree(conf->spasswd);
194    MyFree(conf->reason);
195 +  MyFree(conf->certfp);
196    MyFree(conf->user);
197    MyFree(conf->host);
198   #ifdef HAVE_LIBCRYPTO
# Line 195 | Line 204 | conf_free(struct MaskItem *conf)
204    DLINK_FOREACH_SAFE(ptr, ptr_next, conf->hub_list.head)
205    {
206      MyFree(ptr->data);
207 +    dlinkDelete(ptr, &conf->hub_list);
208      free_dlink_node(ptr);
209    }
210  
211    DLINK_FOREACH_SAFE(ptr, ptr_next, conf->leaf_list.head)
212    {
213      MyFree(ptr->data);
214 +    dlinkDelete(ptr, &conf->leaf_list);
215      free_dlink_node(ptr);
216    }
217  
# Line 208 | Line 219 | conf_free(struct MaskItem *conf)
219    {
220      struct exempt *exptr = ptr->data;
221  
222 +    dlinkDelete(ptr, &conf->exempt_list);
223      MyFree(exptr->name);
224      MyFree(exptr->user);
225      MyFree(exptr->host);
# Line 234 | 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 244 | Line 256 | check_client(struct Client *source_p)
256      case TOO_MANY:
257        sendto_realops_flags(UMODE_FULL, L_ALL, SEND_NOTICE,
258                             "Too many on IP for %s (%s).",
259 <                           get_client_name(source_p, SHOW_IP),
260 <                           source_p->sockhost);
259 >                           get_client_name(source_p, SHOW_IP),
260 >                           source_p->sockhost);
261        ilog(LOG_TYPE_IRCD, "Too many connections on IP from %s.",
262 <           get_client_name(source_p, SHOW_IP));
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:
268        sendto_realops_flags(UMODE_FULL, L_ALL, SEND_NOTICE,
269                             "auth{} block is full for %s (%s).",
270 <                           get_client_name(source_p, SHOW_IP),
271 <                           source_p->sockhost);
270 >                           get_client_name(source_p, SHOW_IP),
271 >                           source_p->sockhost);
272        ilog(LOG_TYPE_IRCD, "Too many connections from %s.",
273 <           get_client_name(source_p, SHOW_IP));
273 >           get_client_name(source_p, SHOW_IP));
274        ++ServerStats.is_ref;
275 <      exit_client(source_p, &me,
264 <                "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 269 | Line 280 | check_client(struct Client *source_p)
280        /* jdc - lists server name & port connections are on */
281        /*       a purely cosmetical change */
282        sendto_realops_flags(UMODE_UNAUTH, L_ALL, SEND_NOTICE,
283 <                           "Unauthorized client connection from %s [%s] on [%s/%u].",
284 <                           get_client_name(source_p, SHOW_IP),
285 <                           source_p->sockhost,
286 <                           source_p->localClient->listener->name,
287 <                           source_p->localClient->listener->port);
283 >                           "Unauthorized client connection from %s [%s] on [%s/%u].",
284 >                           get_client_name(source_p, SHOW_IP),
285 >                           source_p->sockhost,
286 >                           source_p->localClient->listener->name,
287 >                           source_p->localClient->listener->port);
288        ilog(LOG_TYPE_IRCD,
289 <          "Unauthorized client connection from %s on [%s/%u].",
290 <          get_client_name(source_p, SHOW_IP),
291 <          source_p->localClient->listener->name,
292 <          source_p->localClient->listener->port);
289 >           "Unauthorized client connection from %s on [%s/%u].",
290 >           get_client_name(source_p, SHOW_IP),
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 306 | 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    {
324      conf = find_address_conf(client_p->host, client_p->username,
325 <                             &client_p->localClient->ip,
326 <                             client_p->localClient->aftype,
325 >                             &client_p->localClient->ip,
326 >                             client_p->localClient->aftype,
327                               client_p->localClient->passwd);
328    }
329    else
330    {
331 <    strlcpy(non_ident+1, client_p->username, sizeof(non_ident)-1);
331 >    strlcpy(non_ident + 1, client_p->username, sizeof(non_ident) - 1);
332      conf = find_address_conf(client_p->host,non_ident,
333 <                             &client_p->localClient->ip,
334 <                             client_p->localClient->aftype,
335 <                             client_p->localClient->passwd);
333 >                             &client_p->localClient->ip,
334 >                             client_p->localClient->aftype,
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 : "",
347 <                   conf->port);
337 <        return(NOT_AUTHORIZED);
344 >        sendto_one_numeric(client_p, &me, RPL_REDIR,
345 >                           conf->name ? conf->name : "",
346 >                           conf->port);
347 >        return NOT_AUTHORIZED;
348        }
349  
350        if (IsConfDoIdentd(conf))
351 <        SetNeedId(client_p);
351 >        SetNeedId(client_p);
352  
353        /* Thanks for spoof idea amm */
354        if (IsConfDoSpoofIp(conf))
# Line 351 | Line 361 | verify_access(struct Client *client_p)
361          AddFlag(client_p, FLAGS_IP_SPOOFING | FLAGS_AUTH_SPOOF);
362        }
363  
364 <      return(attach_iline(client_p, conf));
364 >      return attach_iline(client_p, conf);
365      }
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);
371 <      sendto_one(client_p, ":%s NOTICE %s :*** Banned: %s",
362 <                 me.name, client_p->name, conf->reason);
363 <      return(BANNED_CLIENT);
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    }
374  
375 <  return(NOT_AUTHORIZED);
375 >  return NOT_AUTHORIZED;
376   }
377  
378   /* attach_iline()
# Line 382 | Line 390 | attach_iline(struct Client *client_p, st
390    int a_limit_reached = 0;
391    unsigned int local = 0, global = 0, ident = 0;
392  
393 +  assert(conf->class);
394 +
395    ip_found = find_or_add_ip(&client_p->localClient->ip);
396    ip_found->count++;
397    SetIpHash(client_p);
398  
389  if (conf->class == NULL)
390    return NOT_AUTHORIZED;  /* If class is missing, this is best */
391
399    class = conf->class;
400  
401    count_user_host(client_p->username, client_p->host,
# Line 415 | 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, "
420 <               "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 534 | Line 540 | remove_one_ip(struct irc_ssaddr *ip_in)
540      if (ptr->count > 0)
541        ptr->count--;
542      if (ptr->count == 0 &&
543 <        (CurrentTime-ptr->last_attempt) >= ConfigFileEntry.throttle_time)
543 >        (CurrentTime-ptr->last_attempt) >= ConfigFileEntry.throttle_time)
544      {
545        if (last_ptr != NULL)
546 <        last_ptr->next = ptr->next;
546 >        last_ptr->next = ptr->next;
547        else
548 <        ip_hash_table[hash_index] = ptr->next;
548 >        ip_hash_table[hash_index] = ptr->next;
549  
550        mp_pool_release(ptr);
551        ip_entries_count--;
# Line 576 | 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 588 | 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 776 | 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 868 | Line 874 | find_matching_name_conf(enum maskitem_ty
874        conf = ptr->data;
875  
876        if (EmptyString(conf->name))
877 <        continue;
877 >        continue;
878        if ((name != NULL) && !match(conf->name, name))
879        {
880 <        if ((user == NULL && (host == NULL)))
881 <          return conf;
882 <        if ((conf->flags & flags) != flags)
880 >        if ((user == NULL && (host == NULL)))
881 >          return conf;
882 >        if ((conf->flags & flags) != flags)
883            continue;
884 <        if (EmptyString(conf->user) || EmptyString(conf->host))
885 <          return conf;
886 <        if (!match(conf->user, user) && !match(conf->host, host))
887 <          return conf;
884 >        if (EmptyString(conf->user) || EmptyString(conf->host))
885 >          return conf;
886 >        if (!match(conf->user, user) && !match(conf->host, host))
887 >          return conf;
888        }
889      }
890        break;
# Line 894 | Line 900 | find_matching_name_conf(enum maskitem_ty
900          return conf;
901      }
902      break;
903 <  
903 >
904    default:
905      break;
906    }
# Line 930 | Line 936 | find_exact_name_conf(enum maskitem_type
936        conf = ptr->data;
937  
938        if (EmptyString(conf->name))
939 <        continue;
940 <    
939 >        continue;
940 >
941        if (irccmp(conf->name, name) == 0)
942        {
943 <        if ((user == NULL && (host == NULL)))
944 <          return (conf);
945 <        if (EmptyString(conf->user) || EmptyString(conf->host))
946 <          return (conf);
947 <        if (!match(conf->user, user) && !match(conf->host, host))
948 <          return (conf);
943 >        if ((user == NULL && (host == NULL)))
944 >          return conf;
945 >        if (EmptyString(conf->user) || EmptyString(conf->host))
946 >          return conf;
947 >        if (!match(conf->user, user) && !match(conf->host, host))
948 >          return conf;
949        }
950      }
951      break;
# Line 996 | Line 1002 | find_exact_name_conf(enum maskitem_type
1002        conf = ptr->data;
1003  
1004        if (EmptyString(conf->name))
1005 <        continue;
1006 <    
1005 >        continue;
1006 >
1007        if (name == NULL)
1008        {
1009 <        if (EmptyString(conf->host))
1010 <          continue;
1011 <        if (irccmp(conf->host, host) == 0)
1012 <          return(conf);
1009 >        if (EmptyString(conf->host))
1010 >          continue;
1011 >        if (irccmp(conf->host, host) == 0)
1012 >          return conf;
1013        }
1014        else if (irccmp(conf->name, name) == 0)
1015 <      {
1010 <          return (conf);
1011 <      }
1015 >        return conf;
1016      }
1017 +
1018      break;
1019  
1020    default:
1021      break;
1022    }
1023 <  return(NULL);
1023 >
1024 >  return NULL;
1025   }
1026  
1027   /* rehash()
# Line 1029 | Line 1035 | rehash(int sig)
1035   {
1036    if (sig != 0)
1037      sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1038 <                         "Got signal SIGHUP, reloading ircd.conf file");
1038 >                         "Got signal SIGHUP, reloading configuration file(s)");
1039  
1040    restart_resolver();
1041  
# Line 1116 | Line 1122 | set_default_conf(void)
1122    ConfigServerHide.hide_services = 0;
1123    ConfigServerHide.hidden_name = xstrdup(NETWORK_NAME_DEFAULT);
1124    ConfigServerHide.hide_server_ips = 0;
1125 +  ConfigServerHide.disable_remote_commands = 0;
1126  
1120  
1127    ConfigFileEntry.service_name = xstrdup(SERVICE_NAME_DEFAULT);
1128    ConfigFileEntry.max_watch = WATCHSIZE_DEFAULT;
1129 +  ConfigFileEntry.cycle_on_host_change = 1;
1130    ConfigFileEntry.glines = 0;
1131    ConfigFileEntry.gline_time = 12 * 3600;
1132    ConfigFileEntry.gline_request_time = GLINE_REQUEST_EXPIRE_DEFAULT;
# Line 1130 | Line 1137 | set_default_conf(void)
1137    ConfigFileEntry.hide_spoof_ips = 1;
1138    ConfigFileEntry.ignore_bogus_ts = 0;
1139    ConfigFileEntry.disable_auth = 0;
1133  ConfigFileEntry.disable_remote = 0;
1140    ConfigFileEntry.kill_chase_time_limit = 90;
1141    ConfigFileEntry.default_floodcount = 8;
1142    ConfigFileEntry.failed_oper_notice = 1;
# Line 1149 | Line 1155 | set_default_conf(void)
1155    ConfigFileEntry.stats_k_oper_only = 1;  /* masked */
1156    ConfigFileEntry.stats_i_oper_only = 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 1201 | Line 1208 | read_conf(FILE *file)
1208  
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  
# Line 1281 | Line 1288 | conf_connect_allowed(struct irc_ssaddr *
1288    return 0;
1289   }
1290  
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
1291   /* cleanup_tklines()
1292   *
1293   * inputs       - NONE
# Line 1325 | 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 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;
1378    const struct oper_privs *opriv = flag_list;
1379  
# Line 1425 | 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 1433 | 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        {
1414 <        snprintf(buffer, sizeof(buffer), "%s!%s@%s{%s}", client_p->name,
1414 >        snprintf(buffer, sizeof(buffer), "%s!%s@%s{%s}", client_p->name,
1415                   client_p->username, client_p->host, conf->name);
1416 <        return buffer;
1416 >        return buffer;
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! */
1424    }
1425  
1426    snprintf(buffer, sizeof(buffer), "%s!%s@%s{%s}", client_p->name,
1427 <           client_p->username, client_p->host, client_p->servptr->name);
1427 >           client_p->username, client_p->host, client_p->servptr->name);
1428    return buffer;
1429   }
1430  
# Line 1464 | Line 1438 | void
1438   read_conf_files(int cold)
1439   {
1440    const char *filename;
1441 <  char chanmodes[32];
1442 <  char chanlimit[32];
1441 >  char chanmodes[IRCD_BUFSIZE];
1442 >  char chanlimit[IRCD_BUFSIZE];
1443  
1444    conf_parser_ctx.boot = cold;
1445    filename = ConfigFileEntry.configfile;
# Line 1474 | 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 1489 | Line 1463 | read_conf_files(int cold)
1463      else
1464      {
1465        sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1466 <                           "Unable to read configuration file '%s': %s",
1467 <                           filename, strerror(errno));
1466 >                           "Unable to read configuration file '%s': %s",
1467 >                           filename, strerror(errno));
1468        return;
1469      }
1470    }
# Line 1548 | 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 1561 | Line 1535 | clear_out_old_conf(void)
1535        if (conf->type == CONF_SERVER || conf->type == CONF_OPER)
1536        {
1537          if (!conf->ref_count)
1538 <          conf_free(conf);
1538 >          conf_free(conf);
1539        }
1540        else if (conf->type == CONF_XLINE)
1541        {
# Line 1635 | 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  
1621      if (conf->type == CONF_CLIENT)
1622        sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1623 <                           "Warning *** Defaulting to default class for %s@%s",
1624 <                           conf->user, conf->host);
1623 >                           "Warning *** Defaulting to default class for %s@%s",
1624 >                           conf->user, conf->host);
1625      else
1626        sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1627 <                           "Warning *** Defaulting to default class for %s",
1628 <                           conf->name);
1627 >                           "Warning *** Defaulting to default class for %s",
1628 >                           conf->name);
1629    }
1630    else
1631      conf->class = class_find(class_name, 1);
# Line 1660 | Line 1634 | conf_add_class_to_conf(struct MaskItem *
1634    {
1635      if (conf->type == CONF_CLIENT)
1636        sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1637 <                           "Warning *** Defaulting to default class for %s@%s",
1638 <                           conf->user, conf->host);
1637 >                           "Warning *** Defaulting to default class for %s@%s",
1638 >                           conf->user, conf->host);
1639      else
1640        sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1641 <                           "Warning *** Defaulting to default class for %s",
1642 <                           conf->name);
1641 >                           "Warning *** Defaulting to default class for %s",
1642 >                           conf->name);
1643      conf->class = class_default;
1644    }
1645   }
# Line 1707 | 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 1716 | Line 1690 | conf_error_report(const char *msg)
1690   * Originally written by Dianora (Diane, db@db.net)
1691   */
1692   time_t
1693 < valid_tkline(const char *p, int minutes)
1693 > valid_tkline(const char *data, const int minutes)
1694   {
1695 +  const unsigned char *p = (const unsigned char *)data;
1696 +  unsigned char tmpch = '\0';
1697    time_t result = 0;
1698  
1699 <  for (; *p; ++p)
1699 >  while ((tmpch = *p++))
1700    {
1701 <    if (!IsDigit(*p))
1701 >    if (!IsDigit(tmpch))
1702        return 0;
1703  
1704      result *= 10;
1705 <    result += ((*p) & 0xF);
1705 >    result += (tmpch & 0xF);
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 / (time_t)60;
1721 >    result = result / 60;
1722  
1723    if (result > MAX_TDKLINE_TIME)
1724      result = MAX_TDKLINE_TIME;
1725  
1726 <  result = result * (time_t)60;  /* turn it into seconds */
1726 >  result = result * 60;  /* turn it into seconds */
1727  
1728    return result;
1729   }
# Line 1827 | Line 1803 | valid_wild_card(struct Client *source_p,
1803           * break - no point in searching further.
1804           */
1805          if (++nonwild >= ConfigFileEntry.min_nonwildcard)
1806 +        {
1807 +          va_end(args);
1808            return 1;
1809 +        }
1810        }
1811      }
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   }
1821  
# Line 1848 | 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 1870 | Line 1851 | valid_wild_card(struct Client *source_p,
1851   */
1852   int
1853   parse_aline(const char *cmd, struct Client *source_p,
1854 <            int parc, char **parv,
1855 <            int parse_flags, char **up_p, char **h_p, time_t *tkline_time,
1856 <            char **target_server, char **reason)
1854 >            int parc, char **parv,
1855 >            int parse_flags, char **up_p, char **h_p, time_t *tkline_time,
1856 >            char **target_server, char **reason)
1857   {
1858    int found_tkline_time=0;
1859    static char def_reason[] = "No Reason";
# Line 1893 | 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",
1897 <                 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),
1905 <               me.name, source_p->name, cmd);
1884 >    sendto_one_numeric(source_p, &me, ERR_NEEDMOREPARAMS, cmd);
1885      return -1;
1886    }
1887  
# Line 1916 | 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 1929 | 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",
1912 <                   me.name, source_p->name, cmd);
1934 <        return -1;
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),
1940 <                   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),
1924 <                   me.name, source_p->name, cmd);
1948 <        return -1;
1923 >        sendto_one_numeric(source_p, &me, ERR_NEEDMOREPARAMS, cmd);
1924 >        return -1;
1925        }
1926  
1927        *target_server = *parv;
# Line 1958 | Line 1934 | parse_aline(const char *cmd, struct Clie
1934         * caller probably NULL'd it first, but no harm to do it again -db
1935         */
1936        if (target_server != NULL)
1937 <        *target_server = NULL;
1937 >        *target_server = NULL;
1938      }
1939    }
1940  
# Line 1966 | 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",
1970 <                 me.name, source_p->name);
1945 >      sendto_one_notice(source_p, &me, ":Invalid character '!' in kline");
1946        return -1;
1947      }
1948  
# Line 1984 | Line 1959 | parse_aline(const char *cmd, struct Clie
1959      {
1960        *reason = *parv;
1961        if (!valid_comment(source_p, *reason, 1))
1962 <        return -1;
1962 >        return -1;
1963      }
1964      else
1965        *reason = def_reason;
# Line 2023 | Line 1998 | find_user_host(struct Client *source_p,
1998      {
1999        *(hostp++) = '\0';                       /* short and squat */
2000        if (*user_host_or_nick)
2001 <        strlcpy(luser, user_host_or_nick, USERLEN*4 + 1); /* here is my user */
2001 >        strlcpy(luser, user_host_or_nick, USERLEN*4 + 1); /* here is my user */
2002        else
2003 <        strcpy(luser, "*");
2003 >        strcpy(luser, "*");
2004 >
2005        if (*hostp)
2006 <        strlcpy(lhost, hostp, HOSTLEN + 1);    /* here is my host */
2006 >        strlcpy(lhost, hostp, HOSTLEN + 1);    /* here is my host */
2007        else
2008 <        strcpy(lhost, "*");
2008 >        strcpy(lhost, "*");
2009      }
2010      else
2011      {
2012        luser[0] = '*';             /* no @ found, assume its *@somehost */
2013 <      luser[1] = '\0';    
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, 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,
2055 <                   ":%s NOTICE %s :%s is E-lined",
2056 <                   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  
# Line 2147 | Line 2121 | cluster_a_line(struct Client *source_p,
2121  
2122      if (conf->flags & cluster_type)
2123        sendto_match_servs(source_p, conf->name, CAP_CLUSTER|capab,
2124 <                         "%s %s %s", command, conf->name, buffer);
2124 >                         "%s %s %s", command, conf->name, buffer);
2125    }
2126   }
2127  
# Line 2198 | Line 2172 | split_nuh(struct split_nuh_item *const i
2172      if (iptr->nickptr && *iptr->nuhmask != '\0')
2173        strlcpy(iptr->nickptr, iptr->nuhmask, iptr->nicksize);
2174  
2175 <    if ((q = strchr(++p, '@'))) {
2175 >    if ((q = strchr(++p, '@')))
2176 >    {
2177        *q++ = '\0';
2178  
2179        if (*p != '\0')

Diff Legend

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