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-8/src/s_user.c (file contents), Revision 1156 by michael, Tue Aug 9 20:29:20 2011 UTC vs.
ircd-hybrid/trunk/src/user.c (file contents), Revision 8223 by michael, Sun Apr 16 12:54:01 2017 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-2017 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 16 | Line 15
15   *
16   *  You should have received a copy of the GNU General Public License
17   *  along with this program; if not, write to the Free Software
18 < *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
18 > *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19   *  USA
20 < *
21 < *  $Id$
20 > */
21 >
22 > /*! \file user.c
23 > * \brief User related functions.
24 > * \version $Id$
25   */
26  
27   #include "stdinc.h"
28   #include "list.h"
29 < #include "s_user.h"
28 < #include "s_misc.h"
29 > #include "user.h"
30   #include "channel.h"
31   #include "channel_mode.h"
32   #include "client.h"
32 #include "common.h"
33 #include "fdlist.h"
33   #include "hash.h"
34 + #include "id.h"
35   #include "irc_string.h"
36 #include "sprintf_irc.h"
37 #include "s_bsd.h"
36   #include "ircd.h"
37   #include "listener.h"
38   #include "motd.h"
39   #include "numeric.h"
40 < #include "s_conf.h"
41 < #include "s_log.h"
42 < #include "s_serv.h"
40 > #include "conf.h"
41 > #include "conf_gecos.h"
42 > #include "log.h"
43 > #include "server.h"
44 > #include "server_capab.h" /* TBR: RHOST compatibility mode */
45   #include "send.h"
46 #include "supported.h"
47 #include "whowas.h"
46   #include "memory.h"
47   #include "packet.h"
48   #include "rng_mt.h"
49   #include "userhost.h"
50 < #include "hook.h"
51 < #include "s_misc.h"
54 < #include "msg.h"
50 > #include "misc.h"
51 > #include "parse.h"
52   #include "watch.h"
53 + #include "isupport.h"
54 + #include "tls.h"
55  
56 + static char umode_buffer[UMODE_MAX_STR];
57  
58 < struct Callback *entering_umode_cb = NULL;
59 < struct Callback *umode_cb = NULL;
60 <
61 < static char umode_buffer[IRCD_BUFSIZE];
62 <
63 < static void user_welcome(struct Client *);
64 < static void report_and_set_user_flags(struct Client *, const struct AccessItem *);
65 < static int check_xline(struct Client *);
66 < static void introduce_client(struct Client *);
67 < static const char *uid_get(void);
68 <
69 < /* Used for building up the isupport string,
70 < * used with init_isupport, add_isupport, delete_isupport
71 < */
72 <
73 < struct Isupport
74 < {
75 <  dlink_node node;
76 <  char *name;
77 <  char *options;
78 <  int number;
79 < };
80 <
81 < static dlink_list support_list = { NULL, NULL, 0 };
82 < MessageFile *isupportFile;
83 <
84 < /* memory is cheap. map 0-255 to equivalent mode */
85 < unsigned int user_modes[256] =
58 > const struct user_modes *umode_map[256];
59 > const struct user_modes  umode_tab[] =
60   {
61 <  /* 0x00 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x0F */
62 <  /* 0x10 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x1F */
63 <  /* 0x20 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x2F */
64 <  /* 0x30 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x3F */
65 <  0,                  /* @ */
66 <  0,                  /* A */
67 <  0,                  /* B */
68 <  UMODE_CCONN_FULL,   /* C */
69 <  UMODE_DEAF,         /* D */
70 <  0,                  /* E */
71 <  0,                  /* F */
72 <  UMODE_SOFTCALLERID, /* G */
73 <  0,                  /* H */
74 <  0,                  /* I */
75 <  0,                  /* J */
76 <  0,                  /* K */
77 <  0,                  /* L */
78 <  0,                  /* M */
79 <  0,                  /* N */
80 <  0,                  /* O */
81 <  0,                  /* P */
82 <  0,                  /* Q */
83 <  0,                  /* R */
84 <  0,                  /* S */
85 <  0,                  /* T */
86 <  0,                  /* U */
87 <  0,                  /* V */
88 <  0,                  /* W */
115 <  0,                  /* X */
116 <  0,                  /* Y */
117 <  0,                  /* Z 0x5A */
118 <  0, 0, 0, 0, 0,      /* 0x5F   */
119 <  0,                  /* 0x60   */
120 <  UMODE_ADMIN,        /* a */
121 <  UMODE_BOTS,         /* b */
122 <  UMODE_CCONN,        /* c */
123 <  UMODE_DEBUG,        /* d */
124 <  0,                  /* e */
125 <  UMODE_FULL,         /* f */
126 <  UMODE_CALLERID,     /* g */
127 <  0,                  /* h */
128 <  UMODE_INVISIBLE,    /* i */
129 <  0,                  /* j */
130 <  UMODE_SKILL,        /* k */
131 <  UMODE_LOCOPS,       /* l */
132 <  0,                  /* m */
133 <  UMODE_NCHANGE,      /* n */
134 <  UMODE_OPER,         /* o */
135 <  0,                  /* p */
136 <  0,                  /* q */
137 <  UMODE_REJ,          /* r */
138 <  UMODE_SERVNOTICE,   /* s */
139 <  0,                  /* t */
140 <  UMODE_UNAUTH,       /* u */
141 <  0,                  /* v */
142 <  UMODE_WALLOP,       /* w */
143 <  UMODE_EXTERNAL,     /* x */
144 <  UMODE_SPY,          /* y */
145 <  UMODE_OPERWALL,     /* z      0x7A */
146 <  0,0,0,0,0,          /* 0x7B - 0x7F */
147 <
148 <  /* 0x80 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x8F */
149 <  /* 0x90 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x9F */
150 <  /* 0xA0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xAF */
151 <  /* 0xB0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xBF */
152 <  /* 0xC0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xCF */
153 <  /* 0xD0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xDF */
154 <  /* 0xE0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xEF */
155 <  /* 0xF0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0  /* 0xFF */
61 >  { 'D', UMODE_DEAF         },
62 >  { 'F', UMODE_FARCONNECT   },
63 >  { 'G', UMODE_SOFTCALLERID },
64 >  { 'H', UMODE_HIDDEN       },
65 >  { 'R', UMODE_REGONLY      },
66 >  { 'S', UMODE_SSL          },
67 >  { 'W', UMODE_WEBIRC       },
68 >  { 'a', UMODE_ADMIN        },
69 >  { 'b', UMODE_BOTS         },
70 >  { 'c', UMODE_CCONN        },
71 >  { 'd', UMODE_DEBUG        },
72 >  { 'e', UMODE_EXTERNAL     },
73 >  { 'f', UMODE_FULL         },
74 >  { 'g', UMODE_CALLERID     },
75 >  { 'i', UMODE_INVISIBLE    },
76 >  { 'j', UMODE_REJ          },
77 >  { 'k', UMODE_SKILL        },
78 >  { 'l', UMODE_LOCOPS       },
79 >  { 'n', UMODE_NCHANGE      },
80 >  { 'o', UMODE_OPER         },
81 >  { 'p', UMODE_HIDECHANS    },
82 >  { 'q', UMODE_HIDEIDLE     },
83 >  { 'r', UMODE_REGISTERED   },
84 >  { 's', UMODE_SERVNOTICE   },
85 >  { 'u', UMODE_UNAUTH       },
86 >  { 'w', UMODE_WALLOP       },
87 >  { 'y', UMODE_SPY          },
88 >  { '\0', 0 }
89   };
90  
91   void
92 < assemble_umode_buffer(void)
92 > user_modes_init(void)
93   {
161  unsigned int idx = 0;
94    char *umode_buffer_ptr = umode_buffer;
95  
96 <  for (; idx < (sizeof(user_modes) / sizeof(user_modes[0])); ++idx)
97 <    if (user_modes[idx])
98 <      *umode_buffer_ptr++ = idx;
96 >  for (const struct user_modes *tab = umode_tab; tab->c; ++tab)
97 >  {
98 >    umode_map[tab->c] = tab;
99 >    *umode_buffer_ptr++ = tab->c;
100 >  }
101  
102    *umode_buffer_ptr = '\0';
103   }
# Line 175 | Line 109 | assemble_umode_buffer(void)
109   * side effects - display to client user counts etc.
110   */
111   void
112 < show_lusers(struct Client *source_p)
112 > show_lusers(struct Client *client_p)
113   {
114 <  const char *from, *to;
114 >  if (!ConfigServerHide.hide_servers || HasUMode(client_p, UMODE_OPER))
115 >    sendto_one_numeric(client_p, &me, RPL_LUSERCLIENT, (dlink_list_length(&global_client_list) - Count.invisi),
116 >                       Count.invisi, dlink_list_length(&global_server_list));
117 >  else
118 >    sendto_one_numeric(client_p, &me, RPL_LUSERCLIENT, (dlink_list_length(&global_client_list) - Count.invisi),
119 >                       Count.invisi, 1);
120 >
121 >  if (Count.oper)
122 >    sendto_one_numeric(client_p, &me, RPL_LUSEROP, Count.oper);
123 >
124 >  if (dlink_list_length(&unknown_list))
125 >    sendto_one_numeric(client_p, &me, RPL_LUSERUNKNOWN, dlink_list_length(&unknown_list));
126 >
127 >  if (dlink_list_length(&channel_list))
128 >    sendto_one_numeric(client_p, &me, RPL_LUSERCHANNELS, dlink_list_length(&channel_list));
129  
130 <  if (!MyConnect(source_p) && IsCapable(source_p->from, CAP_TS6) && HasID(source_p))
130 >  if (!ConfigServerHide.hide_servers || HasUMode(client_p, UMODE_OPER))
131    {
132 <    from = me.id;
133 <    to = source_p->id;
132 >    sendto_one_numeric(client_p, &me, RPL_LUSERME, dlink_list_length(&local_client_list), dlink_list_length(&local_server_list));
133 >    sendto_one_numeric(client_p, &me, RPL_LOCALUSERS, dlink_list_length(&local_client_list), Count.max_loc);
134 >    sendto_one_numeric(client_p, &me, RPL_GLOBALUSERS, dlink_list_length(&global_client_list), Count.max_tot);
135 >    sendto_one_numeric(client_p, &me, RPL_STATSCONN, Count.max_loc_con, Count.max_loc, Count.totalrestartcount);
136    }
137    else
138    {
139 <    from = me.name;
140 <    to = source_p->name;
139 >    sendto_one_numeric(client_p, &me, RPL_LUSERME, dlink_list_length(&global_client_list), 0);
140 >    sendto_one_numeric(client_p, &me, RPL_LOCALUSERS, dlink_list_length(&global_client_list), Count.max_tot);
141 >    sendto_one_numeric(client_p, &me, RPL_GLOBALUSERS, dlink_list_length(&global_client_list), Count.max_tot);
142    }
143 + }
144  
145 <  if (!ConfigServerHide.hide_servers || IsOper(source_p))
146 <    sendto_one(source_p, form_str(RPL_LUSERCLIENT),
147 <               from, to, (Count.total-Count.invisi),
148 <               Count.invisi, dlink_list_length(&global_serv_list));
149 <  else
150 <    sendto_one(source_p, form_str(RPL_LUSERCLIENT), from, to,
151 <               (Count.total-Count.invisi), Count.invisi, 1);
145 > /* report_and_set_user_flags()
146 > *
147 > * inputs       - pointer to client_p
148 > *              - pointer to conf for this user
149 > * output       - NONE
150 > * side effects - Report to user any special flags
151 > *                they are getting, and set them.
152 > */
153 > static void
154 > report_and_set_user_flags(struct Client *client_p, const struct MaskItem *conf)
155 > {
156 >  /* If this user is being spoofed, tell them so */
157 >  if (IsConfDoSpoofIp(conf))
158 >    sendto_one_notice(client_p, &me, ":*** Spoofing your IP");
159 >
160 >  /* If this user is in the exception class, set it "E lined" */
161 >  if (IsConfExemptKline(conf))
162 >  {
163 >    AddFlag(client_p, FLAGS_EXEMPTKLINE);
164 >    sendto_one_notice(client_p, &me, ":*** You are exempt from K/D lines");
165 >  }
166  
167 <  if (Count.oper > 0)
168 <    sendto_one(source_p, form_str(RPL_LUSEROP),
169 <               from, to, Count.oper);
170 <
205 <  if (dlink_list_length(&unknown_list) > 0)
206 <    sendto_one(source_p, form_str(RPL_LUSERUNKNOWN),
207 <               from, to, dlink_list_length(&unknown_list));
208 <
209 <  if (dlink_list_length(&global_channel_list) > 0)
210 <    sendto_one(source_p, form_str(RPL_LUSERCHANNELS),
211 <               from, to, dlink_list_length(&global_channel_list));
212 <
213 <  if (!ConfigServerHide.hide_servers || IsOper(source_p))
214 <  {
215 <    sendto_one(source_p, form_str(RPL_LUSERME),
216 <               from, to, Count.local, Count.myserver);
217 <    sendto_one(source_p, form_str(RPL_LOCALUSERS),
218 <               from, to, Count.local, Count.max_loc,
219 <               Count.local, Count.max_loc);
167 >  if (IsConfExemptXline(conf))
168 >  {
169 >    AddFlag(client_p, FLAGS_EXEMPTXLINE);
170 >    sendto_one_notice(client_p, &me, ":*** You are exempt from X lines");
171    }
172 <  else
172 >
173 >  if (IsConfExemptResv(conf))
174    {
175 <    sendto_one(source_p, form_str(RPL_LUSERME),
176 <               from, to, Count.total, 0);
177 <    sendto_one(source_p, form_str(RPL_LOCALUSERS),
226 <               from, to, Count.total, Count.max_tot,
227 <               Count.total, Count.max_tot);
228 <  }
229 <
230 <  sendto_one(source_p, form_str(RPL_GLOBALUSERS),
231 <             from, to, Count.total, Count.max_tot,
232 <             Count.total, Count.max_tot);
233 <
234 <  if (!ConfigServerHide.hide_servers || IsOper(source_p))
235 <    sendto_one(source_p, form_str(RPL_STATSCONN), from, to,
236 <               Count.max_loc_con, Count.max_loc_cli, Count.totalrestartcount);
175 >    AddFlag(client_p, FLAGS_EXEMPTRESV);
176 >    sendto_one_notice(client_p, &me, ":*** You are exempt from resvs");
177 >  }
178  
179 <  if (Count.local > Count.max_loc_cli)
180 <    Count.max_loc_cli = Count.local;
179 >  /* If this user is exempt from user limits set it "F lined" */
180 >  if (IsConfExemptLimits(conf))
181 >  {
182 >    AddFlag(client_p, FLAGS_NOLIMIT);
183 >    sendto_one_notice(client_p, &me, ":*** You are exempt from user limits");
184 >  }
185  
186 <  if ((Count.local + Count.myserver) > Count.max_loc_con)
187 <    Count.max_loc_con = Count.local + Count.myserver;
186 >  if (IsConfCanFlood(conf))
187 >  {
188 >    AddFlag(client_p, FLAGS_CANFLOOD);
189 >    sendto_one_notice(client_p, &me, ":*** You are exempt from flood protection");
190 >  }
191   }
192  
193 < /* show_isupport()
193 > /* introduce_client()
194   *
195 < * inputs       - pointer to client
195 > * inputs       - client_p
196   * output       - NONE
197 < * side effects - display to client what we support (for them)
197 > * side effects - This common function introduces a client to the rest
198 > *                of the net, either from a local client connect or
199 > *                from a remote connect.
200   */
201 < void
202 < show_isupport(struct Client *source_p)
201 > static void
202 > introduce_client(struct Client *client_p)
203   {
204 <  send_message_file(source_p, isupportFile);
204 >  dlink_node *node;
205 >  char buf[UMODE_MAX_STR] = "";
206 >
207 >  send_umode(client_p, MyConnect(client_p), 0, buf);
208 >  watch_check_hash(client_p, RPL_LOGON);
209 >
210 >  if (buf[0] == '\0')
211 >  {
212 >    buf[0] = '+';
213 >    buf[1] = '\0';
214 >  }
215 >
216 >  DLINK_FOREACH(node, local_server_list.head)
217 >  {
218 >    struct Client *server_p = node->data;
219 >
220 >    if (server_p == client_p->from)
221 >      continue;
222 >
223 >    /* TBR: compatibility mode */
224 >    if (IsCapable(server_p, CAPAB_RHOST))
225 >      sendto_one(server_p, ":%s UID %s %u %ju %s %s %s %s %s %s %s :%s",
226 >                 client_p->servptr->id,
227 >                 client_p->name, client_p->hopcount+1,
228 >                 client_p->tsinfo,
229 >                 buf, client_p->username, client_p->host, client_p->realhost,
230 >                 client_p->sockhost, client_p->id,
231 >                 client_p->account,
232 >                 client_p->info);
233 >    else
234 >      sendto_one(server_p, ":%s UID %s %u %ju %s %s %s %s %s %s :%s",
235 >                 client_p->servptr->id,
236 >                 client_p->name, client_p->hopcount+1,
237 >                 client_p->tsinfo,
238 >                 buf, client_p->username, client_p->host,
239 >                 client_p->sockhost, client_p->id,
240 >                 client_p->account,
241 >                 client_p->info);
242 >
243 >    if (!EmptyString(client_p->certfp))
244 >      sendto_one(server_p, ":%s CERTFP %s", client_p->id, client_p->certfp);
245 >  }
246   }
247  
248 < /*
249 < ** register_local_user
250 < **      This function is called when both NICK and USER messages
251 < **      have been accepted for the client, in whatever order. Only
252 < **      after this, is the USER message propagated.
253 < **
254 < **      NICK's must be propagated at once when received, although
255 < **      it would be better to delay them too until full info is
265 < **      available. Doing it is not so simple though, would have
266 < **      to implement the following:
267 < **
268 < **      (actually it has been implemented already for a while) -orabidoo
269 < **
270 < **      1) user telnets in and gives only "NICK foobar" and waits
271 < **      2) another user far away logs in normally with the nick
272 < **         "foobar" (quite legal, as this server didn't propagate
273 < **         it).
274 < **      3) now this server gets nick "foobar" from outside, but
275 < **         has alread the same defined locally. Current server
276 < **         would just issue "KILL foobar" to clean out dups. But,
277 < **         this is not fair. It should actually request another
278 < **         nick from local user or kill him/her...
279 < */
280 < void
281 < register_local_user(struct Client *source_p)
248 > /* user_welcome()
249 > *
250 > * inputs       - client pointer to client to welcome
251 > * output       - NONE
252 > * side effects -
253 > */
254 > static void
255 > user_welcome(struct Client *client_p)
256   {
257 <  const char *id = NULL;
284 <  const struct AccessItem *aconf = NULL;
285 <  dlink_node *ptr = NULL;
257 >  static const char built_date[] = __DATE__ " at " __TIME__;
258  
259 <  assert(source_p != NULL);
260 <  assert(source_p == source_p->from);
261 <  assert(MyConnect(source_p));
262 <  assert(!source_p->localClient->registration);
259 >  if (HasFlag(client_p, FLAGS_SSL))
260 >  {
261 >    AddUMode(client_p, UMODE_SSL);
262 >    sendto_one_notice(client_p, &me, ":*** Connected securely via %s",
263 >                      tls_get_cipher(&client_p->connection->fd.ssl));
264 >  }
265 >
266 >  sendto_one_numeric(client_p, &me, RPL_WELCOME, ConfigServerInfo.network_name,
267 >                     client_p->name);
268 >  sendto_one_numeric(client_p, &me, RPL_YOURHOST,
269 >                     listener_get_name(client_p->connection->listener), ircd_version);
270 >  sendto_one_numeric(client_p, &me, RPL_CREATED, built_date);
271 >  sendto_one_numeric(client_p, &me, RPL_MYINFO, me.name, ircd_version, umode_buffer);
272 >
273 >  isupport_show(client_p);
274 >  show_lusers(client_p);
275 >  motd_signon(client_p);
276 > }
277  
278 <  ClearCap(source_p, CAP_TS6);
278 > /* check_xline()
279 > *
280 > * inputs       - pointer to client to test
281 > * outupt       - 1 if exiting 0 if ok
282 > * side effects -
283 > */
284 > static int
285 > check_xline(struct Client *client_p)
286 > {
287 >  const struct GecosItem *gecos = NULL;
288 >
289 >  if (HasFlag(client_p, FLAGS_EXEMPTXLINE))
290 >    return 0;
291  
292 <  if (ConfigFileEntry.ping_cookie)
292 >  if ((gecos = gecos_find(client_p->info, match)))
293    {
294 <    if (!IsPingSent(source_p) && source_p->localClient->random_ping == 0)
294 >    sendto_realops_flags(UMODE_REJ, L_ALL, SEND_NOTICE,
295 >                         "X-line Rejecting [%s] [%s], user %s [%s]",
296 >                         client_p->info, gecos->reason,
297 >                         client_get_name(client_p, HIDE_IP),
298 >                         client_p->sockhost);
299 >
300 >    ++ServerStats.is_ref;
301 >    exit_client(client_p, "Bad user info");
302 >    return 1;
303 >  }
304 >
305 >  return 0;
306 > }
307 >
308 > /*! \brief This function is called when both NICK and USER messages
309 > *      have been accepted for the client, in whatever order. Only
310 > *      after this, is the UID message propagated.
311 > * \param client_p Pointer to given client to introduce
312 > */
313 > void
314 > register_local_user(struct Client *client_p)
315 > {
316 >  const struct MaskItem *conf = NULL;
317 >
318 >  assert(client_p == client_p->from);
319 >  assert(MyConnect(client_p));
320 >  assert(IsUnknown(client_p));
321 >  assert(!client_p->connection->registration);
322 >
323 >  if (ConfigGeneral.ping_cookie)
324 >  {
325 >    if (!HasFlag(client_p, FLAGS_PINGSENT) && !client_p->connection->random_ping)
326      {
327        do
328 <        source_p->localClient->random_ping = genrand_int32();
329 <      while (!source_p->localClient->random_ping);
328 >        client_p->connection->random_ping = genrand_int32();
329 >      while (!client_p->connection->random_ping);
330  
331 <      sendto_one(source_p, "PING :%u",
332 <                 source_p->localClient->random_ping);
304 <      SetPingSent(source_p);
331 >      sendto_one(client_p, "PING :%u", client_p->connection->random_ping);
332 >      AddFlag(client_p, FLAGS_PINGSENT);
333        return;
334      }
335  
336 <    if (!HasPingCookie(source_p))
336 >    if (!HasFlag(client_p, FLAGS_PING_COOKIE))
337        return;
338    }
339  
340 <  source_p->localClient->last = CurrentTime;
340 >  client_p->connection->last_privmsg = CurrentTime;
341    /* Straight up the maximum rate of flooding... */
342 <  source_p->localClient->allow_read = MAX_FLOOD_BURST;
342 >  client_p->connection->allow_read = MAX_FLOOD_BURST;
343  
344 <  if (!execute_callback(client_check_cb, source_p, source_p->username))
344 >  if (!check_client(client_p))
345      return;
346  
347 <  if (valid_hostname(source_p->host) == 0)
320 <  {
321 <    sendto_one(source_p, ":%s NOTICE %s :*** Notice -- You have an illegal "
322 <               "character in your hostname", me.name, source_p->name);
323 <    strlcpy(source_p->host, source_p->sockhost,
324 <            sizeof(source_p->host));
325 <  }
326 <
327 <  ptr   = source_p->localClient->confs.head;
328 <  aconf = map_to_conf(ptr->data);
347 >  conf = client_p->connection->confs.head->data;
348  
349 <  if (!IsGotId(source_p))
349 >  if (!HasFlag(client_p, FLAGS_GOTID))
350    {
351 <    char username[USERLEN + 1];
333 <    const char *p = username;
351 >    char username[USERLEN + 1] = "";
352      unsigned int i = 0;
353  
354 <    if (IsNeedIdentd(aconf))
354 >    if (IsNeedIdentd(conf))
355      {
356        ++ServerStats.is_ref;
357 <      sendto_one(source_p, ":%s NOTICE %s :*** Notice -- You need to install "
358 <                 "identd to use this server", me.name, source_p->name);
359 <      exit_client(source_p, &me, "Install identd");
357 >      sendto_one_notice(client_p, &me, ":*** Notice -- You need to install "
358 >                        "identd to use this server");
359 >      exit_client(client_p, "Install identd");
360        return;
361      }
362  
363 <    strlcpy(username, source_p->username, sizeof(username));
363 >    strlcpy(username, client_p->username, sizeof(username));
364  
365 <    if (!IsNoTilde(aconf))
366 <      source_p->username[i++] = '~';
365 >    if (!IsNoTilde(conf))
366 >      client_p->username[i++] = '~';
367  
368 <    for (; *p && i < USERLEN; ++p)
369 <      if (*p != '[')
352 <        source_p->username[i++] = *p;
368 >    for (const char *p = username; *p && i < USERLEN; ++p)
369 >      client_p->username[i++] = *p;
370  
371 <    source_p->username[i] = '\0';
371 >    client_p->username[i] = '\0';
372    }
373  
374 <  /* password check */
375 <  if (!EmptyString(aconf->passwd))
374 >  /* Password check */
375 >  if (!EmptyString(conf->passwd))
376    {
377 <    const char *pass = source_p->localClient->passwd;
361 <
362 <    if (!match_conf_password(pass, aconf))
377 >    if (!match_conf_password(client_p->connection->password, conf))
378      {
379        ++ServerStats.is_ref;
380 <      sendto_one(source_p, form_str(ERR_PASSWDMISMATCH),
381 <                 me.name, source_p->name);
382 <      exit_client(source_p, &me, "Bad Password");
380 >
381 >      sendto_one_numeric(client_p, &me, ERR_PASSWDMISMATCH);
382 >      exit_client(client_p, "Bad Password");
383        return;
384      }
385    }
386  
387 <  /* don't free source_p->localClient->passwd here - it can be required
388 <   * by masked /stats I if there are auth{} blocks with need_password = no;
387 >  /*
388 >   * Don't free client_p->connection->password here - it can be required
389 >   * by masked /stats I if there are auth {} blocks with need_password = no;
390     * --adx
391     */
392  
393 <  /* report if user has &^>= etc. and set flags as needed in source_p */
394 <  report_and_set_user_flags(source_p, aconf);
393 >  /*
394 >   * Report if user has &^>= etc. and set flags as needed in client_p
395 >   */
396 >  report_and_set_user_flags(client_p, conf);
397  
398 <  if (IsDead(source_p))
398 >  if (IsDead(client_p))
399      return;
400  
401 <  /* Limit clients -
401 >  /*
402 >   * Limit clients -
403     * We want to be able to have servers and F-line clients
404     * connect, so save room for "buffer" connections.
405     * Smaller servers may want to decrease this, and it should
406     * probably be just a percentage of the MAXCLIENTS...
407     *   -Taner
408     */
409 <  /* Except "F:" clients */
410 <  if ((Count.local >= ServerInfo.max_clients + MAX_BUFFER) ||
392 <      (Count.local >= ServerInfo.max_clients && !IsExemptLimits(source_p)))
409 >  if ((dlink_list_length(&local_client_list) >= GlobalSetOptions.maxclients + MAX_BUFFER) ||
410 >      (dlink_list_length(&local_client_list) >= GlobalSetOptions.maxclients && !HasFlag(client_p, FLAGS_NOLIMIT)))
411    {
412 <    sendto_realops_flags(UMODE_FULL, L_ALL,
412 >    sendto_realops_flags(UMODE_FULL, L_ALL, SEND_NOTICE,
413                           "Too many clients, rejecting %s[%s].",
414 <                         source_p->name, source_p->host);
414 >                         client_p->name, client_p->host);
415      ++ServerStats.is_ref;
416 <    exit_client(source_p, &me, "Sorry, server is full - try later");
416 >    exit_client(client_p, "Sorry, server is full - try later");
417      return;
418    }
419  
420 <  /* valid user name check */
403 <  if (valid_username(source_p->username) == 0)
420 >  if (!valid_username(client_p->username, 1))
421    {
422 <    char tmpstr2[IRCD_BUFSIZE];
422 >    char buf[IRCD_BUFSIZE] = "";
423  
424 <    sendto_realops_flags(UMODE_REJ, L_ALL, "Invalid username: %s (%s@%s)",
425 <                         source_p->name, source_p->username, source_p->host);
424 >    sendto_realops_flags(UMODE_REJ, L_ALL, SEND_NOTICE,
425 >                         "Invalid username: %s (%s@%s)",
426 >                         client_p->name, client_p->username, client_p->host);
427      ++ServerStats.is_ref;
428 <    snprintf(tmpstr2, sizeof(tmpstr2), "Invalid username [%s]",
429 <             source_p->username);
412 <    exit_client(source_p, &me, tmpstr2);
428 >    snprintf(buf, sizeof(buf), "Invalid username [%s]", client_p->username);
429 >    exit_client(client_p, buf);
430      return;
431    }
432  
433 <  if (check_xline(source_p))
433 >  if (check_xline(client_p))
434      return;
435  
436 <  while (hash_find_id((id = uid_get())) != NULL)
436 >  const char *id;
437 >  while (hash_find_id((id = uid_get())))
438      ;
439  
440 <  strlcpy(source_p->id, id, sizeof(source_p->id));
441 <  hash_add_id(source_p);
440 >  strlcpy(client_p->id, id, sizeof(client_p->id));
441 >  hash_add_id(client_p);
442  
443 <  sendto_realops_flags(UMODE_CCONN, L_ALL,
443 >  sendto_realops_flags(UMODE_CCONN, L_ALL, SEND_NOTICE,
444                         "Client connecting: %s (%s@%s) [%s] {%s} [%s] <%s>",
445 <                       source_p->name, source_p->username, source_p->host,
446 <                       ConfigFileEntry.hide_spoof_ips && IsIPSpoof(source_p) ?
447 <                       "255.255.255.255" : source_p->sockhost,
448 <                       get_client_class(source_p),
431 <                       source_p->info, source_p->id);
432 <
433 <  sendto_realops_flags(UMODE_CCONN_FULL, L_ALL,
434 <                       "CLICONN %s %s %s %s %s %s %s 0 %s",
435 <                       source_p->name, source_p->username, source_p->host,
436 <                       ConfigFileEntry.hide_spoof_ips && IsIPSpoof(source_p) ?
437 <                       "255.255.255.255" : source_p->sockhost,
438 <                       get_client_class(source_p),
439 <                       ConfigFileEntry.hide_spoof_ips && IsIPSpoof(source_p) ?
440 <                           "<hidden>" : source_p->localClient->client_host,
441 <                       ConfigFileEntry.hide_spoof_ips && IsIPSpoof(source_p) ?
442 <                           "<hidden>" : source_p->localClient->client_server,
443 <                       source_p->info);
444 <
445 >                       client_p->name, client_p->username, client_p->realhost,
446 >                       client_p->sockhost,
447 >                       get_client_class(&client_p->connection->confs),
448 >                       client_p->info, client_p->id);
449  
450 <  if (ConfigFileEntry.invisible_on_connect)
450 >  if (ConfigGeneral.invisible_on_connect)
451    {
452 <    source_p->umodes |= UMODE_INVISIBLE;
452 >    AddUMode(client_p, UMODE_INVISIBLE);
453      ++Count.invisi;
454    }
455  
456 <  if ((++Count.local) > Count.max_loc)
456 >  assert(client_p->servptr == &me);
457 >  SetClient(client_p);
458 >  dlinkAdd(client_p, &client_p->lnode, &client_p->servptr->serv->client_list);
459 >  dlinkAdd(client_p, &client_p->node, &global_client_list);
460 >
461 >  assert(dlinkFind(&unknown_list, client_p));
462 >
463 >  dlink_move_node(&client_p->connection->lclient_node,
464 >                  &unknown_list, &local_client_list);
465 >
466 >  if (dlink_list_length(&local_client_list) > Count.max_loc)
467    {
468 <    Count.max_loc = Count.local;
468 >    Count.max_loc = dlink_list_length(&local_client_list);
469  
470      if (!(Count.max_loc % 10))
471 <      sendto_realops_flags(UMODE_ALL, L_ALL, "New Max Local Clients: %d",
471 >      sendto_realops_flags(UMODE_SERVNOTICE, L_ALL, SEND_NOTICE,
472 >                           "New maximum local client connections: %u",
473                             Count.max_loc);
474    }
475  
476 <  /* Increment our total user count here */
477 <  if (++Count.total > Count.max_tot)
478 <    Count.max_tot = Count.total;
479 <  ++Count.totalrestartcount;
465 <
466 <  assert(source_p->servptr == &me);
467 <  SetClient(source_p);
468 <  dlinkAdd(source_p, &source_p->lnode, &source_p->servptr->serv->client_list);
476 >  if ((dlink_list_length(&local_client_list) +
477 >       dlink_list_length(&local_server_list)) > Count.max_loc_con)
478 >    Count.max_loc_con = dlink_list_length(&local_client_list) +
479 >                        dlink_list_length(&local_server_list);
480  
481 <  source_p->localClient->allow_read = MAX_FLOOD_BURST;
482 <
483 <  assert(dlinkFind(&unknown_list, source_p));
473 <
474 <  dlink_move_node(&source_p->localClient->lclient_node,
475 <                  &unknown_list, &local_client_list);
481 >  if (dlink_list_length(&global_client_list) > Count.max_tot)
482 >    Count.max_tot = dlink_list_length(&global_client_list);
483 >  ++Count.totalrestartcount;
484  
485 <  user_welcome(source_p);
486 <  add_user_host(source_p->username, source_p->host, 0);
487 <  SetUserHost(source_p);
485 >  user_welcome(client_p);
486 >  userhost_add(client_p->sockhost, 0);
487 >  AddFlag(client_p, FLAGS_USERHOST);
488  
489 <  introduce_client(source_p);
489 >  introduce_client(client_p);
490   }
491  
492   /* register_remote_user()
493   *
494 < * inputs       - source_p remote or directly connected client
494 > * inputs       - client_p remote or directly connected client
495   *              - username to register as
496   *              - host name to register as
497   *              - server name
490 *              - realname (gecos)
498   * output       - NONE
499   * side effects - This function is called when a remote client
500   *                is introduced by a server.
501   */
502   void
503 < register_remote_user(struct Client *source_p,
497 <                     const char *username, const char *host, const char *server,
498 <                     const char *realname)
503 > register_remote_user(struct Client *client_p)
504   {
505 <  struct Client *target_p = NULL;
501 <
502 <  assert(source_p != NULL);
503 <  assert(source_p->username != username);
504 <
505 <  strlcpy(source_p->host, host, sizeof(source_p->host));
506 <  strlcpy(source_p->username, username, sizeof(source_p->username));
505 >  assert(client_p->servptr->from == client_p->from);
506  
507    /*
508 <   * coming from another server, take the servers word for it
508 >   * If the nick has been introduced by a services server,
509 >   * make it a service as well.
510     */
511 <  source_p->servptr = find_server(server);
512 <
513 <  /* Super GhostDetect:
514 <   * If we can't find the server the user is supposed to be on,
515 <   * then simply blow the user away.        -Taner
516 <   */
517 <  if (source_p->servptr == NULL)
518 <  {
519 <    sendto_realops_flags(UMODE_ALL, L_ALL,
520 <                         "No server %s for user %s[%s@%s] from %s",
521 <                         server, source_p->name, source_p->username,
522 <                         source_p->host, source_p->from->name);
523 <    kill_client(source_p->from, source_p, "%s (Server doesn't exist)", me.name);
511 >  if (HasFlag(client_p->servptr, FLAGS_SERVICE))
512 >    AddFlag(client_p, FLAGS_SERVICE);
513  
514 <    SetKilled(source_p);
515 <    exit_client(source_p, &me, "Ghosted Client");
516 <    return;
517 <  }
518 <
519 <  if ((target_p = source_p->servptr) && target_p->from != source_p->from)
520 <  {
521 <    sendto_realops_flags(UMODE_DEBUG, L_ALL,
522 <                         "Bad User [%s] :%s USER %s@%s %s, != %s[%s]",
523 <                         source_p->from->name, source_p->name, source_p->username,
524 <                         source_p->host, source_p->servptr->name,
525 <                         target_p->name, target_p->from->name);
526 <    kill_client(source_p->from, source_p,
527 <                "%s (NICK from wrong direction (%s != %s))",
528 <                me.name, source_p->servptr->name, target_p->from->name);
529 <    SetKilled(source_p);
541 <    exit_client(source_p, &me, "USER server wrong direction");
542 <    return;
543 <  }
514 >  SetClient(client_p);
515 >  dlinkAdd(client_p, &client_p->lnode, &client_p->servptr->serv->client_list);
516 >  dlinkAdd(client_p, &client_p->node, &global_client_list);
517 >
518 >  if (dlink_list_length(&global_client_list) > Count.max_tot)
519 >    Count.max_tot = dlink_list_length(&global_client_list);
520 >
521 >  userhost_add(client_p->sockhost, 1);
522 >  AddFlag(client_p, FLAGS_USERHOST);
523 >
524 >  if (HasFlag(client_p->servptr, FLAGS_EOB))
525 >    sendto_realops_flags(UMODE_FARCONNECT, L_ALL, SEND_NOTICE,
526 >                         "Client connecting at %s: %s (%s@%s) [%s] [%s] <%s>",
527 >                         client_p->servptr->name,
528 >                         client_p->name, client_p->username, client_p->realhost,
529 >                         client_p->sockhost, client_p->info, client_p->id);
530  
531 <  /* Increment our total user count here */
546 <  if (++Count.total > Count.max_tot)
547 <    Count.max_tot = Count.total;
548 <
549 <  SetClient(source_p);
550 <  dlinkAdd(source_p, &source_p->lnode, &source_p->servptr->serv->client_list);
551 <  add_user_host(source_p->username, source_p->host, 1);
552 <  SetUserHost(source_p);
553 <
554 <  introduce_client(source_p);
555 < }
556 <
557 < /* introduce_client()
558 < *
559 < * inputs       - source_p
560 < * output       - NONE
561 < * side effects - This common function introduces a client to the rest
562 < *                of the net, either from a local client connect or
563 < *                from a remote connect.
564 < */
565 < static void
566 < introduce_client(struct Client *source_p)
567 < {
568 <  dlink_node *server_node = NULL;
569 <  static char ubuf[12];
570 <
571 <  if (MyClient(source_p))
572 <    send_umode(source_p, source_p, 0, SEND_UMODES, ubuf);
573 <  else
574 <    send_umode(NULL, source_p, 0, SEND_UMODES, ubuf);
575 <
576 <  watch_check_hash(source_p, RPL_LOGON);
577 <
578 <  if (*ubuf == '\0')
579 <  {
580 <    ubuf[0] = '+';
581 <    ubuf[1] = '\0';
582 <  }
583 <
584 <  DLINK_FOREACH(server_node, serv_list.head)
585 <  {
586 <    struct Client *server = server_node->data;
587 <
588 <    if (server == source_p->from)
589 <        continue;
590 <
591 <    if (IsCapable(server, CAP_TS6) && HasID(source_p))
592 <      sendto_one(server, ":%s UID %s %d %lu %s %s %s %s %s :%s",
593 <                 source_p->servptr->id,
594 <                 source_p->name, source_p->hopcount+1,
595 <                 (unsigned long)source_p->tsinfo,
596 <                 ubuf, source_p->username, source_p->host,
597 <                 (MyClient(source_p) && IsIPSpoof(source_p)) ?
598 <                 "0" : source_p->sockhost, source_p->id, source_p->info);
599 <    else
600 <      sendto_one(server, "NICK %s %d %lu %s %s %s %s :%s",
601 <                 source_p->name, source_p->hopcount+1,
602 <                 (unsigned long)source_p->tsinfo,
603 <                 ubuf, source_p->username, source_p->host,
604 <                 source_p->servptr->name, source_p->info);
605 <  }
531 >  introduce_client(client_p);
532   }
533  
534   /* valid_hostname()
# Line 619 | Line 545 | valid_hostname(const char *hostname)
545   {
546    const char *p = hostname;
547  
548 <  assert(p != NULL);
548 >  assert(p);
549  
550 <  if (*p == '.' || *p == ':')
550 >  if (EmptyString(p) || *p == '.' || *p == ':')
551      return 0;
552  
553    for (; *p; ++p)
554      if (!IsHostChar(*p))
555        return 0;
556  
557 <  return 1;
557 >  return p - hostname <= HOSTLEN;
558   }
559  
560   /* valid_username()
# Line 643 | Line 569 | valid_hostname(const char *hostname)
569   * style of username
570   */
571   int
572 < valid_username(const char *username)
572 > valid_username(const char *username, const int local)
573   {
648  int dots      = 0;
574    const char *p = username;
575  
576 <  assert(p != NULL);
576 >  assert(p);
577  
578    if (*p == '~')
579      ++p;
580  
581 <  /* reject usernames that don't start with an alphanum
581 >  /*
582 >   * Reject usernames that don't start with an alphanum
583     * i.e. reject jokers who have '-@somehost' or '.@somehost'
584     * or "-hi-@somehost", "h-----@somehost" would still be accepted.
585     */
586    if (!IsAlNum(*p))
587      return 0;
588  
589 <  while (*++p)
589 >  if (local)
590    {
591 <    if ((*p == '.') && ConfigFileEntry.dots_in_ident)
591 >    unsigned int dots = 0;
592 >
593 >    while (*++p)
594      {
595 <      if (++dots > ConfigFileEntry.dots_in_ident)
596 <        return 0;
597 <      if (!IsUserChar(*(p + 1)))
595 >      if (*p == '.' && ConfigGeneral.dots_in_ident)
596 >      {
597 >        if (++dots > ConfigGeneral.dots_in_ident)
598 >          return 0;
599 >        if (!IsUserChar(*(p + 1)))
600 >          return 0;
601 >      }
602 >      else if (!IsUserChar(*p))
603          return 0;
604      }
672    else if (!IsUserChar(*p))
673      return 0;
674  }
675
676  return 1;
677 }
678
679 /* report_and_set_user_flags()
680 *
681 * inputs       - pointer to source_p
682 *              - pointer to aconf for this user
683 * output       - NONE
684 * side effects - Report to user any special flags
685 *                they are getting, and set them.
686 */
687 static void
688 report_and_set_user_flags(struct Client *source_p, const struct AccessItem *aconf)
689 {
690  /* If this user is being spoofed, tell them so */
691  if (IsConfDoSpoofIp(aconf))
692  {
693    sendto_one(source_p,
694               ":%s NOTICE %s :*** Spoofing your IP. congrats.",
695               me.name, source_p->name);
605    }
606 <
698 <  /* If this user is in the exception class, Set it "E lined" */
699 <  if (IsConfExemptKline(aconf))
700 <  {
701 <    SetExemptKline(source_p);
702 <    sendto_one(source_p,
703 <               ":%s NOTICE %s :*** You are exempt from K/D/G lines. congrats.",
704 <               me.name, source_p->name);
705 <  }
706 <
707 <  /* The else here is to make sure that G line exempt users
708 <   * do not get noticed twice.
709 <   */
710 <  else if (IsConfExemptGline(aconf))
711 <  {
712 <    SetExemptGline(source_p);
713 <    sendto_one(source_p, ":%s NOTICE %s :*** You are exempt from G lines.",
714 <               me.name, source_p->name);
715 <  }
716 <
717 <  if (IsConfExemptResv(aconf))
718 <  {
719 <    SetExemptResv(source_p);
720 <    sendto_one(source_p, ":%s NOTICE %s :*** You are exempt from resvs.",
721 <               me.name, source_p->name);
722 <  }
723 <
724 <  /* If this user is exempt from user limits set it "F lined" */
725 <  if (IsConfExemptLimits(aconf))
726 <  {
727 <    SetExemptLimits(source_p);
728 <    sendto_one(source_p,
729 <               ":%s NOTICE %s :*** You are exempt from user limits. congrats.",
730 <               me.name,source_p->name);
731 <  }
732 <
733 <  /* If this user is exempt from idle time outs */
734 <  if (IsConfIdlelined(aconf))
735 <  {
736 <    SetIdlelined(source_p);
737 <    sendto_one(source_p,
738 <               ":%s NOTICE %s :*** You are exempt from idle limits. congrats.",
739 <               me.name, source_p->name);
740 <  }
741 <
742 <  if (IsConfCanFlood(aconf))
606 >  else
607    {
608 <    SetCanFlood(source_p);
609 <    sendto_one(source_p, ":%s NOTICE %s :*** You are exempt from flood "
610 <               "protection, aren't you fearsome.",
747 <               me.name, source_p->name);
608 >    while (*++p)
609 >      if (!IsUserChar(*p))
610 >        return 0;
611    }
749 }
750
751 /* change_simple_umode()
752 *
753 * this callback can be hooked to allow special handling of
754 * certain usermodes
755 */
756 static void *
757 change_simple_umode(va_list args)
758 {
759  struct Client *client_p;
760  struct Client *source_p;
761  int what;
762  unsigned int flag;
763
764  client_p = va_arg(args, struct Client *);
765  source_p = va_arg(args, struct Client *);
766  what = va_arg(args, int);
767  flag = va_arg(args, unsigned int);
768
769  if (what == MODE_ADD)
770    source_p->umodes |= flag;
771  else
772    source_p->umodes &= ~flag;
612  
613 <  return NULL;
613 >  return p - username <= USERLEN;
614   }
615  
616 < /* set_user_mode()
616 > /* clean_nick_name()
617   *
618 < * added 15/10/91 By Darren Reed.
619 < * parv[0] - sender
620 < * parv[1] - username to change mode for
621 < * parv[2] - modes to change
618 > * input        - nickname
619 > *              - whether it's a local nick (1) or remote (0)
620 > * output       - none
621 > * side effects - walks through the nickname, returning 0 if erroneous
622   */
623 < void
624 < set_user_mode(struct Client *client_p, struct Client *source_p,
786 <              int parc, char *parv[])
623 > int
624 > valid_nickname(const char *nickname, const int local)
625   {
626 <  unsigned int flag, setflags;
789 <  char **p, *m, buf[IRCD_BUFSIZE];
790 <  struct Client *target_p;
791 <  int what = MODE_ADD, badflag = 0, i;
792 <
793 <  assert(!(parc < 2));
794 <
795 <  if ((target_p = find_person(client_p, parv[1])) == NULL)
796 <  {
797 <    if (MyConnect(source_p))
798 <      sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL),
799 <                 me.name, source_p->name, parv[1]);
800 <    return;
801 <  }
802 <
803 <  if (IsServer(source_p))
804 <  {
805 <     sendto_realops_flags(UMODE_ALL, L_ADMIN, "*** Mode for User %s from %s",
806 <                          parv[1], source_p->name);
807 <     return;
808 <  }
809 <
810 <  if (source_p != target_p)
811 <  {
812 <     sendto_one(source_p, form_str(ERR_USERSDONTMATCH),
813 <                me.name, source_p->name);
814 <     return;
815 <  }
816 <
817 <  if (parc < 3)
818 <  {
819 <    m = buf;
820 <    *m++ = '+';
821 <
822 <    for (i = 0; i < 128; i++)
823 <      if (source_p->umodes & user_modes[i])
824 <        *m++ = (char)i;
825 <    *m = '\0';
826 <
827 <    sendto_one(source_p, form_str(RPL_UMODEIS),
828 <               me.name, source_p->name, buf);
829 <    return;
830 <  }
831 <
832 <  execute_callback(entering_umode_cb, client_p, source_p);
833 <
834 <  /* find flags already set for user */
835 <  setflags = source_p->umodes;
836 <
837 <  /* parse mode change string(s) */
838 <  for (p = &parv[2]; p && *p; p++)
839 <  {
840 <    for (m = *p; *m; m++)
841 <    {
842 <      switch (*m)
843 <      {
844 <        case '+':
845 <          what = MODE_ADD;
846 <          break;
847 <        case '-':
848 <          what = MODE_DEL;
849 <          break;
850 <        case 'o':
851 <          if (what == MODE_ADD)
852 <          {
853 <            if (IsServer(client_p) && !IsOper(source_p))
854 <            {
855 <              ++Count.oper;
856 <              SetOper(source_p);
857 <            }
858 <          }
859 <          else
860 <          {
861 <            /* Only decrement the oper counts if an oper to begin with
862 <             * found by Pat Szuta, Perly , perly@xnet.com
863 <             */
864 <            if (!IsOper(source_p))
865 <              break;
866 <
867 <            ClearOper(source_p);
868 <            Count.oper--;
869 <
870 <            if (MyConnect(source_p))
871 <            {
872 <              dlink_node *dm;
873 <
874 <              detach_conf(source_p, OPER_TYPE);
875 <              ClearOperFlags(source_p);
876 <              source_p->umodes &= ~ConfigFileEntry.oper_only_umodes;
877 <
878 <              if ((dm = dlinkFindDelete(&oper_list, source_p)) != NULL)
879 <                free_dlink_node(dm);
880 <            }
881 <          }
882 <
883 <          break;
884 <
885 <        /* we may not get these,
886 <         * but they shouldnt be in default
887 <         */
888 <        case ' ' :
889 <        case '\n':
890 <        case '\r':
891 <        case '\t':
892 <          break;
893 <
894 <        default:
895 <          if ((flag = user_modes[(unsigned char)*m]))
896 <          {
897 <            if (MyConnect(source_p) && !IsOper(source_p) &&
898 <                (ConfigFileEntry.oper_only_umodes & flag))
899 <            {
900 <              badflag = 1;
901 <            }
902 <            else
903 <              execute_callback(umode_cb, client_p, source_p, what, flag);
904 <          }
905 <          else
906 <          {
907 <            if (MyConnect(source_p))
908 <              badflag = 1;
909 <          }
910 <
911 <          break;
912 <      }
913 <    }
914 <  }
915 <
916 <  if (badflag)
917 <    sendto_one(source_p, form_str(ERR_UMODEUNKNOWNFLAG),
918 <               me.name, source_p->name);
919 <
920 <  if ((source_p->umodes & UMODE_NCHANGE) && !IsOperN(source_p))
921 <  {
922 <    sendto_one(source_p, ":%s NOTICE %s :*** You have no admin flag;",
923 <               me.name, source_p->name);
924 <    source_p->umodes &= ~UMODE_NCHANGE; /* only tcm's really need this */
925 <  }
926 <
927 <  if (MyConnect(source_p) && (source_p->umodes & UMODE_ADMIN) &&
928 <      !IsOperAdmin(source_p) && !IsOperHiddenAdmin(source_p))
929 <  {
930 <    sendto_one(source_p, ":%s NOTICE %s :*** You have no admin flag;",
931 <               me.name, source_p->name);
932 <    source_p->umodes &= ~UMODE_ADMIN;
933 <  }
626 >  const char *p = nickname;
627  
628 <  if (!(setflags & UMODE_INVISIBLE) && IsInvisible(source_p))
936 <    ++Count.invisi;
937 <  if ((setflags & UMODE_INVISIBLE) && !IsInvisible(source_p))
938 <    --Count.invisi;
628 >  assert(p);
629  
630    /*
631 <   * compare new flags with old flags and send string which
942 <   * will cause servers to update correctly.
631 >   * Nicks can't start with a digit or - or be 0 length.
632     */
633 <  send_umode_out(client_p, source_p, setflags);
633 >  if (EmptyString(p) || *p == '-' || (IsDigit(*p) && local))
634 >    return 0;
635 >
636 >  for (; *p; ++p)
637 >    if (!IsNickChar(*p))
638 >      return 0;
639 >
640 >  return p - nickname <= NICKLEN;
641   }
642  
643 < /* send_umode()
644 < * send the MODE string for user (user) to connection client_p
645 < * -avalon
646 < *
647 < * inputs       - client_p
952 < *              - source_p
953 < *              - int old
954 < *              - sendmask mask of modes to send
955 < *              - suplied umode_buf
956 < * output       - NONE
643 > /*! \brief Builds a mode change string to buffer pointed by \a buf
644 > * \param client_p  Pointer to client
645 > * \param dispatch  Whether to send a MODE message to client_p
646 > * \param old       Old user mode to compare against when building new mode buffer
647 > * \param buf       Pointer to buffer to build string in
648   */
649   void
650 < send_umode(struct Client *client_p, struct Client *source_p,
651 <           unsigned int old, unsigned int sendmask, char *umode_buf)
650 > send_umode(struct Client *client_p, unsigned int dispatch,
651 >           unsigned int old, char *buf)
652   {
653 <  char *m = umode_buf;
653 >  char *m = buf;
654    int what = 0;
964  unsigned int i;
965  unsigned int flag;
655  
656    /*
657 <   * build a string in umode_buf to represent the change in the user's
658 <   * mode between the new (source_p->umodes) and 'old'.
657 >   * Build a string in umode_buf to represent the change in the user's
658 >   * mode between the new (client_p->umodes) and 'old'.
659     */
660 <  for (i = 0; i < 128; i++)
660 >  for (const struct user_modes *tab = umode_tab; tab->c; ++tab)
661    {
662 <    flag = user_modes[i];
974 <    if (!flag)
975 <      continue;
976 <
977 <    if (MyClient(source_p) && !(flag & sendmask))
978 <      continue;
979 <
980 <    if ((flag & old) && !(source_p->umodes & flag))
662 >    if ((tab->flag & old) && !HasUMode(client_p, tab->flag))
663      {
664        if (what == MODE_DEL)
665 <        *m++ = (char)i;
665 >        *m++ = tab->c;
666        else
667        {
668          what = MODE_DEL;
669          *m++ = '-';
670 <        *m++ = (char)i;
670 >        *m++ = tab->c;
671        }
672      }
673 <    else if (!(flag & old) && (source_p->umodes & flag))
673 >    else if (!(tab->flag & old) && HasUMode(client_p, tab->flag))
674      {
675        if (what == MODE_ADD)
676 <        *m++ = (char)i;
676 >        *m++ = tab->c;
677        else
678        {
679          what = MODE_ADD;
680          *m++ = '+';
681 <        *m++ = (char)i;
681 >        *m++ = tab->c;
682        }
683      }
684    }
685  
686    *m = '\0';
687  
688 <  if (*umode_buf && client_p)
688 >  if (dispatch && *buf)
689      sendto_one(client_p, ":%s!%s@%s MODE %s :%s",
690 <               source_p->name, source_p->username,
691 <               source_p->host, source_p->name, umode_buf);
690 >               client_p->name, client_p->username,
691 >               client_p->host, client_p->name, buf);
692   }
693  
694   /* send_umode_out()
# Line 1016 | Line 698 | send_umode(struct Client *client_p, stru
698   * side effects - Only send ubuf out to servers that know about this client
699   */
700   void
701 < send_umode_out(struct Client *client_p, struct Client *source_p,
1020 <               unsigned int old)
701 > send_umode_out(struct Client *client_p, unsigned int old)
702   {
703 <  char buf[IRCD_BUFSIZE] = { '\0' };
1023 <  dlink_node *ptr = NULL;
703 >  char buf[UMODE_MAX_STR] = "";
704  
705 <  send_umode(NULL, source_p, old, IsOperHiddenAdmin(source_p) ?
1026 <             SEND_UMODES & ~UMODE_ADMIN : SEND_UMODES, buf);
705 >  send_umode(client_p, MyConnect(client_p), old, buf);
706  
707    if (buf[0])
708 <  {
709 <    DLINK_FOREACH(ptr, serv_list.head)
1031 <    {
1032 <      struct Client *target_p = ptr->data;
1033 <
1034 <      if ((target_p != client_p) && (target_p != source_p))
1035 <        sendto_one(target_p, ":%s MODE %s :%s",
1036 <                   ID_or_name(source_p, target_p),
1037 <                   ID_or_name(source_p, target_p), buf);
1038 <    }
1039 <  }
1040 <
1041 <  if (client_p && MyClient(client_p))
1042 <    send_umode(client_p, source_p, old, 0xffffffff, buf);
1043 < }
1044 <
1045 < /* user_welcome()
1046 < *
1047 < * inputs       - client pointer to client to welcome
1048 < * output       - NONE
1049 < * side effects -
1050 < */
1051 < static void
1052 < user_welcome(struct Client *source_p)
1053 < {
1054 < #if defined(__TIME__) && defined(__DATE__)
1055 <  static const char built_date[] = __DATE__ " at " __TIME__;
1056 < #else
1057 <  static const char built_date[] = "unknown";
1058 < #endif
1059 <
1060 < #ifdef HAVE_LIBCRYPTO
1061 <  if (source_p->localClient->fd.ssl != NULL)
1062 <    sendto_one(source_p, ":%s NOTICE %s :*** Connected securely via %s",
1063 <               me.name, source_p->name,
1064 <               ssl_get_cipher(source_p->localClient->fd.ssl));
1065 < #endif
1066 <
1067 <  sendto_one(source_p, form_str(RPL_WELCOME), me.name, source_p->name,
1068 <             ServerInfo.network_name, source_p->name);
1069 <  sendto_one(source_p, form_str(RPL_YOURHOST), me.name, source_p->name,
1070 <             get_listener_name(source_p->localClient->listener), ircd_version);
1071 <  sendto_one(source_p, form_str(RPL_CREATED),
1072 <             me.name, source_p->name, built_date);
1073 <  sendto_one(source_p, form_str(RPL_MYINFO),
1074 <             me.name, source_p->name, me.name, ircd_version, umode_buffer);
1075 <  show_isupport(source_p);
1076 <
1077 <  if (source_p->id[0] != '\0')
1078 <    sendto_one(source_p, form_str(RPL_YOURID), me.name,
1079 <               source_p->name, source_p->id);
1080 <
1081 <  show_lusers(source_p);
1082 <
1083 <  if (ConfigFileEntry.short_motd)
1084 <  {
1085 <    sendto_one(source_p, ":%s NOTICE %s :*** Notice -- motd was last changed at %s",
1086 <               me.name, source_p->name, ConfigFileEntry.motd.lastChangedDate);
1087 <    sendto_one(source_p,
1088 <               ":%s NOTICE %s :*** Notice -- Please read the motd if you haven't "
1089 <               "read it", me.name, source_p->name);
1090 <    sendto_one(source_p, form_str(RPL_MOTDSTART),
1091 <               me.name, source_p->name, me.name);
1092 <    sendto_one(source_p, form_str(RPL_MOTD),
1093 <               me.name, source_p->name,
1094 <               "*** This is the short motd ***");
1095 <    sendto_one(source_p, form_str(RPL_ENDOFMOTD),
1096 <               me.name, source_p->name);
1097 <  }
1098 <  else  
1099 <    send_message_file(source_p, &ConfigFileEntry.motd);
1100 < }
1101 <
1102 < /* check_xline()
1103 < *
1104 < * inputs       - pointer to client to test
1105 < * outupt       - 1 if exiting 0 if ok
1106 < * side effects -
1107 < */
1108 < static int
1109 < check_xline(struct Client *source_p)
1110 < {
1111 <  struct ConfItem *conf = NULL;
1112 <  const char *reason = NULL;
1113 <
1114 <  if ((conf = find_matching_name_conf(XLINE_TYPE, source_p->info, NULL, NULL, 0)) ||
1115 <      (conf = find_matching_name_conf(RXLINE_TYPE, source_p->info, NULL, NULL, 0)))
1116 <  {
1117 <    struct MatchItem *reg = map_to_conf(conf);
1118 <
1119 <    ++reg->count;
1120 <
1121 <    if (reg->reason != NULL)
1122 <      reason = reg->reason;
1123 <    else
1124 <      reason = "No Reason";
1125 <
1126 <    sendto_realops_flags(UMODE_REJ, L_ALL,
1127 <                         "X-line Rejecting [%s] [%s], user %s [%s]",
1128 <                         source_p->info, reason,
1129 <                         get_client_name(source_p, HIDE_IP),
1130 <                         source_p->sockhost);
1131 <
1132 <    ++ServerStats.is_ref;
1133 <    if (REJECT_HOLD_TIME > 0)
1134 <    {
1135 <      sendto_one(source_p, ":%s NOTICE %s :Bad user info",
1136 <                 me.name, source_p->name);
1137 <      source_p->localClient->reject_delay = CurrentTime + REJECT_HOLD_TIME;
1138 <      SetCaptured(source_p);
1139 <    }
1140 <    else
1141 <      exit_client(source_p, &me, "Bad user info");
1142 <    return 1;
1143 <  }
1144 <
1145 <  return 0;
1146 < }
1147 <
1148 < /* oper_up()
1149 < *
1150 < * inputs       - pointer to given client to oper
1151 < * output       - NONE
1152 < * side effects - Blindly opers up given source_p, using aconf info
1153 < *                all checks on passwords have already been done.
1154 < *                This could also be used by rsa oper routines.
1155 < */
1156 < void
1157 < oper_up(struct Client *source_p)
1158 < {
1159 <  unsigned int old = source_p->umodes;
1160 <  const char *operprivs = "";
1161 <  const struct AccessItem *oconf = NULL;
1162 <
1163 <  assert(source_p->localClient->confs.head);
1164 <  oconf = map_to_conf((source_p->localClient->confs.head)->data);
1165 <
1166 <  ++Count.oper;
1167 <  SetOper(source_p);
1168 <
1169 <  if (oconf->modes)
1170 <    source_p->umodes |= oconf->modes;
1171 <  else if (ConfigFileEntry.oper_umodes)
1172 <    source_p->umodes |= ConfigFileEntry.oper_umodes;
1173 <  else
1174 <    source_p->umodes |= (UMODE_SERVNOTICE|UMODE_OPERWALL|
1175 <                         UMODE_WALLOP|UMODE_LOCOPS);
1176 <
1177 <  if (!(old & UMODE_INVISIBLE) && IsInvisible(source_p))
1178 <    ++Count.invisi;
1179 <  if ((old & UMODE_INVISIBLE) && !IsInvisible(source_p))
1180 <    --Count.invisi;
1181 <
1182 <  assert(dlinkFind(&oper_list, source_p) == NULL);
1183 <  dlinkAdd(source_p, make_dlink_node(), &oper_list);
1184 <
1185 <  operprivs = oper_privs_as_string(oconf->port);
1186 <
1187 <  SetOFlag(source_p, oconf->port);
1188 <
1189 <  if (IsOperAdmin(source_p) || IsOperHiddenAdmin(source_p))
1190 <    source_p->umodes |= UMODE_ADMIN;
1191 <  if (!IsOperN(source_p))
1192 <    source_p->umodes &= ~UMODE_NCHANGE;
1193 <
1194 <  sendto_realops_flags(UMODE_ALL, L_ALL, "%s (%s@%s) is now an operator",
1195 <                       source_p->name, source_p->username, source_p->host);
1196 <  send_umode_out(source_p, source_p, old);
1197 <  sendto_one(source_p, form_str(RPL_YOUREOPER), me.name, source_p->name);
1198 <  sendto_one(source_p, ":%s NOTICE %s :*** Oper privs are %s",
1199 <             me.name, source_p->name, operprivs);
1200 <  send_message_file(source_p, &ConfigFileEntry.opermotd);
1201 < }
1202 <
1203 < static char new_uid[TOTALSIDUID + 1];     /* allow for \0 */
1204 <
1205 < int
1206 < valid_sid(const char *sid)
1207 < {
1208 <  if (strlen(sid) == IRC_MAXSID)
1209 <    if (IsDigit(*sid))
1210 <      if (IsAlNum(*(sid + 1)) && IsAlNum(*(sid + 2)))
1211 <        return 1;
1212 <
1213 <  return 0;
708 >    sendto_server(client_p, 0, 0, ":%s MODE %s :%s",
709 >                  client_p->id, client_p->id, buf);
710   }
711  
1216 /*
1217 * init_uid()
1218 *
1219 * inputs       - NONE
1220 * output       - NONE
1221 * side effects - new_uid is filled in with server id portion (sid)
1222 *                (first 3 bytes) or defaulted to 'A'.
1223 *                Rest is filled in with 'A'
1224 */
712   void
713 < init_uid(void)
713 > user_set_hostmask(struct Client *client_p, const char *hostname)
714   {
715 <  int i;
1229 <
1230 <  memset(new_uid, 0, sizeof(new_uid));
715 >  dlink_node *node;
716  
717 <  if (!EmptyString(ServerInfo.sid))
718 <    strlcpy(new_uid, ServerInfo.sid, sizeof(new_uid));
717 >  if (!strcmp(client_p->host, hostname))
718 >    return;
719  
720 <  for (i = 0; i < IRC_MAXSID; ++i)
721 <    if (new_uid[i] == '\0')
722 <      new_uid[i] = 'A';
720 >  if (ConfigGeneral.cycle_on_host_change)
721 >    sendto_common_channels_local(client_p, 0, 0, CAP_CHGHOST, ":%s!%s@%s QUIT :Changing hostname",
722 >                                 client_p->name, client_p->username, client_p->host);
723  
724 <  /* NOTE: if IRC_MAXUID != 6, this will have to be rewritten */
725 <  /* Yes nenolod, I have known it was off by one ever since I wrote it
726 <   * But *JUST* for you, though, it really doesn't look as *pretty*
1242 <   * -Dianora
1243 <   */
1244 <  memcpy(new_uid + IRC_MAXSID, "AAAAA@", IRC_MAXUID);
724 >  sendto_common_channels_local(client_p, 0, CAP_CHGHOST, 0, ":%s!%s@%s CHGHOST %s %s",
725 >                               client_p->name, client_p->username,
726 >                               client_p->host, client_p->username, hostname);
727  
728 <  entering_umode_cb = register_callback("entering_umode", NULL);
1247 <  umode_cb = register_callback("changing_umode", change_simple_umode);
1248 < }
728 >  strlcpy(client_p->host, hostname, sizeof(client_p->host));
729  
730 < /*
1251 < * add_one_to_uid
1252 < *
1253 < * inputs       - index number into new_uid
1254 < * output       - NONE
1255 < * side effects - new_uid is incremented by one
1256 < *                note this is a recursive function
1257 < */
1258 < static void
1259 < add_one_to_uid(int i)
1260 < {
1261 <  if (i != IRC_MAXSID)    /* Not reached server SID portion yet? */
1262 <  {
1263 <    if (new_uid[i] == 'Z')
1264 <      new_uid[i] = '0';
1265 <    else if (new_uid[i] == '9')
1266 <    {
1267 <      new_uid[i] = 'A';
1268 <      add_one_to_uid(i-1);
1269 <    }
1270 <    else
1271 <      ++new_uid[i];
1272 <  }
1273 <  else
730 >  if (MyConnect(client_p))
731    {
732 <    /* NOTE: if IRC_MAXUID != 6, this will have to be rewritten */
733 <    if (new_uid[i] == 'Z')
1277 <      memcpy(new_uid + IRC_MAXSID, "AAAAAA", IRC_MAXUID);
1278 <    else
1279 <      ++new_uid[i];
732 >    sendto_one_numeric(client_p, &me, RPL_VISIBLEHOST, client_p->host);
733 >    clear_ban_cache_list(&client_p->channel);
734    }
1281 }
1282
1283 /*
1284 * uid_get
1285 *
1286 * inputs       - struct Client *
1287 * output       - new UID is returned to caller
1288 * side effects - new_uid is incremented by one.
1289 */
1290 static const char *
1291 uid_get(void)
1292 {
1293  add_one_to_uid(TOTALSIDUID - 1);    /* index from 0 */
1294  return new_uid;
1295 }
735  
736 < /*
737 < * init_isupport()
1299 < *
1300 < * input        - NONE
1301 < * output       - NONE
1302 < * side effects - Must be called before isupport is enabled
1303 < */
1304 < void
1305 < init_isupport(void)
1306 < {
1307 <  isupportFile = init_MessageLine();
1308 <
1309 <  add_isupport("CALLERID", NULL, -1);
1310 <  add_isupport("CASEMAPPING", CASEMAP, -1);
1311 <  add_isupport("DEAF", "D", -1);
1312 <  add_isupport("KICKLEN", NULL, KICKLEN);
1313 <  add_isupport("MODES", NULL, MAXMODEPARAMS);
1314 <  add_isupport("NICKLEN", NULL, NICKLEN-1);
1315 < #ifdef HALFOPS
1316 <  add_isupport("PREFIX", "(ohv)@%+", -1);
1317 <  add_isupport("STATUSMSG", "@%+", -1);
1318 < #else
1319 <  add_isupport("PREFIX", "(ov)@+", -1);
1320 <  add_isupport("STATUSMSG", "@+", -1);
1321 < #endif
1322 <  add_isupport("TOPICLEN", NULL, TOPICLEN);
1323 < }
1324 <
1325 < /*
1326 < * add_isupport()
1327 < *
1328 < * input        - name of supported function
1329 < *              - options if any
1330 < *              - number if any
1331 < * output       - NONE
1332 < * side effects - Each supported item must call this when activated
1333 < */
1334 < void
1335 < add_isupport(const char *name, const char *options, int n)
1336 < {
1337 <  dlink_node *ptr;
1338 <  struct Isupport *support;
1339 <
1340 <  DLINK_FOREACH(ptr, support_list.head)
1341 <  {
1342 <    support = ptr->data;
1343 <    if (irccmp(support->name, name) == 0)
1344 <    {
1345 <      MyFree(support->name);
1346 <      MyFree(support->options);
1347 <      break;
1348 <    }
1349 <  }
736 >  if (!ConfigGeneral.cycle_on_host_change)
737 >    return;
738  
739 <  if (ptr == NULL)
739 >  DLINK_FOREACH(node, client_p->channel.head)
740    {
741 <    support = MyMalloc(sizeof(*support));
742 <    dlinkAddTail(support, &support->node, &support_list);
743 <  }
744 <
745 <  DupString(support->name, name);
1358 <  if (options != NULL)
1359 <    DupString(support->options, options);
1360 <  support->number = n;
741 >    char modebuf[CMEMBER_STATUS_FLAGS_LEN + 1];
742 >    char nickbuf[CMEMBER_STATUS_FLAGS_LEN * NICKLEN + CMEMBER_STATUS_FLAGS_LEN] = "";
743 >    char *p = modebuf;
744 >    int len = 0;
745 >    const struct Membership *member = node->data;
746  
747 <  rebuild_isupport_message_line();
1363 < }
1364 <
1365 < /*
1366 < * delete_isupport()
1367 < *
1368 < * input        - name of supported function
1369 < * output       - NONE
1370 < * side effects - Each supported item must call this when deactivated
1371 < */
1372 < void
1373 < delete_isupport(const char *name)
1374 < {
1375 <  dlink_node *ptr;
1376 <  struct Isupport *support;
1377 <
1378 <  DLINK_FOREACH(ptr, support_list.head)
1379 <  {
1380 <    support = ptr->data;
1381 <    if (irccmp(support->name, name) == 0)
747 >    if (has_member_flags(member, CHFL_CHANOP))
748      {
749 <      dlinkDelete(ptr, &support_list);
750 <      MyFree(support->name);
1385 <      MyFree(support->options);
1386 <      MyFree(support);
1387 <      break;
749 >      *p++ = 'o';
750 >      len += snprintf(nickbuf + len, sizeof(nickbuf) - len, len ? " %s" : "%s", client_p->name);
751      }
1389  }
1390
1391  rebuild_isupport_message_line();
1392 }
752  
753 < /*
1395 < * rebuild_isupport_message_line
1396 < *
1397 < * input        - NONE
1398 < * output       - NONE
1399 < * side effects - Destroy the isupport MessageFile lines, and rebuild.
1400 < */
1401 < void
1402 < rebuild_isupport_message_line(void)
1403 < {
1404 <  char isupportbuffer[IRCD_BUFSIZE];
1405 <  char *p = isupportbuffer;
1406 <  dlink_node *ptr = NULL;
1407 <  int n = 0;
1408 <  int tokens = 0;
1409 <  size_t len = 0;
1410 <  size_t reserve = strlen(me.name) + HOSTLEN + strlen(form_str(RPL_ISUPPORT));
1411 <
1412 <  destroy_MessageLine(isupportFile);
1413 <
1414 <  DLINK_FOREACH(ptr, support_list.head)
1415 <  {
1416 <    struct Isupport *support = ptr->data;
1417 <
1418 <    p += (n = ircsprintf(p, "%s", support->name));
1419 <    len += n;
1420 <
1421 <    if (support->options != NULL)
753 >    if (has_member_flags(member, CHFL_HALFOP))
754      {
755 <      p += (n = ircsprintf(p, "=%s", support->options));
756 <      len += n;
755 >      *p++ = 'h';
756 >      len += snprintf(nickbuf + len, sizeof(nickbuf) - len, len ? " %s" : "%s", client_p->name);
757      }
758  
759 <    if (support->number > 0)
759 >    if (has_member_flags(member, CHFL_VOICE))
760      {
761 <      p += (n = ircsprintf(p, "=%d", support->number));
762 <      len += n;
761 >      *p++ = 'v';
762 >      len += snprintf(nickbuf + len, sizeof(nickbuf) - len, len ? " %s" : "%s", client_p->name);
763      }
764  
1433    *p++ = ' ';
1434    len++;
765      *p = '\0';
766  
767 <    if (++tokens == (MAXPARA-2) || len >= (sizeof(isupportbuffer)-reserve))
768 <    { /* arbritrary for now */
769 <      if (*--p == ' ')
770 <        *p = '\0';
771 <
772 <      addto_MessageLine(isupportFile, isupportbuffer);
773 <      p = isupportbuffer;
774 <      len = 0;
775 <      n = tokens = 0;
776 <    }
777 <  }
778 <
779 <  if (len != 0)
780 <  {
781 <    if (*--p == ' ')
782 <      *p = '\0';
783 <    addto_MessageLine(isupportFile, isupportbuffer);
784 <  }
767 >    sendto_channel_local(client_p, member->chptr, 0, CAP_EXTENDED_JOIN, CAP_CHGHOST, ":%s!%s@%s JOIN %s %s :%s",
768 >                         client_p->name, client_p->username,
769 >                         client_p->host, member->chptr->name,
770 >                         client_p->account, client_p->info);
771 >    sendto_channel_local(client_p, member->chptr, 0, 0, CAP_EXTENDED_JOIN | CAP_CHGHOST, ":%s!%s@%s JOIN :%s",
772 >                         client_p->name, client_p->username,
773 >                         client_p->host, member->chptr->name);
774 >
775 >    if (nickbuf[0])
776 >      sendto_channel_local(client_p, member->chptr, 0, 0, CAP_CHGHOST, ":%s MODE %s +%s %s",
777 >                           client_p->servptr->name, member->chptr->name,
778 >                           modebuf, nickbuf);
779 >  }
780 >
781 >  if (client_p->away[0])
782 >    sendto_common_channels_local(client_p, 0, CAP_AWAY_NOTIFY, CAP_CHGHOST,
783 >                                 ":%s!%s@%s AWAY :%s",
784 >                                 client_p->name, client_p->username,
785 >                                 client_p->host, client_p->away);
786   }

Comparing:
ircd-hybrid-8/src/s_user.c (property svn:keywords), Revision 1156 by michael, Tue Aug 9 20:29:20 2011 UTC vs.
ircd-hybrid/trunk/src/user.c (property svn:keywords), Revision 8223 by michael, Sun Apr 16 12:54:01 2017 UTC

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

Diff Legend

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