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 1832 by michael, Fri Apr 19 19:16:09 2013 UTC vs.
Revision 2525 by michael, Sat Nov 2 17:07:38 2013 UTC

# Line 53 | Line 53
53   #include "s_misc.h"
54   #include "conf_db.h"
55   #include "conf_class.h"
56 + #include "motd.h"
57  
58   struct config_server_hide ConfigServerHide;
59  
# Line 63 | Line 64 | dlink_list cluster_items = { NULL, NULL,
64   dlink_list oconf_items   = { NULL, NULL, 0 };
65   dlink_list uconf_items   = { NULL, NULL, 0 };
66   dlink_list xconf_items   = { NULL, NULL, 0 };
66 dlink_list rxconf_items  = { NULL, NULL, 0 };
67 dlink_list rkconf_items  = { NULL, NULL, 0 };
67   dlink_list nresv_items   = { NULL, NULL, 0 };
68 < dlink_list temporary_resv = { NULL, NULL, 0 };
68 > dlink_list cresv_items = { NULL, NULL, 0 };
69  
70   extern unsigned int lineno;
71   extern char linebuf[];
# Line 85 | Line 84 | static int verify_access(struct Client *
84   static int attach_iline(struct Client *, struct MaskItem *);
85   static struct ip_entry *find_or_add_ip(struct irc_ssaddr *);
86   static dlink_list *map_to_list(enum maskitem_type);
88 static struct MaskItem *find_regexp_kline(const char *[]);
87   static int find_user_host(struct Client *, char *, char *, char *, unsigned int);
88  
89  
# Line 186 | Line 184 | conf_free(struct MaskItem *conf)
184    MyFree(conf->passwd);
185    MyFree(conf->spasswd);
186    MyFree(conf->reason);
187 +  MyFree(conf->certfp);
188    MyFree(conf->user);
189    MyFree(conf->host);
191  MyFree(conf->regexuser);
192  MyFree(conf->regexhost);
190   #ifdef HAVE_LIBCRYPTO
191    MyFree(conf->cipher_list);
192  
# Line 208 | Line 205 | conf_free(struct MaskItem *conf)
205      free_dlink_node(ptr);
206    }
207  
208 <  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)
208 >  DLINK_FOREACH_SAFE(ptr, ptr_next, conf->exempt_list.head)
209    {
210 <  case CONF_XLINE:
250 <    DLINK_FOREACH(ptr, xconf_items.head)
251 <    {
252 <      conf = ptr->data;
253 <
254 <      sendto_one(source_p, 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;
266 <
267 <      sendto_one(source_p, RPL_STATSXLINE,
268 <                 me.name, source_p->name,
269 <                 "XR", conf->count,
270 <                 conf->name, conf->reason);
271 <    }
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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, RPL_STATSLLINE, me.name,
422 <                   source_p->name, 'L', dptr->data, conf->name, 0, "*");
423 <    }
210 >    struct exempt *exptr = ptr->data;
211  
212 <    break;
213 <
214 <  default:
215 <    break;
212 >    MyFree(exptr->name);
213 >    MyFree(exptr->user);
214 >    MyFree(exptr->host);
215 >    MyFree(exptr);
216    }
217 +
218 +  MyFree(conf);
219   }
220  
221   /* check_client()
# Line 456 | Line 245 | check_client(struct Client *source_p)
245      case TOO_MANY:
246        sendto_realops_flags(UMODE_FULL, L_ALL, SEND_NOTICE,
247                             "Too many on IP for %s (%s).",
248 <                           get_client_name(source_p, SHOW_IP),
249 <                           source_p->sockhost);
248 >                           get_client_name(source_p, SHOW_IP),
249 >                           source_p->sockhost);
250        ilog(LOG_TYPE_IRCD, "Too many connections on IP from %s.",
251 <           get_client_name(source_p, SHOW_IP));
251 >           get_client_name(source_p, SHOW_IP));
252        ++ServerStats.is_ref;
253        exit_client(source_p, &me, "No more connections allowed on that IP");
254        break;
# Line 467 | Line 256 | check_client(struct Client *source_p)
256      case I_LINE_FULL:
257        sendto_realops_flags(UMODE_FULL, L_ALL, SEND_NOTICE,
258                             "auth{} block is full for %s (%s).",
259 <                           get_client_name(source_p, SHOW_IP),
260 <                           source_p->sockhost);
259 >                           get_client_name(source_p, SHOW_IP),
260 >                           source_p->sockhost);
261        ilog(LOG_TYPE_IRCD, "Too many connections from %s.",
262 <           get_client_name(source_p, SHOW_IP));
262 >           get_client_name(source_p, SHOW_IP));
263        ++ServerStats.is_ref;
264        exit_client(source_p, &me,
265 <                "No more connections allowed in your connection class");
265 >                  "No more connections allowed in your connection class");
266        break;
267  
268      case NOT_AUTHORIZED:
# Line 481 | Line 270 | check_client(struct Client *source_p)
270        /* jdc - lists server name & port connections are on */
271        /*       a purely cosmetical change */
272        sendto_realops_flags(UMODE_UNAUTH, L_ALL, SEND_NOTICE,
273 <                           "Unauthorized client connection from %s [%s] on [%s/%u].",
274 <                           get_client_name(source_p, SHOW_IP),
275 <                           source_p->sockhost,
276 <                           source_p->localClient->listener->name,
277 <                           source_p->localClient->listener->port);
273 >                           "Unauthorized client connection from %s [%s] on [%s/%u].",
274 >                           get_client_name(source_p, SHOW_IP),
275 >                           source_p->sockhost,
276 >                           source_p->localClient->listener->name,
277 >                           source_p->localClient->listener->port);
278        ilog(LOG_TYPE_IRCD,
279 <          "Unauthorized client connection from %s on [%s/%u].",
280 <          get_client_name(source_p, SHOW_IP),
281 <          source_p->localClient->listener->name,
282 <          source_p->localClient->listener->port);
279 >           "Unauthorized client connection from %s on [%s/%u].",
280 >           get_client_name(source_p, SHOW_IP),
281 >           source_p->localClient->listener->name,
282 >           source_p->localClient->listener->port);
283  
284        exit_client(source_p, &me, "You are not authorized to use this server");
285        break;
# Line 517 | Line 306 | check_client(struct Client *source_p)
306   static int
307   verify_access(struct Client *client_p)
308   {
309 <  struct MaskItem *conf = NULL, *rkconf = NULL;
309 >  struct MaskItem *conf = NULL;
310    char non_ident[USERLEN + 1] = { '~', '\0' };
522  const char *uhi[3];
311  
312    if (IsGotId(client_p))
313    {
314      conf = find_address_conf(client_p->host, client_p->username,
315 <                             &client_p->localClient->ip,
316 <                             client_p->localClient->aftype,
315 >                             &client_p->localClient->ip,
316 >                             client_p->localClient->aftype,
317                               client_p->localClient->passwd);
318    }
319    else
320    {
321 <    strlcpy(non_ident+1, client_p->username, sizeof(non_ident)-1);
321 >    strlcpy(non_ident + 1, client_p->username, sizeof(non_ident) - 1);
322      conf = find_address_conf(client_p->host,non_ident,
323 <                             &client_p->localClient->ip,
324 <                             client_p->localClient->aftype,
325 <                             client_p->localClient->passwd);
323 >                             &client_p->localClient->ip,
324 >                             client_p->localClient->aftype,
325 >                             client_p->localClient->passwd);
326    }
327  
540  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
328    if (conf != NULL)
329    {
330 <    if (IsConfClient(conf) && !rkconf)
330 >    if (IsConfClient(conf))
331      {
332        if (IsConfRedir(conf))
333        {
334 <        sendto_one(client_p, RPL_REDIR,
334 >        sendto_one(client_p, form_str(RPL_REDIR),
335                     me.name, client_p->name,
336                     conf->name ? conf->name : "",
337                     conf->port);
338 <        return(NOT_AUTHORIZED);
338 >        return NOT_AUTHORIZED;
339        }
340  
341        if (IsConfDoIdentd(conf))
342 <        SetNeedId(client_p);
342 >        SetNeedId(client_p);
343  
344        /* Thanks for spoof idea amm */
345        if (IsConfDoSpoofIp(conf))
# Line 567 | Line 349 | verify_access(struct Client *client_p)
349                                 "%s spoofing: %s as %s",
350                                 client_p->name, client_p->host, conf->name);
351          strlcpy(client_p->host, conf->name, sizeof(client_p->host));
352 <        SetIPSpoof(client_p);
352 >        AddFlag(client_p, FLAGS_IP_SPOOFING | FLAGS_AUTH_SPOOF);
353        }
354  
355 <      return(attach_iline(client_p, conf));
355 >      return attach_iline(client_p, conf);
356      }
357 <    else if (rkconf || IsConfKill(conf) || (ConfigFileEntry.glines && IsConfGline(conf)))
357 >    else if (IsConfKill(conf) || (ConfigFileEntry.glines && IsConfGline(conf)))
358      {
577      /* XXX */
578      conf = rkconf ? rkconf : conf;
359        if (IsConfGline(conf))
360          sendto_one(client_p, ":%s NOTICE %s :*** G-lined", me.name,
361                     client_p->name);
362        sendto_one(client_p, ":%s NOTICE %s :*** Banned: %s",
363                   me.name, client_p->name, conf->reason);
364 <      return(BANNED_CLIENT);
364 >      return BANNED_CLIENT;
365      }
366    }
367  
368 <  return(NOT_AUTHORIZED);
368 >  return NOT_AUTHORIZED;
369   }
370  
371   /* attach_iline()
# Line 603 | Line 383 | attach_iline(struct Client *client_p, st
383    int a_limit_reached = 0;
384    unsigned int local = 0, global = 0, ident = 0;
385  
386 +  assert(conf->class);
387 +
388    ip_found = find_or_add_ip(&client_p->localClient->ip);
389    ip_found->count++;
390    SetIpHash(client_p);
391  
610  if (conf->class == NULL)
611    return NOT_AUTHORIZED;  /* If class is missing, this is best */
612
392    class = conf->class;
393  
394    count_user_host(client_p->username, client_p->host,
# Line 654 | Line 433 | attach_iline(struct Client *client_p, st
433   void
434   init_ip_hash_table(void)
435   {
436 <  ip_entry_pool = mp_pool_new(sizeof(struct ip_entry),
658 <    2 * hard_fdlimit);
436 >  ip_entry_pool = mp_pool_new(sizeof(struct ip_entry), MP_CHUNK_SIZE_IP_ENTRY);
437    memset(ip_hash_table, 0, sizeof(ip_hash_table));
438   }
439  
# Line 756 | Line 534 | remove_one_ip(struct irc_ssaddr *ip_in)
534      if (ptr->count > 0)
535        ptr->count--;
536      if (ptr->count == 0 &&
537 <        (CurrentTime-ptr->last_attempt) >= ConfigFileEntry.throttle_time)
537 >        (CurrentTime-ptr->last_attempt) >= ConfigFileEntry.throttle_time)
538      {
539        if (last_ptr != NULL)
540 <        last_ptr->next = ptr->next;
540 >        last_ptr->next = ptr->next;
541        else
542 <        ip_hash_table[hash_index] = ptr->next;
542 >        ip_hash_table[hash_index] = ptr->next;
543  
544        mp_pool_release(ptr);
545        ip_entries_count--;
# Line 1021 | Line 799 | map_to_list(enum maskitem_type type)
799   {
800    switch(type)
801    {
1024  case CONF_RKLINE:
1025    return(&rkconf_items);
1026    break;
1027  case CONF_RXLINE:
1028    return(&rxconf_items);
1029    break;
802    case CONF_XLINE:
803      return(&xconf_items);
804      break;
# Line 1037 | Line 809 | map_to_list(enum maskitem_type type)
809      return(&nresv_items);
810      break;
811    case CONF_CRESV:
812 <    return(&resv_channel_list);
812 >    return(&cresv_items);
813    case CONF_OPER:
814      return(&oconf_items);
815      break;
# Line 1075 | Line 847 | find_matching_name_conf(enum maskitem_ty
847  
848    switch (type)
849    {
1078 #ifdef HAVE_LIBPCRE
1079  case CONF_RXLINE:
1080      DLINK_FOREACH(ptr, list_p->head)
1081      {
1082        conf = ptr->data;
1083        assert(conf->regexuser);
1084
1085        if (!ircd_pcre_exec(conf->regexuser, name))
1086          return conf;
1087      }
1088      break;
1089 #endif
850    case CONF_SERVICE:
851      DLINK_FOREACH(ptr, list_p->head)
852      {
# Line 1108 | Line 868 | find_matching_name_conf(enum maskitem_ty
868        conf = ptr->data;
869  
870        if (EmptyString(conf->name))
871 <        continue;
871 >        continue;
872        if ((name != NULL) && !match(conf->name, name))
873        {
874 <        if ((user == NULL && (host == NULL)))
875 <          return conf;
876 <        if ((conf->flags & flags) != flags)
874 >        if ((user == NULL && (host == NULL)))
875 >          return conf;
876 >        if ((conf->flags & flags) != flags)
877            continue;
878 <        if (EmptyString(conf->user) || EmptyString(conf->host))
879 <          return conf;
880 <        if (!match(conf->user, user) && !match(conf->host, host))
881 <          return conf;
878 >        if (EmptyString(conf->user) || EmptyString(conf->host))
879 >          return conf;
880 >        if (!match(conf->user, user) && !match(conf->host, host))
881 >          return conf;
882        }
883      }
884        break;
# Line 1160 | Line 920 | find_exact_name_conf(enum maskitem_type
920  
921    switch(type)
922    {
1163  case CONF_RXLINE:
923    case CONF_XLINE:
924    case CONF_ULINE:
925    case CONF_NRESV:
# Line 1171 | Line 930 | find_exact_name_conf(enum maskitem_type
930        conf = ptr->data;
931  
932        if (EmptyString(conf->name))
933 <        continue;
933 >        continue;
934      
935        if (irccmp(conf->name, name) == 0)
936        {
937 <        if ((user == NULL && (host == NULL)))
938 <          return (conf);
939 <        if (EmptyString(conf->user) || EmptyString(conf->host))
940 <          return (conf);
941 <        if (!match(conf->user, user) && !match(conf->host, host))
942 <          return (conf);
937 >        if ((user == NULL && (host == NULL)))
938 >          return conf;
939 >        if (EmptyString(conf->user) || EmptyString(conf->host))
940 >          return conf;
941 >        if (!match(conf->user, user) && !match(conf->host, host))
942 >          return conf;
943        }
944      }
945      break;
# Line 1237 | Line 996 | find_exact_name_conf(enum maskitem_type
996        conf = ptr->data;
997  
998        if (EmptyString(conf->name))
999 <        continue;
999 >        continue;
1000      
1001        if (name == NULL)
1002        {
1003 <        if (EmptyString(conf->host))
1004 <          continue;
1005 <        if (irccmp(conf->host, host) == 0)
1006 <          return(conf);
1003 >        if (EmptyString(conf->host))
1004 >          continue;
1005 >        if (irccmp(conf->host, host) == 0)
1006 >          return conf;
1007        }
1008        else if (irccmp(conf->name, name) == 0)
1009 <      {
1251 <          return (conf);
1252 <      }
1009 >        return conf;
1010      }
1011 +
1012      break;
1013  
1014    default:
1015      break;
1016    }
1017 <  return(NULL);
1017 >
1018 >  return NULL;
1019   }
1020  
1021   /* rehash()
# Line 1340 | Line 1099 | set_default_conf(void)
1099    ConfigLoggingEntry.use_logging = 1;
1100  
1101    ConfigChannel.disable_fake_channels = 0;
1343  ConfigChannel.restrict_channels = 0;
1102    ConfigChannel.knock_delay = 300;
1103    ConfigChannel.knock_delay_channel = 60;
1104    ConfigChannel.max_chans_per_user = 25;
1105    ConfigChannel.max_chans_per_oper = 50;
1348  ConfigChannel.quiet_on_ban = 1;
1106    ConfigChannel.max_bans = 25;
1107    ConfigChannel.default_split_user_count = 0;
1108    ConfigChannel.default_split_server_count = 0;
# Line 1356 | Line 1113 | set_default_conf(void)
1113    ConfigServerHide.links_delay = 300;
1114    ConfigServerHide.hidden = 0;
1115    ConfigServerHide.hide_servers = 0;
1116 +  ConfigServerHide.hide_services = 0;
1117    ConfigServerHide.hidden_name = xstrdup(NETWORK_NAME_DEFAULT);
1118    ConfigServerHide.hide_server_ips = 0;
1119 +  ConfigServerHide.disable_remote_commands = 0;
1120  
1121    
1122    ConfigFileEntry.service_name = xstrdup(SERVICE_NAME_DEFAULT);
1123    ConfigFileEntry.max_watch = WATCHSIZE_DEFAULT;
1124 +  ConfigFileEntry.cycle_on_host_change = 1;
1125    ConfigFileEntry.glines = 0;
1126    ConfigFileEntry.gline_time = 12 * 3600;
1127    ConfigFileEntry.gline_request_time = GLINE_REQUEST_EXPIRE_DEFAULT;
# Line 1372 | Line 1132 | set_default_conf(void)
1132    ConfigFileEntry.hide_spoof_ips = 1;
1133    ConfigFileEntry.ignore_bogus_ts = 0;
1134    ConfigFileEntry.disable_auth = 0;
1375  ConfigFileEntry.disable_remote = 0;
1135    ConfigFileEntry.kill_chase_time_limit = 90;
1136    ConfigFileEntry.default_floodcount = 8;
1137    ConfigFileEntry.failed_oper_notice = 1;
# Line 1391 | Line 1150 | set_default_conf(void)
1150    ConfigFileEntry.stats_k_oper_only = 1;  /* masked */
1151    ConfigFileEntry.stats_i_oper_only = 1;  /* masked */
1152    ConfigFileEntry.stats_P_oper_only = 0;
1153 +  ConfigFileEntry.stats_u_oper_only = 0;
1154    ConfigFileEntry.caller_id_wait = 60;
1155    ConfigFileEntry.opers_bypass_callerid = 0;
1156    ConfigFileEntry.pace_wait = 10;
# Line 1443 | Line 1203 | read_conf(FILE *file)
1203  
1204    set_default_conf(); /* Set default values prior to conf parsing */
1205    conf_parser_ctx.pass = 1;
1206 <  yyparse();          /* pick up the classes first */
1206 >  yyparse();          /* pick up the classes first */
1207  
1208    rewind(file);
1209  
# Line 1523 | Line 1283 | conf_connect_allowed(struct irc_ssaddr *
1283    return 0;
1284   }
1285  
1526 static struct MaskItem *
1527 find_regexp_kline(const char *uhi[])
1528 {
1529 #ifdef HAVE_LIBPCRE
1530  const dlink_node *ptr = NULL;
1531
1532  DLINK_FOREACH(ptr, rkconf_items.head)
1533  {
1534    struct MaskItem *aptr = ptr->data;
1535
1536    assert(aptr->regexuser);
1537    assert(aptr->regexhost);
1538
1539    if (!ircd_pcre_exec(aptr->regexuser, uhi[0]) &&
1540        (!ircd_pcre_exec(aptr->regexhost, uhi[1]) ||
1541         !ircd_pcre_exec(aptr->regexhost, uhi[2])))
1542      return aptr;
1543  }
1544 #endif
1545  return NULL;
1546 }
1547
1548 /* find_kill()
1549 *
1550 * inputs       - pointer to client structure
1551 * output       - pointer to struct MaskItem if found
1552 * side effects - See if this user is klined already,
1553 *                and if so, return struct MaskItem pointer
1554 */
1555 struct MaskItem *
1556 find_kill(struct Client *client_p)
1557 {
1558  struct MaskItem *conf = NULL;
1559  const char *uhi[3];
1560
1561  uhi[0] = client_p->username;
1562  uhi[1] = client_p->host;
1563  uhi[2] = client_p->sockhost;
1564
1565  assert(client_p != NULL);
1566
1567  conf = find_conf_by_address(client_p->host, &client_p->localClient->ip,
1568                              CONF_KLINE, client_p->localClient->aftype,
1569                              client_p->username, NULL, 1);
1570  if (conf == NULL)
1571    conf = find_regexp_kline(uhi);
1572
1573  return conf;
1574 }
1575
1576 struct MaskItem *
1577 find_gline(struct Client *client_p)
1578 {
1579  struct MaskItem *conf;
1580
1581  assert(client_p != NULL);
1582
1583  conf = find_conf_by_address(client_p->host, &client_p->localClient->ip,
1584                              CONF_GLINE, client_p->localClient->aftype,
1585                              client_p->username, NULL, 1);
1586  return conf;
1587 }
1588
1286   /* cleanup_tklines()
1287   *
1288   * inputs       - NONE
# Line 1599 | Line 1296 | cleanup_tklines(void *notused)
1296    hostmask_expire_temporary();
1297    expire_tklines(&xconf_items);
1298    expire_tklines(&nresv_items);
1299 <  expire_tklines(&resv_channel_list);
1299 >  expire_tklines(&cresv_items);
1300   }
1301  
1302   /* expire_tklines()
# Line 1650 | Line 1347 | static const struct oper_privs
1347    const unsigned int flag;
1348    const unsigned char c;
1349   } flag_list[] = {
1350 <  { OPER_FLAG_ADMIN,       'A' },
1351 <  { OPER_FLAG_REMOTEBAN,   'B' },
1352 <  { OPER_FLAG_DIE,         'D' },
1353 <  { OPER_FLAG_GLINE,       'G' },
1354 <  { OPER_FLAG_REHASH,      'H' },
1355 <  { OPER_FLAG_K,           'K' },
1356 <  { OPER_FLAG_OPERWALL,    'L' },
1357 <  { OPER_FLAG_N,           'N' },
1358 <  { OPER_FLAG_GLOBAL_KILL, 'O' },
1359 <  { OPER_FLAG_REMOTE,      'R' },
1360 <  { OPER_FLAG_OPER_SPY,    'S' },
1361 <  { OPER_FLAG_UNKLINE,     'U' },
1362 <  { OPER_FLAG_X,           'X' },
1350 >  { OPER_FLAG_ADMIN,          'A' },
1351 >  { OPER_FLAG_REMOTEBAN,      'B' },
1352 >  { OPER_FLAG_DIE,            'D' },
1353 >  { OPER_FLAG_GLINE,          'G' },
1354 >  { OPER_FLAG_REHASH,         'H' },
1355 >  { OPER_FLAG_K,              'K' },
1356 >  { OPER_FLAG_OPERWALL,       'L' },
1357 >  { OPER_FLAG_KILL,           'N' },
1358 >  { OPER_FLAG_KILL_REMOTE,    'O' },
1359 >  { OPER_FLAG_CONNECT,        'P' },
1360 >  { OPER_FLAG_CONNECT_REMOTE, 'Q' },
1361 >  { OPER_FLAG_SQUIT,          'R' },
1362 >  { OPER_FLAG_SQUIT_REMOTE,   'S' },
1363 >  { OPER_FLAG_UNKLINE,        'U' },
1364 >  { OPER_FLAG_X,              'X' },
1365    { 0, '\0' }
1366   };
1367  
# Line 1707 | Line 1406 | get_oper_name(const struct Client *clien
1406  
1407        if (IsConfOperator(conf))
1408        {
1409 <        snprintf(buffer, sizeof(buffer), "%s!%s@%s{%s}", client_p->name,
1409 >        snprintf(buffer, sizeof(buffer), "%s!%s@%s{%s}", client_p->name,
1410                   client_p->username, client_p->host, conf->name);
1411 <        return buffer;
1411 >        return buffer;
1412        }
1413      }
1414  
# Line 1720 | Line 1419 | get_oper_name(const struct Client *clien
1419    }
1420  
1421    snprintf(buffer, sizeof(buffer), "%s!%s@%s{%s}", client_p->name,
1422 <           client_p->username, client_p->host, client_p->servptr->name);
1422 >           client_p->username, client_p->host, client_p->servptr->name);
1423    return buffer;
1424   }
1425  
# Line 1759 | Line 1458 | read_conf_files(int cold)
1458      else
1459      {
1460        sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1461 <                           "Unable to read configuration file '%s': %s",
1462 <                           filename, strerror(errno));
1461 >                           "Unable to read configuration file '%s': %s",
1462 >                           filename, strerror(errno));
1463        return;
1464      }
1465    }
# Line 1787 | Line 1486 | read_conf_files(int cold)
1486    snprintf(chanmodes, sizeof(chanmodes), "%s", "beI,k,l,imnprstORS");
1487    add_isupport("CHANNELLEN", NULL, LOCAL_CHANNELLEN);
1488    add_isupport("TOPICLEN", NULL, ServerInfo.max_topic_length);
1790  add_isupport("EXCEPTS", "e", -1);
1791  add_isupport("INVEX", "I", -1);
1489    add_isupport("CHANMODES", chanmodes, -1);
1490  
1491    /*
# Line 1811 | Line 1508 | clear_out_old_conf(void)
1508    struct MaskItem *conf;
1509    dlink_list *free_items [] = {
1510      &server_items,   &oconf_items,
1511 <     &uconf_items,   &xconf_items, &rxconf_items, &rkconf_items,
1512 <     &nresv_items, &cluster_items,  &service_items, &resv_channel_list, NULL
1511 >     &uconf_items,   &xconf_items,
1512 >     &nresv_items, &cluster_items,  &service_items, &cresv_items, NULL
1513    };
1514  
1515    dlink_list ** iterator = free_items; /* C is dumb */
# Line 1833 | Line 1530 | clear_out_old_conf(void)
1530        if (conf->type == CONF_SERVER || conf->type == CONF_OPER)
1531        {
1532          if (!conf->ref_count)
1533 <          conf_free(conf);
1533 >          conf_free(conf);
1534        }
1535 <      else if (conf->type == CONF_XLINE  ||
1839 <               conf->type == CONF_RXLINE ||
1840 <               conf->type == CONF_RKLINE)
1535 >      else if (conf->type == CONF_XLINE)
1536        {
1537          if (!conf->until)
1538            conf_free(conf);
# Line 1847 | Line 1542 | clear_out_old_conf(void)
1542      }
1543    }
1544  
1545 +  motd_clear();
1546 +
1547    /*
1548     * don't delete the class table, rather mark all entries
1549     * for deletion. The table is cleaned up by class_delete_marked. - avalon
# Line 1901 | Line 1598 | clear_out_old_conf(void)
1598    /* clean out general */
1599    MyFree(ConfigFileEntry.service_name);
1600    ConfigFileEntry.service_name = NULL;
1904
1905  delete_isupport("INVEX");
1906  delete_isupport("EXCEPTS");
1601   }
1602  
1603   /* conf_add_class_to_conf()
# Line 1921 | Line 1615 | conf_add_class_to_conf(struct MaskItem *
1615  
1616      if (conf->type == CONF_CLIENT)
1617        sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1618 <                           "Warning *** Defaulting to default class for %s@%s",
1619 <                           conf->user, conf->host);
1618 >                           "Warning *** Defaulting to default class for %s@%s",
1619 >                           conf->user, conf->host);
1620      else
1621        sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1622 <                           "Warning *** Defaulting to default class for %s",
1623 <                           conf->name);
1622 >                           "Warning *** Defaulting to default class for %s",
1623 >                           conf->name);
1624    }
1625    else
1626      conf->class = class_find(class_name, 1);
# Line 1935 | Line 1629 | conf_add_class_to_conf(struct MaskItem *
1629    {
1630      if (conf->type == CONF_CLIENT)
1631        sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1632 <                           "Warning *** Defaulting to default class for %s@%s",
1633 <                           conf->user, conf->host);
1632 >                           "Warning *** Defaulting to default class for %s@%s",
1633 >                           conf->user, conf->host);
1634      else
1635        sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1636 <                           "Warning *** Defaulting to default class for %s",
1637 <                           conf->name);
1636 >                           "Warning *** Defaulting to default class for %s",
1637 >                           conf->name);
1638      conf->class = class_default;
1639    }
1640   }
# Line 1991 | Line 1685 | conf_error_report(const char *msg)
1685   * Originally written by Dianora (Diane, db@db.net)
1686   */
1687   time_t
1688 < valid_tkline(const char *p, int minutes)
1688 > valid_tkline(const char *data, const int minutes)
1689   {
1690 +  const unsigned char *p = (const unsigned char *)data;
1691 +  unsigned char tmpch = '\0';
1692    time_t result = 0;
1693  
1694 <  for (; *p; ++p)
1694 >  while ((tmpch = *p++))
1695    {
1696 <    if (!IsDigit(*p))
1696 >    if (!IsDigit(tmpch))
1697        return 0;
1698  
1699      result *= 10;
1700 <    result += ((*p) & 0xF);
1700 >    result += (tmpch & 0xF);
1701    }
1702  
1703    /*
# Line 2017 | Line 1713 | valid_tkline(const char *p, int minutes)
1713     * of this calculation
1714     */
1715    if (!minutes)
1716 <    result = result / (time_t)60;
1716 >    result = result / 60;
1717  
1718    if (result > MAX_TDKLINE_TIME)
1719      result = MAX_TDKLINE_TIME;
1720  
1721 <  result = result * (time_t)60;  /* turn it into seconds */
1721 >  result = result * 60;  /* turn it into seconds */
1722  
1723    return result;
1724   }
1725  
1726 + /* valid_wild_card_simple()
1727 + *
1728 + * inputs       - data to check for sufficient non-wildcard characters
1729 + * outputs      - 1 if valid, else 0
1730 + * side effects - none
1731 + */
1732 + int
1733 + valid_wild_card_simple(const char *data)
1734 + {
1735 +  const unsigned char *p = (const unsigned char *)data;
1736 +  unsigned char tmpch = '\0';
1737 +  int nonwild = 0;
1738 +
1739 +  while ((tmpch = *p++))
1740 +  {
1741 +    if (tmpch == '\\')
1742 +    {
1743 +      ++p;
1744 +      if (++nonwild >= ConfigFileEntry.min_nonwildcard_simple)
1745 +        return 1;
1746 +    }
1747 +    else if (!IsMWildChar(tmpch))
1748 +    {
1749 +      if (++nonwild >= ConfigFileEntry.min_nonwildcard_simple)
1750 +        return 1;
1751 +    }
1752 +  }
1753 +
1754 +  return 0;
1755 + }
1756 +
1757   /* valid_wild_card()
1758   *
1759   * input        - pointer to client
# Line 2038 | Line 1765 | valid_tkline(const char *p, int minutes)
1765   int
1766   valid_wild_card(struct Client *source_p, int warn, int count, ...)
1767   {
2041  char *p;
1768    char tmpch;
1769    int nonwild = 0;
1770    va_list args;
# Line 2059 | Line 1785 | valid_wild_card(struct Client *source_p,
1785  
1786    while (count--)
1787    {
1788 <    p = va_arg(args, char *);
1788 >    const char *p = va_arg(args, const char *);
1789      if (p == NULL)
1790        continue;
1791  
# Line 2115 | Line 1841 | valid_wild_card(struct Client *source_p,
1841   */
1842   int
1843   parse_aline(const char *cmd, struct Client *source_p,
1844 <            int parc, char **parv,
1845 <            int parse_flags, char **up_p, char **h_p, time_t *tkline_time,
1846 <            char **target_server, char **reason)
1844 >            int parc, char **parv,
1845 >            int parse_flags, char **up_p, char **h_p, time_t *tkline_time,
1846 >            char **target_server, char **reason)
1847   {
1848    int found_tkline_time=0;
1849    static char def_reason[] = "No Reason";
# Line 2139 | Line 1865 | parse_aline(const char *cmd, struct Clie
1865      else
1866      {
1867        sendto_one(source_p, ":%s NOTICE %s :temp_line not supported by %s",
1868 <                 me.name, source_p->name, cmd);
1868 >                 me.name, source_p->name, cmd);
1869        return -1;
1870      }
1871    }
1872  
1873    if (parc == 0)
1874    {
1875 <    sendto_one(source_p, ERR_NEEDMOREPARAMS,
1875 >    sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
1876                 me.name, source_p->name, cmd);
1877      return -1;
1878    }
# Line 2174 | Line 1900 | parse_aline(const char *cmd, struct Clie
1900  
1901        if (target_server == NULL)
1902        {
1903 <        sendto_one(source_p, ":%s NOTICE %s :ON server not supported by %s",
1904 <                   me.name, source_p->name, cmd);
1905 <        return -1;
1903 >        sendto_one(source_p, ":%s NOTICE %s :ON server not supported by %s",
1904 >                   me.name, source_p->name, cmd);
1905 >        return -1;
1906        }
1907  
1908        if (!HasOFlag(source_p, OPER_FLAG_REMOTEBAN))
1909        {
1910 <        sendto_one(source_p, ERR_NOPRIVS,
1910 >        sendto_one(source_p, form_str(ERR_NOPRIVS),
1911                     me.name, source_p->name, "remoteban");
1912          return -1;
1913        }
1914  
1915        if (parc == 0 || EmptyString(*parv))
1916        {
1917 <        sendto_one(source_p, ERR_NEEDMOREPARAMS,
1918 <                   me.name, source_p->name, cmd);
1919 <        return -1;
1917 >        sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
1918 >                   me.name, source_p->name, cmd);
1919 >        return -1;
1920        }
1921  
1922        *target_server = *parv;
# Line 2203 | Line 1929 | parse_aline(const char *cmd, struct Clie
1929         * caller probably NULL'd it first, but no harm to do it again -db
1930         */
1931        if (target_server != NULL)
1932 <        *target_server = NULL;
1932 >        *target_server = NULL;
1933      }
1934    }
1935  
# Line 2229 | 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 2268 | 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      
# Line 2290 | Line 2017 | find_user_host(struct Client *source_p,
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)
2020 >        find_chasing(source_p, user_host_or_nick, NULL)) == NULL)
2021        return 0;
2022  
2023      if (IsExemptKline(target_p))
2024      {
2025        if (!IsServer(source_p))
2026 <        sendto_one(source_p,
2027 <                   ":%s NOTICE %s :%s is E-lined",
2028 <                   me.name, source_p->name, target_p->name);
2026 >        sendto_one(source_p,
2027 >                   ":%s NOTICE %s :%s is E-lined",
2028 >                   me.name, source_p->name, target_p->name);
2029        return 0;
2030      }
2031  
# Line 2392 | Line 2119 | cluster_a_line(struct Client *source_p,
2119  
2120      if (conf->flags & cluster_type)
2121        sendto_match_servs(source_p, conf->name, CAP_CLUSTER|capab,
2122 <                         "%s %s %s", command, conf->name, buffer);
2122 >                         "%s %s %s", command, conf->name, buffer);
2123    }
2124   }
2125  
# Line 2443 | Line 2170 | split_nuh(struct split_nuh_item *const i
2170      if (iptr->nickptr && *iptr->nuhmask != '\0')
2171        strlcpy(iptr->nickptr, iptr->nuhmask, iptr->nicksize);
2172  
2173 <    if ((q = strchr(++p, '@'))) {
2173 >    if ((q = strchr(++p, '@')))
2174 >    {
2175        *q++ = '\0';
2176  
2177        if (*p != '\0')

Diff Legend

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