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 1751 by michael, Wed Jan 16 18:30:52 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 63 | Line 70 | dlink_list cluster_items = { NULL, NULL,
70   dlink_list oconf_items   = { NULL, NULL, 0 };
71   dlink_list uconf_items   = { NULL, NULL, 0 };
72   dlink_list xconf_items   = { NULL, NULL, 0 };
66 – dlink_list rxconf_items  = { NULL, NULL, 0 };
67 – dlink_list rkconf_items  = { NULL, NULL, 0 };
73   dlink_list nresv_items   = { NULL, NULL, 0 };
74 < dlink_list temporary_resv = { NULL, NULL, 0 };
74 > dlink_list cresv_items = { NULL, NULL, 0 };
75  
76   extern unsigned int lineno;
77   extern char linebuf[];
# Line 85 | Line 90 | static int verify_access(struct Client *
90   static int attach_iline(struct Client *, struct MaskItem *);
91   static struct ip_entry *find_or_add_ip(struct irc_ssaddr *);
92   static dlink_list *map_to_list(enum maskitem_type);
88 – static struct MaskItem *find_regexp_kline(const char *[]);
93   static int find_user_host(struct Client *, char *, char *, char *, unsigned int);
94  
95  
# Line 125 | 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 176 | 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 186 | 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);
191 –  MyFree(conf->regexuser);
192 –  MyFree(conf->regexhost);
196   #ifdef HAVE_LIBCRYPTO
197    MyFree(conf->cipher_list);
198  
# Line 199 | 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  
216 <  MyFree(conf);
212 < }
213 <
214 < static const struct shared_flags
215 < {
216 <  const unsigned int type;
217 <  const unsigned char letter;
218 < } flag_table[] = {
219 <  { SHARED_KLINE,   'K' },
220 <  { SHARED_UNKLINE, 'U' },
221 <  { SHARED_XLINE,   'X' },
222 <  { SHARED_UNXLINE, 'Y' },
223 <  { SHARED_RESV,    'Q' },
224 <  { SHARED_UNRESV,  'R' },
225 <  { SHARED_LOCOPS,  'L' },
226 <  { SHARED_DLINE,   'D' },
227 <  { SHARED_UNDLINE, 'E' },
228 <  { 0, '\0' }
229 < };
230 <
231 < /*
232 < * inputs       - pointer to client requesting confitem report
233 < *              - ConfType to report
234 < * output       - none
235 < * side effects -
236 < */
237 < void
238 < report_confitem_types(struct Client *source_p, enum maskitem_type type)
239 < {
240 <  dlink_node *ptr = NULL, *dptr = NULL;
241 <  struct MaskItem *conf = NULL;
242 <  const struct ClassItem *class = NULL;
243 <  const struct shared_flags *shared = NULL;
244 <  char buf[12];
245 <  char *p = NULL;
246 <
247 <  switch (type)
216 >  DLINK_FOREACH_SAFE(ptr, ptr_next, conf->exempt_list.head)
217    {
218 <  case CONF_XLINE:
250 <    DLINK_FOREACH(ptr, xconf_items.head)
251 <    {
252 <      conf = ptr->data;
253 <
254 <      sendto_one(source_p, form_str(RPL_STATSXLINE),
255 <                 me.name, source_p->name,
256 <                 conf->until ? "x": "X", conf->count,
257 <                 conf->name, conf->reason);
258 <    }
259 <    break;
260 <
261 < #ifdef HAVE_LIBPCRE
262 <  case CONF_RXLINE:
263 <    DLINK_FOREACH(ptr, rxconf_items.head)
264 <    {
265 <      conf = ptr->data;
218 >    struct exempt *exptr = ptr->data;
219  
220 <      sendto_one(source_p, form_str(RPL_STATSXLINE),
221 <                 me.name, source_p->name,
222 <                 "XR", conf->count,
223 <                 conf->name, conf->reason);
224 <    }
272 <    break;
273 <
274 <  case CONF_RKLINE:
275 <    DLINK_FOREACH(ptr, rkconf_items.head)
276 <    {
277 <      conf = ptr->data;
278 <
279 <      sendto_one(source_p, form_str(RPL_STATSKLINE), me.name,
280 <                 source_p->name, "KR", conf->host, conf->user,
281 <                 conf->reason);
282 <    }
283 <    break;
284 < #endif
285 <
286 <  case CONF_ULINE:
287 <    shared = flag_table;
288 <    DLINK_FOREACH(ptr, uconf_items.head)
289 <    {
290 <      conf = ptr->data;
291 <
292 <      p = buf;
293 <
294 <      *p++ = 'c';
295 <      for (; shared->type; ++shared)
296 <        if (shared->type & conf->flags)
297 <          *p++ = shared->letter;
298 <        else
299 <          *p++ = ToLower(shared->letter);
300 <
301 <      sendto_one(source_p, form_str(RPL_STATSULINE),
302 <                 me.name, source_p->name, conf->name,
303 <                 conf->user?conf->user: "*",
304 <                 conf->host?conf->host: "*", buf);
305 <    }
306 <
307 <    shared = flag_table;
308 <    DLINK_FOREACH(ptr, cluster_items.head)
309 <    {
310 <      conf = ptr->data;
311 <
312 <      p = buf;
313 <
314 <      *p++ = 'C';
315 <      for (; shared->type; ++shared)
316 <        if (shared->type & conf->flags)
317 <          *p++ = shared->letter;
318 <        else
319 <          *p++ = ToLower(shared->letter);
320 <
321 <      sendto_one(source_p, form_str(RPL_STATSULINE),
322 <                 me.name, source_p->name, conf->name,
323 <                 "*", "*", buf);
324 <    }
325 <
326 <    break;
327 <
328 <  case CONF_OPER:
329 <    DLINK_FOREACH(ptr, oconf_items.head)
330 <    {
331 <      conf = ptr->data;
332 <
333 <      /* Don't allow non opers to see oper privs */
334 <      if (HasUMode(source_p, UMODE_OPER))
335 <        sendto_one(source_p, form_str(RPL_STATSOLINE),
336 <                   me.name, source_p->name, 'O', conf->user, conf->host,
337 <                   conf->name, oper_privs_as_string(conf->port),
338 <                   conf->class ? conf->class->name : "<default>");
339 <      else
340 <        sendto_one(source_p, form_str(RPL_STATSOLINE),
341 <                   me.name, source_p->name, 'O', conf->user, conf->host,
342 <                   conf->name, "0",
343 <                   conf->class ? conf->class->name : "<default>");
344 <    }
345 <    break;
346 <
347 <  case CONF_CLASS:
348 <    DLINK_FOREACH(ptr, class_get_list()->head)
349 <    {
350 <      class = ptr->data;
351 <      sendto_one(source_p, form_str(RPL_STATSYLINE),
352 <                 me.name, source_p->name, 'Y',
353 <                 class->name, class->ping_freq,
354 <                 class->con_freq,
355 <                 class->max_total, class->max_sendq,
356 <                 class->max_recvq,
357 <                 class->ref_count,
358 <                 class->number_per_cidr, class->cidr_bitlen_ipv4,
359 <                 class->number_per_cidr, class->cidr_bitlen_ipv6,
360 <                 class->active ? "active" : "disabled");
361 <    }
362 <    break;
363 <
364 <  case CONF_SERVICE:
365 <    DLINK_FOREACH(ptr, service_items.head)
366 <    {
367 <      conf = ptr->data;
368 <      sendto_one(source_p, form_str(RPL_STATSSERVICE),
369 <                 me.name, source_p->name, 'S', "*", conf->name, 0, 0);
370 <    }
371 <    break;
372 <
373 <  case CONF_SERVER:
374 <    DLINK_FOREACH(ptr, server_items.head)
375 <    {
376 <      p = buf;
377 <      conf = ptr->data;
378 <
379 <      buf[0] = '\0';
380 <
381 <      if (IsConfAllowAutoConn(conf))
382 <        *p++ = 'A';
383 <      if (IsConfSSL(conf))
384 <        *p++ = 'S';
385 <      if (buf[0] == '\0')
386 <        *p++ = '*';
387 <
388 <      *p = '\0';
389 <
390 <      /*
391 <       * Allow admins to see actual ips unless hide_server_ips is enabled
392 <       */
393 <      if (!ConfigServerHide.hide_server_ips && HasUMode(source_p, UMODE_ADMIN))
394 <        sendto_one(source_p, form_str(RPL_STATSCLINE),
395 <                   me.name, source_p->name, 'C', conf->host,
396 <                   buf, conf->name, conf->port,
397 <                   conf->class ? conf->class->name : "<default>");
398 <        else
399 <          sendto_one(source_p, form_str(RPL_STATSCLINE),
400 <                     me.name, source_p->name, 'C',
401 <                     "*@127.0.0.1", buf, conf->name, conf->port,
402 <                     conf->class ? conf->class->name : "<default>");
403 <    }
404 <    break;
405 <
406 <  case CONF_HUB:
407 <    DLINK_FOREACH(ptr, server_items.head)
408 <    {
409 <      conf = ptr->data;
410 <
411 <      DLINK_FOREACH(dptr, conf->hub_list.head)
412 <        sendto_one(source_p, form_str(RPL_STATSHLINE), me.name,
413 <                   source_p->name, 'H', dptr->data, conf->name, 0, "*");
414 <    }
415 <
416 <    DLINK_FOREACH(ptr, server_items.head)
417 <    {
418 <      conf = ptr->data;
419 <
420 <      DLINK_FOREACH(dptr, conf->leaf_list.head)
421 <        sendto_one(source_p, form_str(RPL_STATSLLINE), me.name,
422 <                   source_p->name, 'L', dptr->data, conf->name, 0, "*");
423 <    }
424 <
425 <    break;
426 <
427 <  default:
428 <    break;
220 >    dlinkDelete(ptr, &conf->exempt_list);
221 >    MyFree(exptr->name);
222 >    MyFree(exptr->user);
223 >    MyFree(exptr->host);
224 >    MyFree(exptr);
225    }
226 +
227 +  MyFree(conf);
228   }
229  
230   /* check_client()
# Line 446 | 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 456 | 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,
476 <                "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 481 | 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 517 | Line 314 | check_client(struct Client *source_p)
314   static int
315   verify_access(struct Client *client_p)
316   {
317 <  struct MaskItem *conf = NULL, *rkconf = NULL;
318 <  char non_ident[USERLEN + 1] = { '~', '\0' };
522 <  const char *uhi[3];
317 >  struct MaskItem *conf = NULL;
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 <  uhi[0] = IsGotId(client_p) ? client_p->username : non_ident;
541 <  uhi[1] = client_p->host;
542 <  uhi[2] = client_p->sockhost;
543 <
544 <  rkconf = find_regexp_kline(uhi);
545 <
546 <  if (conf != NULL)
336 >  if (conf)
337    {
338 <    if (IsConfClient(conf) && !rkconf)
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);
556 <        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 567 | Line 356 | verify_access(struct Client *client_p)
356                                 "%s spoofing: %s as %s",
357                                 client_p->name, client_p->host, conf->name);
358          strlcpy(client_p->host, conf->name, sizeof(client_p->host));
359 <        SetIPSpoof(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 (rkconf || IsConfKill(conf) || (ConfigFileEntry.glines && IsConfGline(conf)))
364 >    else if (IsConfKill(conf) || (ConfigFileEntry.glines && IsConfGline(conf)))
365      {
577 –      /* XXX */
578 –      conf = rkconf ? rkconf : conf;
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",
583 <                 me.name, client_p->name, conf->reason);
584 <      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 603 | 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  
610 –  if (conf->class == NULL)
611 –    return NOT_AUTHORIZED;  /* If class is missing, this is best */
612 –
397    class = conf->class;
398  
399    count_user_host(client_p->username, client_p->host,
# Line 636 | 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, "
641 <               "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 654 | Line 437 | attach_iline(struct Client *client_p, st
437   void
438   init_ip_hash_table(void)
439   {
440 <  ip_entry_pool = mp_pool_new(sizeof(struct ip_entry),
658 <    2 * hard_fdlimit);
440 >  ip_entry_pool = mp_pool_new(sizeof(struct ip_entry), MP_CHUNK_SIZE_IP_ENTRY);
441    memset(ip_hash_table, 0, sizeof(ip_hash_table));
442   }
443  
# Line 756 | 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 798 | 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 810 | 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 886 | 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 929 | 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 998 | 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 1021 | Line 803 | map_to_list(enum maskitem_type type)
803   {
804    switch(type)
805    {
1024 –  case CONF_RKLINE:
1025 –    return(&rkconf_items);
1026 –    break;
1027 –  case CONF_RXLINE:
1028 –    return(&rxconf_items);
1029 –    break;
806    case CONF_XLINE:
807      return(&xconf_items);
808      break;
# Line 1036 | Line 812 | map_to_list(enum maskitem_type type)
812    case CONF_NRESV:
813      return(&nresv_items);
814      break;
815 +  case CONF_CRESV:
816 +    return(&cresv_items);
817    case CONF_OPER:
818      return(&oconf_items);
819      break;
# Line 1073 | Line 851 | find_matching_name_conf(enum maskitem_ty
851  
852    switch (type)
853    {
1076 – #ifdef HAVE_LIBPCRE
1077 –  case CONF_RXLINE:
1078 –      DLINK_FOREACH(ptr, list_p->head)
1079 –      {
1080 –        conf = ptr->data;
1081 –        assert(conf->regexuser);
1082 –
1083 –        if (!ircd_pcre_exec(conf->regexuser, name))
1084 –          return conf;
1085 –      }
1086 –      break;
1087 – #endif
854    case CONF_SERVICE:
855      DLINK_FOREACH(ptr, list_p->head)
856      {
# Line 1100 | Line 866 | find_matching_name_conf(enum maskitem_ty
866    case CONF_XLINE:
867    case CONF_ULINE:
868    case CONF_NRESV:
869 +  case CONF_CRESV:
870      DLINK_FOREACH(ptr, list_p->head)
871      {
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 1131 | Line 898 | find_matching_name_conf(enum maskitem_ty
898          return conf;
899      }
900      break;
901 <  
901 >
902    default:
903      break;
904    }
# Line 1157 | Line 924 | find_exact_name_conf(enum maskitem_type
924  
925    switch(type)
926    {
1160 –  case CONF_RXLINE:
927    case CONF_XLINE:
928    case CONF_ULINE:
929    case CONF_NRESV:
930 +  case CONF_CRESV:
931  
932      DLINK_FOREACH(ptr, list_p->head)
933      {
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 1233 | 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 <      {
1247 <          return (conf);
1248 <      }
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 1264 | 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 1277 | 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();
1051  
1052    rehashed_klines = 1;
1286 – /* XXX */
1287 –  if (ConfigLoggingEntry.use_logging)
1288 –    log_close_all();
1053  
1054 <  return(0);
1054 >  return 0;
1055   }
1056  
1057   /* set_default_conf()
# Line 1334 | Line 1098 | set_default_conf(void)
1098    AdminInfo.email = NULL;
1099    AdminInfo.description = NULL;
1100  
1101 <  log_close_all();
1101 >  log_del_all();
1102  
1103    ConfigLoggingEntry.use_logging = 1;
1104  
1105    ConfigChannel.disable_fake_channels = 0;
1342 –  ConfigChannel.restrict_channels = 0;
1106    ConfigChannel.knock_delay = 300;
1107    ConfigChannel.knock_delay_channel = 60;
1108    ConfigChannel.max_chans_per_user = 25;
1109    ConfigChannel.max_chans_per_oper = 50;
1347 –  ConfigChannel.quiet_on_ban = 1;
1110    ConfigChannel.max_bans = 25;
1111    ConfigChannel.default_split_user_count = 0;
1112    ConfigChannel.default_split_server_count = 0;
# Line 1355 | Line 1117 | set_default_conf(void)
1117    ConfigServerHide.links_delay = 300;
1118    ConfigServerHide.hidden = 0;
1119    ConfigServerHide.hide_servers = 0;
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  
1361 –  
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 1371 | Line 1135 | set_default_conf(void)
1135    ConfigFileEntry.hide_spoof_ips = 1;
1136    ConfigFileEntry.ignore_bogus_ts = 0;
1137    ConfigFileEntry.disable_auth = 0;
1374 –  ConfigFileEntry.disable_remote = 0;
1138    ConfigFileEntry.kill_chase_time_limit = 90;
1139    ConfigFileEntry.default_floodcount = 8;
1140    ConfigFileEntry.failed_oper_notice = 1;
# Line 1390 | 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 1429 | 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 1442 | 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 1480 | 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 1506 | 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 1522 | Line 1286 | conf_connect_allowed(struct irc_ssaddr *
1286    return 0;
1287   }
1288  
1525 – static struct MaskItem *
1526 – find_regexp_kline(const char *uhi[])
1527 – {
1528 – #ifdef HAVE_LIBPCRE
1529 –  const dlink_node *ptr = NULL;
1530 –
1531 –  DLINK_FOREACH(ptr, rkconf_items.head)
1532 –  {
1533 –    struct MaskItem *aptr = ptr->data;
1534 –
1535 –    assert(aptr->regexuser);
1536 –    assert(aptr->regexhost);
1537 –
1538 –    if (!ircd_pcre_exec(aptr->regexuser, uhi[0]) &&
1539 –        (!ircd_pcre_exec(aptr->regexhost, uhi[1]) ||
1540 –         !ircd_pcre_exec(aptr->regexhost, uhi[2])))
1541 –      return aptr;
1542 –  }
1543 – #endif
1544 –  return NULL;
1545 – }
1546 –
1547 – /* find_kill()
1548 – *
1549 – * inputs       - pointer to client structure
1550 – * output       - pointer to struct MaskItem if found
1551 – * side effects - See if this user is klined already,
1552 – *                and if so, return struct MaskItem pointer
1553 – */
1554 – struct MaskItem *
1555 – find_kill(struct Client *client_p)
1556 – {
1557 –  struct MaskItem *conf = NULL;
1558 –  const char *uhi[3];
1559 –
1560 –  uhi[0] = client_p->username;
1561 –  uhi[1] = client_p->host;
1562 –  uhi[2] = client_p->sockhost;
1563 –
1564 –  assert(client_p != NULL);
1565 –
1566 –  conf = find_conf_by_address(client_p->host, &client_p->localClient->ip,
1567 –                              CONF_KLINE, client_p->localClient->aftype,
1568 –                              client_p->username, NULL, 1);
1569 –  if (conf == NULL)
1570 –    conf = find_regexp_kline(uhi);
1571 –
1572 –  return conf;
1573 – }
1574 –
1575 – struct MaskItem *
1576 – find_gline(struct Client *client_p)
1577 – {
1578 –  struct MaskItem *conf;
1579 –
1580 –  assert(client_p != NULL);
1581 –
1582 –  conf = find_conf_by_address(client_p->host, &client_p->localClient->ip,
1583 –                              CONF_GLINE, client_p->localClient->aftype,
1584 –                              client_p->username, NULL, 1);
1585 –  return conf;
1586 – }
1587 –
1289   /* cleanup_tklines()
1290   *
1291   * inputs       - NONE
# Line 1596 | 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(&resv_channel_list);
1302 >  expire_tklines(&cresv_items);
1303   }
1304  
1305   /* expire_tklines()
# Line 1610 | 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;
1615 <  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 1628 | Line 1328 | expire_tklines(dlink_list *tklist)
1328                                 "Temporary X-line for [%s] expired", conf->name);
1329        conf_free(conf);
1330      }
1331 <    else if (conf->type == CONF_NRESV)
1331 >    else if (conf->type == CONF_NRESV || conf->type == CONF_CRESV)
1332      {
1333        if (ConfigFileEntry.tkline_expire_notices)
1334          sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1335                                 "Temporary RESV for [%s] expired", conf->name);
1336        conf_free(conf);
1337      }
1638 –    else if (conf->type == CONF_CRESV)
1639 –    {
1640 –      if (ConfigFileEntry.tkline_expire_notices)
1641 –        sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1642 –                               "Temporary RESV for [%s] expired", conf->name);
1643 –      delete_channel_resv(conf);
1644 –    }
1338    }
1339   }
1340  
# Line 1656 | Line 1349 | static const struct oper_privs
1349    const unsigned int flag;
1350    const unsigned char c;
1351   } flag_list[] = {
1352 <  { OPER_FLAG_ADMIN,       'A' },
1353 <  { OPER_FLAG_REMOTEBAN,   'B' },
1354 <  { OPER_FLAG_DIE,         'D' },
1355 <  { OPER_FLAG_GLINE,       'G' },
1356 <  { OPER_FLAG_REHASH,      'H' },
1357 <  { OPER_FLAG_K,           'K' },
1358 <  { OPER_FLAG_OPERWALL,    'L' },
1359 <  { OPER_FLAG_N,           'N' },
1360 <  { OPER_FLAG_GLOBAL_KILL, 'O' },
1361 <  { OPER_FLAG_REMOTE,      'R' },
1362 <  { OPER_FLAG_OPER_SPY,    'S' },
1363 <  { OPER_FLAG_UNKLINE,     'U' },
1364 <  { OPER_FLAG_X,           'X' },
1352 >  { OPER_FLAG_ADMIN,          'A' },
1353 >  { OPER_FLAG_REMOTEBAN,      'B' },
1354 >  { OPER_FLAG_DIE,            'D' },
1355 >  { OPER_FLAG_GLINE,          'G' },
1356 >  { OPER_FLAG_REHASH,         'H' },
1357 >  { OPER_FLAG_K,              'K' },
1358 >  { OPER_FLAG_OPERWALL,       'L' },
1359 >  { OPER_FLAG_KILL,           'N' },
1360 >  { OPER_FLAG_KILL_REMOTE,    'O' },
1361 >  { OPER_FLAG_CONNECT,        'P' },
1362 >  { OPER_FLAG_CONNECT_REMOTE, 'Q' },
1363 >  { OPER_FLAG_SQUIT,          'R' },
1364 >  { OPER_FLAG_SQUIT_REMOTE,   'S' },
1365 >  { OPER_FLAG_UNKLINE,        'U' },
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;
1680 –  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 1701 | 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 1709 | 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 1740 | 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 1750 | 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 1765 | 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 1777 | Line 1471 | read_conf_files(int cold)
1471    read_conf(conf_parser_ctx.conf_file);
1472    fclose(conf_parser_ctx.conf_file);
1473  
1474 +  log_reopen_all();
1475 +
1476    add_isupport("NICKLEN", NULL, ServerInfo.max_nick_length);
1477    add_isupport("NETWORK", ServerInfo.network_name, -1);
1478  
# Line 1791 | Line 1487 | read_conf_files(int cold)
1487    snprintf(chanmodes, sizeof(chanmodes), "%s", "beI,k,l,imnprstORS");
1488    add_isupport("CHANNELLEN", NULL, LOCAL_CHANNELLEN);
1489    add_isupport("TOPICLEN", NULL, ServerInfo.max_topic_length);
1794 –  add_isupport("EXCEPTS", "e", -1);
1795 –  add_isupport("INVEX", "I", -1);
1490    add_isupport("CHANMODES", chanmodes, -1);
1491  
1492    /*
# Line 1815 | Line 1509 | clear_out_old_conf(void)
1509    struct MaskItem *conf;
1510    dlink_list *free_items [] = {
1511      &server_items,   &oconf_items,
1512 <     &uconf_items,   &xconf_items, &rxconf_items, &rkconf_items,
1513 <     &nresv_items, &cluster_items,  &service_items, NULL
1512 >     &uconf_items,   &xconf_items,
1513 >     &nresv_items, &cluster_items,  &service_items, &cresv_items, NULL
1514    };
1515  
1516    dlink_list ** iterator = free_items; /* C is dumb */
# Line 1824 | 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 1837 | 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  ||
1843 <               conf->type == CONF_RXLINE ||
1844 <               conf->type == CONF_RKLINE)
1536 >      else if (conf->type == CONF_XLINE)
1537        {
1538          if (!conf->until)
1539            conf_free(conf);
# Line 1851 | Line 1543 | clear_out_old_conf(void)
1543      }
1544    }
1545  
1546 +  motd_clear();
1547 +
1548    /*
1549     * don't delete the class table, rather mark all entries
1550     * for deletion. The table is cleaned up by class_delete_marked. - avalon
# Line 1872 | 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 1891 | Line 1585 | clear_out_old_conf(void)
1585                                                 SSL_OP_NO_TLSv1);
1586   #endif
1587  
1894 –  /* clean out old resvs from the conf */
1895 –  clear_conf_resv();
1896 –
1588    /* clean out AdminInfo */
1589    MyFree(AdminInfo.name);
1590    AdminInfo.name = NULL;
# Line 1908 | Line 1599 | clear_out_old_conf(void)
1599    /* clean out general */
1600    MyFree(ConfigFileEntry.service_name);
1601    ConfigFileEntry.service_name = NULL;
1911 –
1912 –  delete_isupport("INVEX");
1913 –  delete_isupport("EXCEPTS");
1602   }
1603  
1604   /* conf_add_class_to_conf()
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 1942 | 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 1989 | 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 1998 | 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   }
1726  
1727 + /* valid_wild_card_simple()
1728 + *
1729 + * inputs       - data to check for sufficient non-wildcard characters
1730 + * outputs      - 1 if valid, else 0
1731 + * side effects - none
1732 + */
1733 + int
1734 + valid_wild_card_simple(const char *data)
1735 + {
1736 +  const unsigned char *p = (const unsigned char *)data;
1737 +  unsigned char tmpch = '\0';
1738 +  int nonwild = 0;
1739 +
1740 +  while ((tmpch = *p++))
1741 +  {
1742 +    if (tmpch == '\\')
1743 +    {
1744 +      ++p;
1745 +      if (++nonwild >= ConfigFileEntry.min_nonwildcard_simple)
1746 +        return 1;
1747 +    }
1748 +    else if (!IsMWildChar(tmpch))
1749 +    {
1750 +      if (++nonwild >= ConfigFileEntry.min_nonwildcard_simple)
1751 +        return 1;
1752 +    }
1753 +  }
1754 +
1755 +  return 0;
1756 + }
1757 +
1758   /* valid_wild_card()
1759   *
1760   * input        - pointer to client
# Line 2045 | Line 1766 | valid_tkline(const char *p, int minutes)
1766   int
1767   valid_wild_card(struct Client *source_p, int warn, int count, ...)
1768   {
2048 –  char *p;
1769    char tmpch;
1770    int nonwild = 0;
1771    va_list args;
# Line 2066 | Line 1786 | valid_wild_card(struct Client *source_p,
1786  
1787    while (count--)
1788    {
1789 <    p = va_arg(args, char *);
1789 >    const char *p = va_arg(args, const char *);
1790      if (p == NULL)
1791        continue;
1792  
# Line 2079 | 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 2100 | 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 2122 | 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 2145 | 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",
2149 <                 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),
2157 <               me.name, source_p->name, cmd);
1880 >    sendto_one_numeric(source_p, &me, ERR_NEEDMOREPARAMS, cmd);
1881      return -1;
1882    }
1883  
# Line 2168 | 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 2181 | 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);
2186 <        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),
2192 <                   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);
2200 <        return -1;
1919 >        sendto_one_numeric(source_p, &me, ERR_NEEDMOREPARAMS, cmd);
1920 >        return -1;
1921        }
1922  
1923        *target_server = *parv;
# Line 2210 | 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 2218 | 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",
2222 <                 me.name, source_p->name);
1941 >      sendto_one_notice(source_p, &me, ":Invalid character '!' in kline");
1942        return -1;
1943      }
1944  
# Line 2236 | 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 2275 | 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,
2307 <                   ":%s NOTICE %s :%s is E-lined",
2308 <                   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 2366 | 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 2374 | 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 2399 | 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 2450 | 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)