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 3347 by michael, Sun Apr 20 14:03:06 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 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 244 | Line 254 | check_client(struct Client *source_p)
254      case TOO_MANY:
255        sendto_realops_flags(UMODE_FULL, L_ALL, SEND_NOTICE,
256                             "Too many on IP for %s (%s).",
257 <                           get_client_name(source_p, SHOW_IP),
258 <                           source_p->sockhost);
257 >                           get_client_name(source_p, SHOW_IP),
258 >                           source_p->sockhost);
259        ilog(LOG_TYPE_IRCD, "Too many connections on IP from %s.",
260 <           get_client_name(source_p, SHOW_IP));
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:
266        sendto_realops_flags(UMODE_FULL, L_ALL, SEND_NOTICE,
267                             "auth{} block is full for %s (%s).",
268 <                           get_client_name(source_p, SHOW_IP),
269 <                           source_p->sockhost);
268 >                           get_client_name(source_p, SHOW_IP),
269 >                           source_p->sockhost);
270        ilog(LOG_TYPE_IRCD, "Too many connections from %s.",
271 <           get_client_name(source_p, SHOW_IP));
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 269 | Line 278 | check_client(struct Client *source_p)
278        /* jdc - lists server name & port connections are on */
279        /*       a purely cosmetical change */
280        sendto_realops_flags(UMODE_UNAUTH, L_ALL, SEND_NOTICE,
281 <                           "Unauthorized client connection from %s [%s] on [%s/%u].",
282 <                           get_client_name(source_p, SHOW_IP),
283 <                           source_p->sockhost,
284 <                           source_p->localClient->listener->name,
285 <                           source_p->localClient->listener->port);
281 >                           "Unauthorized client connection from %s [%s] on [%s/%u].",
282 >                           get_client_name(source_p, SHOW_IP),
283 >                           source_p->sockhost,
284 >                           source_p->localClient->listener->name,
285 >                           source_p->localClient->listener->port);
286        ilog(LOG_TYPE_IRCD,
287 <          "Unauthorized client connection from %s on [%s/%u].",
288 <          get_client_name(source_p, SHOW_IP),
289 <          source_p->localClient->listener->name,
290 <          source_p->localClient->listener->port);
287 >           "Unauthorized client connection from %s on [%s/%u].",
288 >           get_client_name(source_p, SHOW_IP),
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    {
322      conf = find_address_conf(client_p->host, client_p->username,
323 <                             &client_p->localClient->ip,
324 <                             client_p->localClient->aftype,
323 >                             &client_p->localClient->ip,
324 >                             client_p->localClient->aftype,
325                               client_p->localClient->passwd);
326    }
327    else
328    {
329 <    strlcpy(non_ident+1, client_p->username, sizeof(non_ident)-1);
329 >    strlcpy(non_ident + 1, client_p->username, sizeof(non_ident) - 1);
330      conf = find_address_conf(client_p->host,non_ident,
331 <                             &client_p->localClient->ip,
332 <                             client_p->localClient->aftype,
333 <                             client_p->localClient->passwd);
331 >                             &client_p->localClient->ip,
332 >                             client_p->localClient->aftype,
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 : "",
345 <                   conf->port);
337 <        return(NOT_AUTHORIZED);
342 >        sendto_one_numeric(client_p, &me, RPL_REDIR,
343 >                           conf->name ? conf->name : "",
344 >                           conf->port);
345 >        return NOT_AUTHORIZED;
346        }
347  
348        if (IsConfDoIdentd(conf))
349 <        SetNeedId(client_p);
349 >        SetNeedId(client_p);
350  
351        /* Thanks for spoof idea amm */
352        if (IsConfDoSpoofIp(conf))
# Line 351 | Line 359 | verify_access(struct Client *client_p)
359          AddFlag(client_p, FLAGS_IP_SPOOFING | FLAGS_AUTH_SPOOF);
360        }
361  
362 <      return(attach_iline(client_p, conf));
362 >      return attach_iline(client_p, conf);
363      }
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);
369 <      sendto_one(client_p, ":%s NOTICE %s :*** Banned: %s",
362 <                 me.name, client_p->name, conf->reason);
363 <      return(BANNED_CLIENT);
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    }
372  
373 <  return(NOT_AUTHORIZED);
373 >  return NOT_AUTHORIZED;
374   }
375  
376   /* attach_iline()
# 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 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 534 | Line 538 | remove_one_ip(struct irc_ssaddr *ip_in)
538      if (ptr->count > 0)
539        ptr->count--;
540      if (ptr->count == 0 &&
541 <        (CurrentTime-ptr->last_attempt) >= ConfigFileEntry.throttle_time)
541 >        (CurrentTime-ptr->last_attempt) >= ConfigFileEntry.throttle_time)
542      {
543        if (last_ptr != NULL)
544 <        last_ptr->next = ptr->next;
544 >        last_ptr->next = ptr->next;
545        else
546 <        ip_hash_table[hash_index] = ptr->next;
546 >        ip_hash_table[hash_index] = ptr->next;
547  
548        mp_pool_release(ptr);
549        ip_entries_count--;
# 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 664 | Line 668 | garbage_collect_ip_entries(void)
668   void
669   detach_conf(struct Client *client_p, enum maskitem_type type)
670   {
671 <  dlink_node *ptr = NULL, *next_ptr = NULL;
671 >  dlink_node *ptr = NULL, *ptr_next = NULL;
672  
673 <  DLINK_FOREACH_SAFE(ptr, next_ptr, client_p->localClient->confs.head)
673 >  DLINK_FOREACH_SAFE(ptr, ptr_next, client_p->localClient->confs.head)
674    {
675      struct MaskItem *conf = ptr->data;
676  
# Line 707 | Line 711 | detach_conf(struct Client *client_p, enu
711   int
712   attach_conf(struct Client *client_p, struct MaskItem *conf)
713   {
714 <  if (dlinkFind(&client_p->localClient->confs, conf) != NULL)
714 >  if (dlinkFind(&client_p->localClient->confs, conf))
715      return 1;
716  
717    if (conf->type == CONF_CLIENT)
# Line 776 | Line 780 | find_conf_name(dlink_list *list, const c
780    DLINK_FOREACH(ptr, list->head)
781    {
782      conf = ptr->data;
783 <    
783 >
784      if (conf->type == type)
785      {
786        if (conf->name && (irccmp(conf->name, name) == 0 ||
# Line 868 | Line 872 | find_matching_name_conf(enum maskitem_ty
872        conf = ptr->data;
873  
874        if (EmptyString(conf->name))
875 <        continue;
875 >        continue;
876        if ((name != NULL) && !match(conf->name, name))
877        {
878 <        if ((user == NULL && (host == NULL)))
879 <          return conf;
880 <        if ((conf->flags & flags) != flags)
878 >        if ((user == NULL && (host == NULL)))
879 >          return conf;
880 >        if ((conf->flags & flags) != flags)
881            continue;
882 <        if (EmptyString(conf->user) || EmptyString(conf->host))
883 <          return conf;
884 <        if (!match(conf->user, user) && !match(conf->host, host))
885 <          return conf;
882 >        if (EmptyString(conf->user) || EmptyString(conf->host))
883 >          return conf;
884 >        if (!match(conf->user, user) && !match(conf->host, host))
885 >          return conf;
886        }
887      }
888        break;
# Line 894 | Line 898 | find_matching_name_conf(enum maskitem_ty
898          return conf;
899      }
900      break;
901 <  
901 >
902    default:
903      break;
904    }
# Line 930 | Line 934 | find_exact_name_conf(enum maskitem_type
934        conf = ptr->data;
935  
936        if (EmptyString(conf->name))
937 <        continue;
938 <    
937 >        continue;
938 >
939        if (irccmp(conf->name, name) == 0)
940        {
941 <        if ((user == NULL && (host == NULL)))
942 <          return (conf);
943 <        if (EmptyString(conf->user) || EmptyString(conf->host))
944 <          return (conf);
945 <        if (!match(conf->user, user) && !match(conf->host, host))
946 <          return (conf);
941 >        if ((user == NULL && (host == NULL)))
942 >          return conf;
943 >        if (EmptyString(conf->user) || EmptyString(conf->host))
944 >          return conf;
945 >        if (!match(conf->user, user) && !match(conf->host, host))
946 >          return conf;
947        }
948      }
949      break;
# Line 996 | Line 1000 | find_exact_name_conf(enum maskitem_type
1000        conf = ptr->data;
1001  
1002        if (EmptyString(conf->name))
1003 <        continue;
1004 <    
1003 >        continue;
1004 >
1005        if (name == NULL)
1006        {
1007 <        if (EmptyString(conf->host))
1008 <          continue;
1009 <        if (irccmp(conf->host, host) == 0)
1010 <          return(conf);
1007 >        if (EmptyString(conf->host))
1008 >          continue;
1009 >        if (irccmp(conf->host, host) == 0)
1010 >          return conf;
1011        }
1012        else if (irccmp(conf->name, name) == 0)
1013 <      {
1010 <          return (conf);
1011 <      }
1013 >        return conf;
1014      }
1015 +
1016      break;
1017  
1018    default:
1019      break;
1020    }
1021 <  return(NULL);
1021 >
1022 >  return NULL;
1023   }
1024  
1025   /* rehash()
# Line 1027 | Line 1031 | find_exact_name_conf(enum maskitem_type
1031   int
1032   rehash(int sig)
1033   {
1034 <  if (sig != 0)
1034 >  if (sig)
1035      sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1036 <                         "Got signal SIGHUP, reloading ircd.conf file");
1036 >                         "Got signal SIGHUP, reloading configuration file(s)");
1037  
1038    restart_resolver();
1039  
# Line 1040 | Line 1044 | rehash(int sig)
1044  
1045    read_conf_files(0);
1046  
1047 <  if (ServerInfo.description != NULL)
1047 >  if (ServerInfo.description)
1048      strlcpy(me.info, ServerInfo.description, sizeof(me.info));
1049  
1050    load_conf_modules();
# Line 1116 | Line 1120 | set_default_conf(void)
1120    ConfigServerHide.hide_services = 0;
1121    ConfigServerHide.hidden_name = xstrdup(NETWORK_NAME_DEFAULT);
1122    ConfigServerHide.hide_server_ips = 0;
1123 +  ConfigServerHide.disable_remote_commands = 0;
1124  
1120 –  
1125    ConfigFileEntry.service_name = xstrdup(SERVICE_NAME_DEFAULT);
1126    ConfigFileEntry.max_watch = WATCHSIZE_DEFAULT;
1127 +  ConfigFileEntry.cycle_on_host_change = 1;
1128    ConfigFileEntry.glines = 0;
1129    ConfigFileEntry.gline_time = 12 * 3600;
1130    ConfigFileEntry.gline_request_time = GLINE_REQUEST_EXPIRE_DEFAULT;
# Line 1130 | Line 1135 | set_default_conf(void)
1135    ConfigFileEntry.hide_spoof_ips = 1;
1136    ConfigFileEntry.ignore_bogus_ts = 0;
1137    ConfigFileEntry.disable_auth = 0;
1133 –  ConfigFileEntry.disable_remote = 0;
1138    ConfigFileEntry.kill_chase_time_limit = 90;
1139    ConfigFileEntry.default_floodcount = 8;
1140    ConfigFileEntry.failed_oper_notice = 1;
# Line 1149 | Line 1153 | set_default_conf(void)
1153    ConfigFileEntry.stats_k_oper_only = 1;  /* masked */
1154    ConfigFileEntry.stats_i_oper_only = 1;  /* masked */
1155    ConfigFileEntry.stats_P_oper_only = 0;
1156 +  ConfigFileEntry.stats_u_oper_only = 0;
1157    ConfigFileEntry.caller_id_wait = 60;
1158    ConfigFileEntry.opers_bypass_callerid = 0;
1159    ConfigFileEntry.pace_wait = 10;
# Line 1188 | Line 1193 | validate_conf(void)
1193    ConfigFileEntry.max_watch = IRCD_MAX(ConfigFileEntry.max_watch, WATCHSIZE_MIN);
1194   }
1195  
1196 < /* read_conf()
1196 > /* read_conf()
1197   *
1198   * inputs       - file descriptor pointing to config file to use
1199   * output       - None
# Line 1201 | Line 1206 | read_conf(FILE *file)
1206  
1207    set_default_conf(); /* Set default values prior to conf parsing */
1208    conf_parser_ctx.pass = 1;
1209 <  yyparse();          /* pick up the classes first */
1209 >  yyparse();          /* pick up the classes first */
1210  
1211    rewind(file);
1212  
# Line 1239 | Line 1244 | lookup_confhost(struct MaskItem *conf)
1244      return;
1245    }
1246  
1247 <  assert(res != NULL);
1247 >  assert(res);
1248  
1249    memcpy(&conf->addr, res->ai_addr, res->ai_addrlen);
1250    conf->addr.ss_len = res->ai_addrlen;
# Line 1265 | Line 1270 | conf_connect_allowed(struct irc_ssaddr *
1270    if (conf && (conf->type == CONF_EXEMPT))
1271      return 0;
1272  
1273 <  if (conf != NULL)
1273 >  if (conf)
1274      return BANNED_CLIENT;
1275  
1276    ip_found = find_or_add_ip(addr);
# Line 1281 | Line 1286 | conf_connect_allowed(struct irc_ssaddr *
1286    return 0;
1287   }
1288  
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 –
1289   /* cleanup_tklines()
1290   *
1291   * inputs       - NONE
# Line 1325 | Line 1297 | void
1297   cleanup_tklines(void *notused)
1298   {
1299    hostmask_expire_temporary();
1300 <  expire_tklines(&xconf_items);
1300 >  expire_tklines(&xconf_items);
1301    expire_tklines(&nresv_items);
1302    expire_tklines(&cresv_items);
1303   }
# Line 1339 | Line 1311 | cleanup_tklines(void *notused)
1311   static void
1312   expire_tklines(dlink_list *tklist)
1313   {
1314 <  dlink_node *ptr;
1315 <  dlink_node *next_ptr;
1344 <  struct MaskItem *conf;
1314 >  dlink_node *ptr = NULL, *ptr_next = NULL;
1315 >  struct MaskItem *conf = NULL;
1316  
1317 <  DLINK_FOREACH_SAFE(ptr, next_ptr, tklist->head)
1317 >  DLINK_FOREACH_SAFE(ptr, ptr_next, tklist->head)
1318    {
1319      conf = ptr->data;
1320  
# Line 1392 | Line 1363 | static const struct oper_privs
1363    { OPER_FLAG_SQUIT,          'R' },
1364    { OPER_FLAG_SQUIT_REMOTE,   'S' },
1365    { OPER_FLAG_UNKLINE,        'U' },
1366 <  { OPER_FLAG_X,              'X' },
1366 >  { OPER_FLAG_XLINE,          'X' },
1367    { 0, '\0' }
1368   };
1369  
1370   char *
1371   oper_privs_as_string(const unsigned int port)
1372   {
1373 <  static char privs_out[16];
1373 >  static char privs_out[IRCD_BUFSIZE];
1374    char *privs_ptr = privs_out;
1404 –  const struct oper_privs *opriv = flag_list;
1375  
1376 <  for (; opriv->flag; ++opriv)
1376 >  for (const struct oper_privs *opriv = flag_list; opriv->flag; ++opriv)
1377    {
1378      if (port & opriv->flag)
1379        *privs_ptr++ = opriv->c;
# Line 1425 | Line 1395 | oper_privs_as_string(const unsigned int
1395   const char *
1396   get_oper_name(const struct Client *client_p)
1397   {
1398 <  dlink_node *cnode = NULL;
1398 >  const dlink_node *cnode = NULL;
1399    /* +5 for !,@,{,} and null */
1400    static char buffer[NICKLEN + USERLEN + HOSTLEN + HOSTLEN + 5];
1401  
# Line 1433 | Line 1403 | get_oper_name(const struct Client *clien
1403    {
1404      if ((cnode = client_p->localClient->confs.head))
1405      {
1406 <      struct MaskItem *conf = cnode->data;
1406 >      const struct MaskItem *conf = cnode->data;
1407  
1408        if (IsConfOperator(conf))
1409        {
1410 <        snprintf(buffer, sizeof(buffer), "%s!%s@%s{%s}", client_p->name,
1410 >        snprintf(buffer, sizeof(buffer), "%s!%s@%s{%s}", client_p->name,
1411                   client_p->username, client_p->host, conf->name);
1412 <        return buffer;
1412 >        return buffer;
1413        }
1414      }
1415  
1416 <    /* Probably should assert here for now. If there is an oper out there
1416 >    /* Probably should assert here for now. If there is an oper out there
1417       * with no oper{} conf attached, it would be good for us to know...
1418       */
1419      assert(0); /* Oper without oper conf! */
1420    }
1421  
1422    snprintf(buffer, sizeof(buffer), "%s!%s@%s{%s}", client_p->name,
1423 <           client_p->username, client_p->host, client_p->servptr->name);
1423 >           client_p->username, client_p->host, client_p->servptr->name);
1424    return buffer;
1425   }
1426  
# Line 1464 | Line 1434 | void
1434   read_conf_files(int cold)
1435   {
1436    const char *filename;
1437 <  char chanmodes[32];
1438 <  char chanlimit[32];
1437 >  char chanmodes[IRCD_BUFSIZE];
1438 >  char chanlimit[IRCD_BUFSIZE];
1439  
1440    conf_parser_ctx.boot = cold;
1441    filename = ConfigFileEntry.configfile;
# Line 1474 | Line 1444 | read_conf_files(int cold)
1444       FIXME: The full path is in conffilenamebuf first time since we
1445               dont know anything else
1446  
1447 <     - Gozem 2002-07-21
1447 >     - Gozem 2002-07-21
1448    */
1449    strlcpy(conffilebuf, filename, sizeof(conffilebuf));
1450  
# Line 1489 | Line 1459 | read_conf_files(int cold)
1459      else
1460      {
1461        sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1462 <                           "Unable to read configuration file '%s': %s",
1463 <                           filename, strerror(errno));
1462 >                           "Unable to read configuration file '%s': %s",
1463 >                           filename, strerror(errno));
1464        return;
1465      }
1466    }
# Line 1548 | Line 1518 | clear_out_old_conf(void)
1518    /* We only need to free anything allocated by yyparse() here.
1519     * Resetting structs, etc, is taken care of by set_default_conf().
1520     */
1521 <  
1521 >
1522    for (; *iterator != NULL; iterator++)
1523    {
1524      DLINK_FOREACH_SAFE(ptr, next_ptr, (*iterator)->head)
# Line 1561 | Line 1531 | clear_out_old_conf(void)
1531        if (conf->type == CONF_SERVER || conf->type == CONF_OPER)
1532        {
1533          if (!conf->ref_count)
1534 <          conf_free(conf);
1534 >          conf_free(conf);
1535        }
1536        else if (conf->type == CONF_XLINE)
1537        {
# Line 1596 | Line 1566 | clear_out_old_conf(void)
1566    MyFree(ConfigFileEntry.egdpool_path);
1567    ConfigFileEntry.egdpool_path = NULL;
1568   #ifdef HAVE_LIBCRYPTO
1569 <  if (ServerInfo.rsa_private_key != NULL)
1569 >  if (ServerInfo.rsa_private_key)
1570    {
1571      RSA_free(ServerInfo.rsa_private_key);
1572      ServerInfo.rsa_private_key = NULL;
# Line 1635 | Line 1605 | clear_out_old_conf(void)
1605   *
1606   * inputs       - pointer to config item
1607   * output       - NONE
1608 < * side effects - Add a class pointer to a conf
1608 > * side effects - Add a class pointer to a conf
1609   */
1610   void
1611   conf_add_class_to_conf(struct MaskItem *conf, const char *class_name)
1612   {
1613 <  if (class_name == NULL)
1613 >  if (class_name == NULL)
1614    {
1615      conf->class = class_default;
1616  
1617      if (conf->type == CONF_CLIENT)
1618        sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1619 <                           "Warning *** Defaulting to default class for %s@%s",
1620 <                           conf->user, conf->host);
1619 >                           "Warning *** Defaulting to default class for %s@%s",
1620 >                           conf->user, conf->host);
1621      else
1622        sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1623 <                           "Warning *** Defaulting to default class for %s",
1624 <                           conf->name);
1623 >                           "Warning *** Defaulting to default class for %s",
1624 >                           conf->name);
1625    }
1626    else
1627      conf->class = class_find(class_name, 1);
# Line 1660 | Line 1630 | conf_add_class_to_conf(struct MaskItem *
1630    {
1631      if (conf->type == CONF_CLIENT)
1632        sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1633 <                           "Warning *** Defaulting to default class for %s@%s",
1634 <                           conf->user, conf->host);
1633 >                           "Warning *** Defaulting to default class for %s@%s",
1634 >                           conf->user, conf->host);
1635      else
1636        sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1637 <                           "Warning *** Defaulting to default class for %s",
1638 <                           conf->name);
1637 >                           "Warning *** Defaulting to default class for %s",
1638 >                           conf->name);
1639      conf->class = class_default;
1640    }
1641   }
# Line 1707 | Line 1677 | conf_error_report(const char *msg)
1677  
1678   /*
1679   * valid_tkline()
1680 < *
1680 > *
1681   * inputs       - pointer to ascii string to check
1682   *              - whether the specified time is in seconds or minutes
1683   * output       - -1 not enough parameters
# Line 1716 | Line 1686 | conf_error_report(const char *msg)
1686   * Originally written by Dianora (Diane, db@db.net)
1687   */
1688   time_t
1689 < valid_tkline(const char *p, int minutes)
1689 > valid_tkline(const char *data, const int minutes)
1690   {
1691 +  const unsigned char *p = (const unsigned char *)data;
1692 +  unsigned char tmpch = '\0';
1693    time_t result = 0;
1694  
1695 <  for (; *p; ++p)
1695 >  while ((tmpch = *p++))
1696    {
1697 <    if (!IsDigit(*p))
1697 >    if (!IsDigit(tmpch))
1698        return 0;
1699  
1700      result *= 10;
1701 <    result += ((*p) & 0xF);
1701 >    result += (tmpch & 0xF);
1702    }
1703  
1704    /*
1705 <   * In the degenerate case where oper does a /quote kline 0 user@host :reason
1705 >   * In the degenerate case where oper does a /quote kline 0 user@host :reason
1706     * i.e. they specifically use 0, I am going to return 1 instead
1707     * as a return value of non-zero is used to flag it as a temporary kline
1708     */
1709    if (result == 0)
1710      result = 1;
1711  
1712 <  /*
1712 >  /*
1713     * If the incoming time is in seconds convert it to minutes for the purpose
1714     * of this calculation
1715     */
1716    if (!minutes)
1717 <    result = result / (time_t)60;
1717 >    result = result / 60;
1718  
1719    if (result > MAX_TDKLINE_TIME)
1720      result = MAX_TDKLINE_TIME;
1721  
1722 <  result = result * (time_t)60;  /* turn it into seconds */
1722 >  result = result * 60;  /* turn it into seconds */
1723  
1724    return result;
1725   }
# Line 1827 | Line 1799 | valid_wild_card(struct Client *source_p,
1799           * break - no point in searching further.
1800           */
1801          if (++nonwild >= ConfigFileEntry.min_nonwildcard)
1802 +        {
1803 +          va_end(args);
1804            return 1;
1805 +        }
1806        }
1807      }
1808    }
1809  
1810    if (warn)
1811 <    sendto_one(source_p, ":%s NOTICE %s :Please include at least %d non-wildcard characters with the mask",
1812 <               me.name, source_p->name, ConfigFileEntry.min_nonwildcard);
1811 >    sendto_one_notice(source_p, &me,
1812 >                      ":Please include at least %d non-wildcard characters with the mask",
1813 >                      ConfigFileEntry.min_nonwildcard);
1814 >  va_end(args);
1815    return 0;
1816   }
1817  
# Line 1848 | Line 1825 | valid_wild_card(struct Client *source_p,
1825   *              - parse_flags bit map of things to test
1826   *              - pointer to user or string to parse into
1827   *              - pointer to host or NULL to parse into if non NULL
1828 < *              - pointer to optional tkline time or NULL
1828 > *              - pointer to optional tkline time or NULL
1829   *              - pointer to target_server to parse into if non NULL
1830   *              - pointer to reason to parse into
1831   *
# Line 1870 | Line 1847 | valid_wild_card(struct Client *source_p,
1847   */
1848   int
1849   parse_aline(const char *cmd, struct Client *source_p,
1850 <            int parc, char **parv,
1851 <            int parse_flags, char **up_p, char **h_p, time_t *tkline_time,
1852 <            char **target_server, char **reason)
1850 >            int parc, char **parv,
1851 >            int parse_flags, char **up_p, char **h_p, time_t *tkline_time,
1852 >            char **target_server, char **reason)
1853   {
1854    int found_tkline_time=0;
1855    static char def_reason[] = "No Reason";
# Line 1893 | Line 1870 | parse_aline(const char *cmd, struct Clie
1870        *tkline_time = found_tkline_time;
1871      else
1872      {
1873 <      sendto_one(source_p, ":%s NOTICE %s :temp_line not supported by %s",
1897 <                 me.name, source_p->name, cmd);
1873 >      sendto_one_notice(source_p, &me, ":temp_line not supported by %s", cmd);
1874        return -1;
1875      }
1876    }
1877  
1878    if (parc == 0)
1879    {
1880 <    sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
1905 <               me.name, source_p->name, cmd);
1880 >    sendto_one_numeric(source_p, &me, ERR_NEEDMOREPARAMS, cmd);
1881      return -1;
1882    }
1883  
# Line 1916 | Line 1891 | parse_aline(const char *cmd, struct Clie
1891      *up_p = user;
1892      *h_p = host;
1893    }
1894 <
1894 >
1895    parc--;
1896    parv++;
1897  
# Line 1929 | Line 1904 | parse_aline(const char *cmd, struct Clie
1904  
1905        if (target_server == NULL)
1906        {
1907 <        sendto_one(source_p, ":%s NOTICE %s :ON server not supported by %s",
1908 <                   me.name, source_p->name, cmd);
1934 <        return -1;
1907 >        sendto_one_notice(source_p, &me, ":ON server not supported by %s", cmd);
1908 >        return -1;
1909        }
1910  
1911        if (!HasOFlag(source_p, OPER_FLAG_REMOTEBAN))
1912        {
1913 <        sendto_one(source_p, form_str(ERR_NOPRIVS),
1940 <                   me.name, source_p->name, "remoteban");
1913 >        sendto_one_numeric(source_p, &me, ERR_NOPRIVS, "remoteban");
1914          return -1;
1915        }
1916  
1917        if (parc == 0 || EmptyString(*parv))
1918        {
1919 <        sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
1920 <                   me.name, source_p->name, cmd);
1948 <        return -1;
1919 >        sendto_one_numeric(source_p, &me, ERR_NEEDMOREPARAMS, cmd);
1920 >        return -1;
1921        }
1922  
1923        *target_server = *parv;
# Line 1958 | Line 1930 | parse_aline(const char *cmd, struct Clie
1930         * caller probably NULL'd it first, but no harm to do it again -db
1931         */
1932        if (target_server != NULL)
1933 <        *target_server = NULL;
1933 >        *target_server = NULL;
1934      }
1935    }
1936  
# Line 1966 | Line 1938 | parse_aline(const char *cmd, struct Clie
1938    {
1939      if (strchr(user, '!') != NULL)
1940      {
1941 <      sendto_one(source_p, ":%s NOTICE %s :Invalid character '!' in kline",
1970 <                 me.name, source_p->name);
1941 >      sendto_one_notice(source_p, &me, ":Invalid character '!' in kline");
1942        return -1;
1943      }
1944  
# Line 1984 | Line 1955 | parse_aline(const char *cmd, struct Clie
1955      {
1956        *reason = *parv;
1957        if (!valid_comment(source_p, *reason, 1))
1958 <        return -1;
1958 >        return -1;
1959      }
1960      else
1961        *reason = def_reason;
# Line 2023 | Line 1994 | find_user_host(struct Client *source_p,
1994      {
1995        *(hostp++) = '\0';                       /* short and squat */
1996        if (*user_host_or_nick)
1997 <        strlcpy(luser, user_host_or_nick, USERLEN*4 + 1); /* here is my user */
1997 >        strlcpy(luser, user_host_or_nick, USERLEN*4 + 1); /* here is my user */
1998        else
1999 <        strcpy(luser, "*");
1999 >        strcpy(luser, "*");
2000 >
2001        if (*hostp)
2002 <        strlcpy(lhost, hostp, HOSTLEN + 1);    /* here is my host */
2002 >        strlcpy(lhost, hostp, HOSTLEN + 1);    /* here is my host */
2003        else
2004 <        strcpy(lhost, "*");
2004 >        strcpy(lhost, "*");
2005      }
2006      else
2007      {
2008        luser[0] = '*';             /* no @ found, assume its *@somehost */
2009 <      luser[1] = '\0';    
2009 >      luser[1] = '\0';
2010        strlcpy(lhost, user_host_or_nick, HOSTLEN*4 + 1);
2011      }
2012 <    
2012 >
2013      return 1;
2014    }
2015    else
2016    {
2017      /* Try to find user@host mask from nick */
2018      /* Okay to use source_p as the first param, because source_p == client_p */
2019 <    if ((target_p =
2020 <        find_chasing(source_p, source_p, user_host_or_nick, NULL)) == NULL)
2019 >    if ((target_p =
2020 >        find_chasing(source_p, user_host_or_nick)) == NULL)
2021        return 0;
2022  
2023      if (IsExemptKline(target_p))
2024      {
2025        if (!IsServer(source_p))
2026 <        sendto_one(source_p,
2055 <                   ":%s NOTICE %s :%s is E-lined",
2056 <                   me.name, source_p->name, target_p->name);
2026 >        sendto_one_notice(source_p, &me, ":%s is E-lined", target_p->name);
2027        return 0;
2028      }
2029  
# Line 2114 | Line 2084 | match_conf_password(const char *password
2084    else
2085      encr = password;
2086  
2087 <  return !strcmp(encr, conf->passwd);
2087 >  return encr && !strcmp(encr, conf->passwd);
2088   }
2089  
2090   /*
# Line 2122 | Line 2092 | match_conf_password(const char *password
2092   *
2093   * inputs       - client sending the cluster
2094   *              - command name "KLINE" "XLINE" etc.
2095 < *              - capab -- CAP_KLN etc. from s_serv.h
2095 > *              - capab -- CAP_KLN etc. from server.h
2096   *              - cluster type -- CLUSTER_KLINE etc. from conf.h
2097   *              - pattern and args to send along
2098   * output       - none
# Line 2147 | Line 2117 | cluster_a_line(struct Client *source_p,
2117  
2118      if (conf->flags & cluster_type)
2119        sendto_match_servs(source_p, conf->name, CAP_CLUSTER|capab,
2120 <                         "%s %s %s", command, conf->name, buffer);
2120 >                         "%s %s %s", command, conf->name, buffer);
2121    }
2122   }
2123  
# Line 2198 | Line 2168 | split_nuh(struct split_nuh_item *const i
2168      if (iptr->nickptr && *iptr->nuhmask != '\0')
2169        strlcpy(iptr->nickptr, iptr->nuhmask, iptr->nicksize);
2170  
2171 <    if ((q = strchr(++p, '@'))) {
2171 >    if ((q = strchr(++p, '@')))
2172 >    {
2173        *q++ = '\0';
2174  
2175        if (*p != '\0')

Diff Legend

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