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 1864 by michael, Thu Apr 25 17:07:20 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  
# Line 212 | 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 221 | Line 227 | conf_free(struct MaskItem *conf)
227    MyFree(conf);
228   }
229  
224 – static const struct shared_flags
225 – {
226 –  const unsigned int type;
227 –  const unsigned char letter;
228 – } flag_table[] = {
229 –  { SHARED_KLINE,   'K' },
230 –  { SHARED_UNKLINE, 'U' },
231 –  { SHARED_XLINE,   'X' },
232 –  { SHARED_UNXLINE, 'Y' },
233 –  { SHARED_RESV,    'Q' },
234 –  { SHARED_UNRESV,  'R' },
235 –  { SHARED_LOCOPS,  'L' },
236 –  { SHARED_DLINE,   'D' },
237 –  { SHARED_UNDLINE, 'E' },
238 –  { 0, '\0' }
239 – };
240 –
241 – /*
242 – * inputs       - pointer to client requesting confitem report
243 – *              - ConfType to report
244 – * output       - none
245 – * side effects -
246 – */
247 – void
248 – report_confitem_types(struct Client *source_p, enum maskitem_type type)
249 – {
250 –  dlink_node *ptr = NULL, *dptr = NULL;
251 –  struct MaskItem *conf = NULL;
252 –  const struct ClassItem *class = NULL;
253 –  const struct shared_flags *shared = NULL;
254 –  char buf[12];
255 –  char *p = NULL;
256 –
257 –  switch (type)
258 –  {
259 –  case CONF_XLINE:
260 –    DLINK_FOREACH(ptr, xconf_items.head)
261 –    {
262 –      conf = ptr->data;
263 –
264 –      sendto_one(source_p, form_str(RPL_STATSXLINE),
265 –                 me.name, source_p->name,
266 –                 conf->until ? "x": "X", conf->count,
267 –                 conf->name, conf->reason);
268 –    }
269 –    break;
270 –
271 – #ifdef HAVE_LIBPCRE
272 –  case CONF_RXLINE:
273 –    DLINK_FOREACH(ptr, rxconf_items.head)
274 –    {
275 –      conf = ptr->data;
276 –
277 –      sendto_one(source_p, form_str(RPL_STATSXLINE),
278 –                 me.name, source_p->name,
279 –                 "XR", conf->count,
280 –                 conf->name, conf->reason);
281 –    }
282 –    break;
283 –
284 –  case CONF_RKLINE:
285 –    DLINK_FOREACH(ptr, rkconf_items.head)
286 –    {
287 –      conf = ptr->data;
288 –
289 –      sendto_one(source_p, form_str(RPL_STATSKLINE), me.name,
290 –                 source_p->name, "KR", conf->host, conf->user,
291 –                 conf->reason);
292 –    }
293 –    break;
294 – #endif
295 –
296 –  case CONF_ULINE:
297 –    shared = flag_table;
298 –    DLINK_FOREACH(ptr, uconf_items.head)
299 –    {
300 –      conf = ptr->data;
301 –
302 –      p = buf;
303 –
304 –      *p++ = 'c';
305 –      for (; shared->type; ++shared)
306 –        if (shared->type & conf->flags)
307 –          *p++ = shared->letter;
308 –        else
309 –          *p++ = ToLower(shared->letter);
310 –
311 –      sendto_one(source_p, form_str(RPL_STATSULINE),
312 –                 me.name, source_p->name, conf->name,
313 –                 conf->user?conf->user: "*",
314 –                 conf->host?conf->host: "*", buf);
315 –    }
316 –
317 –    shared = flag_table;
318 –    DLINK_FOREACH(ptr, cluster_items.head)
319 –    {
320 –      conf = ptr->data;
321 –
322 –      p = buf;
323 –
324 –      *p++ = 'C';
325 –      for (; shared->type; ++shared)
326 –        if (shared->type & conf->flags)
327 –          *p++ = shared->letter;
328 –        else
329 –          *p++ = ToLower(shared->letter);
330 –
331 –      sendto_one(source_p, form_str(RPL_STATSULINE),
332 –                 me.name, source_p->name, conf->name,
333 –                 "*", "*", buf);
334 –    }
335 –
336 –    break;
337 –
338 –  case CONF_OPER:
339 –    DLINK_FOREACH(ptr, oconf_items.head)
340 –    {
341 –      conf = ptr->data;
342 –
343 –      /* Don't allow non opers to see oper privs */
344 –      if (HasUMode(source_p, UMODE_OPER))
345 –        sendto_one(source_p, form_str(RPL_STATSOLINE),
346 –                   me.name, source_p->name, 'O', conf->user, conf->host,
347 –                   conf->name, oper_privs_as_string(conf->port),
348 –                   conf->class ? conf->class->name : "<default>");
349 –      else
350 –        sendto_one(source_p, form_str(RPL_STATSOLINE),
351 –                   me.name, source_p->name, 'O', conf->user, conf->host,
352 –                   conf->name, "0",
353 –                   conf->class ? conf->class->name : "<default>");
354 –    }
355 –    break;
356 –
357 –  case CONF_CLASS:
358 –    DLINK_FOREACH(ptr, class_get_list()->head)
359 –    {
360 –      class = ptr->data;
361 –      sendto_one(source_p, form_str(RPL_STATSYLINE),
362 –                 me.name, source_p->name, 'Y',
363 –                 class->name, class->ping_freq,
364 –                 class->con_freq,
365 –                 class->max_total, class->max_sendq,
366 –                 class->max_recvq,
367 –                 class->ref_count,
368 –                 class->number_per_cidr, class->cidr_bitlen_ipv4,
369 –                 class->number_per_cidr, class->cidr_bitlen_ipv6,
370 –                 class->active ? "active" : "disabled");
371 –    }
372 –    break;
373 –
374 –  case CONF_SERVICE:
375 –    DLINK_FOREACH(ptr, service_items.head)
376 –    {
377 –      conf = ptr->data;
378 –      sendto_one(source_p, form_str(RPL_STATSSERVICE),
379 –                 me.name, source_p->name, 'S', "*", conf->name, 0, 0);
380 –    }
381 –    break;
382 –
383 –  case CONF_SERVER:
384 –    DLINK_FOREACH(ptr, server_items.head)
385 –    {
386 –      p = buf;
387 –      conf = ptr->data;
388 –
389 –      buf[0] = '\0';
390 –
391 –      if (IsConfAllowAutoConn(conf))
392 –        *p++ = 'A';
393 –      if (IsConfSSL(conf))
394 –        *p++ = 'S';
395 –      if (buf[0] == '\0')
396 –        *p++ = '*';
397 –
398 –      *p = '\0';
399 –
400 –      /*
401 –       * Allow admins to see actual ips unless hide_server_ips is enabled
402 –       */
403 –      if (!ConfigServerHide.hide_server_ips && HasUMode(source_p, UMODE_ADMIN))
404 –        sendto_one(source_p, form_str(RPL_STATSCLINE),
405 –                   me.name, source_p->name, 'C', conf->host,
406 –                   buf, conf->name, conf->port,
407 –                   conf->class ? conf->class->name : "<default>");
408 –        else
409 –          sendto_one(source_p, form_str(RPL_STATSCLINE),
410 –                     me.name, source_p->name, 'C',
411 –                     "*@127.0.0.1", buf, conf->name, conf->port,
412 –                     conf->class ? conf->class->name : "<default>");
413 –    }
414 –    break;
415 –
416 –  case CONF_HUB:
417 –    DLINK_FOREACH(ptr, server_items.head)
418 –    {
419 –      conf = ptr->data;
420 –
421 –      DLINK_FOREACH(dptr, conf->hub_list.head)
422 –        sendto_one(source_p, form_str(RPL_STATSHLINE), me.name,
423 –                   source_p->name, 'H', dptr->data, conf->name, 0, "*");
424 –    }
425 –
426 –    DLINK_FOREACH(ptr, server_items.head)
427 –    {
428 –      conf = ptr->data;
429 –
430 –      DLINK_FOREACH(dptr, conf->leaf_list.head)
431 –        sendto_one(source_p, form_str(RPL_STATSLLINE), me.name,
432 –                   source_p->name, 'L', dptr->data, conf->name, 0, "*");
433 –    }
434 –
435 –    break;
436 –
437 –  default:
438 –    break;
439 –  }
440 – }
441 –
230   /* check_client()
231   *
232   * inputs       - pointer to client
# Line 456 | 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 466 | 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,
486 <                "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 491 | 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 527 | 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' };
532 <  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;
551 <  uhi[1] = client_p->host;
552 <  uhi[2] = client_p->sockhost;
553 <
554 <  rkconf = find_regexp_kline(uhi);
555 <
556 <  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);
566 <        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 577 | 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      {
587 –      /* XXX */
588 –      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",
593 <                 me.name, client_p->name, conf->reason);
594 <      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 613 | 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  
620 –  if (conf->class == NULL)
621 –    return NOT_AUTHORIZED;  /* If class is missing, this is best */
622 –
397    class = conf->class;
398  
399    count_user_host(client_p->username, client_p->host,
# Line 646 | 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, "
651 <               "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 664 | 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),
668 <    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 766 | 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 808 | 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 820 | 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 896 | 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 939 | 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 1008 | 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 1031 | Line 803 | map_to_list(enum maskitem_type type)
803   {
804    switch(type)
805    {
1034 –  case CONF_RKLINE:
1035 –    return(&rkconf_items);
1036 –    break;
1037 –  case CONF_RXLINE:
1038 –    return(&rxconf_items);
1039 –    break;
806    case CONF_XLINE:
807      return(&xconf_items);
808      break;
# Line 1047 | Line 813 | map_to_list(enum maskitem_type type)
813      return(&nresv_items);
814      break;
815    case CONF_CRESV:
816 <    return(&resv_channel_list);
816 >    return(&cresv_items);
817    case CONF_OPER:
818      return(&oconf_items);
819      break;
# Line 1085 | Line 851 | find_matching_name_conf(enum maskitem_ty
851  
852    switch (type)
853    {
1088 – #ifdef HAVE_LIBPCRE
1089 –  case CONF_RXLINE:
1090 –      DLINK_FOREACH(ptr, list_p->head)
1091 –      {
1092 –        conf = ptr->data;
1093 –        assert(conf->regexuser);
1094 –
1095 –        if (!ircd_pcre_exec(conf->regexuser, name))
1096 –          return conf;
1097 –      }
1098 –      break;
1099 – #endif
854    case CONF_SERVICE:
855      DLINK_FOREACH(ptr, list_p->head)
856      {
# Line 1118 | 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 1144 | Line 898 | find_matching_name_conf(enum maskitem_ty
898          return conf;
899      }
900      break;
901 <  
901 >
902    default:
903      break;
904    }
# Line 1170 | Line 924 | find_exact_name_conf(enum maskitem_type
924  
925    switch(type)
926    {
1173 –  case CONF_RXLINE:
927    case CONF_XLINE:
928    case CONF_ULINE:
929    case CONF_NRESV:
# Line 1181 | 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 1247 | 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 <      {
1261 <          return (conf);
1262 <      }
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 1278 | 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 1291 | 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 1354 | Line 1107 | set_default_conf(void)
1107    ConfigChannel.knock_delay_channel = 60;
1108    ConfigChannel.max_chans_per_user = 25;
1109    ConfigChannel.max_chans_per_oper = 50;
1357 –  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 1368 | 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  
1372 –  
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 1382 | Line 1135 | set_default_conf(void)
1135    ConfigFileEntry.hide_spoof_ips = 1;
1136    ConfigFileEntry.ignore_bogus_ts = 0;
1137    ConfigFileEntry.disable_auth = 0;
1385 –  ConfigFileEntry.disable_remote = 0;
1138    ConfigFileEntry.kill_chase_time_limit = 90;
1139    ConfigFileEntry.default_floodcount = 8;
1140    ConfigFileEntry.failed_oper_notice = 1;
# Line 1401 | 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 1440 | 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 1453 | 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 1491 | 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 1517 | 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 1533 | Line 1286 | conf_connect_allowed(struct irc_ssaddr *
1286    return 0;
1287   }
1288  
1536 – static struct MaskItem *
1537 – find_regexp_kline(const char *uhi[])
1538 – {
1539 – #ifdef HAVE_LIBPCRE
1540 –  const dlink_node *ptr = NULL;
1541 –
1542 –  DLINK_FOREACH(ptr, rkconf_items.head)
1543 –  {
1544 –    struct MaskItem *aptr = ptr->data;
1545 –
1546 –    assert(aptr->regexuser);
1547 –    assert(aptr->regexhost);
1548 –
1549 –    if (!ircd_pcre_exec(aptr->regexuser, uhi[0]) &&
1550 –        (!ircd_pcre_exec(aptr->regexhost, uhi[1]) ||
1551 –         !ircd_pcre_exec(aptr->regexhost, uhi[2])))
1552 –      return aptr;
1553 –  }
1554 – #endif
1555 –  return NULL;
1556 – }
1557 –
1558 – /* find_kill()
1559 – *
1560 – * inputs       - pointer to client structure
1561 – * output       - pointer to struct MaskItem if found
1562 – * side effects - See if this user is klined already,
1563 – *                and if so, return struct MaskItem pointer
1564 – */
1565 – struct MaskItem *
1566 – find_kill(struct Client *client_p)
1567 – {
1568 –  struct MaskItem *conf = NULL;
1569 –  const char *uhi[3];
1570 –
1571 –  uhi[0] = client_p->username;
1572 –  uhi[1] = client_p->host;
1573 –  uhi[2] = client_p->sockhost;
1574 –
1575 –  assert(client_p != NULL);
1576 –
1577 –  conf = find_conf_by_address(client_p->host, &client_p->localClient->ip,
1578 –                              CONF_KLINE, client_p->localClient->aftype,
1579 –                              client_p->username, NULL, 1);
1580 –  if (conf == NULL)
1581 –    conf = find_regexp_kline(uhi);
1582 –
1583 –  return conf;
1584 – }
1585 –
1586 – struct MaskItem *
1587 – find_gline(struct Client *client_p)
1588 – {
1589 –  struct MaskItem *conf;
1590 –
1591 –  assert(client_p != NULL);
1592 –
1593 –  conf = find_conf_by_address(client_p->host, &client_p->localClient->ip,
1594 –                              CONF_GLINE, client_p->localClient->aftype,
1595 –                              client_p->username, NULL, 1);
1596 –  return conf;
1597 – }
1598 –
1289   /* cleanup_tklines()
1290   *
1291   * inputs       - NONE
# Line 1607 | 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 1621 | 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;
1626 <  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 1660 | 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;
1684 –  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 1705 | 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 1713 | 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 1744 | 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 1754 | 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 1769 | 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 1797 | 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);
1800 –  add_isupport("EXCEPTS", "e", -1);
1801 –  add_isupport("INVEX", "I", -1);
1490    add_isupport("CHANMODES", chanmodes, -1);
1491  
1492    /*
# Line 1821 | 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, &resv_channel_list, 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 1830 | 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 1843 | 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  ||
1849 <               conf->type == CONF_RXLINE ||
1850 <               conf->type == CONF_RKLINE)
1536 >      else if (conf->type == CONF_XLINE)
1537        {
1538          if (!conf->until)
1539            conf_free(conf);
# Line 1857 | 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 1878 | 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 1911 | Line 1599 | clear_out_old_conf(void)
1599    /* clean out general */
1600    MyFree(ConfigFileEntry.service_name);
1601    ConfigFileEntry.service_name = NULL;
1914 –
1915 –  delete_isupport("INVEX");
1916 –  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 1945 | 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 1992 | 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 2001 | 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 2048 | Line 1766 | valid_tkline(const char *p, int minutes)
1766   int
1767   valid_wild_card(struct Client *source_p, int warn, int count, ...)
1768   {
2051 –  char *p;
1769    char tmpch;
1770    int nonwild = 0;
1771    va_list args;
# Line 2069 | 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 2082 | 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 2103 | 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 2125 | 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 2148 | 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",
2152 <                 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),
2160 <               me.name, source_p->name, cmd);
1880 >    sendto_one_numeric(source_p, &me, ERR_NEEDMOREPARAMS, cmd);
1881      return -1;
1882    }
1883  
# Line 2171 | 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 2184 | 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);
2189 <        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),
2195 <                   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);
2203 <        return -1;
1919 >        sendto_one_numeric(source_p, &me, ERR_NEEDMOREPARAMS, cmd);
1920 >        return -1;
1921        }
1922  
1923        *target_server = *parv;
# Line 2213 | 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 2221 | 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",
2225 <                 me.name, source_p->name);
1941 >      sendto_one_notice(source_p, &me, ":Invalid character '!' in kline");
1942        return -1;
1943      }
1944  
# Line 2239 | 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 2278 | 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,
2310 <                   ":%s NOTICE %s :%s is E-lined",
2311 <                   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 2369 | 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 2377 | 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 2402 | 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 2453 | 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)