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/src/s_user.c (file contents), Revision 31 by knight, Sun Oct 2 20:34:05 2005 UTC vs.
ircd-hybrid/trunk/src/s_user.c (file contents), Revision 3316 by michael, Tue Apr 15 14:09:39 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 int check_regexp_xline(struct Client *);
71 < static void introduce_client(struct Client *, struct Client *);
72 < 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 <
78 < struct Isupport
59 > struct Isupport
60   {
61    dlink_node node;
62    char *name;
# Line 83 | 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 99 | Line 80 | unsigned int user_modes[256] =
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 111 | 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 139 | 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 166 | 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 180 | 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))
188 <  {
189 <    from = me.id;
190 <    to = source_p->id;
191 <  }
192 <  else
193 <  {
194 <    from = me.name;
195 <    to = source_p->name;
196 <  }
197 <
198 <  if (!ConfigServerHide.hide_servers || IsOper(source_p))
199 <    sendto_one(source_p, form_str(RPL_LUSERCLIENT),
200 <               from, to, (Count.total-Count.invisi),
201 <               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),
208 <               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),
212 <               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),
181 <               from, to,
182 <               dlink_list_length(&global_channel_list));
183 <
184 <  if (!ConfigServerHide.hide_servers || IsOper(source_p))
185 <  {
221 <    sendto_one(source_p, form_str(RPL_LUSERME),
222 <               from, to,
223 <               Count.local, Count.myserver);
224 <    sendto_one(source_p, form_str(RPL_LOCALUSERS),
225 <               from, to, Count.local, Count.max_loc,
226 <               Count.local, Count.max_loc);
180 >    sendto_one_numeric(source_p, &me, RPL_LUSERCHANNELS, dlink_list_length(&global_channel_list));
181 >
182 >  if (!ConfigServerHide.hide_servers || HasUMode(source_p, UMODE_OPER))
183 >  {
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);
235 <  }
236 <
237 <  sendto_one(source_p, form_str(RPL_GLOBALUSERS),
238 <             from, to, Count.total, Count.max_tot,
239 <             Count.total, Count.max_tot);
240 <
241 <  if (!ConfigServerHide.hide_servers || IsOper(source_p))
242 <    sendto_one(source_p, form_str(RPL_STATSCONN), from, to,
243 <               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 256 | 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 >  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 <  send_message_file(source_p, isupportFile);
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   /*
408 < ** register_local_user
409 < **      This function is called when both NICK and USER messages
410 < **      have been accepted for the client, in whatever order. Only
411 < **      after this, is the USER message propagated.
412 < **
413 < **      NICK's must be propagated at once when received, although
414 < **      it would be better to delay them too until full info is
415 < **      available. Doing it is not so simple though, would have
416 < **      to implement the following:
417 < **
418 < **      (actually it has been implemented already for a while) -orabidoo
419 < **
420 < **      1) user telnets in and gives only "NICK foobar" and waits
421 < **      2) another user far away logs in normally with the nick
422 < **         "foobar" (quite legal, as this server didn't propagate
280 < **         it).
281 < **      3) now this server gets nick "foobar" from outside, but
282 < **         has alread the same defined locally. Current server
283 < **         would just issue "KILL foobar" to clean out dups. But,
284 < **         this is not fair. It should actually request another
285 < **         nick from local user or kill him/her...
286 < */
408 > * register_local_user
409 > *      This function is called when both NICK and USER messages
410 > *      have been accepted for the client, in whatever order. Only
411 > *      after this, is the UID message propagated.
412 > *
413 > *      1) user telnets in and gives only "NICK foobar" and waits
414 > *      2) another user far away logs in normally with the nick
415 > *         "foobar" (quite legal, as this server didn't propagate
416 > *         it).
417 > *      3) now this server gets nick "foobar" from outside, but
418 > *         has alread the same defined locally. Current server
419 > *         would just issue "KILL foobar" to clean out dups. But,
420 > *         this is not fair. It should actually request another
421 > *         nick from local user or kill him/her...
422 > */
423   void
424 < register_local_user(struct Client *client_p, struct Client *source_p,
289 <                    const char *nick, const char *username)
424 > register_local_user(struct Client *source_p)
425   {
426 <  const struct AccessItem *aconf = NULL;
427 <  char ipaddr[HOSTIPLEN];
293 <  dlink_node *ptr;
294 <  dlink_node *m;
426 >  const char *id = NULL;
427 >  const struct MaskItem *conf = NULL;
428  
429 <  assert(source_p != NULL);
429 >  assert(source_p == source_p->from);
430    assert(MyConnect(source_p));
431 <  assert(source_p->username != username);
431 >  assert(!source_p->localClient->registration);
432 >
433 >  ClearCap(source_p, CAP_TS6);
434  
435    if (ConfigFileEntry.ping_cookie)
436    {
437 <    if (!IsPingSent(source_p) &&
303 <       source_p->localClient->random_ping == 0)
437 >    if (!IsPingSent(source_p) && !source_p->localClient->random_ping)
438      {
439 <      source_p->localClient->random_ping = (unsigned long)rand();
440 <      sendto_one(source_p, "PING :%lu",
439 >      do
440 >        source_p->localClient->random_ping = genrand_int32();
441 >      while (!source_p->localClient->random_ping);
442 >
443 >      sendto_one(source_p, "PING :%u",
444                   source_p->localClient->random_ping);
445        SetPingSent(source_p);
446        return;
# Line 313 | Line 450 | register_local_user(struct Client *clien
450        return;
451    }
452  
453 <  source_p->localClient->last = CurrentTime;
453 >  source_p->localClient->last_privmsg = CurrentTime;
454    /* Straight up the maximum rate of flooding... */
455    source_p->localClient->allow_read = MAX_FLOOD_BURST;
456  
457 <  if (!execute_callback(client_check_cb, source_p, username))
457 >  if (!check_client(source_p))
458      return;
459  
460 <  if (valid_hostname(source_p->host) == 0)
460 >  if (!valid_hostname(source_p->host))
461    {
462 <    sendto_one(source_p, ":%s NOTICE %s :*** Notice -- You have an illegal "
463 <               "character in your hostname", me.name, source_p->name);
462 >    sendto_one_notice(source_p, &me, ":*** Notice -- You have an illegal "
463 >                      "character in your hostname");
464      strlcpy(source_p->host, source_p->sockhost,
465              sizeof(source_p->host));
466    }
467  
468 <  ptr   = source_p->localClient->confs.head;
332 <  aconf = map_to_conf(ptr->data);
468 >  conf = source_p->localClient->confs.head->data;
469  
470    if (!IsGotId(source_p))
471    {
472 <    const char *p = NULL;
472 >    char username[USERLEN + 1] = "";
473 >    const char *p = username;
474      unsigned int i = 0;
475  
476 <    if (IsNeedIdentd(aconf))
476 >    if (IsNeedIdentd(conf))
477      {
478 <      ServerStats->is_ref++;
479 <      sendto_one(source_p, ":%s NOTICE %s :*** Notice -- You need to install "
480 <                 "identd to use this server", me.name, source_p->name);
481 <      exit_client(source_p, &me, "Install identd");
478 >      ++ServerStats.is_ref;
479 >      sendto_one_notice(source_p, &me, ":*** Notice -- You need to install "
480 >                        "identd to use this server");
481 >      exit_client(source_p, "Install identd");
482        return;
483      }
484  
485 <    p = username;
485 >    strlcpy(username, source_p->username, sizeof(username));
486  
487 <    if (!IsNoTilde(aconf))
487 >    if (!IsNoTilde(conf))
488        source_p->username[i++] = '~';
489  
490 <    while (*p && i < USERLEN)
354 <    {
490 >    for (; *p && i < USERLEN; ++p)
491        if (*p != '[')
492          source_p->username[i++] = *p;
357      p++;
358    }
493  
494      source_p->username[i] = '\0';
495    }
496  
497    /* password check */
498 <  if (!EmptyString(aconf->passwd))
498 >  if (!EmptyString(conf->passwd))
499    {
500      const char *pass = source_p->localClient->passwd;
501  
502 <    if (!match_conf_password(pass, aconf))
502 >    if (!match_conf_password(pass, conf))
503      {
504 <      ServerStats->is_ref++;
505 <      sendto_one(source_p, form_str(ERR_PASSWDMISMATCH),
506 <                 me.name, source_p->name);
507 <      exit_client(source_p, &me, "Bad Password");
504 >      ++ServerStats.is_ref;
505 >
506 >      sendto_one_numeric(source_p, &me, ERR_PASSWDMISMATCH);
507 >      exit_client(source_p, "Bad Password");
508        return;
509      }
510    }
# Line 381 | Line 515 | register_local_user(struct Client *clien
515     */
516  
517    /* report if user has &^>= etc. and set flags as needed in source_p */
518 <  report_and_set_user_flags(source_p, aconf);
518 >  report_and_set_user_flags(source_p, conf);
519 >
520 >  if (IsDead(source_p))
521 >    return;
522  
523    /* Limit clients -
524     * We want to be able to have servers and F-line clients
# Line 394 | Line 531 | register_local_user(struct Client *clien
531    if ((Count.local >= ServerInfo.max_clients + MAX_BUFFER) ||
532        (Count.local >= ServerInfo.max_clients && !IsExemptLimits(source_p)))
533    {
534 <    sendto_realops_flags(UMODE_FULL, L_ALL,
534 >    sendto_realops_flags(UMODE_FULL, L_ALL, SEND_NOTICE,
535                           "Too many clients, rejecting %s[%s].",
536 <                         nick, source_p->host);
537 <    ServerStats->is_ref++;
538 <    exit_client(source_p, &me, "Sorry, server is full - try later");
536 >                         source_p->name, source_p->host);
537 >    ++ServerStats.is_ref;
538 >    exit_client(source_p, "Sorry, server is full - try later");
539      return;
540    }
541  
542    /* valid user name check */
543 <  if (valid_username(source_p->username) == 0)
543 >  if (!valid_username(source_p->username, 1))
544    {
545 <    char tmpstr2[IRCD_BUFSIZE];
545 >    char tmpstr2[IRCD_BUFSIZE] = "";
546  
547 <    sendto_realops_flags(UMODE_REJ, L_ALL, "Invalid username: %s (%s@%s)",
548 <                         nick, source_p->username, source_p->host);
549 <    ServerStats->is_ref++;
550 <    ircsprintf(tmpstr2, "Invalid username [%s]", source_p->username);
551 <    exit_client(source_p, &me, tmpstr2);
547 >    sendto_realops_flags(UMODE_REJ, L_ALL, SEND_NOTICE,
548 >                         "Invalid username: %s (%s@%s)",
549 >                         source_p->name, source_p->username, source_p->host);
550 >    ++ServerStats.is_ref;
551 >    snprintf(tmpstr2, sizeof(tmpstr2), "Invalid username [%s]",
552 >             source_p->username);
553 >    exit_client(source_p, tmpstr2);
554      return;
555    }
556  
557 <  assert(source_p == client_p);
419 <
420 <  /* end of valid user name check */
421 <  if (check_xline(source_p) || check_regexp_xline(source_p))
557 >  if (check_xline(source_p))
558      return;
559  
560 <  if (IsDead(client_p))
561 <    return;
426 <
427 <  if (source_p->id[0] == '\0' && me.id[0])
428 <  {
429 <    char *id = (char *) execute_callback(uid_get_cb, source_p);
430 <    while (hash_find_id(id) != NULL)
431 <      id = uid_get(NULL);
560 >  while (hash_find_id((id = uid_get())))
561 >    ;
562  
563 <    strlcpy(source_p->id, id, sizeof(source_p->id));
564 <    hash_add_id(source_p);
435 <  }
563 >  strlcpy(source_p->id, id, sizeof(source_p->id));
564 >  hash_add_id(source_p);
565  
566 <  irc_getnameinfo((struct sockaddr *)&source_p->localClient->ip,
567 <                  source_p->localClient->ip.ss_len, ipaddr,
568 <                  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,
566 >  sendto_realops_flags(UMODE_CCONN, L_ALL, SEND_NOTICE,
567 >                       "Client connecting: %s (%s@%s) [%s] {%s} [%s] <%s>",
568 >                       source_p->name, source_p->username, source_p->host,
569                         ConfigFileEntry.hide_spoof_ips && IsIPSpoof(source_p) ?
570 <                       "255.255.255.255" : ipaddr, get_client_class(source_p),
571 <                       source_p->info);
572 <
448 <  /* If they have died in send_* don't do anything. */
449 <  if (IsDead(source_p))
450 <    return;
570 >                       "255.255.255.255" : source_p->sockhost,
571 >                       get_client_class(&source_p->localClient->confs),
572 >                       source_p->info, source_p->id);
573  
574    if (ConfigFileEntry.invisible_on_connect)
575 <    source_p->umodes |= UMODE_INVISIBLE;
576 <  Count.invisi++;
575 >  {
576 >    AddUMode(source_p, UMODE_INVISIBLE);
577 >    ++Count.invisi;
578 >  }
579  
580 <  if ((++Count.local) > Count.max_loc)
580 >  if (++Count.local > Count.max_loc)
581    {
582      Count.max_loc = Count.local;
583  
584      if (!(Count.max_loc % 10))
585 <      sendto_realops_flags(UMODE_ALL, L_ALL, "New Max Local Clients: %d",
585 >      sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
586 >                           "New Max Local Clients: %d",
587                             Count.max_loc);
588    }
589  
465  SetClient(source_p);
466
467  source_p->servptr = &me;
468  dlinkAdd(source_p, &source_p->lnode, &source_p->servptr->serv->users);
469
590    /* Increment our total user count here */
591    if (++Count.total > Count.max_tot)
592      Count.max_tot = Count.total;
593 <  Count.totalrestartcount++;
593 >  ++Count.totalrestartcount;
594 >
595 >  assert(source_p->servptr == &me);
596 >  SetClient(source_p);
597 >  dlinkAdd(source_p, &source_p->lnode, &source_p->servptr->serv->client_list);
598  
599    source_p->localClient->allow_read = MAX_FLOOD_BURST;
600  
601 <  if ((m = dlinkFindDelete(&unknown_list, source_p)) != NULL)
602 <  {
603 <    free_dlink_node(m);
604 <    dlinkAdd(source_p, &source_p->localClient->lclient_node, &local_client_list);
481 <  }
482 <  else assert(0);
601 >  assert(dlinkFind(&unknown_list, source_p));
602 >
603 >  dlink_move_node(&source_p->localClient->lclient_node,
604 >                  &unknown_list, &local_client_list);
605  
606    user_welcome(source_p);
607    add_user_host(source_p->username, source_p->host, 0);
608    SetUserHost(source_p);
609  
610 <  introduce_client(client_p, source_p);
610 >  introduce_client(source_p);
611   }
612  
613   /* register_remote_user()
614   *
615 < * inputs       - client_p directly connected client
494 < *              - source_p remote or directly connected client
615 > * inputs       - source_p remote or directly connected client
616   *              - username to register as
617   *              - host name to register as
618   *              - server name
498 *              - realname (gecos)
619   * output       - NONE
620   * side effects - This function is called when a remote client
621   *                is introduced by a server.
622   */
623   void
624 < register_remote_user(struct Client *client_p, struct Client *source_p,
625 <                     const char *username, const char *host, const char *server,
506 <                     const char *realname)
624 > register_remote_user(struct Client *source_p, const char *username,
625 >                     const char *host, const char *server)
626   {
627 <  struct Client *target_p;
627 >  struct Client *target_p = NULL;
628  
510  assert(source_p != NULL);
629    assert(source_p->username != username);
630  
631 <  strlcpy(source_p->host, host, sizeof(source_p->host));
514 <  strlcpy(source_p->info, realname, sizeof(source_p->info));
631 >  strlcpy(source_p->host, host, sizeof(source_p->host));
632    strlcpy(source_p->username, username, sizeof(source_p->username));
633  
517  /* Increment our total user count here */
518  if (++Count.total > Count.max_tot)
519    Count.max_tot = Count.total;
520
521  source_p->from->serv->dep_users++;
522
634    /*
635     * coming from another server, take the servers word for it
636     */
637 <  source_p->servptr = find_server(server);
637 >  source_p->servptr = hash_find_server(server);
638  
639 <  /* Super GhostDetect:
639 >  /*
640 >   * Super GhostDetect:
641     * If we can't find the server the user is supposed to be on,
642     * then simply blow the user away.        -Taner
643     */
644    if (source_p->servptr == NULL)
645    {
646 <    sendto_realops_flags(UMODE_ALL, L_ALL,
646 >    sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
647                           "No server %s for user %s[%s@%s] from %s",
648                           server, source_p->name, source_p->username,
649                           source_p->host, source_p->from->name);
650 <    kill_client(client_p, source_p, "%s (Server doesn't exist)", me.name);
650 >    sendto_one(source_p->from,
651 >               ":%s KILL %s :%s (Ghosted, server %s doesn't exist)",
652 >               me.id, source_p->id, me.name, server);
653  
654 <    /* XXX */
655 <    SetKilled(source_p);
542 <    exit_client(source_p, &me, "Ghosted Client");
654 >    AddFlag(source_p, FLAGS_KILLED);
655 >    exit_client(source_p, "Ghosted Client");
656      return;
657    }
658  
659    if ((target_p = source_p->servptr) && target_p->from != source_p->from)
660    {
661 <    sendto_realops_flags(UMODE_DEBUG, L_ALL,
661 >    sendto_realops_flags(UMODE_DEBUG, L_ALL, SEND_NOTICE,
662                           "Bad User [%s] :%s USER %s@%s %s, != %s[%s]",
663 <                         client_p->name, source_p->name, source_p->username,
663 >                         source_p->from->name, source_p->name, source_p->username,
664                           source_p->host, source_p->servptr->name,
665                           target_p->name, target_p->from->name);
666 <    kill_client(client_p, source_p,
667 <                "%s (NICK from wrong direction (%s != %s))",
668 <                me.name, source_p->servptr->name, target_p->from->name);
669 <    SetKilled(source_p);
557 <    exit_client(source_p, &me, "USER server wrong direction");
558 <    return;
559 <  }
560 <
561 <  SetClient(source_p);
562 <  dlinkAdd(source_p, &source_p->lnode, &source_p->servptr->serv->users);
563 <  add_user_host(source_p->username, source_p->host, 1);
564 <  SetUserHost(source_p);
565 <
566 <  introduce_client(client_p, source_p);
567 < }
568 <
569 < /* introduce_client()
570 < *
571 < * inputs       - client_p
572 < *              - source_p
573 < * output       - NONE
574 < * side effects - This common function introduces a client to the rest
575 < *                of the net, either from a local client connect or
576 < *                from a remote connect.
577 < */
578 < static void
579 < introduce_client(struct Client *client_p, struct Client *source_p)
580 < {
581 <  dlink_node *server_node;
582 <  static char ubuf[12];
666 >    sendto_one(source_p->from,
667 >               ":%s KILL %s :%s (NICK from wrong direction (%s != %s))",
668 >               me.id, source_p->id, me.name, source_p->servptr->name,
669 >               target_p->from->name);
670  
671 <  if (MyClient(source_p))
672 <    send_umode(source_p, source_p, 0, SEND_UMODES, ubuf);
673 <  else
587 <    send_umode(NULL, source_p, 0, SEND_UMODES, ubuf);
588 <
589 <  if (*ubuf == '\0')
590 <  {
591 <    ubuf[0] = '+';
592 <    ubuf[1] = '\0';
671 >    AddFlag(source_p, FLAGS_KILLED);
672 >    exit_client(source_p, "USER server wrong direction");
673 >    return;
674    }
675  
676 <  /* arghhh one could try not introducing new nicks to ll leafs
677 <   * but then you have to introduce them "on the fly" in SJOIN
678 <   * not fun.
598 <   * Its not going to cost much more bandwidth to simply let new
599 <   * nicks just ride on through.
676 >  /*
677 >   * If the nick has been introduced by a services server,
678 >   * make it a service as well.
679     */
680 +  if (HasFlag(source_p->servptr, FLAGS_SERVICE))
681 +    AddFlag(source_p, FLAGS_SERVICE);
682  
683 <  /* We now introduce nicks "on the fly" in SJOIN anyway --
684 <   * you _need_ to if you aren't going to burst everyone initially.
685 <   *
605 <   * Only send to non CAP_LL servers, unless we're a lazylink leaf,
606 <   * in that case just send it to the uplink.
607 <   * -davidt
608 <   * rewritten to cope with SIDs .. eww eww eww --is
609 <   */
683 >  /* Increment our total user count here */
684 >  if (++Count.total > Count.max_tot)
685 >    Count.max_tot = Count.total;
686  
687 <  /* XXX THESE NEED A PREFIX!?!?!? */
688 <  if (!ServerInfo.hub && uplink && IsCapable(uplink, CAP_LL) &&
689 <      client_p != uplink)
690 <  {
615 <    if (IsCapable(uplink, CAP_TS6) && HasID(source_p))
616 <    {
617 <      sendto_one(uplink, ":%s UID %s %d %lu %s %s %s %s %s :%s",
618 <                 source_p->servptr->id,
619 <                 source_p->name, source_p->hopcount+1,
620 <                 (unsigned long)source_p->tsinfo,
621 <                 ubuf, source_p->username, source_p->host,
622 <                 ((MyClient(source_p) && !IsIPSpoof(source_p)) ?
623 <                 source_p->sockhost : "0"),
624 <                 source_p->id, source_p->info);
625 <    }
626 <    else
627 <    {
628 <      sendto_one(uplink, "NICK %s %d %lu %s %s %s %s :%s",
629 <                 source_p->name, source_p->hopcount+1,
630 <                 (unsigned long)source_p->tsinfo,
631 <                 ubuf, source_p->username, source_p->host,
632 <                 source_p->servptr->name,
633 <                 source_p->info);
634 <    }
635 <  }
636 <  else
637 <  {
638 <    DLINK_FOREACH(server_node, serv_list.head)
639 <    {
640 <      struct Client *server = server_node->data;
687 >  SetClient(source_p);
688 >  dlinkAdd(source_p, &source_p->lnode, &source_p->servptr->serv->client_list);
689 >  add_user_host(source_p->username, source_p->host, 1);
690 >  SetUserHost(source_p);
691  
692 <      if (IsCapable(server, CAP_LL) || server == client_p)
693 <        continue;
692 >  if (HasFlag(source_p->servptr, FLAGS_EOB))
693 >    sendto_realops_flags(UMODE_FARCONNECT, L_ALL, SEND_NOTICE,
694 >                         "Client connecting at %s: %s (%s@%s) [%s] <%s>",
695 >                         source_p->servptr->name,
696 >                         source_p->name, source_p->username, source_p->host,
697 >                         source_p->info, source_p->id);
698  
699 <      if (IsCapable(server, CAP_TS6) && HasID(source_p))
646 <        sendto_one(server, ":%s UID %s %d %lu %s %s %s %s %s :%s",
647 <                   source_p->servptr->id,
648 <                   source_p->name, source_p->hopcount+1,
649 <                   (unsigned long)source_p->tsinfo,
650 <                   ubuf, source_p->username, source_p->host,
651 <                   ((MyClient(source_p)&&!IsIPSpoof(source_p))?source_p->sockhost:"0"),
652 <                   source_p->id, source_p->info);
653 <      else
654 <        sendto_one(server, "NICK %s %d %lu %s %s %s %s :%s",
655 <                   source_p->name, source_p->hopcount+1,
656 <                   (unsigned long)source_p->tsinfo,
657 <                   ubuf, source_p->username, source_p->host,
658 <                   source_p->servptr->name,
659 <                   source_p->info);
660 <    }
661 <  }
699 >  introduce_client(source_p);
700   }
701  
702   /* valid_hostname()
# Line 675 | Line 713 | valid_hostname(const char *hostname)
713   {
714    const char *p = hostname;
715  
716 <  assert(p != NULL);
716 >  assert(p);
717  
718 <  if (('.' == *p) || (':' == *p))
719 <    return (0);
718 >  if (EmptyString(p) || *p == '.' || *p == ':')
719 >    return 0;
720  
721 <  while (*p)
684 <  {
721 >  for (; *p; ++p)
722      if (!IsHostChar(*p))
723 <      return (0);
687 <    p++;
688 <  }
723 >      return 0;
724  
725 <  return (1);
725 >  return p - hostname <= HOSTLEN;
726   }
727  
728   /* valid_username()
# Line 702 | Line 737 | valid_hostname(const char *hostname)
737   * style of username
738   */
739   int
740 < valid_username(const char *username)
740 > valid_username(const char *username, const int local)
741   {
742    int dots      = 0;
743    const char *p = username;
744  
745 <  assert(p != NULL);
745 >  assert(p);
746  
747 <  if ('~' == *p)
747 >  if (*p == '~')
748      ++p;
749  
750 <  /* reject usernames that don't start with an alphanum
750 >  /*
751 >   * Reject usernames that don't start with an alphanum
752     * i.e. reject jokers who have '-@somehost' or '.@somehost'
753     * or "-hi-@somehost", "h-----@somehost" would still be accepted.
754     */
755    if (!IsAlNum(*p))
756 <    return (0);
756 >    return 0;
757  
758 <  while (*++p)
758 >  if (local)
759    {
760 <    if ((*p == '.') && ConfigFileEntry.dots_in_ident)
760 >    while (*++p)
761      {
762 <      dots++;
763 <
764 <      if (dots > ConfigFileEntry.dots_in_ident)
765 <        return (0);
766 <      if (!IsUserChar(p[1]))
767 <        return (0);
762 >      if ((*p == '.') && ConfigFileEntry.dots_in_ident)
763 >      {
764 >        if (++dots > ConfigFileEntry.dots_in_ident)
765 >          return 0;
766 >        if (!IsUserChar(*(p + 1)))
767 >          return 0;
768 >      }
769 >      else if (!IsUserChar(*p))
770 >        return 0;
771      }
733    else if (!IsUserChar(*p))
734      return (0);
735  }
736
737  return (1);
738 }
739
740 /* report_and_set_user_flags()
741 *
742 * inputs       - pointer to source_p
743 *              - pointer to aconf for this user
744 * output       - NONE
745 * side effects - Report to user any special flags
746 *                they are getting, and set them.
747 */
748 static void
749 report_and_set_user_flags(struct Client *source_p, const struct AccessItem *aconf)
750 {
751  /* If this user is being spoofed, tell them so */
752  if (IsConfDoSpoofIp(aconf))
753  {
754    sendto_one(source_p,
755               ":%s NOTICE %s :*** Spoofing your IP. congrats.",
756               me.name, source_p->name);
757  }
758
759  /* If this user is in the exception class, Set it "E lined" */
760  if (IsConfExemptKline(aconf))
761  {
762    SetExemptKline(source_p);
763    sendto_one(source_p,
764               ":%s NOTICE %s :*** You are exempt from K/D/G lines. congrats.",
765               me.name, source_p->name);
766  }
767
768  /* The else here is to make sure that G line exempt users
769   * do not get noticed twice.
770   */
771  else if (IsConfExemptGline(aconf))
772  {
773    SetExemptGline(source_p);
774    sendto_one(source_p, ":%s NOTICE %s :*** You are exempt from G lines.",
775               me.name, source_p->name);
772    }
773 <
778 <  if (IsConfExemptResv(aconf))
779 <  {
780 <    SetExemptResv(source_p);
781 <    sendto_one(source_p, ":%s NOTICE %s :*** You are exempt from resvs.",
782 <               me.name, source_p->name);
783 <  }
784 <
785 <  /* If this user is exempt from user limits set it "F lined" */
786 <  if (IsConfExemptLimits(aconf))
787 <  {
788 <    SetExemptLimits(source_p);
789 <    sendto_one(source_p,
790 <               ":%s NOTICE %s :*** You are exempt from user limits. congrats.",
791 <               me.name,source_p->name);
792 <  }
793 <
794 <  /* If this user is exempt from idle time outs */
795 <  if (IsConfIdlelined(aconf))
773 >  else
774    {
775 <    SetIdlelined(source_p);
776 <    sendto_one(source_p,
777 <               ":%s NOTICE %s :*** You are exempt from idle limits. congrats.",
800 <               me.name, source_p->name);
775 >    while (*++p)
776 >      if (!IsUserChar(*p))
777 >        return 0;
778    }
779  
780 <  if (IsConfCanFlood(aconf))
804 <  {
805 <    SetCanFlood(source_p);
806 <    sendto_one(source_p, ":%s NOTICE %s :*** You are exempt from flood "
807 <               "protection, aren't you fearsome.",
808 <               me.name, source_p->name);
809 <  }
780 >  return  p - username <= USERLEN;;
781   }
782  
783 < /* do_local_user()
783 > /* clean_nick_name()
784   *
785 < * inputs       -
786 < * output       - NONE
787 < * side effects -
785 > * input        - nickname
786 > *              - whether it's a local nick (1) or remote (0)
787 > * output       - none
788 > * side effects - walks through the nickname, returning 0 if erroneous
789   */
790 < void
791 < do_local_user(const char *nick, struct Client *client_p, struct Client *source_p,
820 <              const char *username, const char *host, const char *server,
821 <              const char *realname)
790 > int
791 > valid_nickname(const char *nickname, const int local)
792   {
793 <  assert(source_p != NULL);
794 <  assert(source_p->username != username);
793 >  const char *p = nickname;
794 >  assert(nickname && *nickname);
795  
796 <  if (source_p == NULL)
827 <    return;
796 >  assert(p);
797  
798 <  if (!IsUnknown(source_p))
799 <  {
800 <    sendto_one(source_p, form_str(ERR_ALREADYREGISTRED),
801 <               me.name, nick);
833 <    return;
834 <  }
835 <
836 <  source_p->flags |= FLAGS_GOTUSER;
798 >  /* nicks can't start with a digit or - or be 0 length */
799 >  /* This closer duplicates behaviour of hybrid-6 */
800 >  if (*p == '-' || (IsDigit(*p) && local) || *p == '\0')
801 >    return 0;
802  
803 <  /*
804 <   * don't take the clients word for it, ever
805 <   */
841 <  source_p->servptr = &me;
803 >  for (; *p; ++p)
804 >    if (!IsNickChar(*p))
805 >      return 0;
806  
807 <  strlcpy(source_p->info, realname, sizeof(source_p->info));
844 <
845 <  if (!IsGotId(source_p))
846 <  {
847 <    /* save the username in the client
848 <     * If you move this you'll break ping cookies..you've been warned
849 <     */
850 <    strlcpy(source_p->username, username, sizeof(source_p->username));
851 <  }
852 <
853 <  if (source_p->name[0])
854 <  {
855 <    /* NICK already received, now I have USER... */
856 <    register_local_user(client_p, source_p, source_p->name, username);
857 <  }
858 < }
859 <
860 < /* change_simple_umode()
861 < *
862 < * this callback can be hooked to allow special handling of
863 < * certain usermodes
864 < */
865 < static void *
866 < change_simple_umode(va_list args)
867 < {
868 <  struct Client *source_p;
869 <  int what;
870 <  unsigned int flag;
871 <
872 <  va_arg(args, struct Client *);
873 <  source_p = va_arg(args, struct Client *);
874 <  what = va_arg(args, int);
875 <  flag = va_arg(args, unsigned int);
876 <
877 <  if (what == MODE_ADD)
878 <    source_p->umodes |= flag;
879 <  else
880 <    source_p->umodes &= ~flag;
881 <
882 <  return NULL;
883 < }
884 <
885 < /* set_user_mode()
886 < *
887 < * added 15/10/91 By Darren Reed.
888 < * parv[0] - sender
889 < * parv[1] - username to change mode for
890 < * parv[2] - modes to change
891 < */
892 < void
893 < set_user_mode(struct Client *client_p, struct Client *source_p,
894 <              int parc, char *parv[])
895 < {
896 <  unsigned int flag, setflags;
897 <  char **p, *m, buf[IRCD_BUFSIZE];
898 <  struct Client *target_p;
899 <  int what = MODE_ADD, badflag = 0, i;
900 < #if 0
901 <  /* already covered by m_mode */
902 <  if (parc < 2)
903 <  {
904 <    sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
905 <               me.name, source_p->name, "MODE");
906 <    return;
907 <  }
908 < #endif
909 <  if ((target_p = find_person(client_p, parv[1])) == NULL)
910 <  {
911 <    if (MyConnect(source_p))
912 <      sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL),
913 <                 me.name, source_p->name, parv[1]);
914 <    return;
915 <  }
916 <
917 <  /* Dont know why these were commented out..
918 <   * put them back using new sendto() funcs
919 <   */
920 <  if (IsServer(source_p))
921 <  {
922 <     sendto_realops_flags(UMODE_ALL, L_ADMIN, "*** Mode for User %s from %s",
923 <                          parv[1], source_p->name);
924 <     return;
925 <  }
926 <
927 <  if (source_p != target_p || target_p->from != source_p->from)
928 <  {
929 <     sendto_one(source_p, form_str(ERR_USERSDONTMATCH),
930 <                me.name, source_p->name);
931 <     return;
932 <  }
933 <
934 <  if (parc < 3)
935 <  {
936 <    m = buf;
937 <    *m++ = '+';
938 <
939 <    for (i = 0; i < 128; i++)
940 <      if (source_p->umodes & user_modes[i])
941 <        *m++ = (char)i;
942 <    *m = '\0';
943 <
944 <    sendto_one(source_p, form_str(RPL_UMODEIS),
945 <               me.name, source_p->name, buf);
946 <    return;
947 <  }
948 <
949 <  execute_callback(entering_umode_cb, client_p, source_p);
950 <
951 <  /* find flags already set for user */
952 <  setflags = source_p->umodes;
953 <
954 <  /* parse mode change string(s) */
955 <  for (p = &parv[2]; p && *p; p++)
956 <  {
957 <    for (m = *p; *m; m++)
958 <    {
959 <      switch (*m)
960 <      {
961 <        case '+':
962 <          what = MODE_ADD;
963 <          break;
964 <        case '-':
965 <          what = MODE_DEL;
966 <          break;
967 <        case 'o':
968 <          if (what == MODE_ADD)
969 <          {
970 <            if (IsServer(client_p) && !IsOper(source_p))
971 <            {
972 <              ++Count.oper;
973 <              SetOper(source_p);
974 <            }
975 <          }
976 <          else
977 <          {
978 <            /* Only decrement the oper counts if an oper to begin with
979 <             * found by Pat Szuta, Perly , perly@xnet.com
980 <             */
981 <            if (!IsOper(source_p))
982 <              break;
983 <
984 <            ClearOper(source_p);
985 <            source_p->umodes &= ~ConfigFileEntry.oper_only_umodes;
986 <            Count.oper--;
987 <
988 <            if (MyConnect(source_p))
989 <            {
990 <              dlink_node *dm;
991 <
992 <              detach_conf(source_p, OPER_TYPE);
993 <              ClearOperFlags(source_p);
994 <
995 <              if ((dm = dlinkFindDelete(&oper_list, source_p)) != NULL)
996 <                free_dlink_node(dm);
997 <            }
998 <          }
999 <
1000 <          break;
1001 <
1002 <        /* we may not get these,
1003 <         * but they shouldnt be in default
1004 <         */
1005 <        case ' ' :
1006 <        case '\n':
1007 <        case '\r':
1008 <        case '\t':
1009 <          break;
1010 <
1011 <        default:
1012 <          if ((flag = user_modes[(unsigned char)*m]))
1013 <          {
1014 <            if (MyConnect(source_p) && !IsOper(source_p) &&
1015 <                (ConfigFileEntry.oper_only_umodes & flag))
1016 <            {
1017 <              badflag = 1;
1018 <            }
1019 <            else
1020 <              execute_callback(umode_cb, client_p, source_p, what, flag);
1021 <          }
1022 <          else
1023 <          {
1024 <            if (MyConnect(source_p))
1025 <              badflag = 1;
1026 <          }
1027 <
1028 <          break;
1029 <      }
1030 <    }
1031 <  }
1032 <
1033 <  if (badflag)
1034 <    sendto_one(source_p, form_str(ERR_UMODEUNKNOWNFLAG),
1035 <               me.name, source_p->name);
1036 <
1037 <  if ((source_p->umodes & UMODE_NCHANGE) && !IsOperN(source_p))
1038 <  {
1039 <    sendto_one(source_p, ":%s NOTICE %s :*** You have no admin flag;",
1040 <               me.name, source_p->name);
1041 <    source_p->umodes &= ~UMODE_NCHANGE; /* only tcm's really need this */
1042 <  }
1043 <
1044 <  if (MyConnect(source_p) && (source_p->umodes & UMODE_ADMIN) &&
1045 <      !IsOperAdmin(source_p) && !IsOperHiddenAdmin(source_p))
1046 <  {
1047 <    sendto_one(source_p, ":%s NOTICE %s :*** You have no admin flag;",
1048 <               me.name, source_p->name);
1049 <    source_p->umodes &= ~UMODE_ADMIN;
1050 <  }
1051 <
1052 <  if (!(setflags & UMODE_INVISIBLE) && IsInvisible(source_p))
1053 <    ++Count.invisi;
1054 <  if ((setflags & UMODE_INVISIBLE) && !IsInvisible(source_p))
1055 <    --Count.invisi;
1056 <
1057 <  /* compare new flags with old flags and send string which
1058 <   * will cause servers to update correctly.
1059 <   */
1060 <  send_umode_out(client_p, source_p, setflags);
807 >  return p - nickname <= NICKLEN;
808   }
809  
810   /* send_umode()
811   * send the MODE string for user (user) to connection client_p
812   * -avalon
813 + *
814 + * inputs       - client_p
815 + *              - source_p
816 + *              - int old
817 + *              - sendmask mask of modes to send
818 + *              - suplied umode_buf
819 + * output       - NONE
820   */
821   void
822   send_umode(struct Client *client_p, struct Client *source_p,
823             unsigned int old, unsigned int sendmask, char *umode_buf)
824   {
825 +  char *m = umode_buf;
826    int what = 0;
827    unsigned int i;
828    unsigned int flag;
1074  char *m = umode_buf;
829  
830 <  /* build a string in umode_buf to represent the change in the user's
830 >  /*
831 >   * build a string in umode_buf to represent the change in the user's
832     * mode between the new (source_p->umodes) and 'old'.
833     */
834 <  for (i = 0; i < 128; i++)
834 >  for (i = 0; i < 128; ++i)
835    {
836      flag = user_modes[i];
837      if (!flag)
# Line 1085 | Line 840 | send_umode(struct Client *client_p, stru
840      if (MyClient(source_p) && !(flag & sendmask))
841        continue;
842  
843 <    if ((flag & old) && !(source_p->umodes & flag))
843 >    if ((flag & old) && !HasUMode(source_p, flag))
844      {
845        if (what == MODE_DEL)
846          *m++ = (char)i;
# Line 1096 | Line 851 | send_umode(struct Client *client_p, stru
851          *m++ = (char)i;
852        }
853      }
854 <    else if (!(flag & old) && (source_p->umodes & flag))
854 >    else if (!(flag & old) && HasUMode(source_p, flag))
855      {
856        if (what == MODE_ADD)
857          *m++ = (char)i;
# Line 1112 | Line 867 | send_umode(struct Client *client_p, stru
867    *m = '\0';
868  
869    if (*umode_buf && client_p)
870 <    sendto_one(client_p, ":%s MODE %s :%s",
871 <               source_p->name, source_p->name, umode_buf);
870 >    sendto_one(client_p, ":%s!%s@%s MODE %s :%s",
871 >               source_p->name, source_p->username,
872 >               source_p->host, source_p->name, umode_buf);
873   }
874  
875   /* send_umode_out()
# Line 1126 | Line 882 | void
882   send_umode_out(struct Client *client_p, struct Client *source_p,
883                 unsigned int old)
884   {
885 <  char buf[IRCD_BUFSIZE];
1130 <  dlink_node *ptr = NULL;
885 >  char buf[IRCD_BUFSIZE] = "";
886  
887 <  send_umode(NULL, source_p, old, IsOperHiddenAdmin(source_p) ?
1133 <             SEND_UMODES & ~UMODE_ADMIN : SEND_UMODES, buf);
887 >  send_umode(NULL, source_p, old, SEND_UMODES, buf);
888  
889 <  if (*buf)
890 <  {
891 <    DLINK_FOREACH(ptr, serv_list.head)
1138 <    {
1139 <      struct Client *target_p = ptr->data;
1140 <
1141 <      if ((target_p != client_p) && (target_p != source_p))
1142 <      {
1143 <        if ((!(ServerInfo.hub && IsCapable(target_p, CAP_LL))) ||
1144 <            (target_p->localClient->serverMask &
1145 <             source_p->lazyLinkClientExists))
1146 <          sendto_one(target_p, ":%s MODE %s :%s",
1147 <                     ID_or_name(source_p, target_p),
1148 <                     ID_or_name(source_p, target_p), buf);
1149 <      }
1150 <    }
1151 <  }
889 >  if (buf[0])
890 >    sendto_server(source_p, NOCAPS, NOCAPS, ":%s MODE %s :%s",
891 >                  source_p->id, source_p->id, buf);
892  
893    if (client_p && MyClient(client_p))
894      send_umode(client_p, source_p, old, 0xffffffff, buf);
895   }
896  
897 < /* user_welcome()
898 < *
1159 < * inputs       - client pointer to client to welcome
1160 < * output       - NONE
1161 < * side effects -
1162 < */
1163 < static void
1164 < user_welcome(struct Client *source_p)
897 > void
898 > user_set_hostmask(struct Client *target_p, const char *hostname, const int what)
899   {
900 < #if defined(__TIME__) && defined(__DATE__)
1167 <  static const char built_date[] = __DATE__ " at " __TIME__;
1168 < #else
1169 <  static const char built_date[] = "unknown";
1170 < #endif
900 >  dlink_node *ptr = NULL;
901  
902 < #ifdef HAVE_LIBCRYPTO
903 <  if (source_p->localClient->fd.ssl != NULL)
1174 <    sendto_one(source_p, ":%s NOTICE %s :*** Connected securely via %s",
1175 <               me.name, source_p->name,
1176 <               ssl_get_cipher(source_p->localClient->fd.ssl));
1177 < #endif
902 >  if (!strcmp(target_p->host, hostname))
903 >    return;
904  
905 <  sendto_one(source_p, form_str(RPL_WELCOME), me.name, source_p->name,
906 <             ServerInfo.network_name, source_p->name);
907 <  sendto_one(source_p, form_str(RPL_YOURHOST), me.name, source_p->name,
908 <             get_listener_name(source_p->localClient->listener), ircd_version);
909 <  sendto_one(source_p, form_str(RPL_CREATED),
910 <             me.name, source_p->name, built_date);
911 <  sendto_one(source_p, form_str(RPL_MYINFO),
912 <             me.name, source_p->name, me.name, ircd_version, umode_buffer);
1187 <  show_isupport(source_p);
905 >  switch (what)
906 >  {
907 >    case MODE_ADD:
908 >      AddUMode(target_p, UMODE_HIDDENHOST);
909 >      AddFlag(target_p, FLAGS_IP_SPOOFING);
910 >      break;
911 >    case MODE_DEL:
912 >      DelUMode(target_p, UMODE_HIDDENHOST);
913  
914 <  if (source_p->id[0] != '\0')
915 <    sendto_one(source_p, form_str(RPL_YOURID), me.name,
916 <               source_p->name, source_p->id);
914 >      if (!HasFlag(target_p, FLAGS_AUTH_SPOOF))
915 >        DelFlag(target_p, FLAGS_IP_SPOOFING);
916 >      break;
917 >    default: return;
918 >  }
919  
920 <  show_lusers(source_p);
920 >  if (ConfigFileEntry.cycle_on_host_change)
921 >    sendto_common_channels_local(target_p, 0, 0, ":%s!%s@%s QUIT :Changing hostname",
922 >                                 target_p->name, target_p->username, target_p->host);
923  
924 <  if (ConfigFileEntry.short_motd)
925 <  {
1197 <    sendto_one(source_p, "NOTICE %s :*** Notice -- motd was last changed at %s",
1198 <               source_p->name, ConfigFileEntry.motd.lastChangedDate);
1199 <    sendto_one(source_p,
1200 <               "NOTICE %s :*** Notice -- Please read the motd if you haven't "
1201 <               "read it", source_p->name);
1202 <    sendto_one(source_p, form_str(RPL_MOTDSTART),
1203 <               me.name, source_p->name, me.name);
1204 <    sendto_one(source_p, form_str(RPL_MOTD),
1205 <               me.name, source_p->name,
1206 <               "*** This is the short motd ***");
1207 <    sendto_one(source_p, form_str(RPL_ENDOFMOTD),
1208 <               me.name, source_p->name);
1209 <  }
1210 <  else  
1211 <    send_message_file(source_p, &ConfigFileEntry.motd);
1212 < }
924 >  if (IsUserHostIp(target_p))
925 >    delete_user_host(target_p->username, target_p->host, !MyConnect(target_p));
926  
927 < /* check_xline()
928 < *
929 < * inputs       - pointer to client to test
930 < * outupt       - 1 if exiting 0 if ok
1218 < * side effects -
1219 < */
1220 < static int
1221 < check_xline(struct Client *source_p)
1222 < {
1223 <  struct ConfItem *conf;
1224 <  struct MatchItem *xconf;
1225 <  const char *reason;
927 >  strlcpy(target_p->host, hostname, sizeof(target_p->host));
928 >
929 >  add_user_host(target_p->username, target_p->host, !MyConnect(target_p));
930 >  SetUserHost(target_p);
931  
932 <  if ((conf = find_matching_name_conf(XLINE_TYPE, source_p->info,
1228 <                                      NULL, NULL, 0)) != NULL)
932 >  if (MyClient(target_p))
933    {
934 <    xconf = map_to_conf(conf);
935 <    xconf->count++;
934 >    sendto_one_numeric(target_p, &me, RPL_NEWHOSTIS, target_p->host);
935 >    clear_ban_cache_client(target_p);
936 >  }
937  
938 <    if (xconf->reason != NULL)
939 <      reason = xconf->reason;
1235 <    else
1236 <      reason = "No Reason";
938 >  if (!ConfigFileEntry.cycle_on_host_change)
939 >    return;
940  
941 <    sendto_realops_flags(UMODE_REJ, L_ALL,
942 <                         "X-line Rejecting [%s] [%s], user %s [%s]",
943 <                         source_p->info, reason,
944 <                         get_client_name(source_p, HIDE_IP),
945 <                         source_p->sockhost);
941 >  DLINK_FOREACH(ptr, target_p->channel.head)
942 >  {
943 >    char modebuf[4], nickbuf[NICKLEN * 3 + 3] = "";
944 >    char *p = modebuf;
945 >    int len = 0;
946 >    const struct Membership *ms = ptr->data;
947  
948 <    ServerStats->is_ref++;      
1245 <    if(REJECT_HOLD_TIME > 0)
948 >    if (has_member_flags(ms, CHFL_CHANOP))
949      {
950 <      sendto_one(source_p, ":%s NOTICE %s :Bad user info",
951 <                 me.name, source_p->name);
1249 <      source_p->localClient->reject_delay = CurrentTime + REJECT_HOLD_TIME;
1250 <      SetCaptured(source_p);
950 >      *p++ = 'o';
951 >      len += snprintf(nickbuf + len, sizeof(nickbuf) - len, len ? " %s" : "%s", target_p->name);
952      }
1252    else
1253      exit_client(source_p, &me, "Bad user info");
1254    return 1;
1255  }
953  
954 <  return 0;
955 < }
956 <
957 < static int
958 < check_regexp_xline(struct Client *source_p)
1262 < {
1263 <  struct ConfItem *conf = NULL;
1264 <  const char *reason = NULL;
1265 <
1266 <  if ((conf = find_matching_name_conf(RXLINE_TYPE, source_p->info, NULL, NULL, 0)))
1267 <  {
1268 <    struct MatchItem *reg = map_to_conf(conf);
954 >    if (has_member_flags(ms, CHFL_HALFOP))
955 >    {
956 >      *p++ = 'h';
957 >      len += snprintf(nickbuf + len, sizeof(nickbuf) - len, len ? " %s" : "%s", target_p->name);
958 >    }
959  
960 <    ++reg->count;
960 >    if (has_member_flags(ms, CHFL_VOICE))
961 >    {
962 >      *p++ = 'v';
963 >      len += snprintf(nickbuf + len, sizeof(nickbuf) - len, len ? " %s" : "%s", target_p->name);
964 >    }
965  
966 <    if (reg->reason != NULL)
1273 <      reason = reg->reason;
1274 <    else
1275 <      reason = "No Reason";
966 >    *p = '\0';
967  
968 <    sendto_realops_flags(UMODE_REJ, L_ALL,
969 <                         "X-line (REGEX) Rejecting [%s] [%s], user %s [%s]",
970 <                         source_p->info, reason,
971 <                         get_client_name(source_p, HIDE_IP),
972 <                         source_p->sockhost);
968 >    sendto_channel_local_butone(target_p, 0, 0, ms->chptr, ":%s!%s@%s JOIN :%s",
969 >                                target_p->name, target_p->username, target_p->host,
970 >                                ms->chptr->chname);
971 >    if (nickbuf[0])
972 >      sendto_channel_local_butone(target_p, 0, 0, ms->chptr, ":%s MODE %s +%s %s",
973 >                                  target_p->servptr->name, ms->chptr->chname,
974 >                                  modebuf, nickbuf);
975  
1283    ServerStats->is_ref++;
1284    exit_client(source_p, &me, "Bad user info");
1285    return 1;
976    }
977  
978 <  return 0;
978 >  if (target_p->away[0])
979 >    sendto_common_channels_local(target_p, 0, CAP_AWAY_NOTIFY,
980 >                                 ":%s!%s@%s AWAY :%s",
981 >                                 target_p->name, target_p->username,
982 >                                 target_p->host, target_p->away);
983   }
984  
985   /* oper_up()
986   *
987   * inputs       - pointer to given client to oper
988   * output       - NONE
989 < * side effects - Blindly opers up given source_p, using aconf info
989 > * side effects - Blindly opers up given source_p, using conf info
990   *                all checks on passwords have already been done.
991 < *                This could also be used by rsa oper routines.
991 > *                This could also be used by rsa oper routines.
992   */
993   void
994   oper_up(struct Client *source_p)
995   {
996 <  unsigned int old = source_p->umodes;
997 <  const char *operprivs = "";
1304 <  struct AccessItem *oconf;
996 >  const unsigned int old = source_p->umodes;
997 >  const struct MaskItem *conf = source_p->localClient->confs.head->data;
998  
999 +  assert(source_p->localClient->confs.head);
1000 +
1001 +  ++Count.oper;
1002    SetOper(source_p);
1003  
1004 <  if (ConfigFileEntry.oper_umodes)
1005 <    source_p->umodes |= ConfigFileEntry.oper_umodes;
1006 <  else
1007 <    source_p->umodes |= (UMODE_SERVNOTICE|UMODE_OPERWALL|
1312 <                         UMODE_WALLOP|UMODE_LOCOPS);
1004 >  if (conf->modes)
1005 >    AddUMode(source_p, conf->modes);
1006 >  else if (ConfigFileEntry.oper_umodes)
1007 >    AddUMode(source_p, ConfigFileEntry.oper_umodes);
1008  
1009 <  Count.oper++;
1009 >  if (!(old & UMODE_INVISIBLE) && HasUMode(source_p, UMODE_INVISIBLE))
1010 >    ++Count.invisi;
1011 >  if ((old & UMODE_INVISIBLE) && !HasUMode(source_p, UMODE_INVISIBLE))
1012 >    --Count.invisi;
1013  
1014    assert(dlinkFind(&oper_list, source_p) == NULL);
1015    dlinkAdd(source_p, make_dlink_node(), &oper_list);
1016  
1017 <  assert(source_p->localClient->confs.head);
1320 <  oconf = map_to_conf((source_p->localClient->confs.head)->data);
1321 <  operprivs = oper_privs_as_string(oconf->port);
1322 <
1323 <  SetOFlag(source_p, oconf->port);
1017 >  AddOFlag(source_p, conf->port);
1018  
1019 <  if (IsOperAdmin(source_p) || IsOperHiddenAdmin(source_p))
1020 <    source_p->umodes |= UMODE_ADMIN;
1327 <  if (!IsOperN(source_p))
1328 <    source_p->umodes &= ~UMODE_NCHANGE;
1019 >  if (HasOFlag(source_p, OPER_FLAG_ADMIN))
1020 >    AddUMode(source_p, UMODE_ADMIN);
1021  
1022 <  sendto_realops_flags(UMODE_ALL, L_ALL, "%s (%s@%s) is now an operator",
1023 <                       source_p->name, source_p->username, source_p->host);
1022 >  sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, "%s is now an operator",
1023 >                       get_oper_name(source_p));
1024    send_umode_out(source_p, source_p, old);
1025 <  sendto_one(source_p, form_str(RPL_YOUREOPER), me.name, source_p->name);
1334 <  sendto_one(source_p, ":%s NOTICE %s :*** Oper privs are %s",
1335 <             me.name, source_p->name, operprivs);
1336 <  send_message_file(source_p, &ConfigFileEntry.opermotd);
1025 >  sendto_one_numeric(source_p, &me, RPL_YOUREOPER);
1026   }
1027  
1028 < /*
1340 < * Quick and dirty UID code for new proposed SID on EFnet
1341 < *
1342 < */
1028 > static char new_uid[TOTALSIDUID + 1];     /* allow for \0 */
1029  
1030 < static char new_uid[TOTALSIDUID+1];     /* allow for \0 */
1031 < static void add_one_to_uid(int i);
1030 > int
1031 > valid_sid(const char *sid)
1032 > {
1033 >  if (strlen(sid) == IRC_MAXSID)
1034 >    if (IsDigit(*sid))
1035 >      if (IsAlNum(*(sid + 1)) && IsAlNum(*(sid + 2)))
1036 >        return 1;
1037 >
1038 >  return 0;
1039 > }
1040  
1041   /*
1042   * init_uid()
1043 < *
1043 > *
1044   * inputs       - NONE
1045   * output       - NONE
1046   * side effects - new_uid is filled in with server id portion (sid)
# Line 1356 | Line 1050 | static void add_one_to_uid(int i);
1050   void
1051   init_uid(void)
1052   {
1359  int i;
1360
1053    memset(new_uid, 0, sizeof(new_uid));
1054  
1055 <  if (ServerInfo.sid != NULL)
1056 <  {
1365 <    memcpy(new_uid, ServerInfo.sid, IRCD_MIN(strlen(ServerInfo.sid),
1366 <                                             IRC_MAXSID));
1367 <    memcpy(&me.id, ServerInfo.sid, IRCD_MIN(strlen(ServerInfo.sid),
1368 <                                             IRC_MAXSID));
1369 <    hash_add_id(&me);
1370 <  }
1055 >  if (!EmptyString(ServerInfo.sid))
1056 >    strlcpy(new_uid, ServerInfo.sid, sizeof(new_uid));
1057  
1058 <  for (i = 0; i < IRC_MAXSID; i++)
1059 <    if (new_uid[i] == '\0')
1058 >  for (unsigned int i = 0; i < IRC_MAXSID; ++i)
1059 >    if (new_uid[i] == '\0')
1060        new_uid[i] = 'A';
1061  
1062 <  /* XXX if IRC_MAXUID != 6, this will have to be rewritten */
1063 <  /* Yes nenolod, I have known it was off by one ever since I wrote it
1378 <   * But *JUST* for you, though, it really doesn't look as *pretty*
1379 <   * -Dianora
1380 <   */
1381 <  memcpy(new_uid+IRC_MAXSID, "AAAAA@", IRC_MAXUID);
1382 <
1383 <  entering_umode_cb = register_callback("entering_umode", NULL);
1384 <  umode_cb = register_callback("changing_umode", change_simple_umode);
1385 <  uid_get_cb = register_callback("uid_get", uid_get);
1386 < }
1387 <
1388 < /*
1389 < * uid_get
1390 < *
1391 < * inputs       - struct Client *
1392 < * output       - new UID is returned to caller
1393 < * side effects - new_uid is incremented by one.
1394 < */
1395 < static void *
1396 < uid_get(va_list args)
1397 < {
1398 <  add_one_to_uid(TOTALSIDUID-1);        /* index from 0 */
1399 <  return ((void *) new_uid);
1062 >  /* NOTE: if IRC_MAXUID != 6, this will have to be rewritten */
1063 >  memcpy(new_uid + IRC_MAXSID, "AAAAA@", IRC_MAXUID);
1064   }
1065  
1066   /*
# Line 1410 | Line 1074 | uid_get(va_list args)
1074   static void
1075   add_one_to_uid(int i)
1076   {
1077 <  if (i != IRC_MAXSID)          /* Not reached server SID portion yet? */
1077 >  if (i != IRC_MAXSID)    /* Not reached server SID portion yet? */
1078    {
1079      if (new_uid[i] == 'Z')
1080        new_uid[i] = '0';
# Line 1419 | Line 1083 | add_one_to_uid(int i)
1083        new_uid[i] = 'A';
1084        add_one_to_uid(i-1);
1085      }
1086 <    else new_uid[i] = new_uid[i] + 1;
1086 >    else
1087 >      ++new_uid[i];
1088    }
1089    else
1090    {
1091 <    /* XXX if IRC_MAXUID != 6, this will have to be rewritten */
1091 >    /* NOTE: if IRC_MAXUID != 6, this will have to be rewritten */
1092      if (new_uid[i] == 'Z')
1093 <      memcpy(new_uid+IRC_MAXSID, "AAAAAA", IRC_MAXUID);
1093 >      memcpy(new_uid + IRC_MAXSID, "AAAAAA", IRC_MAXUID);
1094      else
1095 <      new_uid[i] = new_uid[i] + 1;
1095 >      ++new_uid[i];
1096    }
1097   }
1098  
1099   /*
1100 + * uid_get
1101 + *
1102 + * inputs       - struct Client *
1103 + * output       - new UID is returned to caller
1104 + * side effects - new_uid is incremented by one.
1105 + */
1106 + static const char *
1107 + uid_get(void)
1108 + {
1109 +  add_one_to_uid(TOTALSIDUID - 1);    /* index from 0 */
1110 +  return new_uid;
1111 + }
1112 +
1113 + /*
1114   * init_isupport()
1115   *
1116   * input        - NONE
# Line 1441 | Line 1120 | add_one_to_uid(int i)
1120   void
1121   init_isupport(void)
1122   {
1444  isupportFile = init_MessageLine();
1445
1123    add_isupport("CALLERID", NULL, -1);
1124    add_isupport("CASEMAPPING", CASEMAP, -1);
1125 +  add_isupport("DEAF", "D", -1);
1126    add_isupport("KICKLEN", NULL, KICKLEN);
1127    add_isupport("MODES", NULL, MAXMODEPARAMS);
1450  add_isupport("NICKLEN", NULL, NICKLEN-1);
1128   #ifdef HALFOPS
1129    add_isupport("PREFIX", "(ohv)@%+", -1);
1130    add_isupport("STATUSMSG", "@%+", -1);
# Line 1455 | Line 1132 | init_isupport(void)
1132    add_isupport("PREFIX", "(ov)@+", -1);
1133    add_isupport("STATUSMSG", "@+", -1);
1134   #endif
1135 <  add_isupport("TOPICLEN", NULL, TOPICLEN);
1135 >  add_isupport("EXCEPTS", "e", -1);
1136 >  add_isupport("INVEX", "I", -1);
1137   }
1138  
1139   /*
# Line 1490 | Line 1168 | add_isupport(const char *name, const cha
1168      dlinkAddTail(support, &support->node, &support_list);
1169    }
1170  
1171 <  DupString(support->name, name);
1171 >  support->name = xstrdup(name);
1172    if (options != NULL)
1173 <    DupString(support->options, options);
1173 >    support->options = xstrdup(options);
1174    support->number = n;
1175  
1176    rebuild_isupport_message_line();
# Line 1539 | Line 1217 | rebuild_isupport_message_line(void)
1217   {
1218    char isupportbuffer[IRCD_BUFSIZE];
1219    char *p = isupportbuffer;
1220 <  dlink_node *ptr = NULL;
1220 >  dlink_node *ptr = NULL, *ptr_next = NULL;
1221    int n = 0;
1222    int tokens = 0;
1223    size_t len = 0;
1224 <  size_t reserve = strlen(me.name) + HOSTLEN + strlen(form_str(RPL_ISUPPORT));
1224 >  size_t reserve = strlen(me.name) + HOSTLEN + strlen(numeric_form(RPL_ISUPPORT));
1225  
1226 <  destroy_MessageLine(isupportFile);
1226 >  DLINK_FOREACH_SAFE(ptr, ptr_next, support_list_lines.head)
1227 >  {
1228 >    dlinkDelete(ptr, &support_list_lines);
1229 >    MyFree(ptr->data);
1230 >    free_dlink_node(ptr);
1231 >  }
1232  
1233    DLINK_FOREACH(ptr, support_list.head)
1234    {
1235      struct Isupport *support = ptr->data;
1236  
1237 <    p += (n = ircsprintf(p, "%s", support->name));
1237 >    p += (n = sprintf(p, "%s", support->name));
1238      len += n;
1239  
1240      if (support->options != NULL)
1241      {
1242 <      p += (n = ircsprintf(p, "=%s", support->options));
1242 >      p += (n = sprintf(p, "=%s", support->options));
1243        len += n;
1244      }
1245  
1246      if (support->number > 0)
1247      {
1248 <      p += (n = ircsprintf(p, "=%d", support->number));
1248 >      p += (n = sprintf(p, "=%d", support->number));
1249        len += n;
1250      }
1251  
# Line 1573 | Line 1256 | rebuild_isupport_message_line(void)
1256      if (++tokens == (MAXPARA-2) || len >= (sizeof(isupportbuffer)-reserve))
1257      { /* arbritrary for now */
1258        if (*--p == ' ')
1259 <        *p = '\0';
1259 >        *p = '\0';
1260  
1261 <      addto_MessageLine(isupportFile, isupportbuffer);
1261 >      dlinkAddTail(xstrdup(isupportbuffer), make_dlink_node(), &support_list_lines);
1262        p = isupportbuffer;
1263        len = 0;
1264        n = tokens = 0;
# Line 1586 | Line 1269 | rebuild_isupport_message_line(void)
1269    {
1270      if (*--p == ' ')
1271        *p = '\0';
1272 <    addto_MessageLine(isupportFile, isupportbuffer);
1272 >    dlinkAddTail(xstrdup(isupportbuffer), make_dlink_node(), &support_list_lines);
1273    }
1274   }

Comparing:
ircd-hybrid/src/s_user.c (property svn:keywords), Revision 31 by knight, Sun Oct 2 20:34:05 2005 UTC vs.
ircd-hybrid/trunk/src/s_user.c (property svn:keywords), Revision 3316 by michael, Tue Apr 15 14:09:39 2014 UTC

# Line 1 | Line 1
1 < "Id Revision"
1 > Id Revision

Diff Legend

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