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 3192 by michael, Sun Mar 23 19:46:39 2014 UTC vs.
Revision 5805 by michael, Tue Apr 21 21:49:58 2015 UTC

# Line 1 | Line 1
1   /*
2   *  ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3   *
4 < *  Copyright (c) 1997-2014 ircd-hybrid development team
4 > *  Copyright (c) 1997-2015 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 15 | Line 15
15   *
16   *  You should have received a copy of the GNU General Public License
17   *  along with this program; if not, write to the Free Software
18 < *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
18 > *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19   *  USA
20   */
21  
# Line 28 | Line 28
28   #include "list.h"
29   #include "ircd_defs.h"
30   #include "conf.h"
31 < #include "s_serv.h"
31 > #include "conf_pseudo.h"
32 > #include "server.h"
33   #include "resv.h"
34   #include "channel.h"
35   #include "client.h"
36   #include "event.h"
36 #include "hook.h"
37   #include "irc_string.h"
38   #include "s_bsd.h"
39   #include "ircd.h"
# Line 44 | Line 44
44   #include "fdlist.h"
45   #include "log.h"
46   #include "send.h"
47 #include "s_gline.h"
47   #include "memory.h"
48 < #include "mempool.h"
50 < #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 + #include "ipcache.h"
58  
59  
60   struct config_channel_entry ConfigChannel;
61 < struct config_server_hide ConfigServerHide;
62 < struct config_file_entry ConfigFileEntry;
63 < struct logging_entry ConfigLoggingEntry = { .use_logging = 1 };
64 < struct server_info ServerInfo;
65 < struct admin_info AdminInfo;
61 > struct config_serverhide_entry ConfigServerHide;
62 > struct config_general_entry ConfigGeneral;
63 > struct config_log_entry ConfigLog = { .use_logging = 1 };
64 > struct config_serverinfo_entry ConfigServerInfo;
65 > struct config_admin_entry ConfigAdminInfo;
66 > struct conf_parser_context conf_parser_ctx;
67  
68   /* general conf items link list root, other than k lines etc. */
69 < dlink_list service_items = { NULL, NULL, 0 };
70 < dlink_list server_items  = { NULL, NULL, 0 };
71 < dlink_list cluster_items = { NULL, NULL, 0 };
72 < dlink_list oconf_items   = { NULL, NULL, 0 };
73 < dlink_list uconf_items   = { NULL, NULL, 0 };
74 < dlink_list xconf_items   = { NULL, NULL, 0 };
75 < dlink_list nresv_items   = { NULL, NULL, 0 };
76 < dlink_list cresv_items = { NULL, NULL, 0 };
69 > dlink_list service_items;
70 > dlink_list server_items;
71 > dlink_list cluster_items;
72 > dlink_list oconf_items;
73 > dlink_list uconf_items;
74 > dlink_list xconf_items;
75 > dlink_list nresv_items;
76 > dlink_list cresv_items;
77  
78   extern unsigned int lineno;
79   extern char linebuf[];
80   extern char conffilebuf[IRCD_BUFSIZE];
81   extern int yyparse(); /* defined in y.tab.c */
82  
83 struct conf_parser_context conf_parser_ctx = { 0, 0, NULL };
84
85 /* internally defined functions */
86 static void read_conf(FILE *);
87 static void clear_out_old_conf(void);
88 static void expire_tklines(dlink_list *);
89 static void garbage_collect_ip_entries(void);
90 static int hash_ip(struct irc_ssaddr *);
91 static int verify_access(struct Client *);
92 static int attach_iline(struct Client *, struct MaskItem *);
93 static struct ip_entry *find_or_add_ip(struct irc_ssaddr *);
94 static dlink_list *map_to_list(enum maskitem_type);
95 static int find_user_host(struct Client *, char *, char *, char *, unsigned int);
96
97
98 /* usually, with hash tables, you use a prime number...
99 * but in this case I am dealing with ip addresses,
100 * not ascii strings.
101 */
102 #define IP_HASH_SIZE 0x1000
103
104 struct ip_entry
105 {
106  struct irc_ssaddr ip;
107  unsigned int count;
108  time_t last_attempt;
109  struct ip_entry *next;
110 };
111
112 static struct ip_entry *ip_hash_table[IP_HASH_SIZE];
113 static mp_pool_t *ip_entry_pool = NULL;
114 static int ip_entries_count = 0;
115
83  
84   /* conf_dns_callback()
85   *
# Line 125 | Line 92 | static int ip_entries_count = 0;
92   * if successful save hp in the conf item it was called with
93   */
94   static void
95 < conf_dns_callback(void *vptr, const struct irc_ssaddr *addr, const char *name)
95 > conf_dns_callback(void *vptr, const struct irc_ssaddr *addr, const char *name, size_t namelength)
96   {
97 <  struct MaskItem *conf = vptr;
97 >  struct MaskItem *const conf = vptr;
98  
99    conf->dns_pending = 0;
100  
101 <  if (addr != NULL)
101 >  if (addr)
102      memcpy(&conf->addr, addr, sizeof(conf->addr));
103    else
104      conf->dns_failed = 1;
# Line 146 | Line 113 | conf_dns_callback(void *vptr, const stru
113   static void
114   conf_dns_lookup(struct MaskItem *conf)
115   {
116 <  if (!conf->dns_pending)
116 >  if (conf->dns_pending)
117 >    return;
118 >
119 >  conf->dns_pending = 1;
120 >
121 >  if (conf->aftype == AF_INET)
122 >    gethost_byname_type(conf_dns_callback, conf, conf->host, T_A);
123 >  else
124 >    gethost_byname_type(conf_dns_callback, conf, conf->host, T_AAAA);
125 > }
126 >
127 > /* map_to_list()
128 > *
129 > * inputs       - ConfType conf
130 > * output       - pointer to dlink_list to use
131 > * side effects - none
132 > */
133 > static dlink_list *
134 > map_to_list(enum maskitem_type type)
135 > {
136 >  switch (type)
137    {
138 <    conf->dns_pending = 1;
139 <    gethost_byname(conf_dns_callback, conf, conf->host);
138 >    case CONF_XLINE:
139 >      return &xconf_items;
140 >      break;
141 >    case CONF_ULINE:
142 >      return &uconf_items;
143 >      break;
144 >    case CONF_NRESV:
145 >      return &nresv_items;
146 >      break;
147 >    case CONF_CRESV:
148 >      return &cresv_items;
149 >      break;
150 >    case CONF_OPER:
151 >      return &oconf_items;
152 >      break;
153 >    case CONF_SERVER:
154 >      return &server_items;
155 >      break;
156 >    case CONF_SERVICE:
157 >      return &service_items;
158 >      break;
159 >    case CONF_CLUSTER:
160 >      return &cluster_items;
161 >      break;
162 >    default:
163 >      return NULL;
164    }
165   }
166  
167   struct MaskItem *
168   conf_make(enum maskitem_type type)
169   {
170 <  struct MaskItem *conf = MyMalloc(sizeof(*conf));
170 >  struct MaskItem *const conf = MyCalloc(sizeof(*conf));
171    dlink_list *list = NULL;
172  
173    conf->type   = type;
# Line 171 | Line 182 | conf_make(enum maskitem_type type)
182   void
183   conf_free(struct MaskItem *conf)
184   {
185 <  dlink_node *ptr = NULL, *ptr_next = NULL;
185 >  dlink_node *node = NULL, *node_next = NULL;
186    dlink_list *list = NULL;
187  
188 <  if (conf->node.next)
189 <    if ((list = map_to_list(conf->type)))
179 <      dlinkDelete(&conf->node, list);
188 >  if ((list = map_to_list(conf->type)))
189 >    dlinkFindDelete(list, conf);
190  
191    MyFree(conf->name);
192  
193    if (conf->dns_pending)
194      delete_resolver_queries(conf);
195 <  if (conf->passwd != NULL)
195 >  if (conf->passwd)
196      memset(conf->passwd, 0, strlen(conf->passwd));
197 <  if (conf->spasswd != NULL)
197 >  if (conf->spasswd)
198      memset(conf->spasswd, 0, strlen(conf->spasswd));
199  
200    conf->class = NULL;
# Line 193 | Line 203 | conf_free(struct MaskItem *conf)
203    MyFree(conf->spasswd);
204    MyFree(conf->reason);
205    MyFree(conf->certfp);
206 +  MyFree(conf->whois);
207    MyFree(conf->user);
208    MyFree(conf->host);
209   #ifdef HAVE_LIBCRYPTO
# Line 201 | Line 212 | conf_free(struct MaskItem *conf)
212    if (conf->rsa_public_key)
213      RSA_free(conf->rsa_public_key);
214   #endif
215 <  DLINK_FOREACH_SAFE(ptr, ptr_next, conf->hub_list.head)
215 >  DLINK_FOREACH_SAFE(node, node_next, conf->hub_list.head)
216    {
217 <    MyFree(ptr->data);
218 <    dlinkDelete(ptr, &conf->hub_list);
219 <    free_dlink_node(ptr);
217 >    MyFree(node->data);
218 >    dlinkDelete(node, &conf->hub_list);
219 >    free_dlink_node(node);
220    }
221  
222 <  DLINK_FOREACH_SAFE(ptr, ptr_next, conf->leaf_list.head)
222 >  DLINK_FOREACH_SAFE(node, node_next, conf->leaf_list.head)
223    {
224 <    MyFree(ptr->data);
225 <    dlinkDelete(ptr, &conf->leaf_list);
226 <    free_dlink_node(ptr);
224 >    MyFree(node->data);
225 >    dlinkDelete(node, &conf->leaf_list);
226 >    free_dlink_node(node);
227    }
228  
229 <  DLINK_FOREACH_SAFE(ptr, ptr_next, conf->exempt_list.head)
229 >  DLINK_FOREACH_SAFE(node, node_next, conf->exempt_list.head)
230    {
231 <    struct exempt *exptr = ptr->data;
231 >    struct exempt *exptr = node->data;
232  
233 <    dlinkDelete(ptr, &conf->exempt_list);
233 >    dlinkDelete(node, &conf->exempt_list);
234      MyFree(exptr->name);
235      MyFree(exptr->user);
236      MyFree(exptr->host);
# Line 229 | Line 240 | conf_free(struct MaskItem *conf)
240    MyFree(conf);
241   }
242  
232 /* check_client()
233 *
234 * inputs       - pointer to client
235 * output       - 0 = Success
236 *                NOT_AUTHORIZED    (-1) = Access denied (no I line match)
237 *                IRCD_SOCKET_ERROR (-2) = Bad socket.
238 *                I_LINE_FULL       (-3) = I-line is full
239 *                TOO_MANY          (-4) = Too many connections from hostname
240 *                BANNED_CLIENT     (-5) = K-lined
241 * side effects - Ordinary client access check.
242 *                Look for conf lines which have the same
243 *                status as the flags passed.
244 */
245 int
246 check_client(struct Client *source_p)
247 {
248  int i;
249
250  if ((i = verify_access(source_p)))
251    ilog(LOG_TYPE_IRCD, "Access denied: %s[%s]",
252         source_p->name, source_p->sockhost);
253
254  switch (i)
255  {
256    case TOO_MANY:
257      sendto_realops_flags(UMODE_FULL, L_ALL, SEND_NOTICE,
258                           "Too many on IP for %s (%s).",
259                           get_client_name(source_p, SHOW_IP),
260                           source_p->sockhost);
261      ilog(LOG_TYPE_IRCD, "Too many connections on IP from %s.",
262           get_client_name(source_p, SHOW_IP));
263      ++ServerStats.is_ref;
264      exit_client(source_p, "No more connections allowed on that IP");
265      break;
266
267    case I_LINE_FULL:
268      sendto_realops_flags(UMODE_FULL, L_ALL, SEND_NOTICE,
269                           "auth{} block is full for %s (%s).",
270                           get_client_name(source_p, SHOW_IP),
271                           source_p->sockhost);
272      ilog(LOG_TYPE_IRCD, "Too many connections from %s.",
273           get_client_name(source_p, SHOW_IP));
274      ++ServerStats.is_ref;
275      exit_client(source_p, "No more connections allowed in your connection class");
276      break;
277
278    case NOT_AUTHORIZED:
279      ++ServerStats.is_ref;
280      /* jdc - lists server name & port connections are on */
281      /*       a purely cosmetical change */
282      sendto_realops_flags(UMODE_UNAUTH, L_ALL, SEND_NOTICE,
283                           "Unauthorized client connection from %s [%s] on [%s/%u].",
284                           get_client_name(source_p, SHOW_IP),
285                           source_p->sockhost,
286                           source_p->localClient->listener->name,
287                           source_p->localClient->listener->port);
288      ilog(LOG_TYPE_IRCD,
289           "Unauthorized client connection from %s on [%s/%u].",
290           get_client_name(source_p, SHOW_IP),
291           source_p->localClient->listener->name,
292           source_p->localClient->listener->port);
293
294      exit_client(source_p, "You are not authorized to use this server");
295      break;
296
297   case BANNED_CLIENT:
298     exit_client(source_p, "Banned");
299     ++ServerStats.is_ref;
300     break;
301
302   case 0:
303   default:
304     break;
305  }
306
307  return (i < 0 ? 0 : 1);
308 }
309
310 /* verify_access()
311 *
312 * inputs       - pointer to client to verify
313 * output       - 0 if success -'ve if not
314 * side effect  - find the first (best) I line to attach.
315 */
316 static int
317 verify_access(struct Client *client_p)
318 {
319  struct MaskItem *conf = NULL;
320  char non_ident[USERLEN + 1] = { '~', '\0' };
321
322  if (IsGotId(client_p))
323  {
324    conf = find_address_conf(client_p->host, client_p->username,
325                             &client_p->localClient->ip,
326                             client_p->localClient->aftype,
327                             client_p->localClient->passwd);
328  }
329  else
330  {
331    strlcpy(non_ident + 1, client_p->username, sizeof(non_ident) - 1);
332    conf = find_address_conf(client_p->host,non_ident,
333                             &client_p->localClient->ip,
334                             client_p->localClient->aftype,
335                             client_p->localClient->passwd);
336  }
337
338  if (conf != NULL)
339  {
340    if (IsConfClient(conf))
341    {
342      if (IsConfRedir(conf))
343      {
344        sendto_one_numeric(client_p, &me, RPL_REDIR,
345                           conf->name ? conf->name : "",
346                           conf->port);
347        return NOT_AUTHORIZED;
348      }
349
350      if (IsConfDoIdentd(conf))
351        SetNeedId(client_p);
352
353      /* Thanks for spoof idea amm */
354      if (IsConfDoSpoofIp(conf))
355      {
356        if (!ConfigFileEntry.hide_spoof_ips && IsConfSpoofNotice(conf))
357          sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE,
358                               "%s spoofing: %s as %s",
359                               client_p->name, client_p->host, conf->name);
360        strlcpy(client_p->host, conf->name, sizeof(client_p->host));
361        AddFlag(client_p, FLAGS_IP_SPOOFING | FLAGS_AUTH_SPOOF);
362      }
363
364      return attach_iline(client_p, conf);
365    }
366    else if (IsConfKill(conf) || (ConfigFileEntry.glines && IsConfGline(conf)))
367    {
368      if (IsConfGline(conf))
369        sendto_one_notice(client_p, &me, ":*** G-lined");
370      sendto_one_notice(client_p, &me, ":*** Banned: %s", conf->reason);
371      return BANNED_CLIENT;
372    }
373  }
374
375  return NOT_AUTHORIZED;
376 }
377
243   /* attach_iline()
244   *
245 < * inputs       - client pointer
246 < *              - conf pointer
247 < * output       -
248 < * side effects - do actual attach
245 > * inputs       - client pointer
246 > *              - conf pointer
247 > * output       -
248 > * side effects - do actual attach
249   */
250   static int
251   attach_iline(struct Client *client_p, struct MaskItem *conf)
252   {
253 <  struct ClassItem *class = NULL;
253 >  const struct ClassItem *const class = conf->class;
254    struct ip_entry *ip_found;
255    int a_limit_reached = 0;
256    unsigned int local = 0, global = 0, ident = 0;
257  
258 <  assert(conf->class);
394 <
395 <  ip_found = find_or_add_ip(&client_p->localClient->ip);
258 >  ip_found = ipcache_find_or_add_address(&client_p->connection->ip);
259    ip_found->count++;
260 <  SetIpHash(client_p);
398 <
399 <  class = conf->class;
260 >  AddFlag(client_p, FLAGS_IPHASH);
261  
262    count_user_host(client_p->username, client_p->host,
263                    &global, &local, &ident);
# Line 405 | Line 266 | attach_iline(struct Client *client_p, st
266     * setting a_limit_reached if any limit is reached.
267     * - Dianora
268     */
269 <  if (class->max_total != 0 && class->ref_count >= class->max_total)
269 >  if (class->max_total && class->ref_count >= class->max_total)
270      a_limit_reached = 1;
271 <  else if (class->max_perip != 0 && ip_found->count > class->max_perip)
271 >  else if (class->max_perip && ip_found->count > class->max_perip)
272      a_limit_reached = 1;
273 <  else if (class->max_local != 0 && local >= class->max_local)
273 >  else if (class->max_local && local >= class->max_local)
274      a_limit_reached = 1;
275 <  else if (class->max_global != 0 && global >= class->max_global)
275 >  else if (class->max_global && global >= class->max_global)
276      a_limit_reached = 1;
277 <  else if (class->max_ident != 0 && ident >= class->max_ident &&
277 >  else if (class->max_ident && ident >= class->max_ident &&
278             client_p->username[0] != '~')
279      a_limit_reached = 1;
280  
# Line 429 | Line 290 | attach_iline(struct Client *client_p, st
290    return attach_conf(client_p, conf);
291   }
292  
293 < /* init_ip_hash_table()
433 < *
434 < * inputs               - NONE
435 < * output               - NONE
436 < * side effects         - allocate memory for ip_entry(s)
437 < *                      - clear the ip hash table
438 < */
439 < void
440 < init_ip_hash_table(void)
441 < {
442 <  ip_entry_pool = mp_pool_new(sizeof(struct ip_entry), MP_CHUNK_SIZE_IP_ENTRY);
443 <  memset(ip_hash_table, 0, sizeof(ip_hash_table));
444 < }
445 <
446 < /* find_or_add_ip()
447 < *
448 < * inputs       - pointer to struct irc_ssaddr
449 < * output       - pointer to a struct ip_entry
450 < * side effects -
293 > /* verify_access()
294   *
295 < * If the ip # was not found, a new struct ip_entry is created, and the ip
296 < * count set to 0.
295 > * inputs       - pointer to client to verify
296 > * output       - 0 if success -'ve if not
297 > * side effect  - find the first (best) I line to attach.
298   */
299 < static struct ip_entry *
300 < find_or_add_ip(struct irc_ssaddr *ip_in)
299 > static int
300 > verify_access(struct Client *client_p)
301   {
302 <  struct ip_entry *ptr, *newptr;
459 <  int hash_index = hash_ip(ip_in), res;
460 <  struct sockaddr_in *v4 = (struct sockaddr_in *)ip_in, *ptr_v4;
461 < #ifdef IPV6
462 <  struct sockaddr_in6 *v6 = (struct sockaddr_in6 *)ip_in, *ptr_v6;
463 < #endif
302 >  struct MaskItem *conf = NULL;
303  
304 <  for (ptr = ip_hash_table[hash_index]; ptr; ptr = ptr->next)
304 >  if (IsGotId(client_p))
305    {
306 < #ifdef IPV6
307 <    if (ptr->ip.ss.ss_family != ip_in->ss.ss_family)
308 <      continue;
309 <    if (ip_in->ss.ss_family == AF_INET6)
471 <    {
472 <      ptr_v6 = (struct sockaddr_in6 *)&ptr->ip;
473 <      res = memcmp(&v6->sin6_addr, &ptr_v6->sin6_addr, sizeof(struct in6_addr));
474 <    }
475 <    else
476 < #endif
477 <    {
478 <      ptr_v4 = (struct sockaddr_in *)&ptr->ip;
479 <      res = memcmp(&v4->sin_addr, &ptr_v4->sin_addr, sizeof(struct in_addr));
480 <    }
481 <    if (res == 0)
482 <    {
483 <      /* Found entry already in hash, return it. */
484 <      return ptr;
485 <    }
306 >    conf = find_address_conf(client_p->host, client_p->username,
307 >                             &client_p->connection->ip,
308 >                             client_p->connection->aftype,
309 >                             client_p->connection->password);
310    }
311 +  else
312 +  {
313 +    char non_ident[USERLEN + 1] = "~";
314  
315 <  if (ip_entries_count >= 2 * hard_fdlimit)
316 <    garbage_collect_ip_entries();
317 <
318 <  newptr = mp_pool_get(ip_entry_pool);
319 <  memset(newptr, 0, sizeof(*newptr));
320 <  ip_entries_count++;
494 <  memcpy(&newptr->ip, ip_in, sizeof(struct irc_ssaddr));
315 >    strlcpy(non_ident + 1, client_p->username, sizeof(non_ident) - 1);
316 >    conf = find_address_conf(client_p->host, non_ident,
317 >                             &client_p->connection->ip,
318 >                             client_p->connection->aftype,
319 >                             client_p->connection->password);
320 >  }
321  
322 <  newptr->next = ip_hash_table[hash_index];
323 <  ip_hash_table[hash_index] = newptr;
322 >  if (!conf)
323 >    return NOT_AUTHORIZED;
324  
325 <  return newptr;
500 < }
325 >  assert(IsConfClient(conf) || IsConfKill(conf));
326  
327 < /* remove_one_ip()
503 < *
504 < * inputs        - unsigned long IP address value
505 < * output        - NONE
506 < * side effects  - The ip address given, is looked up in ip hash table
507 < *                 and number of ip#'s for that ip decremented.
508 < *                 If ip # count reaches 0 and has expired,
509 < *                 the struct ip_entry is returned to the ip_entry_heap
510 < */
511 < void
512 < remove_one_ip(struct irc_ssaddr *ip_in)
513 < {
514 <  struct ip_entry *ptr;
515 <  struct ip_entry *last_ptr = NULL;
516 <  int hash_index = hash_ip(ip_in), res;
517 <  struct sockaddr_in *v4 = (struct sockaddr_in *)ip_in, *ptr_v4;
518 < #ifdef IPV6
519 <  struct sockaddr_in6 *v6 = (struct sockaddr_in6 *)ip_in, *ptr_v6;
520 < #endif
521 <
522 <  for (ptr = ip_hash_table[hash_index]; ptr; ptr = ptr->next)
327 >  if (IsConfClient(conf))
328    {
329 < #ifdef IPV6
525 <    if (ptr->ip.ss.ss_family != ip_in->ss.ss_family)
526 <      continue;
527 <    if (ip_in->ss.ss_family == AF_INET6)
329 >    if (IsConfRedir(conf))
330      {
331 <      ptr_v6 = (struct sockaddr_in6 *)&ptr->ip;
332 <      res = memcmp(&v6->sin6_addr, &ptr_v6->sin6_addr, sizeof(struct in6_addr));
331 >      sendto_one_numeric(client_p, &me, RPL_REDIR,
332 >                         conf->name ? conf->name : "",
333 >                         conf->port);
334 >      return NOT_AUTHORIZED;
335      }
336 <    else
337 < #endif
534 <    {
535 <      ptr_v4 = (struct sockaddr_in *)&ptr->ip;
536 <      res = memcmp(&v4->sin_addr, &ptr_v4->sin_addr, sizeof(struct in_addr));
537 <    }
538 <    if (res)
539 <      continue;
540 <    if (ptr->count > 0)
541 <      ptr->count--;
542 <    if (ptr->count == 0 &&
543 <        (CurrentTime-ptr->last_attempt) >= ConfigFileEntry.throttle_time)
336 >
337 >    if (IsConfDoSpoofIp(conf))
338      {
339 <      if (last_ptr != NULL)
340 <        last_ptr->next = ptr->next;
341 <      else
548 <        ip_hash_table[hash_index] = ptr->next;
339 >      if (IsConfSpoofNotice(conf))
340 >        sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE, "%s spoofing: %s as %s",
341 >                             client_p->name, client_p->host, conf->name);
342  
343 <      mp_pool_release(ptr);
551 <      ip_entries_count--;
552 <      return;
343 >      strlcpy(client_p->host, conf->name, sizeof(client_p->host));
344      }
554    last_ptr = ptr;
555  }
556 }
557
558 /* hash_ip()
559 *
560 * input        - pointer to an irc_inaddr
561 * output       - integer value used as index into hash table
562 * side effects - hopefully, none
563 */
564 static int
565 hash_ip(struct irc_ssaddr *addr)
566 {
567  if (addr->ss.ss_family == AF_INET)
568  {
569    struct sockaddr_in *v4 = (struct sockaddr_in *)addr;
570    int hash;
571    uint32_t ip;
345  
346 <    ip   = ntohl(v4->sin_addr.s_addr);
574 <    hash = ((ip >> 12) + ip) & (IP_HASH_SIZE-1);
575 <    return hash;
346 >    return attach_iline(client_p, conf);
347    }
348 < #ifdef IPV6
349 <  else
350 <  {
580 <    int hash;
581 <    struct sockaddr_in6 *v6 = (struct sockaddr_in6 *)addr;
582 <    uint32_t *ip = (uint32_t *)&v6->sin6_addr.s6_addr;
583 <
584 <    hash  = ip[0] ^ ip[3];
585 <    hash ^= hash >> 16;
586 <    hash ^= hash >> 8;
587 <    hash  = hash & (IP_HASH_SIZE - 1);
588 <    return hash;
589 <  }
590 < #else
591 <  return 0;
592 < #endif
348 >
349 >  sendto_one_notice(client_p, &me, ":*** Banned: %s", conf->reason);
350 >  return BANNED_CLIENT;
351   }
352  
353 < /* count_ip_hash()
596 < *
597 < * inputs        - pointer to counter of number of ips hashed
598 < *               - pointer to memory used for ip hash
599 < * output        - returned via pointers input
600 < * side effects  - NONE
353 > /* check_client()
354   *
355 < * number of hashed ip #'s is counted up, plus the amount of memory
356 < * used in the hash.
355 > * inputs       - pointer to client
356 > * output       - 0 = Success
357 > *                NOT_AUTHORIZED    (-1) = Access denied (no I line match)
358 > *                IRCD_SOCKET_ERROR (-2) = Bad socket.
359 > *                I_LINE_FULL       (-3) = I-line is full
360 > *                TOO_MANY          (-4) = Too many connections from hostname
361 > *                BANNED_CLIENT     (-5) = K-lined
362 > * side effects - Ordinary client access check.
363 > *                Look for conf lines which have the same
364 > *                status as the flags passed.
365   */
366 < void
367 < count_ip_hash(unsigned int *number_ips_stored, uint64_t *mem_ips_stored)
366 > int
367 > check_client(struct Client *source_p)
368   {
608  struct ip_entry *ptr;
369    int i;
370  
371 <  *number_ips_stored = 0;
372 <  *mem_ips_stored    = 0;
371 >  if ((i = verify_access(source_p)))
372 >    ilog(LOG_TYPE_IRCD, "Access denied: %s[%s]",
373 >         source_p->name, source_p->sockhost);
374  
375 <  for (i = 0; i < IP_HASH_SIZE; i++)
375 >  switch (i)
376    {
377 <    for (ptr = ip_hash_table[i]; ptr; ptr = ptr->next)
378 <    {
379 <      *number_ips_stored += 1;
380 <      *mem_ips_stored += sizeof(struct ip_entry);
381 <    }
382 <  }
383 < }
377 >    case TOO_MANY:
378 >      sendto_realops_flags(UMODE_FULL, L_ALL, SEND_NOTICE,
379 >                           "Too many on IP for %s (%s).",
380 >                           get_client_name(source_p, SHOW_IP),
381 >                           source_p->sockhost);
382 >      ilog(LOG_TYPE_IRCD, "Too many connections on IP from %s.",
383 >           get_client_name(source_p, SHOW_IP));
384 >      ++ServerStats.is_ref;
385 >      exit_client(source_p, "No more connections allowed on that IP");
386 >      break;
387  
388 < /* garbage_collect_ip_entries()
389 < *
390 < * input        - NONE
391 < * output       - NONE
392 < * side effects - free up all ip entries with no connections
393 < */
394 < static void
395 < garbage_collect_ip_entries(void)
396 < {
397 <  struct ip_entry *ptr;
634 <  struct ip_entry *last_ptr;
635 <  struct ip_entry *next_ptr;
636 <  int i;
388 >    case I_LINE_FULL:
389 >      sendto_realops_flags(UMODE_FULL, L_ALL, SEND_NOTICE,
390 >                           "auth {} block is full for %s (%s).",
391 >                           get_client_name(source_p, SHOW_IP),
392 >                           source_p->sockhost);
393 >      ilog(LOG_TYPE_IRCD, "Too many connections from %s.",
394 >           get_client_name(source_p, SHOW_IP));
395 >      ++ServerStats.is_ref;
396 >      exit_client(source_p, "No more connections allowed in your connection class");
397 >      break;
398  
399 <  for (i = 0; i < IP_HASH_SIZE; i++)
400 <  {
401 <    last_ptr = NULL;
399 >    case NOT_AUTHORIZED:
400 >      /* jdc - lists server name & port connections are on */
401 >      /*       a purely cosmetical change */
402 >      sendto_realops_flags(UMODE_UNAUTH, L_ALL, SEND_NOTICE,
403 >                           "Unauthorized client connection from %s [%s] on [%s/%u].",
404 >                           get_client_name(source_p, SHOW_IP),
405 >                           source_p->sockhost,
406 >                           source_p->connection->listener->name,
407 >                           source_p->connection->listener->port);
408 >      ilog(LOG_TYPE_IRCD, "Unauthorized client connection from %s on [%s/%u].",
409 >           get_client_name(source_p, SHOW_IP),
410 >           source_p->connection->listener->name,
411 >           source_p->connection->listener->port);
412  
413 <    for (ptr = ip_hash_table[i]; ptr; ptr = next_ptr)
414 <    {
415 <      next_ptr = ptr->next;
413 >      ++ServerStats.is_ref;
414 >      exit_client(source_p, "You are not authorized to use this server");
415 >      break;
416  
417 <      if (ptr->count == 0 &&
418 <          (CurrentTime - ptr->last_attempt) >= ConfigFileEntry.throttle_time)
419 <      {
420 <        if (last_ptr != NULL)
421 <          last_ptr->next = ptr->next;
422 <        else
423 <          ip_hash_table[i] = ptr->next;
424 <        mp_pool_release(ptr);
654 <        ip_entries_count--;
655 <      }
656 <      else
657 <        last_ptr = ptr;
658 <    }
417 >    case BANNED_CLIENT:
418 >      ++ServerStats.is_ref;
419 >      exit_client(source_p, "Banned");
420 >      break;
421 >
422 >    case 0:
423 >    default:
424 >      break;
425    }
426 +
427 +  return !(i < 0);
428   }
429  
430   /* detach_conf()
# Line 670 | Line 438 | garbage_collect_ip_entries(void)
438   void
439   detach_conf(struct Client *client_p, enum maskitem_type type)
440   {
441 <  dlink_node *ptr = NULL, *next_ptr = NULL;
441 >  dlink_node *node = NULL, *node_next = NULL;
442  
443 <  DLINK_FOREACH_SAFE(ptr, next_ptr, client_p->localClient->confs.head)
443 >  DLINK_FOREACH_SAFE(node, node_next, client_p->connection->confs.head)
444    {
445 <    struct MaskItem *conf = ptr->data;
445 >    struct MaskItem *conf = node->data;
446  
447      assert(conf->type & (CONF_CLIENT | CONF_OPER | CONF_SERVER));
448      assert(conf->ref_count > 0);
# Line 683 | Line 451 | detach_conf(struct Client *client_p, enu
451      if (!(conf->type & type))
452        continue;
453  
454 <    dlinkDelete(ptr, &client_p->localClient->confs);
455 <    free_dlink_node(ptr);
454 >    dlinkDelete(node, &client_p->connection->confs);
455 >    free_dlink_node(node);
456  
457      if (conf->type == CONF_CLIENT)
458 <      remove_from_cidr_check(&client_p->localClient->ip, conf->class);
458 >      remove_from_cidr_check(&client_p->connection->ip, conf->class);
459  
460      if (--conf->class->ref_count == 0 && conf->class->active == 0)
461      {
# Line 713 | Line 481 | detach_conf(struct Client *client_p, enu
481   int
482   attach_conf(struct Client *client_p, struct MaskItem *conf)
483   {
484 <  if (dlinkFind(&client_p->localClient->confs, conf) != NULL)
484 >  if (dlinkFind(&client_p->connection->confs, conf))
485      return 1;
486  
487    if (conf->type == CONF_CLIENT)
488      if (cidr_limit_reached(IsConfExemptLimits(conf),
489 <                           &client_p->localClient->ip, conf->class))
489 >                           &client_p->connection->ip, conf->class))
490        return TOO_MANY;    /* Already at maximum allowed */
491  
492    conf->class->ref_count++;
493    conf->ref_count++;
494  
495 <  dlinkAdd(conf, make_dlink_node(), &client_p->localClient->confs);
495 >  dlinkAdd(conf, make_dlink_node(), &client_p->connection->confs);
496  
497    return 0;
498   }
# Line 741 | Line 509 | int
509   attach_connect_block(struct Client *client_p, const char *name,
510                       const char *host)
511   {
512 <  dlink_node *ptr;
745 <  struct MaskItem *conf = NULL;
512 >  dlink_node *node = NULL;
513  
514 <  assert(client_p != NULL);
748 <  assert(host != NULL);
514 >  assert(host);
515  
516 <  if (client_p == NULL || host == NULL)
751 <    return 0;
752 <
753 <  DLINK_FOREACH(ptr, server_items.head)
516 >  DLINK_FOREACH(node, server_items.head)
517    {
518 <    conf = ptr->data;
518 >    struct MaskItem *conf = node->data;
519  
520      if (match(conf->name, name) || match(conf->host, host))
521        continue;
522  
523      attach_conf(client_p, conf);
524 <    return -1;
524 >    return 1;
525    }
526  
527    return 0;
# Line 776 | Line 539 | attach_connect_block(struct Client *clie
539   struct MaskItem *
540   find_conf_name(dlink_list *list, const char *name, enum maskitem_type type)
541   {
542 <  dlink_node *ptr;
780 <  struct MaskItem* conf;
542 >  dlink_node *node = NULL;
543  
544 <  DLINK_FOREACH(ptr, list->head)
544 >  DLINK_FOREACH(node, list->head)
545    {
546 <    conf = ptr->data;
546 >    struct MaskItem *conf = node->data;
547  
548      if (conf->type == type)
549      {
550 <      if (conf->name && (irccmp(conf->name, name) == 0 ||
551 <                         !match(conf->name, name)))
790 <      return conf;
550 >      if (conf->name && !irccmp(conf->name, name))
551 >        return conf;
552      }
553    }
554  
555    return NULL;
556   }
557  
797 /* map_to_list()
798 *
799 * inputs       - ConfType conf
800 * output       - pointer to dlink_list to use
801 * side effects - none
802 */
803 static dlink_list *
804 map_to_list(enum maskitem_type type)
805 {
806  switch(type)
807  {
808  case CONF_XLINE:
809    return(&xconf_items);
810    break;
811  case CONF_ULINE:
812    return(&uconf_items);
813    break;
814  case CONF_NRESV:
815    return(&nresv_items);
816    break;
817  case CONF_CRESV:
818    return(&cresv_items);
819  case CONF_OPER:
820    return(&oconf_items);
821    break;
822  case CONF_SERVER:
823    return(&server_items);
824    break;
825  case CONF_SERVICE:
826    return(&service_items);
827    break;
828  case CONF_CLUSTER:
829    return(&cluster_items);
830    break;
831  default:
832    return NULL;
833  }
834 }
835
558   /* find_matching_name_conf()
559   *
560   * inputs       - type of link list to look in
# Line 847 | Line 569 | struct MaskItem *
569   find_matching_name_conf(enum maskitem_type type, const char *name, const char *user,
570                          const char *host, unsigned int flags)
571   {
572 <  dlink_node *ptr=NULL;
573 <  struct MaskItem *conf=NULL;
574 <  dlink_list *list_p = map_to_list(type);
572 >  dlink_node *node = NULL;
573 >  dlink_list *list = map_to_list(type);
574 >  struct MaskItem *conf = NULL;
575  
576    switch (type)
577    {
578    case CONF_SERVICE:
579 <    DLINK_FOREACH(ptr, list_p->head)
579 >    DLINK_FOREACH(node, list->head)
580      {
581 <      conf = ptr->data;
581 >      conf = node->data;
582  
583        if (EmptyString(conf->name))
584          continue;
585 <      if ((name != NULL) && !irccmp(name, conf->name))
585 >      if (name && !irccmp(name, conf->name))
586          return conf;
587      }
588      break;
# Line 869 | Line 591 | find_matching_name_conf(enum maskitem_ty
591    case CONF_ULINE:
592    case CONF_NRESV:
593    case CONF_CRESV:
594 <    DLINK_FOREACH(ptr, list_p->head)
594 >    DLINK_FOREACH(node, list->head)
595      {
596 <      conf = ptr->data;
596 >      conf = node->data;
597  
598        if (EmptyString(conf->name))
599          continue;
600 <      if ((name != NULL) && !match(conf->name, name))
600 >      if (name && !match(conf->name, name))
601        {
602          if ((user == NULL && (host == NULL)))
603            return conf;
# Line 890 | Line 612 | find_matching_name_conf(enum maskitem_ty
612        break;
613  
614    case CONF_SERVER:
615 <    DLINK_FOREACH(ptr, list_p->head)
615 >    DLINK_FOREACH(node, list->head)
616      {
617 <      conf = ptr->data;
617 >      conf = node->data;
618  
619 <      if ((name != NULL) && !match(name, conf->name))
619 >      if (name && !match(name, conf->name))
620          return conf;
621 <      else if ((host != NULL) && !match(host, conf->host))
621 >      if (host && !match(host, conf->host))
622          return conf;
623      }
624      break;
# Line 920 | Line 642 | struct MaskItem *
642   find_exact_name_conf(enum maskitem_type type, const struct Client *who, const char *name,
643                       const char *user, const char *host)
644   {
645 <  dlink_node *ptr = NULL;
646 <  struct MaskItem *conf;
647 <  dlink_list *list_p = map_to_list(type);
645 >  dlink_node *node = NULL;
646 >  dlink_list *list = map_to_list(type);
647 >  struct MaskItem *conf = NULL;
648  
649    switch(type)
650    {
# Line 931 | Line 653 | find_exact_name_conf(enum maskitem_type
653    case CONF_NRESV:
654    case CONF_CRESV:
655  
656 <    DLINK_FOREACH(ptr, list_p->head)
656 >    DLINK_FOREACH(node, list->head)
657      {
658 <      conf = ptr->data;
658 >      conf = node->data;
659  
660        if (EmptyString(conf->name))
661          continue;
# Line 951 | Line 673 | find_exact_name_conf(enum maskitem_type
673      break;
674  
675    case CONF_OPER:
676 <    DLINK_FOREACH(ptr, list_p->head)
676 >    DLINK_FOREACH(node, list->head)
677      {
678 <      conf = ptr->data;
678 >      conf = node->data;
679  
680        if (EmptyString(conf->name))
681          continue;
# Line 974 | Line 696 | find_exact_name_conf(enum maskitem_type
696                    return conf;
697                break;
698              case HM_IPV4:
699 <              if (who->localClient->aftype == AF_INET)
700 <                if (match_ipv4(&who->localClient->ip, &conf->addr, conf->bits))
699 >              if (who->connection->aftype == AF_INET)
700 >                if (match_ipv4(&who->connection->ip, &conf->addr, conf->bits))
701                    if (!conf->class->max_total || conf->class->ref_count < conf->class->max_total)
702                      return conf;
703                break;
982 #ifdef IPV6
704              case HM_IPV6:
705 <              if (who->localClient->aftype == AF_INET6)
706 <                if (match_ipv6(&who->localClient->ip, &conf->addr, conf->bits))
705 >              if (who->connection->aftype == AF_INET6)
706 >                if (match_ipv6(&who->connection->ip, &conf->addr, conf->bits))
707                    if (!conf->class->max_total || conf->class->ref_count < conf->class->max_total)
708                      return conf;
709                break;
989 #endif
710              default:
711                assert(0);
712            }
# Line 997 | Line 717 | find_exact_name_conf(enum maskitem_type
717      break;
718  
719    case CONF_SERVER:
720 <    DLINK_FOREACH(ptr, list_p->head)
720 >    DLINK_FOREACH(node, list->head)
721      {
722 <      conf = ptr->data;
722 >      conf = node->data;
723  
724        if (EmptyString(conf->name))
725          continue;
# Line 1024 | Line 744 | find_exact_name_conf(enum maskitem_type
744    return NULL;
745   }
746  
1027 /* rehash()
1028 *
1029 * Actual REHASH service routine. Called with sig == 0 if it has been called
1030 * as a result of an operator issuing this command, else assume it has been
1031 * called as a result of the server receiving a HUP signal.
1032 */
1033 int
1034 rehash(int sig)
1035 {
1036  if (sig != 0)
1037    sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1038                         "Got signal SIGHUP, reloading configuration file(s)");
1039
1040  restart_resolver();
1041
1042  /* don't close listeners until we know we can go ahead with the rehash */
1043
1044  /* Check to see if we magically got(or lost) IPv6 support */
1045  check_can_use_v6();
1046
1047  read_conf_files(0);
1048
1049  if (ServerInfo.description != NULL)
1050    strlcpy(me.info, ServerInfo.description, sizeof(me.info));
1051
1052  load_conf_modules();
1053
1054  rehashed_klines = 1;
1055
1056  return 0;
1057 }
1058
747   /* set_default_conf()
748   *
749   * inputs       - NONE
# Line 1074 | Line 762 | set_default_conf(void)
762    assert(class_default == class_get_list()->tail->data);
763  
764   #ifdef HAVE_LIBCRYPTO
765 <  ServerInfo.rsa_private_key = NULL;
766 <  ServerInfo.rsa_private_key_file = NULL;
765 > #if OPENSSL_VERSION_NUMBER >= 0x009080FFL && !defined(OPENSSL_NO_ECDH)
766 >  {
767 >    EC_KEY *key = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1);
768 >
769 >    if (key)
770 >    {
771 >      SSL_CTX_set_tmp_ecdh(ConfigServerInfo.server_ctx, key);
772 >      EC_KEY_free(key);
773 >    }
774 >  }
775 >
776 >  SSL_CTX_set_options(ConfigServerInfo.server_ctx, SSL_OP_SINGLE_ECDH_USE);
777 > #endif
778 >
779 >  SSL_CTX_set_cipher_list(ConfigServerInfo.server_ctx, "EECDH+HIGH:EDH+HIGH:HIGH:!aNULL");
780 >  ConfigServerInfo.message_digest_algorithm = EVP_sha256();
781 >  ConfigServerInfo.rsa_private_key = NULL;
782 >  ConfigServerInfo.rsa_private_key_file = NULL;
783   #endif
784  
785 <  /* ServerInfo.name is not rehashable */
786 <  /* ServerInfo.name = ServerInfo.name; */
787 <  ServerInfo.description = NULL;
788 <  ServerInfo.network_name = xstrdup(NETWORK_NAME_DEFAULT);
789 <  ServerInfo.network_desc = xstrdup(NETWORK_DESC_DEFAULT);
790 <
791 <  memset(&ServerInfo.ip, 0, sizeof(ServerInfo.ip));
792 <  ServerInfo.specific_ipv4_vhost = 0;
793 <  memset(&ServerInfo.ip6, 0, sizeof(ServerInfo.ip6));
794 <  ServerInfo.specific_ipv6_vhost = 0;
795 <
796 <  ServerInfo.max_clients = MAXCLIENTS_MAX;
797 <  ServerInfo.max_nick_length = 9;
798 <  ServerInfo.max_topic_length = 80;
799 <
800 <  ServerInfo.hub = 0;
801 <  ServerInfo.dns_host.sin_addr.s_addr = 0;
802 <  ServerInfo.dns_host.sin_port = 0;
803 <  AdminInfo.name = NULL;
1100 <  AdminInfo.email = NULL;
1101 <  AdminInfo.description = NULL;
785 >  /* ConfigServerInfo.name is not rehashable */
786 >  /* ConfigServerInfo.name = ConfigServerInfo.name; */
787 >  ConfigServerInfo.description = NULL;
788 >  ConfigServerInfo.network_name = xstrdup(NETWORK_NAME_DEFAULT);
789 >  ConfigServerInfo.network_desc = xstrdup(NETWORK_DESC_DEFAULT);
790 >
791 >  memset(&ConfigServerInfo.ip, 0, sizeof(ConfigServerInfo.ip));
792 >  ConfigServerInfo.specific_ipv4_vhost = 0;
793 >  memset(&ConfigServerInfo.ip6, 0, sizeof(ConfigServerInfo.ip6));
794 >  ConfigServerInfo.specific_ipv6_vhost = 0;
795 >
796 >  ConfigServerInfo.default_max_clients = MAXCLIENTS_MAX;
797 >  ConfigServerInfo.max_nick_length = 9;
798 >  ConfigServerInfo.max_topic_length = 80;
799 >  ConfigServerInfo.hub = 0;
800 >
801 >  ConfigAdminInfo.name = NULL;
802 >  ConfigAdminInfo.email = NULL;
803 >  ConfigAdminInfo.description = NULL;
804  
805    log_del_all();
806  
807 <  ConfigLoggingEntry.use_logging = 1;
807 >  ConfigLog.use_logging = 1;
808  
809    ConfigChannel.disable_fake_channels = 0;
810 <  ConfigChannel.knock_delay = 300;
810 >  ConfigChannel.invite_client_count = 10;
811 >  ConfigChannel.invite_client_time = 300;
812 >  ConfigChannel.knock_client_count = 1;
813 >  ConfigChannel.knock_client_time = 300;
814    ConfigChannel.knock_delay_channel = 60;
815 <  ConfigChannel.max_chans_per_user = 25;
1111 <  ConfigChannel.max_chans_per_oper = 50;
815 >  ConfigChannel.max_channels = 25;
816    ConfigChannel.max_bans = 25;
817 +  ConfigChannel.default_join_flood_count = 18;
818 +  ConfigChannel.default_join_flood_time = 6;
819    ConfigChannel.default_split_user_count = 0;
820    ConfigChannel.default_split_server_count = 0;
821    ConfigChannel.no_join_on_split = 0;
# Line 1124 | Line 830 | set_default_conf(void)
830    ConfigServerHide.hide_server_ips = 0;
831    ConfigServerHide.disable_remote_commands = 0;
832  
833 <  ConfigFileEntry.service_name = xstrdup(SERVICE_NAME_DEFAULT);
834 <  ConfigFileEntry.max_watch = WATCHSIZE_DEFAULT;
835 <  ConfigFileEntry.cycle_on_host_change = 1;
836 <  ConfigFileEntry.glines = 0;
837 <  ConfigFileEntry.gline_time = 12 * 3600;
838 <  ConfigFileEntry.gline_request_time = GLINE_REQUEST_EXPIRE_DEFAULT;
839 <  ConfigFileEntry.gline_min_cidr = 16;
840 <  ConfigFileEntry.gline_min_cidr6 = 48;
841 <  ConfigFileEntry.invisible_on_connect = 1;
842 <  ConfigFileEntry.tkline_expire_notices = 1;
843 <  ConfigFileEntry.hide_spoof_ips = 1;
844 <  ConfigFileEntry.ignore_bogus_ts = 0;
845 <  ConfigFileEntry.disable_auth = 0;
846 <  ConfigFileEntry.kill_chase_time_limit = 90;
847 <  ConfigFileEntry.default_floodcount = 8;
848 <  ConfigFileEntry.failed_oper_notice = 1;
849 <  ConfigFileEntry.dots_in_ident = 0;
850 <  ConfigFileEntry.min_nonwildcard = 4;
851 <  ConfigFileEntry.min_nonwildcard_simple = 3;
852 <  ConfigFileEntry.max_accept = 20;
853 <  ConfigFileEntry.anti_nick_flood = 0;
854 <  ConfigFileEntry.max_nick_time = 20;
855 <  ConfigFileEntry.max_nick_changes = 5;
856 <  ConfigFileEntry.anti_spam_exit_message_time = 0;
857 <  ConfigFileEntry.ts_warn_delta = TS_WARN_DELTA_DEFAULT;
858 <  ConfigFileEntry.ts_max_delta = TS_MAX_DELTA_DEFAULT;
859 <  ConfigFileEntry.warn_no_nline = 1;
860 <  ConfigFileEntry.stats_o_oper_only = 0;
861 <  ConfigFileEntry.stats_k_oper_only = 1;  /* masked */
862 <  ConfigFileEntry.stats_i_oper_only = 1;  /* masked */
863 <  ConfigFileEntry.stats_P_oper_only = 0;
864 <  ConfigFileEntry.stats_u_oper_only = 0;
865 <  ConfigFileEntry.caller_id_wait = 60;
866 <  ConfigFileEntry.opers_bypass_callerid = 0;
867 <  ConfigFileEntry.pace_wait = 10;
868 <  ConfigFileEntry.pace_wait_simple = 1;
869 <  ConfigFileEntry.short_motd = 0;
870 <  ConfigFileEntry.ping_cookie = 0;
871 <  ConfigFileEntry.no_oper_flood = 0;
872 <  ConfigFileEntry.true_no_oper_flood = 0;
873 <  ConfigFileEntry.oper_pass_resv = 1;
874 <  ConfigFileEntry.max_targets = MAX_TARGETS_DEFAULT;
875 <  ConfigFileEntry.oper_only_umodes = UMODE_DEBUG;
876 <  ConfigFileEntry.oper_umodes = UMODE_BOTS | UMODE_LOCOPS | UMODE_SERVNOTICE |
877 <    UMODE_OPERWALL | UMODE_WALLOP;
878 <  ConfigFileEntry.use_egd = 0;
879 <  ConfigFileEntry.egdpool_path = NULL;
880 <  ConfigFileEntry.throttle_time = 10;
833 >  ConfigGeneral.away_count = 2;
834 >  ConfigGeneral.away_time = 10;
835 >  ConfigGeneral.max_watch = WATCHSIZE_DEFAULT;
836 >  ConfigGeneral.cycle_on_host_change = 1;
837 >  ConfigGeneral.dline_min_cidr = 16;
838 >  ConfigGeneral.dline_min_cidr6 = 48;
839 >  ConfigGeneral.kline_min_cidr = 16;
840 >  ConfigGeneral.kline_min_cidr6 = 48;
841 >  ConfigGeneral.invisible_on_connect = 1;
842 >  ConfigGeneral.tkline_expire_notices = 1;
843 >  ConfigGeneral.ignore_bogus_ts = 0;
844 >  ConfigGeneral.disable_auth = 0;
845 >  ConfigGeneral.kill_chase_time_limit = 90;
846 >  ConfigGeneral.default_floodcount = 8;
847 >  ConfigGeneral.failed_oper_notice = 1;
848 >  ConfigGeneral.dots_in_ident = 0;
849 >  ConfigGeneral.min_nonwildcard = 4;
850 >  ConfigGeneral.min_nonwildcard_simple = 3;
851 >  ConfigGeneral.max_accept = 20;
852 >  ConfigGeneral.anti_nick_flood = 0;
853 >  ConfigGeneral.max_nick_time = 20;
854 >  ConfigGeneral.max_nick_changes = 5;
855 >  ConfigGeneral.anti_spam_exit_message_time = 0;
856 >  ConfigGeneral.ts_warn_delta = TS_WARN_DELTA_DEFAULT;
857 >  ConfigGeneral.ts_max_delta = TS_MAX_DELTA_DEFAULT;
858 >  ConfigGeneral.warn_no_connect_block = 1;
859 >  ConfigGeneral.stats_e_disabled = 0;
860 >  ConfigGeneral.stats_i_oper_only = 1;  /* 1 = masked */
861 >  ConfigGeneral.stats_k_oper_only = 1;  /* 1 = masked */
862 >  ConfigGeneral.stats_o_oper_only = 1;
863 >  ConfigGeneral.stats_m_oper_only = 1;
864 >  ConfigGeneral.stats_P_oper_only = 0;
865 >  ConfigGeneral.stats_u_oper_only = 0;
866 >  ConfigGeneral.caller_id_wait = 60;
867 >  ConfigGeneral.opers_bypass_callerid = 0;
868 >  ConfigGeneral.pace_wait = 10;
869 >  ConfigGeneral.pace_wait_simple = 1;
870 >  ConfigGeneral.short_motd = 0;
871 >  ConfigGeneral.ping_cookie = 0;
872 >  ConfigGeneral.no_oper_flood = 0;
873 >  ConfigGeneral.oper_pass_resv = 1;
874 >  ConfigGeneral.max_targets = MAX_TARGETS_DEFAULT;
875 >  ConfigGeneral.oper_only_umodes = UMODE_DEBUG | UMODE_LOCOPS | UMODE_HIDDEN | UMODE_FARCONNECT |
876 >                                   UMODE_UNAUTH | UMODE_EXTERNAL | UMODE_BOTS | UMODE_NCHANGE |
877 >                                   UMODE_SPY | UMODE_FULL | UMODE_SKILL | UMODE_REJ | UMODE_CCONN;
878 >  ConfigGeneral.oper_umodes = UMODE_BOTS | UMODE_LOCOPS | UMODE_SERVNOTICE | UMODE_WALLOP;
879 >  ConfigGeneral.throttle_count = 1;
880 >  ConfigGeneral.throttle_time = 1;
881   }
882  
883   static void
884   validate_conf(void)
885   {
886 <  if (ConfigFileEntry.ts_warn_delta < TS_WARN_DELTA_MIN)
887 <    ConfigFileEntry.ts_warn_delta = TS_WARN_DELTA_DEFAULT;
886 >  if (ConfigGeneral.ts_warn_delta < TS_WARN_DELTA_MIN)
887 >    ConfigGeneral.ts_warn_delta = TS_WARN_DELTA_DEFAULT;
888  
889 <  if (ConfigFileEntry.ts_max_delta < TS_MAX_DELTA_MIN)
890 <    ConfigFileEntry.ts_max_delta = TS_MAX_DELTA_DEFAULT;
889 >  if (ConfigGeneral.ts_max_delta < TS_MAX_DELTA_MIN)
890 >    ConfigGeneral.ts_max_delta = TS_MAX_DELTA_DEFAULT;
891  
892 <  if (ServerInfo.network_name == NULL)
893 <    ServerInfo.network_name = xstrdup(NETWORK_NAME_DEFAULT);
892 >  if (EmptyString(ConfigServerInfo.network_name))
893 >    ConfigServerInfo.network_name = xstrdup(NETWORK_NAME_DEFAULT);
894  
895 <  if (ServerInfo.network_desc == NULL)
896 <    ServerInfo.network_desc = xstrdup(NETWORK_DESC_DEFAULT);
895 >  if (EmptyString(ConfigServerInfo.network_desc))
896 >    ConfigServerInfo.network_desc = xstrdup(NETWORK_DESC_DEFAULT);
897  
898 <  if (ConfigFileEntry.service_name == NULL)
1193 <    ConfigFileEntry.service_name = xstrdup(SERVICE_NAME_DEFAULT);
1194 <
1195 <  ConfigFileEntry.max_watch = IRCD_MAX(ConfigFileEntry.max_watch, WATCHSIZE_MIN);
898 >  ConfigGeneral.max_watch = IRCD_MAX(ConfigGeneral.max_watch, WATCHSIZE_MIN);
899   }
900  
901   /* read_conf()
# Line 1206 | Line 909 | read_conf(FILE *file)
909   {
910    lineno = 0;
911  
912 <  set_default_conf(); /* Set default values prior to conf parsing */
912 >  set_default_conf();  /* Set default values prior to conf parsing */
913    conf_parser_ctx.pass = 1;
914 <  yyparse();          /* pick up the classes first */
914 >  yyparse();  /* Pick up the classes first */
915  
916    rewind(file);
917  
918    conf_parser_ctx.pass = 2;
919 <  yyparse();          /* Load the values from the conf */
920 <  validate_conf();    /* Check to make sure some values are still okay. */
921 <                      /* Some global values are also loaded here. */
922 <  class_delete_marked();      /* Make sure classes are valid */
919 >  yyparse();  /* Load the values from the conf */
920 >  validate_conf();  /* Check to make sure some values are still okay. */
921 >                    /* Some global values are also loaded here. */
922 >  class_delete_marked();  /* Delete unused classes that are marked for deletion */
923 > }
924 >
925 > /* conf_rehash()
926 > *
927 > * Actual REHASH service routine. Called with sig == 0 if it has been called
928 > * as a result of an operator issuing this command, else assume it has been
929 > * called as a result of the server receiving a HUP signal.
930 > */
931 > void
932 > conf_rehash(int sig)
933 > {
934 >  if (sig)
935 >    sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
936 >                         "Got signal SIGHUP, reloading configuration file(s)");
937 >
938 >  restart_resolver();
939 >
940 >  /* don't close listeners until we know we can go ahead with the rehash */
941 >
942 >  read_conf_files(0);
943 >
944 >  load_conf_modules();
945 >  check_conf_klines();
946   }
947  
948   /* lookup_confhost()
# Line 1229 | Line 955 | lookup_confhost(struct MaskItem *conf)
955   {
956    struct addrinfo hints, *res;
957  
958 <  /* Do name lookup now on hostnames given and store the
958 >  /*
959 >   * Do name lookup now on hostnames given and store the
960     * ip numbers in conf structure.
961     */
962    memset(&hints, 0, sizeof(hints));
# Line 1246 | Line 973 | lookup_confhost(struct MaskItem *conf)
973      return;
974    }
975  
976 <  assert(res != NULL);
976 >  assert(res);
977  
978    memcpy(&conf->addr, res->ai_addr, res->ai_addrlen);
979    conf->addr.ss_len = res->ai_addrlen;
# Line 1265 | Line 992 | lookup_confhost(struct MaskItem *conf)
992   int
993   conf_connect_allowed(struct irc_ssaddr *addr, int aftype)
994   {
995 <  struct ip_entry *ip_found;
996 <  struct MaskItem *conf = find_dline_conf(addr, aftype);
995 >  struct ip_entry *ip_found = NULL;
996 >  struct MaskItem *const conf = find_dline_conf(addr, aftype);
997  
998    /* DLINE exempt also gets you out of static limits/pacing... */
999    if (conf && (conf->type == CONF_EXEMPT))
1000      return 0;
1001  
1002 <  if (conf != NULL)
1002 >  if (conf)
1003      return BANNED_CLIENT;
1004  
1005 <  ip_found = find_or_add_ip(addr);
1005 >  ip_found = ipcache_find_or_add_address(addr);
1006  
1007 <  if ((CurrentTime - ip_found->last_attempt) <
1281 <      ConfigFileEntry.throttle_time)
1007 >  if ((CurrentTime - ip_found->last_attempt) < ConfigGeneral.throttle_time)
1008    {
1009 <    ip_found->last_attempt = CurrentTime;
1010 <    return TOO_FAST;
1009 >    if (ip_found->connection_count >= ConfigGeneral.throttle_count)
1010 >      return TOO_FAST;
1011 >
1012 >    ++ip_found->connection_count;
1013    }
1014 +  else
1015 +    ip_found->connection_count = 1;
1016  
1017    ip_found->last_attempt = CurrentTime;
1018    return 0;
1019   }
1020  
1291 /* cleanup_tklines()
1292 *
1293 * inputs       - NONE
1294 * output       - NONE
1295 * side effects - call function to expire temporary k/d lines
1296 *                This is an event started off in ircd.c
1297 */
1298 void
1299 cleanup_tklines(void *notused)
1300 {
1301  hostmask_expire_temporary();
1302  expire_tklines(&xconf_items);
1303  expire_tklines(&nresv_items);
1304  expire_tklines(&cresv_items);
1305 }
1306
1021   /* expire_tklines()
1022   *
1023   * inputs       - tkline list pointer
# Line 1311 | Line 1025 | cleanup_tklines(void *notused)
1025   * side effects - expire tklines
1026   */
1027   static void
1028 < expire_tklines(dlink_list *tklist)
1028 > expire_tklines(dlink_list *list)
1029   {
1030 <  dlink_node *ptr;
1317 <  dlink_node *next_ptr;
1318 <  struct MaskItem *conf;
1030 >  dlink_node *node = NULL, *node_next = NULL;
1031  
1032 <  DLINK_FOREACH_SAFE(ptr, next_ptr, tklist->head)
1032 >  DLINK_FOREACH_SAFE(node, node_next, list->head)
1033    {
1034 <    conf = ptr->data;
1034 >    struct MaskItem *conf = node->data;
1035  
1036      if (!conf->until || conf->until > CurrentTime)
1037        continue;
1038  
1039      if (conf->type == CONF_XLINE)
1040      {
1041 <      if (ConfigFileEntry.tkline_expire_notices)
1041 >      if (ConfigGeneral.tkline_expire_notices)
1042          sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1043 <                               "Temporary X-line for [%s] expired", conf->name);
1043 >                             "Temporary X-line for [%s] expired", conf->name);
1044        conf_free(conf);
1045      }
1046      else if (conf->type == CONF_NRESV || conf->type == CONF_CRESV)
1047      {
1048 <      if (ConfigFileEntry.tkline_expire_notices)
1048 >      if (ConfigGeneral.tkline_expire_notices)
1049          sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1050 <                               "Temporary RESV for [%s] expired", conf->name);
1050 >                             "Temporary RESV for [%s] expired", conf->name);
1051        conf_free(conf);
1052      }
1053    }
1054   }
1055  
1056 + /* cleanup_tklines()
1057 + *
1058 + * inputs       - NONE
1059 + * output       - NONE
1060 + * side effects - call function to expire temporary k/d lines
1061 + *                This is an event started off in ircd.c
1062 + */
1063 + void
1064 + cleanup_tklines(void *unused)
1065 + {
1066 +  hostmask_expire_temporary();
1067 +  expire_tklines(&xconf_items);
1068 +  expire_tklines(&nresv_items);
1069 +  expire_tklines(&cresv_items);
1070 + }
1071 +
1072   /* oper_privs_as_string()
1073   *
1074   * inputs        - pointer to client_p
# Line 1355 | Line 1083 | static const struct oper_privs
1083    { OPER_FLAG_ADMIN,          'A' },
1084    { OPER_FLAG_REMOTEBAN,      'B' },
1085    { OPER_FLAG_DIE,            'D' },
1358  { OPER_FLAG_GLINE,          'G' },
1086    { OPER_FLAG_REHASH,         'H' },
1087 <  { OPER_FLAG_K,              'K' },
1361 <  { OPER_FLAG_OPERWALL,       'L' },
1087 >  { OPER_FLAG_KLINE,          'K' },
1088    { OPER_FLAG_KILL,           'N' },
1089    { OPER_FLAG_KILL_REMOTE,    'O' },
1090    { OPER_FLAG_CONNECT,        'P' },
# Line 1370 | Line 1096 | static const struct oper_privs
1096    { 0, '\0' }
1097   };
1098  
1099 < char *
1099 > const char *
1100   oper_privs_as_string(const unsigned int port)
1101   {
1102    static char privs_out[IRCD_BUFSIZE];
1103    char *privs_ptr = privs_out;
1378  const struct oper_privs *opriv = flag_list;
1104  
1105 <  for (; opriv->flag; ++opriv)
1105 >  for (const struct oper_privs *opriv = flag_list; opriv->flag; ++opriv)
1106    {
1107      if (port & opriv->flag)
1108        *privs_ptr++ = opriv->c;
# Line 1391 | Line 1116 | oper_privs_as_string(const unsigned int
1116   }
1117  
1118   /*
1119 < * Input: A client to find the active oper{} name for.
1119 > * Input: A client to find the active operator {} name for.
1120   * Output: The nick!user@host{oper} of the oper.
1121   *         "oper" is server name for remote opers
1122   * Side effects: None.
# Line 1399 | Line 1124 | oper_privs_as_string(const unsigned int
1124   const char *
1125   get_oper_name(const struct Client *client_p)
1126   {
1127 <  const dlink_node *cnode = NULL;
1128 <  /* +5 for !,@,{,} and null */
1129 <  static char buffer[NICKLEN + USERLEN + HOSTLEN + HOSTLEN + 5];
1127 >  static char buffer[IRCD_BUFSIZE];
1128 >
1129 >  if (IsServer(client_p))
1130 >    return client_p->name;
1131  
1132    if (MyConnect(client_p))
1133    {
1134 <    if ((cnode = client_p->localClient->confs.head))
1134 >    const dlink_node *const node = client_p->connection->confs.head;
1135 >
1136 >    if (node)
1137      {
1138 <      const struct MaskItem *conf = cnode->data;
1138 >      const struct MaskItem *const conf = node->data;
1139  
1140 <      if (IsConfOperator(conf))
1140 >      if (conf->type == CONF_OPER)
1141        {
1142          snprintf(buffer, sizeof(buffer), "%s!%s@%s{%s}", client_p->name,
1143                   client_p->username, client_p->host, conf->name);
# Line 1417 | Line 1145 | get_oper_name(const struct Client *clien
1145        }
1146      }
1147  
1148 <    /* Probably should assert here for now. If there is an oper out there
1149 <     * with no oper{} conf attached, it would be good for us to know...
1148 >    /*
1149 >     * Probably should assert here for now. If there is an oper out there
1150 >     * with no operator {} conf attached, it would be good for us to know...
1151       */
1152 <    assert(0); /* Oper without oper conf! */
1152 >    assert(0);  /* Oper without oper conf! */
1153    }
1154  
1155    snprintf(buffer, sizeof(buffer), "%s!%s@%s{%s}", client_p->name,
# Line 1428 | Line 1157 | get_oper_name(const struct Client *clien
1157    return buffer;
1158   }
1159  
1431 /* read_conf_files()
1432 *
1433 * inputs       - cold start YES or NO
1434 * output       - none
1435 * side effects - read all conf files needed, ircd.conf kline.conf etc.
1436 */
1437 void
1438 read_conf_files(int cold)
1439 {
1440  const char *filename;
1441  char chanmodes[IRCD_BUFSIZE];
1442  char chanlimit[IRCD_BUFSIZE];
1443
1444  conf_parser_ctx.boot = cold;
1445  filename = ConfigFileEntry.configfile;
1446
1447  /* We need to know the initial filename for the yyerror() to report
1448     FIXME: The full path is in conffilenamebuf first time since we
1449             dont know anything else
1450
1451     - Gozem 2002-07-21
1452  */
1453  strlcpy(conffilebuf, filename, sizeof(conffilebuf));
1454
1455  if ((conf_parser_ctx.conf_file = fopen(filename, "r")) == NULL)
1456  {
1457    if (cold)
1458    {
1459      ilog(LOG_TYPE_IRCD, "Unable to read configuration file '%s': %s",
1460           filename, strerror(errno));
1461      exit(-1);
1462    }
1463    else
1464    {
1465      sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1466                           "Unable to read configuration file '%s': %s",
1467                           filename, strerror(errno));
1468      return;
1469    }
1470  }
1471
1472  if (!cold)
1473    clear_out_old_conf();
1474
1475  read_conf(conf_parser_ctx.conf_file);
1476  fclose(conf_parser_ctx.conf_file);
1477
1478  log_reopen_all();
1479
1480  add_isupport("NICKLEN", NULL, ServerInfo.max_nick_length);
1481  add_isupport("NETWORK", ServerInfo.network_name, -1);
1482
1483  snprintf(chanmodes, sizeof(chanmodes), "beI:%d", ConfigChannel.max_bans);
1484  add_isupport("MAXLIST", chanmodes, -1);
1485  add_isupport("MAXTARGETS", NULL, ConfigFileEntry.max_targets);
1486  add_isupport("CHANTYPES", "#", -1);
1487
1488  snprintf(chanlimit, sizeof(chanlimit), "#:%d",
1489           ConfigChannel.max_chans_per_user);
1490  add_isupport("CHANLIMIT", chanlimit, -1);
1491  snprintf(chanmodes, sizeof(chanmodes), "%s", "beI,k,l,imnprstORS");
1492  add_isupport("CHANNELLEN", NULL, LOCAL_CHANNELLEN);
1493  add_isupport("TOPICLEN", NULL, ServerInfo.max_topic_length);
1494  add_isupport("CHANMODES", chanmodes, -1);
1495
1496  /*
1497   * message_locale may have changed.  rebuild isupport since it relies
1498   * on strlen(form_str(RPL_ISUPPORT))
1499   */
1500  rebuild_isupport_message_line();
1501 }
1502
1160   /* clear_out_old_conf()
1161   *
1162   * inputs       - none
# Line 1509 | Line 1166 | read_conf_files(int cold)
1166   static void
1167   clear_out_old_conf(void)
1168   {
1169 <  dlink_node *ptr = NULL, *next_ptr = NULL;
1513 <  struct MaskItem *conf;
1169 >  dlink_node *node = NULL, *node_next = NULL;
1170    dlink_list *free_items [] = {
1171      &server_items,   &oconf_items,
1172       &uconf_items,   &xconf_items,
# Line 1523 | Line 1179 | clear_out_old_conf(void)
1179     * Resetting structs, etc, is taken care of by set_default_conf().
1180     */
1181  
1182 <  for (; *iterator != NULL; iterator++)
1182 >  for (; *iterator; iterator++)
1183    {
1184 <    DLINK_FOREACH_SAFE(ptr, next_ptr, (*iterator)->head)
1184 >    DLINK_FOREACH_SAFE(node, node_next, (*iterator)->head)
1185      {
1186 <      conf = ptr->data;
1186 >      struct MaskItem *conf = node->data;
1187  
1188 <      dlinkDelete(&conf->node, map_to_list(conf->type));
1188 >      conf->active = 0;
1189 >      dlinkDelete(&conf->node, *iterator);
1190  
1191        /* XXX This is less than pretty */
1192        if (conf->type == CONF_SERVER || conf->type == CONF_OPER)
# Line 1550 | Line 1207 | clear_out_old_conf(void)
1207    motd_clear();
1208  
1209    /*
1210 <   * don't delete the class table, rather mark all entries
1211 <   * for deletion. The table is cleaned up by class_delete_marked. - avalon
1210 >   * Don't delete the class table, rather mark all entries for deletion.
1211 >   * The table is cleaned up by class_delete_marked. - avalon
1212     */
1213    class_mark_for_deletion();
1214  
1215    clear_out_address_conf();
1216  
1217 <  /* clean out module paths */
1217 >  /* Clean out module paths */
1218    mod_clear_paths();
1219  
1220 <  /* clean out ServerInfo */
1221 <  MyFree(ServerInfo.description);
1222 <  ServerInfo.description = NULL;
1223 <  MyFree(ServerInfo.network_name);
1224 <  ServerInfo.network_name = NULL;
1225 <  MyFree(ServerInfo.network_desc);
1226 <  ServerInfo.network_desc = NULL;
1227 <  MyFree(ConfigFileEntry.egdpool_path);
1228 <  ConfigFileEntry.egdpool_path = NULL;
1220 >  pseudo_clear();
1221 >
1222 >  /* Clean out ConfigServerInfo */
1223 >  MyFree(ConfigServerInfo.description);
1224 >  ConfigServerInfo.description = NULL;
1225 >  MyFree(ConfigServerInfo.network_name);
1226 >  ConfigServerInfo.network_name = NULL;
1227 >  MyFree(ConfigServerInfo.network_desc);
1228 >  ConfigServerInfo.network_desc = NULL;
1229   #ifdef HAVE_LIBCRYPTO
1230 <  if (ServerInfo.rsa_private_key != NULL)
1230 >  if (ConfigServerInfo.rsa_private_key)
1231    {
1232 <    RSA_free(ServerInfo.rsa_private_key);
1233 <    ServerInfo.rsa_private_key = NULL;
1232 >    RSA_free(ConfigServerInfo.rsa_private_key);
1233 >    ConfigServerInfo.rsa_private_key = NULL;
1234    }
1235  
1236 <  MyFree(ServerInfo.rsa_private_key_file);
1237 <  ServerInfo.rsa_private_key_file = NULL;
1581 <
1582 <  if (ServerInfo.server_ctx)
1583 <    SSL_CTX_set_options(ServerInfo.server_ctx, SSL_OP_NO_SSLv2|
1584 <                                               SSL_OP_NO_SSLv3|
1585 <                                               SSL_OP_NO_TLSv1);
1586 <  if (ServerInfo.client_ctx)
1587 <    SSL_CTX_set_options(ServerInfo.client_ctx, SSL_OP_NO_SSLv2|
1588 <                                               SSL_OP_NO_SSLv3|
1589 <                                               SSL_OP_NO_TLSv1);
1236 >  MyFree(ConfigServerInfo.rsa_private_key_file);
1237 >  ConfigServerInfo.rsa_private_key_file = NULL;
1238   #endif
1239  
1240 <  /* clean out AdminInfo */
1241 <  MyFree(AdminInfo.name);
1242 <  AdminInfo.name = NULL;
1243 <  MyFree(AdminInfo.email);
1244 <  AdminInfo.email = NULL;
1245 <  MyFree(AdminInfo.description);
1246 <  AdminInfo.description = NULL;
1240 >  /* Clean out ConfigAdminInfo */
1241 >  MyFree(ConfigAdminInfo.name);
1242 >  ConfigAdminInfo.name = NULL;
1243 >  MyFree(ConfigAdminInfo.email);
1244 >  ConfigAdminInfo.email = NULL;
1245 >  MyFree(ConfigAdminInfo.description);
1246 >  ConfigAdminInfo.description = NULL;
1247  
1248 <  /* clean out listeners */
1248 >  /* Clean out listeners */
1249    close_listeners();
1250 + }
1251 +
1252 + /* read_conf_files()
1253 + *
1254 + * inputs       - cold start YES or NO
1255 + * output       - none
1256 + * side effects - read all conf files needed, ircd.conf kline.conf etc.
1257 + */
1258 + void
1259 + read_conf_files(int cold)
1260 + {
1261 +  const char *filename = NULL;
1262 +  char chanmodes[IRCD_BUFSIZE] = "";
1263 +  char chanlimit[IRCD_BUFSIZE] = "";
1264 +
1265 +  conf_parser_ctx.boot = cold;
1266 +  filename = ConfigGeneral.configfile;
1267 +
1268 +  /* We need to know the initial filename for the yyerror() to report
1269 +     FIXME: The full path is in conffilenamebuf first time since we
1270 +             don't know anything else
1271 +
1272 +     - Gozem 2002-07-21
1273 +  */
1274 +  strlcpy(conffilebuf, filename, sizeof(conffilebuf));
1275 +
1276 +  if ((conf_parser_ctx.conf_file = fopen(filename, "r")) == NULL)
1277 +  {
1278 +    if (cold)
1279 +    {
1280 +      ilog(LOG_TYPE_IRCD, "Unable to read configuration file '%s': %s",
1281 +           filename, strerror(errno));
1282 +      exit(-1);
1283 +    }
1284 +    else
1285 +    {
1286 +      sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1287 +                           "Unable to read configuration file '%s': %s",
1288 +                           filename, strerror(errno));
1289 +      return;
1290 +    }
1291 +  }
1292 +
1293 +  if (!cold)
1294 +    clear_out_old_conf();
1295 +
1296 +  read_conf(conf_parser_ctx.conf_file);
1297 +  fclose(conf_parser_ctx.conf_file);
1298  
1299 <  /* clean out general */
1300 <  MyFree(ConfigFileEntry.service_name);
1301 <  ConfigFileEntry.service_name = NULL;
1299 >  log_reopen_all();
1300 >
1301 >  add_isupport("NICKLEN", NULL, ConfigServerInfo.max_nick_length);
1302 >  add_isupport("NETWORK", ConfigServerInfo.network_name, -1);
1303 >
1304 >  snprintf(chanmodes, sizeof(chanmodes), "beI:%d", ConfigChannel.max_bans);
1305 >  add_isupport("MAXLIST", chanmodes, -1);
1306 >  add_isupport("MAXTARGETS", NULL, ConfigGeneral.max_targets);
1307 >  add_isupport("CHANTYPES", "#", -1);
1308 >
1309 >  snprintf(chanlimit, sizeof(chanlimit), "#:%d",
1310 >           ConfigChannel.max_channels);
1311 >  add_isupport("CHANLIMIT", chanlimit, -1);
1312 >  snprintf(chanmodes, sizeof(chanmodes), "%s", "beI,k,l,cimnprstCMORS");
1313 >  add_isupport("CHANNELLEN", NULL, CHANNELLEN);
1314 >  add_isupport("TOPICLEN", NULL, ConfigServerInfo.max_topic_length);
1315 >  add_isupport("CHANMODES", chanmodes, -1);
1316 >
1317 >  /*
1318 >   * message_locale may have changed.  rebuild isupport since it relies
1319 >   * on strlen(form_str(RPL_ISUPPORT))
1320 >   */
1321 >  rebuild_isupport_message_line();
1322   }
1323  
1324   /* conf_add_class_to_conf()
# Line 1612 | Line 1328 | clear_out_old_conf(void)
1328   * side effects - Add a class pointer to a conf
1329   */
1330   void
1331 < conf_add_class_to_conf(struct MaskItem *conf, const char *class_name)
1331 > conf_add_class_to_conf(struct MaskItem *conf, const char *name)
1332   {
1333 <  if (class_name == NULL)
1333 >  if (EmptyString(name) || (conf->class = class_find(name, 1)) == NULL)
1334    {
1335      conf->class = class_default;
1336  
1337 <    if (conf->type == CONF_CLIENT)
1337 >    if (conf->type == CONF_CLIENT || conf->type == CONF_OPER)
1338        sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1339                             "Warning *** Defaulting to default class for %s@%s",
1340                             conf->user, conf->host);
# Line 1627 | Line 1343 | conf_add_class_to_conf(struct MaskItem *
1343                             "Warning *** Defaulting to default class for %s",
1344                             conf->name);
1345    }
1630  else
1631    conf->class = class_find(class_name, 1);
1632
1633  if (conf->class == NULL)
1634  {
1635    if (conf->type == CONF_CLIENT)
1636      sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1637                           "Warning *** Defaulting to default class for %s@%s",
1638                           conf->user, conf->host);
1639    else
1640      sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1641                           "Warning *** Defaulting to default class for %s",
1642                           conf->name);
1643    conf->class = class_default;
1644  }
1346   }
1347  
1348   /* yyerror()
# Line 1707 | Line 1408 | valid_tkline(const char *data, const int
1408  
1409    /*
1410     * In the degenerate case where oper does a /quote kline 0 user@host :reason
1411 <   * i.e. they specifically use 0, I am going to return 1 instead
1412 <   * as a return value of non-zero is used to flag it as a temporary kline
1411 >   * i.e. they specifically use 0, I am going to return 1 instead as a return
1412 >   * value of non-zero is used to flag it as a temporary kline
1413     */
1414    if (result == 0)
1415      result = 1;
# Line 1723 | Line 1424 | valid_tkline(const char *data, const int
1424    if (result > MAX_TDKLINE_TIME)
1425      result = MAX_TDKLINE_TIME;
1426  
1427 <  result = result * 60;  /* turn it into seconds */
1427 >  result = result * 60;  /* Turn it into seconds */
1428  
1429    return result;
1430   }
# Line 1739 | Line 1440 | valid_wild_card_simple(const char *data)
1440   {
1441    const unsigned char *p = (const unsigned char *)data;
1442    unsigned char tmpch = '\0';
1443 <  int nonwild = 0;
1443 >  unsigned int nonwild = 0;
1444  
1445    while ((tmpch = *p++))
1446    {
1447 <    if (tmpch == '\\')
1447 >    if (tmpch == '\\' && *p)
1448      {
1449        ++p;
1450 <      if (++nonwild >= ConfigFileEntry.min_nonwildcard_simple)
1450 >      if (++nonwild >= ConfigGeneral.min_nonwildcard_simple)
1451          return 1;
1452      }
1453      else if (!IsMWildChar(tmpch))
1454      {
1455 <      if (++nonwild >= ConfigFileEntry.min_nonwildcard_simple)
1455 >      if (++nonwild >= ConfigGeneral.min_nonwildcard_simple)
1456          return 1;
1457      }
1458    }
# Line 1768 | Line 1469 | valid_wild_card_simple(const char *data)
1469   * side effects - NOTICE is given to source_p if warn is 1
1470   */
1471   int
1472 < valid_wild_card(struct Client *source_p, int warn, int count, ...)
1472 > valid_wild_card(struct Client *source_p, int count, ...)
1473   {
1474 <  char tmpch;
1475 <  int nonwild = 0;
1474 >  unsigned char tmpch = '\0';
1475 >  unsigned int nonwild = 0;
1476    va_list args;
1477  
1478    /*
# Line 1790 | Line 1491 | valid_wild_card(struct Client *source_p,
1491  
1492    while (count--)
1493    {
1494 <    const char *p = va_arg(args, const char *);
1494 >    const unsigned char *p = va_arg(args, const unsigned char *);
1495      if (p == NULL)
1496        continue;
1497  
# Line 1802 | Line 1503 | valid_wild_card(struct Client *source_p,
1503           * If we find enough non-wild characters, we can
1504           * break - no point in searching further.
1505           */
1506 <        if (++nonwild >= ConfigFileEntry.min_nonwildcard)
1506 >        if (++nonwild >= ConfigGeneral.min_nonwildcard)
1507          {
1508            va_end(args);
1509            return 1;
# Line 1811 | Line 1512 | valid_wild_card(struct Client *source_p,
1512      }
1513    }
1514  
1515 <  if (warn)
1515 >  if (IsClient(source_p))
1516      sendto_one_notice(source_p, &me,
1517 <                      ":Please include at least %d non-wildcard characters with the mask",
1518 <                      ConfigFileEntry.min_nonwildcard);
1517 >                      ":Please include at least %u non-wildcard characters with the mask",
1518 >                      ConfigGeneral.min_nonwildcard);
1519    va_end(args);
1520    return 0;
1521   }
1522  
1523 + /* find_user_host()
1524 + *
1525 + * inputs       - pointer to client placing kline
1526 + *              - pointer to user_host_or_nick
1527 + *              - pointer to user buffer
1528 + *              - pointer to host buffer
1529 + * output       - 0 if not ok to kline, 1 to kline i.e. if valid user host
1530 + * side effects -
1531 + */
1532 + static int
1533 + find_user_host(struct Client *source_p, char *user_host_or_nick,
1534 +               char *luser, char *lhost)
1535 + {
1536 +  struct Client *target_p = NULL;
1537 +  char *hostp = NULL;
1538 +
1539 +  if (lhost == NULL)
1540 +  {
1541 +    strlcpy(luser, user_host_or_nick, USERLEN*4 + 1);
1542 +    return 1;
1543 +  }
1544 +
1545 +  if ((hostp = strchr(user_host_or_nick, '@')) || *user_host_or_nick == '*')
1546 +  {
1547 +    /* Explicit user@host mask given */
1548 +    if (hostp)                            /* I'm a little user@host */
1549 +    {
1550 +      *(hostp++) = '\0';                       /* short and squat */
1551 +
1552 +      if (*user_host_or_nick)
1553 +        strlcpy(luser, user_host_or_nick, USERLEN*4 + 1); /* here is my user */
1554 +      else
1555 +        strcpy(luser, "*");
1556 +
1557 +      if (*hostp)
1558 +        strlcpy(lhost, hostp, HOSTLEN + 1);    /* here is my host */
1559 +      else
1560 +        strcpy(lhost, "*");
1561 +    }
1562 +    else
1563 +    {
1564 +      luser[0] = '*';             /* no @ found, assume its *@somehost */
1565 +      luser[1] = '\0';
1566 +      strlcpy(lhost, user_host_or_nick, HOSTLEN*4 + 1);
1567 +    }
1568 +
1569 +    return 1;
1570 +  }
1571 +  else
1572 +  {
1573 +    /* Try to find user@host mask from nick */
1574 +    /* Okay to use source_p as the first param, because source_p == client_p */
1575 +    if ((target_p =
1576 +        find_chasing(source_p, user_host_or_nick)) == NULL)
1577 +      return 0;  /* find_chasing sends ERR_NOSUCHNICK */
1578 +
1579 +    if (IsExemptKline(target_p))
1580 +    {
1581 +      if (IsClient(source_p))
1582 +        sendto_one_notice(source_p, &me, ":%s is E-lined", target_p->name);
1583 +      return 0;
1584 +    }
1585 +
1586 +    /*
1587 +     * Turn the "user" bit into "*user", blow away '~'
1588 +     * if found in original user name (non-idented)
1589 +     */
1590 +    strlcpy(luser, target_p->username, USERLEN*4 + 1);
1591 +
1592 +    if (target_p->username[0] == '~')
1593 +      luser[0] = '*';
1594 +
1595 +    if (!strcmp(target_p->sockhost, "0"))
1596 +      strlcpy(lhost, target_p->host, HOSTLEN*4 + 1);
1597 +    else
1598 +      strlcpy(lhost, target_p->sockhost, HOSTLEN*4 + 1);
1599 +    return 1;
1600 +  }
1601 +
1602 +  return 0;
1603 + }
1604 +
1605   /* XXX should this go into a separate file ? -Dianora */
1606   /* parse_aline
1607   *
# Line 1833 | Line 1616 | valid_wild_card(struct Client *source_p,
1616   *              - pointer to target_server to parse into if non NULL
1617   *              - pointer to reason to parse into
1618   *
1619 < * output       - 1 if valid, -1 if not valid
1619 > * output       - 1 if valid, 0 if not valid
1620   * side effects - A generalised k/d/x etc. line parser,
1621   *               "ALINE [time] user@host|string [ON] target :reason"
1622   *                will parse returning a parsed user, host if
# Line 1856 | Line 1639 | parse_aline(const char *cmd, struct Clie
1639              char **target_server, char **reason)
1640   {
1641    int found_tkline_time=0;
1642 <  static char def_reason[] = "No Reason";
1642 >  static char def_reason[] = CONF_NOREASON;
1643    static char user[USERLEN*4+1];
1644    static char host[HOSTLEN*4+1];
1645  
# Line 1865 | Line 1648 | parse_aline(const char *cmd, struct Clie
1648  
1649    found_tkline_time = valid_tkline(*parv, TK_MINUTES);
1650  
1651 <  if (found_tkline_time != 0)
1651 >  if (found_tkline_time)
1652    {
1653      parv++;
1654      parc--;
1655  
1656 <    if (tkline_time != NULL)
1656 >    if (tkline_time)
1657        *tkline_time = found_tkline_time;
1658      else
1659      {
1660        sendto_one_notice(source_p, &me, ":temp_line not supported by %s", cmd);
1661 <      return -1;
1661 >      return 0;
1662      }
1663    }
1664  
1665    if (parc == 0)
1666    {
1667      sendto_one_numeric(source_p, &me, ERR_NEEDMOREPARAMS, cmd);
1668 <    return -1;
1668 >    return 0;
1669    }
1670  
1671    if (h_p == NULL)
1672      *up_p = *parv;
1673    else
1674    {
1675 <    if (find_user_host(source_p, *parv, user, host, parse_flags) == 0)
1676 <      return -1;
1675 >    if (find_user_host(source_p, *parv, user, host) == 0)
1676 >      return 0;
1677  
1678      *up_p = user;
1679      *h_p = host;
# Line 1899 | Line 1682 | parse_aline(const char *cmd, struct Clie
1682    parc--;
1683    parv++;
1684  
1685 <  if (parc != 0)
1685 >  if (parc)
1686    {
1687      if (irccmp(*parv, "ON") == 0)
1688      {
# Line 1909 | Line 1692 | parse_aline(const char *cmd, struct Clie
1692        if (target_server == NULL)
1693        {
1694          sendto_one_notice(source_p, &me, ":ON server not supported by %s", cmd);
1695 <        return -1;
1695 >        return 0;
1696        }
1697  
1698        if (!HasOFlag(source_p, OPER_FLAG_REMOTEBAN))
1699        {
1700          sendto_one_numeric(source_p, &me, ERR_NOPRIVS, "remoteban");
1701 <        return -1;
1701 >        return 0;
1702        }
1703  
1704        if (parc == 0 || EmptyString(*parv))
1705        {
1706          sendto_one_numeric(source_p, &me, ERR_NEEDMOREPARAMS, cmd);
1707 <        return -1;
1707 >        return 0;
1708        }
1709  
1710        *target_server = *parv;
# Line 1933 | Line 1716 | parse_aline(const char *cmd, struct Clie
1716        /* Make sure target_server *is* NULL if no ON server found
1717         * caller probably NULL'd it first, but no harm to do it again -db
1718         */
1719 <      if (target_server != NULL)
1719 >      if (target_server)
1720          *target_server = NULL;
1721      }
1722    }
1723  
1724 <  if (h_p != NULL)
1724 >  if (h_p)
1725    {
1726 <    if (strchr(user, '!') != NULL)
1726 >    if (strchr(user, '!'))
1727      {
1728        sendto_one_notice(source_p, &me, ":Invalid character '!' in kline");
1729 <      return -1;
1729 >      return 0;
1730      }
1731  
1732 <    if ((parse_flags & AWILD) && !valid_wild_card(source_p, 1, 2, *up_p, *h_p))
1733 <      return -1;
1732 >    if ((parse_flags & AWILD) && !valid_wild_card(source_p, 2, *up_p, *h_p))
1733 >      return 0;
1734    }
1735    else
1736 <    if ((parse_flags & AWILD) && !valid_wild_card(source_p, 1, 1, *up_p))
1737 <      return -1;
1736 >    if ((parse_flags & AWILD) && !valid_wild_card(source_p, 1, *up_p))
1737 >      return 0;
1738  
1739 <  if (reason != NULL)
1739 >  if (reason)
1740    {
1741 <    if (parc != 0 && !EmptyString(*parv))
1741 >    if (parc && !EmptyString(*parv))
1742      {
1743        *reason = *parv;
1744 +
1745        if (!valid_comment(source_p, *reason, 1))
1746 <        return -1;
1746 >        return 0;
1747      }
1748      else
1749        *reason = def_reason;
# Line 1968 | Line 1752 | parse_aline(const char *cmd, struct Clie
1752    return 1;
1753   }
1754  
1971 /* find_user_host()
1972 *
1973 * inputs       - pointer to client placing kline
1974 *              - pointer to user_host_or_nick
1975 *              - pointer to user buffer
1976 *              - pointer to host buffer
1977 * output       - 0 if not ok to kline, 1 to kline i.e. if valid user host
1978 * side effects -
1979 */
1980 static int
1981 find_user_host(struct Client *source_p, char *user_host_or_nick,
1982               char *luser, char *lhost, unsigned int flags)
1983 {
1984  struct Client *target_p = NULL;
1985  char *hostp = NULL;
1986
1987  if (lhost == NULL)
1988  {
1989    strlcpy(luser, user_host_or_nick, USERLEN*4 + 1);
1990    return 1;
1991  }
1992
1993  if ((hostp = strchr(user_host_or_nick, '@')) || *user_host_or_nick == '*')
1994  {
1995    /* Explicit user@host mask given */
1996
1997    if (hostp != NULL)                            /* I'm a little user@host */
1998    {
1999      *(hostp++) = '\0';                       /* short and squat */
2000      if (*user_host_or_nick)
2001        strlcpy(luser, user_host_or_nick, USERLEN*4 + 1); /* here is my user */
2002      else
2003        strcpy(luser, "*");
2004
2005      if (*hostp)
2006        strlcpy(lhost, hostp, HOSTLEN + 1);    /* here is my host */
2007      else
2008        strcpy(lhost, "*");
2009    }
2010    else
2011    {
2012      luser[0] = '*';             /* no @ found, assume its *@somehost */
2013      luser[1] = '\0';
2014      strlcpy(lhost, user_host_or_nick, HOSTLEN*4 + 1);
2015    }
2016
2017    return 1;
2018  }
2019  else
2020  {
2021    /* Try to find user@host mask from nick */
2022    /* Okay to use source_p as the first param, because source_p == client_p */
2023    if ((target_p =
2024        find_chasing(source_p, user_host_or_nick)) == NULL)
2025      return 0;
2026
2027    if (IsExemptKline(target_p))
2028    {
2029      if (!IsServer(source_p))
2030        sendto_one_notice(source_p, &me, ":%s is E-lined", target_p->name);
2031      return 0;
2032    }
2033
2034    /*
2035     * turn the "user" bit into "*user", blow away '~'
2036     * if found in original user name (non-idented)
2037     */
2038    strlcpy(luser, target_p->username, USERLEN*4 + 1);
2039
2040    if (target_p->username[0] == '~')
2041      luser[0] = '*';
2042
2043    if (target_p->sockhost[0] == '\0' ||
2044        (target_p->sockhost[0] == '0' && target_p->sockhost[1] == '\0'))
2045      strlcpy(lhost, target_p->host, HOSTLEN*4 + 1);
2046    else
2047      strlcpy(lhost, target_p->sockhost, HOSTLEN*4 + 1);
2048    return 1;
2049  }
2050
2051  return 0;
2052 }
2053
1755   /* valid_comment()
1756   *
1757   * inputs       - pointer to client
# Line 2088 | Line 1789 | match_conf_password(const char *password
1789    else
1790      encr = password;
1791  
1792 <  return !strcmp(encr, conf->passwd);
1792 >  return encr && !strcmp(encr, conf->passwd);
1793   }
1794  
1795   /*
# Line 2096 | Line 1797 | match_conf_password(const char *password
1797   *
1798   * inputs       - client sending the cluster
1799   *              - command name "KLINE" "XLINE" etc.
1800 < *              - capab -- CAP_KLN etc. from s_serv.h
1800 > *              - capab -- CAP_KLN etc. from server.h
1801   *              - cluster type -- CLUSTER_KLINE etc. from conf.h
1802   *              - pattern and args to send along
1803   * output       - none
# Line 2104 | Line 1805 | match_conf_password(const char *password
1805   *                along to all servers that match capab and cluster type
1806   */
1807   void
1808 < cluster_a_line(struct Client *source_p, const char *command,
1809 <               int capab, int cluster_type, const char *pattern, ...)
1808 > cluster_a_line(struct Client *source_p, const char *command, unsigned int capab,
1809 >               unsigned int cluster_type, const char *pattern, ...)
1810   {
1811    va_list args;
1812 <  char buffer[IRCD_BUFSIZE];
1813 <  const dlink_node *ptr = NULL;
1812 >  char buffer[IRCD_BUFSIZE] = "";
1813 >  const dlink_node *node = NULL;
1814  
1815    va_start(args, pattern);
1816    vsnprintf(buffer, sizeof(buffer), pattern, args);
1817    va_end(args);
1818  
1819 <  DLINK_FOREACH(ptr, cluster_items.head)
1819 >  DLINK_FOREACH(node, cluster_items.head)
1820    {
1821 <    const struct MaskItem *conf = ptr->data;
1821 >    const struct MaskItem *conf = node->data;
1822  
1823      if (conf->flags & cluster_type)
1824 <      sendto_match_servs(source_p, conf->name, CAP_CLUSTER|capab,
1824 >      sendto_match_servs(source_p, conf->name, CAP_CLUSTER | capab,
1825                           "%s %s %s", command, conf->name, buffer);
1826    }
1827   }
# Line 2160 | Line 1861 | split_nuh(struct split_nuh_item *const i
1861  
1862    if (iptr->nickptr)
1863      strlcpy(iptr->nickptr, "*", iptr->nicksize);
1864 +
1865    if (iptr->userptr)
1866      strlcpy(iptr->userptr, "*", iptr->usersize);
1867 +
1868    if (iptr->hostptr)
1869      strlcpy(iptr->hostptr, "*", iptr->hostsize);
1870  
# Line 2169 | Line 1872 | split_nuh(struct split_nuh_item *const i
1872    {
1873      *p = '\0';
1874  
1875 <    if (iptr->nickptr && *iptr->nuhmask != '\0')
1875 >    if (iptr->nickptr && *iptr->nuhmask)
1876        strlcpy(iptr->nickptr, iptr->nuhmask, iptr->nicksize);
1877  
1878      if ((q = strchr(++p, '@')))
1879      {
1880        *q++ = '\0';
1881  
1882 <      if (*p != '\0')
1882 >      if (*p)
1883          strlcpy(iptr->userptr, p, iptr->usersize);
1884  
1885 <      if (*q != '\0')
1885 >      if (*q)
1886          strlcpy(iptr->hostptr, q, iptr->hostsize);
1887      }
1888      else
1889      {
1890 <      if (*p != '\0')
1890 >      if (*p)
1891          strlcpy(iptr->userptr, p, iptr->usersize);
1892      }
1893    }
# Line 2196 | Line 1899 | split_nuh(struct split_nuh_item *const i
1899        /* if found a @ */
1900        *p++ = '\0';
1901  
1902 <      if (*iptr->nuhmask != '\0')
1902 >      if (*iptr->nuhmask)
1903          strlcpy(iptr->userptr, iptr->nuhmask, iptr->usersize);
1904  
1905 <      if (*p != '\0')
1905 >      if (*p)
1906          strlcpy(iptr->hostptr, p, iptr->hostsize);
1907      }
1908      else
1909      {
1910 <      /* no @ found */
1910 >      /* No @ found */
1911        if (!iptr->nickptr || strpbrk(iptr->nuhmask, ".:"))
1912          strlcpy(iptr->hostptr, iptr->nuhmask, iptr->hostsize);
1913        else

Diff Legend

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