ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/src/user.c
(Generate patch)

Comparing:
ircd-hybrid-7.2/src/s_user.c (file contents), Revision 849 by db, Mon Feb 19 19:41:59 2007 UTC vs.
ircd-hybrid/trunk/src/s_user.c (file contents), Revision 3272 by michael, Sun Apr 6 11:34:14 2014 UTC

# Line 1 | Line 1
1   /*
2 < *  ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3 < *  s_user.c: User related functions.
2 > *  ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3   *
4 < *  Copyright (C) 2002 by the past and present ircd coders, and others.
4 > *  Copyright (c) 1997-2014 ircd-hybrid development team
5   *
6   *  This program is free software; you can redistribute it and/or modify
7   *  it under the terms of the GNU General Public License as published by
# Line 18 | Line 17
17   *  along with this program; if not, write to the Free Software
18   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
19   *  USA
20 < *
21 < *  $Id$
20 > */
21 >
22 > /*! \file s_user.c
23 > * \brief User related functions.
24 > * \version $Id$
25   */
26  
27   #include "stdinc.h"
28 < #include "tools.h"
28 > #include "list.h"
29   #include "s_user.h"
30   #include "s_misc.h"
31   #include "channel.h"
32   #include "channel_mode.h"
33   #include "client.h"
32 – #include "common.h"
33 – #include "fdlist.h"
34   #include "hash.h"
35   #include "irc_string.h"
36 – #include "sprintf_irc.h"
37 – #include "s_bsd.h"
38 – #include "irc_getnameinfo.h"
36   #include "ircd.h"
40 – #include "list.h"
37   #include "listener.h"
38   #include "motd.h"
39   #include "numeric.h"
40 < #include "s_conf.h"
41 < #include "s_log.h"
40 > #include "conf.h"
41 > #include "log.h"
42   #include "s_serv.h"
47 – #include "s_stats.h"
43   #include "send.h"
44   #include "supported.h"
50 – #include "whowas.h"
45   #include "memory.h"
46   #include "packet.h"
47 + #include "rng_mt.h"
48   #include "userhost.h"
54 – #include "hook.h"
49   #include "s_misc.h"
50 < #include "msg.h"
51 < #include "pcre.h"
58 <
59 < int MaxClientCount     = 1;
60 < int MaxConnectionCount = 1;
61 < struct Callback *entering_umode_cb = NULL;
62 < struct Callback *umode_cb = NULL;
63 < struct Callback *uid_get_cb = NULL;
50 > #include "parse.h"
51 > #include "watch.h"
52  
53   static char umode_buffer[IRCD_BUFSIZE];
54 <
67 < static void user_welcome(struct Client *);
68 < static void report_and_set_user_flags(struct Client *, const struct AccessItem *);
69 < static int check_xline(struct Client *);
70 < static void introduce_client(struct Client *, struct Client *);
71 < static void *uid_get(va_list);
54 > static const char *uid_get(void);
55  
56   /* Used for building up the isupport string,
57   * used with init_isupport, add_isupport, delete_isupport
58   */
59 <
77 < struct Isupport
59 > struct Isupport
60   {
61    dlink_node node;
62    char *name;
# Line 82 | Line 64 | struct Isupport
64    int number;
65   };
66  
67 < static dlink_list support_list = { NULL, NULL, 0 };
68 < MessageFile *isupportFile;
67 > static dlink_list support_list;
68 > static dlink_list support_list_lines;
69  
70   /* memory is cheap. map 0-255 to equivalent mode */
71 < unsigned int user_modes[256] =
71 > const unsigned int user_modes[256] =
72   {
73    /* 0x00 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x0F */
74    /* 0x10 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x1F */
# Line 95 | Line 77 | unsigned int user_modes[256] =
77    0,                  /* @ */
78    0,                  /* A */
79    0,                  /* B */
80 <  UMODE_CCONN_FULL,   /* C */
80 >  0,                  /* C */
81    UMODE_DEAF,         /* D */
82    0,                  /* E */
83 <  0,                  /* F */
83 >  UMODE_FARCONNECT,   /* F */
84    UMODE_SOFTCALLERID, /* G */
85 <  0,                  /* H */
85 >  UMODE_HIDDEN,       /* H */
86    0,                  /* I */
87    0,                  /* J */
88    0,                  /* K */
# Line 110 | Line 92 | unsigned int user_modes[256] =
92    0,                  /* O */
93    0,                  /* P */
94    0,                  /* Q */
95 <  0,                  /* R */
96 <  0,                  /* S */
95 >  UMODE_REGONLY,      /* R */
96 >  UMODE_SSL,          /* S */
97    0,                  /* T */
98    0,                  /* U */
99    0,                  /* V */
100 <  0,                  /* W */
100 >  UMODE_WEBIRC,       /* W */
101    0,                  /* X */
102    0,                  /* Y */
103    0,                  /* Z 0x5A */
104 <  0, 0, 0, 0, 0,      /* 0x5F   */
104 >  0, 0, 0, 0, 0,      /* 0x5F   */
105    0,                  /* 0x60   */
106    UMODE_ADMIN,        /* a */
107    UMODE_BOTS,         /* b */
108    UMODE_CCONN,        /* c */
109    UMODE_DEBUG,        /* d */
110 <  0,                  /* e */
110 >  UMODE_EXTERNAL,     /* e */
111    UMODE_FULL,         /* f */
112    UMODE_CALLERID,     /* g */
113    0,                  /* h */
114    UMODE_INVISIBLE,    /* i */
115 <  0,                  /* j */
115 >  UMODE_REJ,          /* j */
116    UMODE_SKILL,        /* k */
117    UMODE_LOCOPS,       /* l */
118    0,                  /* m */
# Line 138 | Line 120 | unsigned int user_modes[256] =
120    UMODE_OPER,         /* o */
121    0,                  /* p */
122    0,                  /* q */
123 <  UMODE_REJ,          /* r */
123 >  UMODE_REGISTERED,   /* r */
124    UMODE_SERVNOTICE,   /* s */
125    0,                  /* t */
126    UMODE_UNAUTH,       /* u */
127    0,                  /* v */
128    UMODE_WALLOP,       /* w */
129 <  UMODE_EXTERNAL,     /* x */
129 >  UMODE_HIDDENHOST,   /* x */
130    UMODE_SPY,          /* y */
131    UMODE_OPERWALL,     /* z      0x7A */
132    0,0,0,0,0,          /* 0x7B - 0x7F */
# Line 165 | Line 147 | assemble_umode_buffer(void)
147    unsigned int idx = 0;
148    char *umode_buffer_ptr = umode_buffer;
149  
150 <  for (; idx < (sizeof(user_modes) / sizeof(int)); ++idx)
150 >  for (; idx < (sizeof(user_modes) / sizeof(user_modes[0])); ++idx)
151      if (user_modes[idx])
152        *umode_buffer_ptr++ = idx;
153  
# Line 179 | Line 161 | assemble_umode_buffer(void)
161   * side effects - display to client user counts etc.
162   */
163   void
164 < show_lusers(struct Client *source_p)
164 > show_lusers(struct Client *source_p)
165   {
166 <  const char *from, *to;
167 <
168 <  if (!MyConnect(source_p) && IsCapable(source_p->from, CAP_TS6) && HasID(source_p))
187 <  {
188 <    from = me.id;
189 <    to = source_p->id;
190 <  }
191 <  else
192 <  {
193 <    from = me.name;
194 <    to = source_p->name;
195 <  }
196 <
197 <  if (!ConfigServerHide.hide_servers || IsOper(source_p))
198 <    sendto_one(source_p, form_str(RPL_LUSERCLIENT),
199 <               from, to, (Count.total-Count.invisi),
200 <               Count.invisi, dlink_list_length(&global_serv_list));
166 >  if (!ConfigServerHide.hide_servers || HasUMode(source_p, UMODE_OPER))
167 >    sendto_one_numeric(source_p, &me, RPL_LUSERCLIENT, (Count.total-Count.invisi),
168 >                       Count.invisi, dlink_list_length(&global_serv_list));
169    else
170 <    sendto_one(source_p, form_str(RPL_LUSERCLIENT), from, to,
171 <               (Count.total-Count.invisi), Count.invisi, 1);
170 >    sendto_one_numeric(source_p, &me, RPL_LUSERCLIENT,
171 >                       (Count.total-Count.invisi), Count.invisi, 1);
172  
173    if (Count.oper > 0)
174 <    sendto_one(source_p, form_str(RPL_LUSEROP),
207 <               from, to, Count.oper);
174 >    sendto_one_numeric(source_p, &me, RPL_LUSEROP, Count.oper);
175  
176    if (dlink_list_length(&unknown_list) > 0)
177 <    sendto_one(source_p, form_str(RPL_LUSERUNKNOWN),
211 <               from, to, dlink_list_length(&unknown_list));
177 >    sendto_one_numeric(source_p, &me, RPL_LUSERUNKNOWN, dlink_list_length(&unknown_list));
178  
179    if (dlink_list_length(&global_channel_list) > 0)
180 <    sendto_one(source_p, form_str(RPL_LUSERCHANNELS),
215 <               from, to, dlink_list_length(&global_channel_list));
180 >    sendto_one_numeric(source_p, &me, RPL_LUSERCHANNELS, dlink_list_length(&global_channel_list));
181  
182 <  if (!ConfigServerHide.hide_servers || IsOper(source_p))
182 >  if (!ConfigServerHide.hide_servers || HasUMode(source_p, UMODE_OPER))
183    {
184 <    sendto_one(source_p, form_str(RPL_LUSERME),
185 <               from, to, Count.local, Count.myserver);
221 <    sendto_one(source_p, form_str(RPL_LOCALUSERS),
222 <               from, to, Count.local, Count.max_loc,
223 <               Count.local, Count.max_loc);
184 >    sendto_one_numeric(source_p, &me, RPL_LUSERME, Count.local, Count.myserver);
185 >    sendto_one_numeric(source_p, &me, RPL_LOCALUSERS, Count.local, Count.max_loc);
186    }
187    else
188    {
189 <    sendto_one(source_p, form_str(RPL_LUSERME),
190 <               from, to, Count.total, 0);
191 <    sendto_one(source_p, form_str(RPL_LOCALUSERS),
192 <               from, to, Count.total, Count.max_tot,
193 <               Count.total, Count.max_tot);
232 <  }
233 <
234 <  sendto_one(source_p, form_str(RPL_GLOBALUSERS),
235 <             from, to, Count.total, Count.max_tot,
236 <             Count.total, Count.max_tot);
237 <
238 <  if (!ConfigServerHide.hide_servers || IsOper(source_p))
239 <    sendto_one(source_p, form_str(RPL_STATSCONN), from, to,
240 <               MaxConnectionCount, MaxClientCount, Count.totalrestartcount);
189 >    sendto_one_numeric(source_p, &me, RPL_LUSERME, Count.total, 0);
190 >    sendto_one_numeric(source_p, &me, RPL_LOCALUSERS, Count.total, Count.max_tot);
191 >  }
192 >
193 >  sendto_one_numeric(source_p, &me, RPL_GLOBALUSERS, Count.total, Count.max_tot);
194  
195 <  if (Count.local > MaxClientCount)
196 <    MaxClientCount = Count.local;
195 >  if (!ConfigServerHide.hide_servers || HasUMode(source_p, UMODE_OPER))
196 >    sendto_one_numeric(source_p, &me, RPL_STATSCONN, Count.max_loc_con,
197 >                       Count.max_loc_cli, Count.totalrestartcount);
198  
199 <  if ((Count.local + Count.myserver) > MaxConnectionCount)
200 <    MaxConnectionCount = Count.local + Count.myserver;
199 >  if (Count.local > Count.max_loc_cli)
200 >    Count.max_loc_cli = Count.local;
201 >
202 >  if ((Count.local + Count.myserver) > Count.max_loc_con)
203 >    Count.max_loc_con = Count.local + Count.myserver;
204   }
205  
206   /* show_isupport()
# Line 253 | Line 210 | show_lusers(struct Client *source_p)
210   * side effects - display to client what we support (for them)
211   */
212   void
213 < show_isupport(struct Client *source_p)
213 > show_isupport(struct Client *source_p)
214   {
215 <  send_message_file(source_p, isupportFile);
215 >  const dlink_node *ptr = NULL;
216 >
217 >  DLINK_FOREACH(ptr, support_list_lines.head)
218 >    sendto_one_numeric(source_p, &me, RPL_ISUPPORT, ptr->data);
219 > }
220 >
221 >
222 > /* report_and_set_user_flags()
223 > *
224 > * inputs       - pointer to source_p
225 > *              - pointer to conf for this user
226 > * output       - NONE
227 > * side effects - Report to user any special flags
228 > *                they are getting, and set them.
229 > */
230 > static void
231 > report_and_set_user_flags(struct Client *source_p, const struct MaskItem *conf)
232 > {
233 >  /* If this user is being spoofed, tell them so */
234 >  if (IsConfDoSpoofIp(conf))
235 >    sendto_one_notice(source_p, &me, ":*** Spoofing your IP. Congrats.");
236 >
237 >  /* If this user is in the exception class, Set it "E lined" */
238 >  if (IsConfExemptKline(conf))
239 >  {
240 >    SetExemptKline(source_p);
241 >    sendto_one_notice(source_p, &me, ":*** You are exempt from K/D/G lines. Congrats.");
242 >  }
243 >
244 >  /*
245 >   * The else here is to make sure that G line exempt users
246 >   * do not get noticed twice.
247 >   */
248 >  else if (IsConfExemptGline(conf))
249 >  {
250 >    SetExemptGline(source_p);
251 >    sendto_one_notice(source_p, &me, ":*** You are exempt from G lines. Congrats.");
252 >  }
253 >
254 >  if (IsConfExemptResv(conf))
255 >  {
256 >    SetExemptResv(source_p);
257 >    sendto_one_notice(source_p, &me, ":*** You are exempt from resvs. Congrats.");
258 >  }
259 >
260 >  /* If this user is exempt from user limits set it "F lined" */
261 >  if (IsConfExemptLimits(conf))
262 >  {
263 >    SetExemptLimits(source_p);
264 >    sendto_one_notice(source_p, &me, ":*** You are exempt from user limits. Congrats.");
265 >  }
266 >
267 >  if (IsConfCanFlood(conf))
268 >  {
269 >    SetCanFlood(source_p);
270 >    sendto_one_notice(source_p, &me, ":*** You are exempt from flood "
271 >                      "protection, aren't you fearsome.");
272 >  }
273 > }
274 >
275 > /* introduce_client()
276 > *
277 > * inputs       - source_p
278 > * output       - NONE
279 > * side effects - This common function introduces a client to the rest
280 > *                of the net, either from a local client connect or
281 > *                from a remote connect.
282 > */
283 > static void
284 > introduce_client(struct Client *source_p)
285 > {
286 >  dlink_node *ptr = NULL;
287 >  char ubuf[IRCD_BUFSIZE] = "";
288 >
289 >  if (MyClient(source_p))
290 >    send_umode(source_p, source_p, 0, SEND_UMODES, ubuf);
291 >  else
292 >    send_umode(NULL, source_p, 0, SEND_UMODES, ubuf);
293 >
294 >  watch_check_hash(source_p, RPL_LOGON);
295 >
296 >  if (ubuf[0] == '\0')
297 >  {
298 >    ubuf[0] = '+';
299 >    ubuf[1] = '\0';
300 >  }
301 >
302 >  DLINK_FOREACH(ptr, serv_list.head)
303 >  {
304 >    struct Client *server = ptr->data;
305 >
306 >    if (server == source_p->from)
307 >      continue;
308 >
309 >    if (IsCapable(server, CAP_SVS))
310 >      sendto_one(server, ":%s UID %s %d %lu %s %s %s %s %s %s :%s",
311 >                 source_p->servptr->id,
312 >                 source_p->name, source_p->hopcount+1,
313 >                 (unsigned long)source_p->tsinfo,
314 >                 ubuf, source_p->username, source_p->host,
315 >                 (MyClient(source_p) && IsIPSpoof(source_p)) ?
316 >                 "0" : source_p->sockhost, source_p->id,
317 >                 source_p->svid,
318 >                 source_p->info);
319 >    else
320 >      sendto_one(server, ":%s UID %s %d %lu %s %s %s %s %s :%s",
321 >                 source_p->servptr->id,
322 >                 source_p->name, source_p->hopcount+1,
323 >                 (unsigned long)source_p->tsinfo,
324 >                 ubuf, source_p->username, source_p->host,
325 >                 (MyClient(source_p) && IsIPSpoof(source_p)) ?
326 >                 "0" : source_p->sockhost, source_p->id, source_p->info);
327 >
328 >    if (!EmptyString(source_p->certfp))
329 >      sendto_one(server, ":%s CERTFP %s", source_p->id, source_p->certfp);
330 >  }
331 > }
332 >
333 > /* user_welcome()
334 > *
335 > * inputs       - client pointer to client to welcome
336 > * output       - NONE
337 > * side effects -
338 > */
339 > static void
340 > user_welcome(struct Client *source_p)
341 > {
342 > #if defined(__TIME__) && defined(__DATE__)
343 >  static const char built_date[] = __DATE__ " at " __TIME__;
344 > #else
345 >  static const char built_date[] = "unknown";
346 > #endif
347 >
348 > #ifdef HAVE_LIBCRYPTO
349 >  if (HasFlag(source_p, FLAGS_SSL))
350 >  {
351 >    AddUMode(source_p, UMODE_SSL);
352 >    sendto_one_notice(source_p, &me, ":*** Connected securely via %s",
353 >                      ssl_get_cipher(source_p->localClient->fd.ssl));
354 >  }
355 > #endif
356 >
357 >  sendto_one_numeric(source_p, &me, RPL_WELCOME, ServerInfo.network_name,
358 >                     source_p->name);
359 >  sendto_one_numeric(source_p, &me, RPL_YOURHOST,
360 >                     get_listener_name(source_p->localClient->listener), ircd_version);
361 >  sendto_one_numeric(source_p, &me, RPL_CREATED, built_date);
362 >  sendto_one_numeric(source_p, &me, RPL_MYINFO, me.name, ircd_version, umode_buffer);
363 >  show_isupport(source_p);
364 >
365 >  if (source_p->id[0])
366 >    sendto_one_numeric(source_p, &me, RPL_YOURID, source_p->id);
367 >
368 >  show_lusers(source_p);
369 >  motd_signon(source_p);
370 > }
371 >
372 > /* check_xline()
373 > *
374 > * inputs       - pointer to client to test
375 > * outupt       - 1 if exiting 0 if ok
376 > * side effects -
377 > */
378 > static int
379 > check_xline(struct Client *source_p)
380 > {
381 >  struct MaskItem *conf = NULL;
382 >  const char *reason = NULL;
383 >
384 >  if ((conf = find_matching_name_conf(CONF_XLINE, source_p->info, NULL, NULL, 0)))
385 >  {
386 >    ++conf->count;
387 >
388 >    if (conf->reason)
389 >      reason = conf->reason;
390 >    else
391 >      reason = CONF_NOREASON;
392 >
393 >    sendto_realops_flags(UMODE_REJ, L_ALL, SEND_NOTICE,
394 >                         "X-line Rejecting [%s] [%s], user %s [%s]",
395 >                         source_p->info, reason,
396 >                         get_client_name(source_p, HIDE_IP),
397 >                         source_p->sockhost);
398 >
399 >    ++ServerStats.is_ref;
400 >    exit_client(source_p, "Bad user info");
401 >    return 1;
402 >  }
403 >
404 >  return 0;
405   }
406  
407   /*
# Line 282 | Line 428 | show_isupport(struct Client *source_p)
428   **         nick from local user or kill him/her...
429   */
430   void
431 < register_local_user(struct Client *client_p, struct Client *source_p,
286 <                    const char *nick, const char *username)
431 > register_local_user(struct Client *source_p)
432   {
433 <  const struct AccessItem *aconf = NULL;
434 <  char ipaddr[HOSTIPLEN];
290 <  dlink_node *ptr = NULL;
291 <  dlink_node *m = NULL;
433 >  const char *id = NULL;
434 >  const struct MaskItem *conf = NULL;
435  
436 <  assert(source_p != NULL);
436 >  assert(source_p == source_p->from);
437    assert(MyConnect(source_p));
295 –  assert(source_p->username != username);
438    assert(!source_p->localClient->registration);
439  
440 <  ClearCap(client_p, CAP_TS6);
440 >  ClearCap(source_p, CAP_TS6);
441  
442    if (ConfigFileEntry.ping_cookie)
443    {
444 <    if (!IsPingSent(source_p) &&
303 <       source_p->localClient->random_ping == 0)
444 >    if (!IsPingSent(source_p) && !source_p->localClient->random_ping)
445      {
446 <      source_p->localClient->random_ping = (unsigned long)rand();
447 <      sendto_one(source_p, "PING :%lu",
446 >      do
447 >        source_p->localClient->random_ping = genrand_int32();
448 >      while (!source_p->localClient->random_ping);
449 >
450 >      sendto_one(source_p, "PING :%u",
451                   source_p->localClient->random_ping);
452        SetPingSent(source_p);
453        return;
# Line 313 | Line 457 | register_local_user(struct Client *clien
457        return;
458    }
459  
460 <  source_p->localClient->last = CurrentTime;
460 >  source_p->localClient->last_privmsg = CurrentTime;
461    /* Straight up the maximum rate of flooding... */
462    source_p->localClient->allow_read = MAX_FLOOD_BURST;
463  
464 <  if (!execute_callback(client_check_cb, source_p, username))
464 >  if (!check_client(source_p))
465      return;
466  
467 <  if (valid_hostname(source_p->host) == 0)
467 >  if (!valid_hostname(source_p->host))
468    {
469 <    sendto_one(source_p, ":%s NOTICE %s :*** Notice -- You have an illegal "
470 <               "character in your hostname", me.name, source_p->name);
469 >    sendto_one_notice(source_p, &me, ":*** Notice -- You have an illegal "
470 >                      "character in your hostname");
471      strlcpy(source_p->host, source_p->sockhost,
472              sizeof(source_p->host));
473    }
474  
475 <  ptr   = source_p->localClient->confs.head;
332 <  aconf = map_to_conf(ptr->data);
475 >  conf = source_p->localClient->confs.head->data;
476  
477    if (!IsGotId(source_p))
478    {
479 <    const char *p = NULL;
479 >    char username[USERLEN + 1] = "";
480 >    const char *p = username;
481      unsigned int i = 0;
482  
483 <    if (IsNeedIdentd(aconf))
483 >    if (IsNeedIdentd(conf))
484      {
485 <      ServerStats->is_ref++;
486 <      sendto_one(source_p, ":%s NOTICE %s :*** Notice -- You need to install "
487 <                 "identd to use this server", me.name, source_p->name);
488 <      exit_client(source_p, &me, "Install identd");
485 >      ++ServerStats.is_ref;
486 >      sendto_one_notice(source_p, &me, ":*** Notice -- You need to install "
487 >                        "identd to use this server");
488 >      exit_client(source_p, "Install identd");
489        return;
490      }
491  
492 <    p = username;
492 >    strlcpy(username, source_p->username, sizeof(username));
493  
494 <    if (!IsNoTilde(aconf))
494 >    if (!IsNoTilde(conf))
495        source_p->username[i++] = '~';
496  
497 <    while (*p && i < USERLEN)
354 <    {
497 >    for (; *p && i < USERLEN; ++p)
498        if (*p != '[')
499          source_p->username[i++] = *p;
357 –      p++;
358 –    }
500  
501      source_p->username[i] = '\0';
502    }
503  
504    /* password check */
505 <  if (!EmptyString(aconf->passwd))
505 >  if (!EmptyString(conf->passwd))
506    {
507      const char *pass = source_p->localClient->passwd;
508  
509 <    if (!match_conf_password(pass, aconf))
509 >    if (!match_conf_password(pass, conf))
510      {
511 <      ServerStats->is_ref++;
512 <      sendto_one(source_p, form_str(ERR_PASSWDMISMATCH),
513 <                 me.name, source_p->name);
514 <      exit_client(source_p, &me, "Bad Password");
511 >      ++ServerStats.is_ref;
512 >
513 >      sendto_one_numeric(source_p, &me, ERR_PASSWDMISMATCH);
514 >      exit_client(source_p, "Bad Password");
515        return;
516      }
517    }
# Line 381 | Line 522 | register_local_user(struct Client *clien
522     */
523  
524    /* report if user has &^>= etc. and set flags as needed in source_p */
525 <  report_and_set_user_flags(source_p, aconf);
525 >  report_and_set_user_flags(source_p, conf);
526 >
527 >  if (IsDead(source_p))
528 >    return;
529  
530    /* Limit clients -
531     * We want to be able to have servers and F-line clients
# Line 394 | Line 538 | register_local_user(struct Client *clien
538    if ((Count.local >= ServerInfo.max_clients + MAX_BUFFER) ||
539        (Count.local >= ServerInfo.max_clients && !IsExemptLimits(source_p)))
540    {
541 <    sendto_realops_flags(UMODE_FULL, L_ALL,
541 >    sendto_realops_flags(UMODE_FULL, L_ALL, SEND_NOTICE,
542                           "Too many clients, rejecting %s[%s].",
543 <                         nick, source_p->host);
544 <    ServerStats->is_ref++;
545 <    exit_client(source_p, &me, "Sorry, server is full - try later");
543 >                         source_p->name, source_p->host);
544 >    ++ServerStats.is_ref;
545 >    exit_client(source_p, "Sorry, server is full - try later");
546      return;
547    }
548  
549    /* valid user name check */
550 <  if (valid_username(source_p->username) == 0)
550 >  if (!valid_username(source_p->username, 1))
551    {
552 <    char tmpstr2[IRCD_BUFSIZE];
552 >    char tmpstr2[IRCD_BUFSIZE] = "";
553  
554 <    sendto_realops_flags(UMODE_REJ, L_ALL, "Invalid username: %s (%s@%s)",
555 <                         nick, source_p->username, source_p->host);
556 <    ServerStats->is_ref++;
557 <    ircsprintf(tmpstr2, "Invalid username [%s]", source_p->username);
558 <    exit_client(source_p, &me, tmpstr2);
554 >    sendto_realops_flags(UMODE_REJ, L_ALL, SEND_NOTICE,
555 >                         "Invalid username: %s (%s@%s)",
556 >                         source_p->name, source_p->username, source_p->host);
557 >    ++ServerStats.is_ref;
558 >    snprintf(tmpstr2, sizeof(tmpstr2), "Invalid username [%s]",
559 >             source_p->username);
560 >    exit_client(source_p, tmpstr2);
561      return;
562    }
563  
418 –  assert(source_p == client_p);
419 –
564    if (check_xline(source_p))
565      return;
566  
567 <  if (IsDead(client_p))
568 <    return;
425 <
426 <  if (me.id[0])
427 <  {
428 <    const char *id = execute_callback(uid_get_cb, source_p);
567 >  while (hash_find_id((id = uid_get())))
568 >    ;
569  
570 <    while (hash_find_id(id) != NULL)
571 <      id = uid_get(NULL);
570 >  strlcpy(source_p->id, id, sizeof(source_p->id));
571 >  hash_add_id(source_p);
572  
573 <    strlcpy(source_p->id, id, sizeof(source_p->id));
574 <    hash_add_id(source_p);
575 <  }
436 <
437 <  irc_getnameinfo((struct sockaddr *)&source_p->localClient->ip,
438 <                  source_p->localClient->ip.ss_len, ipaddr,
439 <                  HOSTIPLEN, NULL, 0, NI_NUMERICHOST);
440 <
441 <  sendto_realops_flags(UMODE_CCONN, L_ALL,
442 <                       "Client connecting: %s (%s@%s) [%s] {%s} [%s]",
443 <                       nick, source_p->username, source_p->host,
573 >  sendto_realops_flags(UMODE_CCONN, L_ALL, SEND_NOTICE,
574 >                       "Client connecting: %s (%s@%s) [%s] {%s} [%s] <%s>",
575 >                       source_p->name, source_p->username, source_p->host,
576                         ConfigFileEntry.hide_spoof_ips && IsIPSpoof(source_p) ?
577 <                       "255.255.255.255" : ipaddr, get_client_class(source_p),
578 <                       source_p->info);
579 <
448 <  sendto_realops_flags(UMODE_CCONN_FULL, L_ALL,
449 <                       "CLICONN %s %s %s %s %s %s %s 0 %s",
450 <                       nick, source_p->username, source_p->host,
451 <                       ConfigFileEntry.hide_spoof_ips && IsIPSpoof(source_p) ?
452 <                       "255.255.255.255" : ipaddr,
453 <                       get_client_class(source_p),
454 <                       ConfigFileEntry.hide_spoof_ips && IsIPSpoof(source_p) ?
455 <                           "<hidden>" : source_p->client_host,
456 <                       ConfigFileEntry.hide_spoof_ips && IsIPSpoof(source_p) ?
457 <                           "<hidden>" : source_p->client_server,
458 <                       source_p->info);
459 <
460 <
461 <  /* If they have died in send_* don't do anything. */
462 <  if (IsDead(source_p))
463 <    return;
577 >                       "255.255.255.255" : source_p->sockhost,
578 >                       get_client_class(&source_p->localClient->confs),
579 >                       source_p->info, source_p->id);
580  
581    if (ConfigFileEntry.invisible_on_connect)
582    {
583 <    source_p->umodes |= UMODE_INVISIBLE;
584 <    Count.invisi++;
583 >    AddUMode(source_p, UMODE_INVISIBLE);
584 >    ++Count.invisi;
585    }
586  
587 <  if ((++Count.local) > Count.max_loc)
587 >  if (++Count.local > Count.max_loc)
588    {
589      Count.max_loc = Count.local;
590  
591      if (!(Count.max_loc % 10))
592 <      sendto_realops_flags(UMODE_ALL, L_ALL, "New Max Local Clients: %d",
592 >      sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
593 >                           "New Max Local Clients: %d",
594                             Count.max_loc);
595    }
596  
480 –  SetClient(source_p);
481 –
482 –  source_p->servptr = &me;
483 –  dlinkAdd(source_p, &source_p->lnode, &source_p->servptr->serv->users);
484 –
597    /* Increment our total user count here */
598    if (++Count.total > Count.max_tot)
599      Count.max_tot = Count.total;
600 <  Count.totalrestartcount++;
600 >  ++Count.totalrestartcount;
601 >
602 >  assert(source_p->servptr == &me);
603 >  SetClient(source_p);
604 >  dlinkAdd(source_p, &source_p->lnode, &source_p->servptr->serv->client_list);
605  
606    source_p->localClient->allow_read = MAX_FLOOD_BURST;
607  
608 <  if ((m = dlinkFindDelete(&unknown_list, source_p)) != NULL)
609 <  {
610 <    free_dlink_node(m);
611 <    dlinkAdd(source_p, &source_p->localClient->lclient_node, &local_client_list);
496 <  }
497 <  else assert(0);
608 >  assert(dlinkFind(&unknown_list, source_p));
609 >
610 >  dlink_move_node(&source_p->localClient->lclient_node,
611 >                  &unknown_list, &local_client_list);
612  
613    user_welcome(source_p);
614    add_user_host(source_p->username, source_p->host, 0);
615    SetUserHost(source_p);
616  
617 <  introduce_client(client_p, source_p);
617 >  introduce_client(source_p);
618   }
619  
620   /* register_remote_user()
621   *
622 < * inputs       - client_p directly connected client
509 < *              - source_p remote or directly connected client
622 > * inputs       - source_p remote or directly connected client
623   *              - username to register as
624   *              - host name to register as
625   *              - server name
513 – *              - realname (gecos)
626   * output       - NONE
627   * side effects - This function is called when a remote client
628   *                is introduced by a server.
629   */
630   void
631 < register_remote_user(struct Client *client_p, struct Client *source_p,
632 <                     const char *username, const char *host, const char *server,
521 <                     const char *realname)
631 > register_remote_user(struct Client *source_p, const char *username,
632 >                     const char *host, const char *server)
633   {
634    struct Client *target_p = NULL;
635  
525 –  assert(source_p != NULL);
636    assert(source_p->username != username);
637  
638 <  strlcpy(source_p->host, host, sizeof(source_p->host));
529 <  strlcpy(source_p->info, realname, sizeof(source_p->info));
638 >  strlcpy(source_p->host, host, sizeof(source_p->host));
639    strlcpy(source_p->username, username, sizeof(source_p->username));
640  
641    /*
642     * coming from another server, take the servers word for it
643     */
644 <  source_p->servptr = find_server(server);
644 >  source_p->servptr = hash_find_server(server);
645  
646 <  /* Super GhostDetect:
646 >  /*
647 >   * Super GhostDetect:
648     * If we can't find the server the user is supposed to be on,
649     * then simply blow the user away.        -Taner
650     */
651    if (source_p->servptr == NULL)
652    {
653 <    sendto_realops_flags(UMODE_ALL, L_ALL,
653 >    sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
654                           "No server %s for user %s[%s@%s] from %s",
655                           server, source_p->name, source_p->username,
656                           source_p->host, source_p->from->name);
657 <    kill_client(client_p, source_p, "%s (Server doesn't exist)", me.name);
657 >    sendto_one(source_p->from,
658 >               ":%s KILL %s :%s (Ghosted, server %s doesn't exist)",
659 >               me.id, source_p->id, me.name, server);
660  
661 <    SetKilled(source_p);
662 <    exit_client(source_p, &me, "Ghosted Client");
661 >    AddFlag(source_p, FLAGS_KILLED);
662 >    exit_client(source_p, "Ghosted Client");
663      return;
664    }
665  
666    if ((target_p = source_p->servptr) && target_p->from != source_p->from)
667    {
668 <    sendto_realops_flags(UMODE_DEBUG, L_ALL,
668 >    sendto_realops_flags(UMODE_DEBUG, L_ALL, SEND_NOTICE,
669                           "Bad User [%s] :%s USER %s@%s %s, != %s[%s]",
670 <                         client_p->name, source_p->name, source_p->username,
670 >                         source_p->from->name, source_p->name, source_p->username,
671                           source_p->host, source_p->servptr->name,
672                           target_p->name, target_p->from->name);
673 <    kill_client(client_p, source_p,
674 <                "%s (NICK from wrong direction (%s != %s))",
675 <                me.name, source_p->servptr->name, target_p->from->name);
676 <    SetKilled(source_p);
677 <    exit_client(source_p, &me, "USER server wrong direction");
673 >    sendto_one(source_p->from,
674 >               ":%s KILL %s :%s (NICK from wrong direction (%s != %s))",
675 >               me.id, source_p->id, me.name, source_p->servptr->name,
676 >               target_p->from->name);
677 >
678 >    AddFlag(source_p, FLAGS_KILLED);
679 >    exit_client(source_p, "USER server wrong direction");
680      return;
681    }
682  
683 +  /*
684 +   * If the nick has been introduced by a services server,
685 +   * make it a service as well.
686 +   */
687 +  if (HasFlag(source_p->servptr, FLAGS_SERVICE))
688 +    AddFlag(source_p, FLAGS_SERVICE);
689 +
690    /* Increment our total user count here */
691    if (++Count.total > Count.max_tot)
692      Count.max_tot = Count.total;
693  
573 –  ++source_p->from->serv->dep_users;
574 –
694    SetClient(source_p);
695 <  dlinkAdd(source_p, &source_p->lnode, &source_p->servptr->serv->users);
695 >  dlinkAdd(source_p, &source_p->lnode, &source_p->servptr->serv->client_list);
696    add_user_host(source_p->username, source_p->host, 1);
697    SetUserHost(source_p);
698  
699 <  introduce_client(client_p, source_p);
700 < }
701 <
702 < /* introduce_client()
703 < *
704 < * inputs       - client_p
586 < *              - source_p
587 < * output       - NONE
588 < * side effects - This common function introduces a client to the rest
589 < *                of the net, either from a local client connect or
590 < *                from a remote connect.
591 < */
592 < static void
593 < introduce_client(struct Client *client_p, struct Client *source_p)
594 < {
595 <  dlink_node *server_node = NULL;
596 <  static char ubuf[12];
597 <
598 <  if (MyClient(source_p))
599 <    send_umode(source_p, source_p, 0, SEND_UMODES, ubuf);
600 <  else
601 <    send_umode(NULL, source_p, 0, SEND_UMODES, ubuf);
602 <
603 <  if (*ubuf == '\0')
604 <  {
605 <    ubuf[0] = '+';
606 <    ubuf[1] = '\0';
607 <  }
699 >  if (HasFlag(source_p->servptr, FLAGS_EOB))
700 >    sendto_realops_flags(UMODE_FARCONNECT, L_ALL, SEND_NOTICE,
701 >                         "Client connecting at %s: %s (%s@%s) [%s] <%s>",
702 >                         source_p->servptr->name,
703 >                         source_p->name, source_p->username, source_p->host,
704 >                         source_p->info, source_p->id);
705  
706 <  /* arghhh one could try not introducing new nicks to ll leafs
610 <   * but then you have to introduce them "on the fly" in SJOIN
611 <   * not fun.
612 <   * Its not going to cost much more bandwidth to simply let new
613 <   * nicks just ride on through.
614 <   */
615 <
616 <  /* We now introduce nicks "on the fly" in SJOIN anyway --
617 <   * you _need_ to if you aren't going to burst everyone initially.
618 <   *
619 <   * Only send to non CAP_LL servers, unless we're a lazylink leaf,
620 <   * in that case just send it to the uplink.
621 <   * -davidt
622 <   * rewritten to cope with SIDs .. eww eww eww --is
623 <   */
624 <  if (!ServerInfo.hub && uplink && IsCapable(uplink, CAP_LL) &&
625 <      client_p != uplink)
626 <  {
627 <    if (IsCapable(uplink, CAP_TS6) && HasID(source_p))
628 <    {
629 <      sendto_one(uplink, ":%s UID %s %d %lu %s %s %s %s %s :%s",
630 <                 source_p->servptr->id,
631 <                 source_p->name, source_p->hopcount+1,
632 <                 (unsigned long)source_p->tsinfo,
633 <                 ubuf, source_p->username, source_p->host,
634 <                 (MyClient(source_p) && IsIPSpoof(source_p)) ?
635 <                 "0" : source_p->sockhost, source_p->id, source_p->info);
636 <    }
637 <    else
638 <    {
639 <      sendto_one(uplink, "NICK %s %d %lu %s %s %s %s :%s",
640 <                 source_p->name, source_p->hopcount+1,
641 <                 (unsigned long)source_p->tsinfo,
642 <                 ubuf, source_p->username, source_p->host,
643 <                 source_p->servptr->name, source_p->info);
644 <    }
645 <  }
646 <  else
647 <  {
648 <    DLINK_FOREACH(server_node, serv_list.head)
649 <    {
650 <      struct Client *server = server_node->data;
651 <
652 <      if (IsCapable(server, CAP_LL) || server == client_p)
653 <        continue;
654 <
655 <      if (IsCapable(server, CAP_TS6) && HasID(source_p))
656 <        sendto_one(server, ":%s UID %s %d %lu %s %s %s %s %s :%s",
657 <                   source_p->servptr->id,
658 <                   source_p->name, source_p->hopcount+1,
659 <                   (unsigned long)source_p->tsinfo,
660 <                   ubuf, source_p->username, source_p->host,
661 <                   (MyClient(source_p) && IsIPSpoof(source_p)) ?
662 <                   "0" : source_p->sockhost, source_p->id, source_p->info);
663 <      else
664 <        sendto_one(server, "NICK %s %d %lu %s %s %s %s :%s",
665 <                   source_p->name, source_p->hopcount+1,
666 <                   (unsigned long)source_p->tsinfo,
667 <                   ubuf, source_p->username, source_p->host,
668 <                   source_p->servptr->name, source_p->info);
669 <    }
670 <  }
706 >  introduce_client(source_p);
707   }
708  
709   /* valid_hostname()
# Line 684 | Line 720 | valid_hostname(const char *hostname)
720   {
721    const char *p = hostname;
722  
723 <  assert(p != NULL);
723 >  assert(p);
724  
725 <  if ('.' == *p || ':' == *p)
725 >  if (EmptyString(p) || *p == '.' || *p == ':')
726      return 0;
727  
728 <  while (*p)
693 <  {
728 >  for (; *p; ++p)
729      if (!IsHostChar(*p))
730        return 0;
696 –    p++;
697 –  }
731  
732 <  return 1;
732 >  return p - hostname <= HOSTLEN;
733   }
734  
735   /* valid_username()
# Line 711 | Line 744 | valid_hostname(const char *hostname)
744   * style of username
745   */
746   int
747 < valid_username(const char *username)
747 > valid_username(const char *username, const int local)
748   {
749    int dots      = 0;
750    const char *p = username;
751  
752 <  assert(p != NULL);
752 >  assert(p);
753  
754 <  if ('~' == *p)
754 >  if (*p == '~')
755      ++p;
756  
757 <  /* reject usernames that don't start with an alphanum
757 >  /*
758 >   * Reject usernames that don't start with an alphanum
759     * i.e. reject jokers who have '-@somehost' or '.@somehost'
760     * or "-hi-@somehost", "h-----@somehost" would still be accepted.
761     */
762    if (!IsAlNum(*p))
763      return 0;
764  
765 <  while (*++p)
765 >  if (local)
766    {
767 <    if ((*p == '.') && ConfigFileEntry.dots_in_ident)
767 >    while (*++p)
768      {
769 <      dots++;
770 <
771 <      if (dots > ConfigFileEntry.dots_in_ident)
772 <        return 0;
773 <      if (!IsUserChar(p[1]))
769 >      if ((*p == '.') && ConfigFileEntry.dots_in_ident)
770 >      {
771 >        if (++dots > ConfigFileEntry.dots_in_ident)
772 >          return 0;
773 >        if (!IsUserChar(*(p + 1)))
774 >          return 0;
775 >      }
776 >      else if (!IsUserChar(*p))
777          return 0;
778      }
742 –    else if (!IsUserChar(*p))
743 –      return 0;
744 –  }
745 –
746 –  return 1;
747 – }
748 –
749 – /* report_and_set_user_flags()
750 – *
751 – * inputs       - pointer to source_p
752 – *              - pointer to aconf for this user
753 – * output       - NONE
754 – * side effects - Report to user any special flags
755 – *                they are getting, and set them.
756 – */
757 – static void
758 – report_and_set_user_flags(struct Client *source_p, const struct AccessItem *aconf)
759 – {
760 –  /* If this user is being spoofed, tell them so */
761 –  if (IsConfDoSpoofIp(aconf))
762 –  {
763 –    sendto_one(source_p,
764 –               ":%s NOTICE %s :*** Spoofing your IP. congrats.",
765 –               me.name, source_p->name);
766 –  }
767 –
768 –  /* If this user is in the exception class, Set it "E lined" */
769 –  if (IsConfExemptKline(aconf))
770 –  {
771 –    SetExemptKline(source_p);
772 –    sendto_one(source_p,
773 –               ":%s NOTICE %s :*** You are exempt from K/D/G lines. congrats.",
774 –               me.name, source_p->name);
775 –  }
776 –
777 –  /* The else here is to make sure that G line exempt users
778 –   * do not get noticed twice.
779 –   */
780 –  else if (IsConfExemptGline(aconf))
781 –  {
782 –    SetExemptGline(source_p);
783 –    sendto_one(source_p, ":%s NOTICE %s :*** You are exempt from G lines.",
784 –               me.name, source_p->name);
785 –  }
786 –
787 –  if (IsConfExemptResv(aconf))
788 –  {
789 –    SetExemptResv(source_p);
790 –    sendto_one(source_p, ":%s NOTICE %s :*** You are exempt from resvs.",
791 –               me.name, source_p->name);
779    }
780 <
794 <  /* If this user is exempt from user limits set it "F lined" */
795 <  if (IsConfExemptLimits(aconf))
796 <  {
797 <    SetExemptLimits(source_p);
798 <    sendto_one(source_p,
799 <               ":%s NOTICE %s :*** You are exempt from user limits. congrats.",
800 <               me.name,source_p->name);
801 <  }
802 <
803 <  /* If this user is exempt from idle time outs */
804 <  if (IsConfIdlelined(aconf))
780 >  else
781    {
782 <    SetIdlelined(source_p);
783 <    sendto_one(source_p,
784 <               ":%s NOTICE %s :*** You are exempt from idle limits. congrats.",
809 <               me.name, source_p->name);
782 >    while (*++p)
783 >      if (!IsUserChar(*p))
784 >        return 0;
785    }
786  
787 <  if (IsConfCanFlood(aconf))
813 <  {
814 <    SetCanFlood(source_p);
815 <    sendto_one(source_p, ":%s NOTICE %s :*** You are exempt from flood "
816 <               "protection, aren't you fearsome.",
817 <               me.name, source_p->name);
818 <  }
787 >  return  p - username <= USERLEN;;
788   }
789  
790 < /* do_local_user()
790 > /* clean_nick_name()
791   *
792 < * inputs       -
793 < * output       - NONE
794 < * side effects -
792 > * input        - nickname
793 > *              - whether it's a local nick (1) or remote (0)
794 > * output       - none
795 > * side effects - walks through the nickname, returning 0 if erroneous
796   */
797 < void
798 < do_local_user(const char *nick, struct Client *client_p, struct Client *source_p,
829 <              const char *username, const char *host, const char *server,
830 <              const char *realname)
797 > int
798 > valid_nickname(const char *nickname, const int local)
799   {
800 <  assert(source_p != NULL);
801 <  assert(source_p->username != username);
834 <
835 <  if (source_p == NULL)
836 <    return;
800 >  const char *p = nickname;
801 >  assert(nickname && *nickname);
802  
803 <  if (!IsUnknown(source_p))
839 <  {
840 <    sendto_one(source_p, form_str(ERR_ALREADYREGISTRED),
841 <               me.name, nick);
842 <    return;
843 <  }
844 <
845 <  source_p->localClient->registration &= ~REG_NEED_USER;
846 <
847 <  /*
848 <   * don't take the clients word for it, ever
849 <   */
850 <  source_p->servptr = &me;
851 <
852 <  strlcpy(source_p->info, realname, sizeof(source_p->info));
853 <
854 <  /* stash for later */
855 <  strlcpy(source_p->client_host, host, sizeof(source_p->client_host));
856 <  strlcpy(source_p->client_server, server, sizeof(source_p->client_server));
857 <
858 <  if (!IsGotId(source_p))
859 <  {
860 <    /* save the username in the client
861 <     * If you move this you'll break ping cookies..you've been warned
862 <     */
863 <    strlcpy(source_p->username, username, sizeof(source_p->username));
864 <  }
865 <
866 <  if (!source_p->localClient->registration)
867 <    /* NICK already received, now I have USER... */
868 <    register_local_user(client_p, source_p, source_p->name, username);
869 < }
870 <
871 < /* change_simple_umode()
872 < *
873 < * this callback can be hooked to allow special handling of
874 < * certain usermodes
875 < */
876 < static void *
877 < change_simple_umode(va_list args)
878 < {
879 <  struct Client *client_p;
880 <  struct Client *source_p;
881 <  int what;
882 <  unsigned int flag;
803 >  assert(p);
804  
805 <  client_p = va_arg(args, struct Client *);
806 <  source_p = va_arg(args, struct Client *);
807 <  what = va_arg(args, int);
808 <  flag = va_arg(args, unsigned int);
805 >  /* nicks can't start with a digit or - or be 0 length */
806 >  /* This closer duplicates behaviour of hybrid-6 */
807 >  if (*p == '-' || (IsDigit(*p) && local) || *p == '\0')
808 >    return 0;
809  
810 <  if (what == MODE_ADD)
811 <    source_p->umodes |= flag;
812 <  else
892 <    source_p->umodes &= ~flag;
810 >  for (; *p; ++p)
811 >    if (!IsNickChar(*p))
812 >      return 0;
813  
814 <  return NULL;
814 >  return p - nickname <= NICKLEN;
815   }
816  
817   /* set_user_mode()
818   *
819   * added 15/10/91 By Darren Reed.
820 < * parv[0] - sender
820 > * parv[0] - command
821   * parv[1] - username to change mode for
822   * parv[2] - modes to change
823   */
824   void
825 < set_user_mode(struct Client *client_p, struct Client *source_p,
906 <              int parc, char *parv[])
825 > set_user_mode(struct Client *source_p, const int parc, char *parv[])
826   {
827    unsigned int flag, setflags;
828 <  char **p, *m, buf[IRCD_BUFSIZE];
828 >  char **p, *m, buf[IRCD_BUFSIZE] = "";
829    struct Client *target_p;
830    int what = MODE_ADD, badflag = 0, i;
831  
832    assert(!(parc < 2));
833  
834 <  if ((target_p = find_person(client_p, parv[1])) == NULL)
834 >  if ((target_p = find_person(source_p, parv[1])) == NULL)
835    {
836      if (MyConnect(source_p))
837 <      sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL),
919 <                 me.name, source_p->name, parv[1]);
837 >      sendto_one_numeric(source_p, &me, ERR_NOSUCHCHANNEL, parv[1]);
838      return;
839    }
840  
841 <  if (IsServer(source_p))
841 >  if (source_p != target_p)
842    {
843 <     sendto_realops_flags(UMODE_ALL, L_ADMIN, "*** Mode for User %s from %s",
926 <                          parv[1], source_p->name);
927 <     return;
928 <  }
929 <
930 <  if (source_p != target_p || target_p->from != source_p->from)
931 <  {
932 <     sendto_one(source_p, form_str(ERR_USERSDONTMATCH),
933 <                me.name, source_p->name);
843 >     sendto_one_numeric(source_p, &me, ERR_USERSDONTMATCH);
844       return;
845    }
846  
# Line 939 | Line 849 | set_user_mode(struct Client *client_p, s
849      m = buf;
850      *m++ = '+';
851  
852 <    for (i = 0; i < 128; i++)
853 <      if (source_p->umodes & user_modes[i])
852 >    for (i = 0; i < 128; ++i)
853 >      if (HasUMode(source_p, user_modes[i]))
854          *m++ = (char)i;
855      *m = '\0';
856  
857 <    sendto_one(source_p, form_str(RPL_UMODEIS),
948 <               me.name, source_p->name, buf);
857 >    sendto_one_numeric(source_p, &me, RPL_UMODEIS, buf);
858      return;
859    }
860  
952 –  execute_callback(entering_umode_cb, client_p, source_p);
953 –
861    /* find flags already set for user */
862    setflags = source_p->umodes;
863  
864    /* parse mode change string(s) */
865 <  for (p = &parv[2]; p && *p; p++)
865 >  for (p = &parv[2]; p && *p; ++p)
866    {
867 <    for (m = *p; *m; m++)
867 >    for (m = *p; *m; ++m)
868      {
869        switch (*m)
870        {
# Line 970 | Line 877 | set_user_mode(struct Client *client_p, s
877          case 'o':
878            if (what == MODE_ADD)
879            {
880 <            if (IsServer(client_p) && !IsOper(source_p))
880 >            if (!MyConnect(source_p) && !HasUMode(source_p, UMODE_OPER))
881              {
882                ++Count.oper;
883                SetOper(source_p);
# Line 978 | Line 885 | set_user_mode(struct Client *client_p, s
885            }
886            else
887            {
888 <            /* Only decrement the oper counts if an oper to begin with
982 <             * found by Pat Szuta, Perly , perly@xnet.com
983 <             */
984 <            if (!IsOper(source_p))
888 >            if (!HasUMode(source_p, UMODE_OPER))
889                break;
890  
891              ClearOper(source_p);
988 –            source_p->umodes &= ~ConfigFileEntry.oper_only_umodes;
892              Count.oper--;
893  
894              if (MyConnect(source_p))
895              {
896 <              dlink_node *dm;
896 >              dlink_node *ptr = NULL;
897  
898 <              detach_conf(source_p, OPER_TYPE);
899 <              ClearOperFlags(source_p);
898 >              detach_conf(source_p, CONF_OPER);
899 >              ClrOFlag(source_p);
900 >              DelUMode(source_p, ConfigFileEntry.oper_only_umodes);
901  
902 <              if ((dm = dlinkFindDelete(&oper_list, source_p)) != NULL)
903 <                free_dlink_node(dm);
902 >              if ((ptr = dlinkFindDelete(&oper_list, source_p)))
903 >                free_dlink_node(ptr);
904              }
905            }
906  
907            break;
908  
909 <        /* we may not get these,
910 <         * but they shouldnt be in default
911 <         */
912 <        case ' ' :
1009 <        case '\n':
1010 <        case '\r':
1011 <        case '\t':
909 >        case 'S':  /* Only servers may set +S in a burst */
910 >        case 'W':  /* Only servers may set +W in a burst */
911 >        case 'r':  /* Only services may set +r */
912 >        case 'x':  /* Only services may set +x */
913            break;
914  
915          default:
916            if ((flag = user_modes[(unsigned char)*m]))
917            {
918 <            if (MyConnect(source_p) && !IsOper(source_p) &&
918 >            if (MyConnect(source_p) && !HasUMode(source_p, UMODE_OPER) &&
919                  (ConfigFileEntry.oper_only_umodes & flag))
1019 –            {
920                badflag = 1;
1021 –            }
921              else
922 <              execute_callback(umode_cb, client_p, source_p, what, flag);
923 <          }
924 <          else
925 <          {
926 <            if (MyConnect(source_p))
927 <              badflag = 1;
922 >            {
923 >              if (what == MODE_ADD)
924 >                AddUMode(source_p, flag);
925 >              else
926 >                DelUMode(source_p, flag);
927 >            }
928            }
929 +          else if (MyConnect(source_p))
930 +            badflag = 1;
931  
932            break;
933        }
# Line 1034 | Line 935 | set_user_mode(struct Client *client_p, s
935    }
936  
937    if (badflag)
938 <    sendto_one(source_p, form_str(ERR_UMODEUNKNOWNFLAG),
1038 <               me.name, source_p->name);
938 >    sendto_one_numeric(source_p, &me, ERR_UMODEUNKNOWNFLAG);
939  
940 <  if ((source_p->umodes & UMODE_NCHANGE) && !IsOperN(source_p))
940 >  if (MyConnect(source_p) && HasUMode(source_p, UMODE_ADMIN) &&
941 >      !HasOFlag(source_p, OPER_FLAG_ADMIN))
942    {
943 <    sendto_one(source_p, ":%s NOTICE %s :*** You have no admin flag;",
944 <               me.name, source_p->name);
1044 <    source_p->umodes &= ~UMODE_NCHANGE; /* only tcm's really need this */
943 >    sendto_one_notice(source_p, &me, ":*** You have no admin flag;");
944 >    DelUMode(source_p, UMODE_ADMIN);
945    }
946  
947 <  if (MyConnect(source_p) && (source_p->umodes & UMODE_ADMIN) &&
1048 <      !IsOperAdmin(source_p) && !IsOperHiddenAdmin(source_p))
1049 <  {
1050 <    sendto_one(source_p, ":%s NOTICE %s :*** You have no admin flag;",
1051 <               me.name, source_p->name);
1052 <    source_p->umodes &= ~UMODE_ADMIN;
1053 <  }
1054 <
1055 <  if (!(setflags & UMODE_INVISIBLE) && IsInvisible(source_p))
947 >  if (!(setflags & UMODE_INVISIBLE) && HasUMode(source_p, UMODE_INVISIBLE))
948      ++Count.invisi;
949 <  if ((setflags & UMODE_INVISIBLE) && !IsInvisible(source_p))
949 >  if ((setflags & UMODE_INVISIBLE) && !HasUMode(source_p, UMODE_INVISIBLE))
950      --Count.invisi;
951  
952    /*
953     * compare new flags with old flags and send string which
954     * will cause servers to update correctly.
955     */
956 <  send_umode_out(client_p, source_p, setflags);
956 >  send_umode_out(source_p, source_p, setflags);
957   }
958  
959   /* send_umode()
# Line 1079 | Line 971 | void
971   send_umode(struct Client *client_p, struct Client *source_p,
972             unsigned int old, unsigned int sendmask, char *umode_buf)
973   {
974 +  char *m = umode_buf;
975    int what = 0;
976    unsigned int i;
977    unsigned int flag;
1085 –  char *m = umode_buf;
978  
979    /*
980     * build a string in umode_buf to represent the change in the user's
981     * mode between the new (source_p->umodes) and 'old'.
982     */
983 <  for (i = 0; i < 128; i++)
983 >  for (i = 0; i < 128; ++i)
984    {
985      flag = user_modes[i];
986      if (!flag)
# Line 1097 | Line 989 | send_umode(struct Client *client_p, stru
989      if (MyClient(source_p) && !(flag & sendmask))
990        continue;
991  
992 <    if ((flag & old) && !(source_p->umodes & flag))
992 >    if ((flag & old) && !HasUMode(source_p, flag))
993      {
994        if (what == MODE_DEL)
995          *m++ = (char)i;
# Line 1108 | Line 1000 | send_umode(struct Client *client_p, stru
1000          *m++ = (char)i;
1001        }
1002      }
1003 <    else if (!(flag & old) && (source_p->umodes & flag))
1003 >    else if (!(flag & old) && HasUMode(source_p, flag))
1004      {
1005        if (what == MODE_ADD)
1006          *m++ = (char)i;
# Line 1139 | Line 1031 | void
1031   send_umode_out(struct Client *client_p, struct Client *source_p,
1032                 unsigned int old)
1033   {
1034 <  char buf[IRCD_BUFSIZE] = { '\0' };
1143 <  dlink_node *ptr = NULL;
1034 >  char buf[IRCD_BUFSIZE] = "";
1035  
1036 <  send_umode(NULL, source_p, old, IsOperHiddenAdmin(source_p) ?
1146 <             SEND_UMODES & ~UMODE_ADMIN : SEND_UMODES, buf);
1036 >  send_umode(NULL, source_p, old, SEND_UMODES, buf);
1037  
1038    if (buf[0])
1039 <  {
1040 <    DLINK_FOREACH(ptr, serv_list.head)
1151 <    {
1152 <      struct Client *target_p = ptr->data;
1153 <
1154 <      if ((target_p != client_p) && (target_p != source_p))
1155 <      {
1156 <        if ((!(ServerInfo.hub && IsCapable(target_p, CAP_LL))) ||
1157 <            (target_p->localClient->serverMask &
1158 <             source_p->lazyLinkClientExists))
1159 <          sendto_one(target_p, ":%s MODE %s :%s",
1160 <                     ID_or_name(source_p, target_p),
1161 <                     ID_or_name(source_p, target_p), buf);
1162 <      }
1163 <    }
1164 <  }
1039 >    sendto_server(source_p, NOCAPS, NOCAPS, ":%s MODE %s :%s",
1040 >                  source_p->id, source_p->id, buf);
1041  
1042    if (client_p && MyClient(client_p))
1043      send_umode(client_p, source_p, old, 0xffffffff, buf);
1044   }
1045  
1046 < /* user_welcome()
1047 < *
1172 < * inputs       - client pointer to client to welcome
1173 < * output       - NONE
1174 < * side effects -
1175 < */
1176 < static void
1177 < user_welcome(struct Client *source_p)
1046 > void
1047 > user_set_hostmask(struct Client *target_p, const char *hostname, const int what)
1048   {
1049 < #if defined(__TIME__) && defined(__DATE__)
1180 <  static const char built_date[] = __DATE__ " at " __TIME__;
1181 < #else
1182 <  static const char built_date[] = "unknown";
1183 < #endif
1049 >  dlink_node *ptr = NULL;
1050  
1051 < #ifdef HAVE_LIBCRYPTO
1052 <  if (source_p->localClient->fd.ssl != NULL)
1187 <    sendto_one(source_p, ":%s NOTICE %s :*** Connected securely via %s",
1188 <               me.name, source_p->name,
1189 <               ssl_get_cipher(source_p->localClient->fd.ssl));
1190 < #endif
1051 >  if (!strcmp(target_p->host, hostname))
1052 >    return;
1053  
1054 <  sendto_one(source_p, form_str(RPL_WELCOME), me.name, source_p->name,
1055 <             ServerInfo.network_name, source_p->name);
1056 <  sendto_one(source_p, form_str(RPL_YOURHOST), me.name, source_p->name,
1057 <             get_listener_name(source_p->localClient->listener), ircd_version);
1058 <  sendto_one(source_p, form_str(RPL_CREATED),
1059 <             me.name, source_p->name, built_date);
1060 <  sendto_one(source_p, form_str(RPL_MYINFO),
1061 <             me.name, source_p->name, me.name, ircd_version, umode_buffer);
1062 <  show_isupport(source_p);
1054 >  switch (what)
1055 >  {
1056 >    case MODE_ADD:
1057 >      AddUMode(target_p, UMODE_HIDDENHOST);
1058 >      AddFlag(target_p, FLAGS_IP_SPOOFING);
1059 >      break;
1060 >    case MODE_DEL:
1061 >      DelUMode(target_p, UMODE_HIDDENHOST);
1062 >
1063 >      if (!HasFlag(target_p, FLAGS_AUTH_SPOOF))
1064 >        DelFlag(target_p, FLAGS_IP_SPOOFING);
1065 >      break;
1066 >    default: return;
1067 >  }
1068  
1069 <  if (source_p->id[0] != '\0')
1070 <    sendto_one(source_p, form_str(RPL_YOURID), me.name,
1071 <               source_p->name, source_p->id);
1069 >  if (ConfigFileEntry.cycle_on_host_change)
1070 >    sendto_common_channels_local(target_p, 0, 0, ":%s!%s@%s QUIT :Changing hostname",
1071 >                                 target_p->name, target_p->username, target_p->host);
1072  
1073 <  show_lusers(source_p);
1073 >  if (IsUserHostIp(target_p))
1074 >    delete_user_host(target_p->username, target_p->host, !MyConnect(target_p));
1075 >
1076 >  strlcpy(target_p->host, hostname, sizeof(target_p->host));
1077  
1078 <  if (ConfigFileEntry.short_motd)
1078 >  add_user_host(target_p->username, target_p->host, !MyConnect(target_p));
1079 >  SetUserHost(target_p);
1080 >
1081 >  if (MyClient(target_p))
1082    {
1083 <    sendto_one(source_p, "NOTICE %s :*** Notice -- motd was last changed at %s",
1084 <               source_p->name, ConfigFileEntry.motd.lastChangedDate);
1212 <    sendto_one(source_p,
1213 <               "NOTICE %s :*** Notice -- Please read the motd if you haven't "
1214 <               "read it", source_p->name);
1215 <    sendto_one(source_p, form_str(RPL_MOTDSTART),
1216 <               me.name, source_p->name, me.name);
1217 <    sendto_one(source_p, form_str(RPL_MOTD),
1218 <               me.name, source_p->name,
1219 <               "*** This is the short motd ***");
1220 <    sendto_one(source_p, form_str(RPL_ENDOFMOTD),
1221 <               me.name, source_p->name);
1083 >    sendto_one_numeric(target_p, &me, RPL_NEWHOSTIS, target_p->host);
1084 >    clear_ban_cache_client(target_p);
1085    }
1223 –  else  
1224 –    send_message_file(source_p, &ConfigFileEntry.motd);
1225 – }
1086  
1087 < /* check_xline()
1088 < *
1229 < * inputs       - pointer to client to test
1230 < * outupt       - 1 if exiting 0 if ok
1231 < * side effects -
1232 < */
1233 < static int
1234 < check_xline(struct Client *source_p)
1235 < {
1236 <  struct ConfItem *conf = NULL;
1237 <  const char *reason = NULL;
1087 >  if (!ConfigFileEntry.cycle_on_host_change)
1088 >    return;
1089  
1090 <  if ((conf = find_matching_name_conf(XLINE_TYPE, source_p->info, NULL, NULL, 0)) ||
1240 <      (conf = find_matching_name_conf(RXLINE_TYPE, source_p->info, NULL, NULL, 0)))
1090 >  DLINK_FOREACH(ptr, target_p->channel.head)
1091    {
1092 <    struct MatchItem *reg = map_to_conf(conf);
1092 >    char modebuf[4], nickbuf[NICKLEN * 3 + 3] = "";
1093 >    char *p = modebuf;
1094 >    int len = 0;
1095 >    const struct Membership *ms = ptr->data;
1096  
1097 <    ++reg->count;
1098 <
1099 <    if (reg->reason != NULL)
1100 <      reason = reg->reason;
1101 <    else
1249 <      reason = "No Reason";
1097 >    if (has_member_flags(ms, CHFL_CHANOP))
1098 >    {
1099 >      *p++ = 'o';
1100 >      len += snprintf(nickbuf + len, sizeof(nickbuf) - len, len ? " %s" : "%s", target_p->name);
1101 >    }
1102  
1103 <    sendto_realops_flags(UMODE_REJ, L_ALL,
1104 <                         "X-line Rejecting [%s] [%s], user %s [%s]",
1105 <                         source_p->info, reason,
1106 <                         get_client_name(source_p, HIDE_IP),
1107 <                         source_p->sockhost);
1103 >    if (has_member_flags(ms, CHFL_HALFOP))
1104 >    {
1105 >      *p++ = 'h';
1106 >      len += snprintf(nickbuf + len, sizeof(nickbuf) - len, len ? " %s" : "%s", target_p->name);
1107 >    }
1108  
1109 <    ServerStats->is_ref++;
1258 <    if (REJECT_HOLD_TIME > 0)
1109 >    if (has_member_flags(ms, CHFL_VOICE))
1110      {
1111 <      sendto_one(source_p, ":%s NOTICE %s :Bad user info",
1112 <                 me.name, source_p->name);
1262 <      source_p->localClient->reject_delay = CurrentTime + REJECT_HOLD_TIME;
1263 <      SetCaptured(source_p);
1111 >      *p++ = 'v';
1112 >      len += snprintf(nickbuf + len, sizeof(nickbuf) - len, len ? " %s" : "%s", target_p->name);
1113      }
1114 <    else
1115 <      exit_client(source_p, &me, "Bad user info");
1116 <    return 1;
1114 >
1115 >    *p = '\0';
1116 >
1117 >    sendto_channel_local_butone(target_p, 0, 0, ms->chptr, ":%s!%s@%s JOIN :%s",
1118 >                                target_p->name, target_p->username, target_p->host,
1119 >                                ms->chptr->chname);
1120 >    if (nickbuf[0])
1121 >      sendto_channel_local_butone(target_p, 0, 0, ms->chptr, ":%s MODE %s +%s %s",
1122 >                                  target_p->servptr->name, ms->chptr->chname,
1123 >                                  modebuf, nickbuf);
1124 >
1125    }
1126  
1127 <  return 0;
1127 >  if (target_p->away[0])
1128 >    sendto_common_channels_local(target_p, 0, CAP_AWAY_NOTIFY,
1129 >                                 ":%s!%s@%s AWAY :%s",
1130 >                                 target_p->name, target_p->username,
1131 >                                 target_p->host, target_p->away);
1132   }
1133  
1134   /* oper_up()
1135   *
1136   * inputs       - pointer to given client to oper
1137   * output       - NONE
1138 < * side effects - Blindly opers up given source_p, using aconf info
1138 > * side effects - Blindly opers up given source_p, using conf info
1139   *                all checks on passwords have already been done.
1140 < *                This could also be used by rsa oper routines.
1140 > *                This could also be used by rsa oper routines.
1141   */
1142   void
1143   oper_up(struct Client *source_p)
1144   {
1145 <  unsigned int old = source_p->umodes;
1146 <  const char *operprivs = "";
1286 <  const struct AccessItem *oconf = NULL;
1145 >  const unsigned int old = source_p->umodes;
1146 >  const struct MaskItem *conf = source_p->localClient->confs.head->data;
1147  
1148    assert(source_p->localClient->confs.head);
1289 –  oconf = map_to_conf((source_p->localClient->confs.head)->data);
1149  
1150    ++Count.oper;
1151    SetOper(source_p);
1152  
1153 <  if (oconf->modes)
1154 <    source_p->umodes |= oconf->modes;
1153 >  if (conf->modes)
1154 >    AddUMode(source_p, conf->modes);
1155    else if (ConfigFileEntry.oper_umodes)
1156 <    source_p->umodes |= ConfigFileEntry.oper_umodes;
1157 <  else
1158 <    source_p->umodes |= (UMODE_SERVNOTICE|UMODE_OPERWALL|
1159 <                         UMODE_WALLOP|UMODE_LOCOPS);
1156 >    AddUMode(source_p, ConfigFileEntry.oper_umodes);
1157 >
1158 >  if (!(old & UMODE_INVISIBLE) && HasUMode(source_p, UMODE_INVISIBLE))
1159 >    ++Count.invisi;
1160 >  if ((old & UMODE_INVISIBLE) && !HasUMode(source_p, UMODE_INVISIBLE))
1161 >    --Count.invisi;
1162  
1163    assert(dlinkFind(&oper_list, source_p) == NULL);
1164    dlinkAdd(source_p, make_dlink_node(), &oper_list);
1165  
1166 <  operprivs = oper_privs_as_string(oconf->port);
1306 <
1307 <  SetOFlag(source_p, oconf->port);
1166 >  AddOFlag(source_p, conf->port);
1167  
1168 <  if (IsOperAdmin(source_p) || IsOperHiddenAdmin(source_p))
1169 <    source_p->umodes |= UMODE_ADMIN;
1311 <  if (!IsOperN(source_p))
1312 <    source_p->umodes &= ~UMODE_NCHANGE;
1168 >  if (HasOFlag(source_p, OPER_FLAG_ADMIN))
1169 >    AddUMode(source_p, UMODE_ADMIN);
1170  
1171 <  sendto_realops_flags(UMODE_ALL, L_ALL, "%s (%s@%s) is now an operator",
1172 <                       source_p->name, source_p->username, source_p->host);
1171 >  sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, "%s is now an operator",
1172 >                       get_oper_name(source_p));
1173    send_umode_out(source_p, source_p, old);
1174 <  sendto_one(source_p, form_str(RPL_YOUREOPER), me.name, source_p->name);
1318 <  sendto_one(source_p, ":%s NOTICE %s :*** Oper privs are %s",
1319 <             me.name, source_p->name, operprivs);
1320 <  send_message_file(source_p, &ConfigFileEntry.opermotd);
1174 >  sendto_one_numeric(source_p, &me, RPL_YOUREOPER);
1175   }
1176  
1177   static char new_uid[TOTALSIDUID + 1];     /* allow for \0 */
# Line 1325 | Line 1179 | static char new_uid[TOTALSIDUID + 1];
1179   int
1180   valid_sid(const char *sid)
1181   {
1328 –
1182    if (strlen(sid) == IRC_MAXSID)
1183      if (IsDigit(*sid))
1184        if (IsAlNum(*(sid + 1)) && IsAlNum(*(sid + 2)))
# Line 1336 | Line 1189 | valid_sid(const char *sid)
1189  
1190   /*
1191   * init_uid()
1192 < *
1192 > *
1193   * inputs       - NONE
1194   * output       - NONE
1195   * side effects - new_uid is filled in with server id portion (sid)
# Line 1346 | Line 1199 | valid_sid(const char *sid)
1199   void
1200   init_uid(void)
1201   {
1349 –  int i;
1350 –
1202    memset(new_uid, 0, sizeof(new_uid));
1203  
1204 <  if (ServerInfo.sid != NULL)
1354 <  {
1204 >  if (!EmptyString(ServerInfo.sid))
1205      strlcpy(new_uid, ServerInfo.sid, sizeof(new_uid));
1356 –    strlcpy(me.id, ServerInfo.sid, sizeof(me.id));
1357 –
1358 –    hash_add_id(&me);
1359 –  }
1206  
1207 <  for (i = 0; i < IRC_MAXSID; i++)
1208 <    if (new_uid[i] == '\0')
1207 >  for (unsigned int i = 0; i < IRC_MAXSID; ++i)
1208 >    if (new_uid[i] == '\0')
1209        new_uid[i] = 'A';
1210  
1211    /* NOTE: if IRC_MAXUID != 6, this will have to be rewritten */
1366 –  /* Yes nenolod, I have known it was off by one ever since I wrote it
1367 –   * But *JUST* for you, though, it really doesn't look as *pretty*
1368 –   * -Dianora
1369 –   */
1212    memcpy(new_uid + IRC_MAXSID, "AAAAA@", IRC_MAXUID);
1371 –
1372 –  entering_umode_cb = register_callback("entering_umode", NULL);
1373 –  umode_cb = register_callback("changing_umode", change_simple_umode);
1374 –  uid_get_cb = register_callback("uid_get", uid_get);
1213   }
1214  
1215   /*
# Line 1414 | Line 1252 | add_one_to_uid(int i)
1252   * output       - new UID is returned to caller
1253   * side effects - new_uid is incremented by one.
1254   */
1255 < static void *
1256 < uid_get(va_list args)
1255 > static const char *
1256 > uid_get(void)
1257   {
1258    add_one_to_uid(TOTALSIDUID - 1);    /* index from 0 */
1259    return new_uid;
# Line 1431 | Line 1269 | uid_get(va_list args)
1269   void
1270   init_isupport(void)
1271   {
1434 –  isupportFile = init_MessageLine();
1435 –
1272    add_isupport("CALLERID", NULL, -1);
1273    add_isupport("CASEMAPPING", CASEMAP, -1);
1274    add_isupport("DEAF", "D", -1);
1275    add_isupport("KICKLEN", NULL, KICKLEN);
1276    add_isupport("MODES", NULL, MAXMODEPARAMS);
1441 –  add_isupport("NICKLEN", NULL, NICKLEN-1);
1277   #ifdef HALFOPS
1278    add_isupport("PREFIX", "(ohv)@%+", -1);
1279    add_isupport("STATUSMSG", "@%+", -1);
# Line 1446 | Line 1281 | init_isupport(void)
1281    add_isupport("PREFIX", "(ov)@+", -1);
1282    add_isupport("STATUSMSG", "@+", -1);
1283   #endif
1284 <  add_isupport("TOPICLEN", NULL, TOPICLEN);
1284 >  add_isupport("EXCEPTS", "e", -1);
1285 >  add_isupport("INVEX", "I", -1);
1286   }
1287  
1288   /*
# Line 1481 | Line 1317 | add_isupport(const char *name, const cha
1317      dlinkAddTail(support, &support->node, &support_list);
1318    }
1319  
1320 <  DupString(support->name, name);
1320 >  support->name = xstrdup(name);
1321    if (options != NULL)
1322 <    DupString(support->options, options);
1322 >    support->options = xstrdup(options);
1323    support->number = n;
1324  
1325    rebuild_isupport_message_line();
# Line 1530 | Line 1366 | rebuild_isupport_message_line(void)
1366   {
1367    char isupportbuffer[IRCD_BUFSIZE];
1368    char *p = isupportbuffer;
1369 <  dlink_node *ptr = NULL;
1369 >  dlink_node *ptr = NULL, *ptr_next = NULL;
1370    int n = 0;
1371    int tokens = 0;
1372    size_t len = 0;
1373 <  size_t reserve = strlen(me.name) + HOSTLEN + strlen(form_str(RPL_ISUPPORT));
1373 >  size_t reserve = strlen(me.name) + HOSTLEN + strlen(numeric_form(RPL_ISUPPORT));
1374  
1375 <  destroy_MessageLine(isupportFile);
1375 >  DLINK_FOREACH_SAFE(ptr, ptr_next, support_list_lines.head)
1376 >  {
1377 >    dlinkDelete(ptr, &support_list_lines);
1378 >    MyFree(ptr->data);
1379 >    free_dlink_node(ptr);
1380 >  }
1381  
1382    DLINK_FOREACH(ptr, support_list.head)
1383    {
1384      struct Isupport *support = ptr->data;
1385  
1386 <    p += (n = ircsprintf(p, "%s", support->name));
1386 >    p += (n = sprintf(p, "%s", support->name));
1387      len += n;
1388  
1389      if (support->options != NULL)
1390      {
1391 <      p += (n = ircsprintf(p, "=%s", support->options));
1391 >      p += (n = sprintf(p, "=%s", support->options));
1392        len += n;
1393      }
1394  
1395      if (support->number > 0)
1396      {
1397 <      p += (n = ircsprintf(p, "=%d", support->number));
1397 >      p += (n = sprintf(p, "=%d", support->number));
1398        len += n;
1399      }
1400  
# Line 1566 | Line 1407 | rebuild_isupport_message_line(void)
1407        if (*--p == ' ')
1408          *p = '\0';
1409  
1410 <      addto_MessageLine(isupportFile, isupportbuffer);
1410 >      dlinkAddTail(xstrdup(isupportbuffer), make_dlink_node(), &support_list_lines);
1411        p = isupportbuffer;
1412        len = 0;
1413        n = tokens = 0;
# Line 1577 | Line 1418 | rebuild_isupport_message_line(void)
1418    {
1419      if (*--p == ' ')
1420        *p = '\0';
1421 <    addto_MessageLine(isupportFile, isupportbuffer);
1421 >    dlinkAddTail(xstrdup(isupportbuffer), make_dlink_node(), &support_list_lines);
1422    }
1423   }

Diff Legend

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