]> jfr.im git - irc/rqf/shadowircd.git/blob - src/s_user.c
[svn] Backport from early 3.x:
[irc/rqf/shadowircd.git] / src / s_user.c
1 /*
2 * ircd-ratbox: A slightly useful ircd.
3 * s_user.c: User related functions.
4 *
5 * Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center
6 * Copyright (C) 1996-2002 Hybrid Development Team
7 * Copyright (C) 2002-2005 ircd-ratbox development team
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
22 * USA
23 *
24 * $Id: s_user.c 3161 2007-01-25 07:23:01Z nenolod $
25 */
26
27 #include "stdinc.h"
28 #include "tools.h"
29 #include "s_user.h"
30 #include "channel.h"
31 #include "class.h"
32 #include "client.h"
33 #include "common.h"
34 #include "hash.h"
35 #include "irc_string.h"
36 #include "sprintf_irc.h"
37 #include "ircd.h"
38 #include "listener.h"
39 #include "msg.h"
40 #include "numeric.h"
41 #include "commio.h"
42 #include "s_conf.h"
43 #include "s_newconf.h"
44 #include "s_log.h"
45 #include "s_serv.h"
46 #include "s_stats.h"
47 #include "scache.h"
48 #include "send.h"
49 #include "supported.h"
50 #include "whowas.h"
51 #include "memory.h"
52 #include "packet.h"
53 #include "reject.h"
54 #include "cache.h"
55 #include "hook.h"
56 #include "monitor.h"
57 #include "snomask.h"
58 #include "blacklist.h"
59 #include "substitution.h"
60
61 static void report_and_set_user_flags(struct Client *, struct ConfItem *);
62 void user_welcome(struct Client *source_p);
63
64 extern char *crypt();
65
66 char umodebuf[128];
67
68 int user_modes[256] = {
69 /* 0x00 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x0F */
70 /* 0x10 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x1F */
71 /* 0x20 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x2F */
72 /* 0x30 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x3F */
73 0, /* @ */
74 0, /* A */
75 0, /* B */
76 0, /* C */
77 UMODE_DEAF, /* D */
78 0, /* E */
79 0, /* F */
80 0, /* G */
81 0, /* H */
82 0, /* I */
83 0, /* J */
84 0, /* K */
85 0, /* L */
86 0, /* M */
87 0, /* N */
88 0, /* O */
89 0, /* P */
90 UMODE_NOFORWARD, /* Q */
91 UMODE_REGONLYMSG, /* R */
92 UMODE_SERVICE, /* S */
93 0, /* T */
94 0, /* U */
95 0, /* V */
96 0, /* W */
97 0, /* X */
98 0, /* Y */
99 0, /* Z */
100 /* 0x5B */ 0, 0, 0, 0, 0, 0, /* 0x60 */
101 UMODE_ADMIN, /* a */
102 0, /* b */
103 0, /* c */
104 0, /* d */
105 0, /* e */
106 0, /* f */
107 UMODE_CALLERID, /* g */
108 0, /* h */
109 UMODE_INVISIBLE, /* i */
110 0, /* j */
111 0, /* k */
112 UMODE_LOCOPS, /* l */
113 0, /* m */
114 0, /* n */
115 UMODE_OPER, /* o */
116 0, /* p */
117 0, /* q */
118 0, /* r */
119 UMODE_SERVNOTICE, /* s */
120 0, /* t */
121 0, /* u */
122 0, /* v */
123 UMODE_WALLOP, /* w */
124 0, /* x */
125 0, /* y */
126 UMODE_OPERWALL, /* z */
127 /* 0x7B */ 0, 0, 0, 0, 0, /* 0x7F */
128 /* 0x80 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x9F */
129 /* 0x90 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x9F */
130 /* 0xA0 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xAF */
131 /* 0xB0 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xBF */
132 /* 0xC0 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xCF */
133 /* 0xD0 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xDF */
134 /* 0xE0 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xEF */
135 /* 0xF0 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 /* 0xFF */
136 };
137 /* *INDENT-ON* */
138
139 /*
140 * show_lusers -
141 *
142 * inputs - pointer to client
143 * output -
144 * side effects - display to client user counts etc.
145 */
146 int
147 show_lusers(struct Client *source_p)
148 {
149 sendto_one_numeric(source_p, RPL_LUSERCLIENT, form_str(RPL_LUSERCLIENT),
150 (Count.total - Count.invisi),
151 Count.invisi, dlink_list_length(&global_serv_list));
152
153 if(dlink_list_length(&oper_list) > 0)
154 sendto_one_numeric(source_p, RPL_LUSEROP,
155 form_str(RPL_LUSEROP), dlink_list_length(&oper_list));
156
157 if(dlink_list_length(&unknown_list) > 0)
158 sendto_one_numeric(source_p, RPL_LUSERUNKNOWN,
159 form_str(RPL_LUSERUNKNOWN),
160 dlink_list_length(&unknown_list));
161
162 if(dlink_list_length(&global_channel_list) > 0)
163 sendto_one_numeric(source_p, RPL_LUSERCHANNELS,
164 form_str(RPL_LUSERCHANNELS),
165 dlink_list_length(&global_channel_list));
166
167 sendto_one_numeric(source_p, RPL_LUSERME, form_str(RPL_LUSERME),
168 dlink_list_length(&lclient_list),
169 dlink_list_length(&serv_list));
170
171 sendto_one_numeric(source_p, RPL_LOCALUSERS,
172 form_str(RPL_LOCALUSERS),
173 dlink_list_length(&lclient_list),
174 Count.max_loc,
175 dlink_list_length(&lclient_list),
176 Count.max_loc);
177
178 sendto_one_numeric(source_p, RPL_GLOBALUSERS, form_str(RPL_GLOBALUSERS),
179 Count.total, Count.max_tot,
180 Count.total, Count.max_tot);
181
182 sendto_one_numeric(source_p, RPL_STATSCONN,
183 form_str(RPL_STATSCONN),
184 MaxConnectionCount, MaxClientCount,
185 Count.totalrestartcount);
186
187 if(dlink_list_length(&lclient_list) > (unsigned long)MaxClientCount)
188 MaxClientCount = dlink_list_length(&lclient_list);
189
190 if((dlink_list_length(&lclient_list) + dlink_list_length(&serv_list)) >
191 (unsigned long)MaxConnectionCount)
192 MaxConnectionCount = dlink_list_length(&lclient_list) +
193 dlink_list_length(&serv_list);
194
195 return 0;
196 }
197
198 /*
199 ** register_local_user
200 ** This function is called when both NICK and USER messages
201 ** have been accepted for the client, in whatever order. Only
202 ** after this, is the USER message propagated.
203 **
204 ** NICK's must be propagated at once when received, although
205 ** it would be better to delay them too until full info is
206 ** available. Doing it is not so simple though, would have
207 ** to implement the following:
208 **
209 ** (actually it has been implemented already for a while) -orabidoo
210 **
211 ** 1) user telnets in and gives only "NICK foobar" and waits
212 ** 2) another user far away logs in normally with the nick
213 ** "foobar" (quite legal, as this server didn't propagate
214 ** it).
215 ** 3) now this server gets nick "foobar" from outside, but
216 ** has alread the same defined locally. Current server
217 ** would just issue "KILL foobar" to clean out dups. But,
218 ** this is not fair. It should actually request another
219 ** nick from local user or kill him/her...
220 */
221
222 int
223 register_local_user(struct Client *client_p, struct Client *source_p, const char *username)
224 {
225 struct ConfItem *aconf;
226 struct User *user = source_p->user;
227 char tmpstr2[IRCD_BUFSIZE];
228 char ipaddr[HOSTIPLEN];
229 char myusername[USERLEN+1];
230 int status;
231
232 s_assert(NULL != source_p);
233 s_assert(MyConnect(source_p));
234 s_assert(source_p->username != username);
235
236 if(source_p == NULL)
237 return -1;
238
239 if(IsAnyDead(source_p))
240 return -1;
241
242 if(ConfigFileEntry.ping_cookie)
243 {
244 if(!(source_p->flags & FLAGS_PINGSENT) && source_p->localClient->random_ping == 0)
245 {
246 source_p->localClient->random_ping = (unsigned long) (rand() * rand()) << 1;
247 sendto_one(source_p, "PING :%08lX",
248 (unsigned long) source_p->localClient->random_ping);
249 source_p->flags |= FLAGS_PINGSENT;
250 return -1;
251 }
252 if(!(source_p->flags2 & FLAGS2_PING_COOKIE))
253 {
254 return -1;
255 }
256 }
257
258 /* hasnt finished client cap negotiation */
259 if(source_p->flags2 & FLAGS2_CLICAP)
260 return -1;
261
262 /* still has DNSbls to validate against */
263 if(dlink_list_length(&source_p->preClient->dnsbl_queries) > 0)
264 return -1;
265
266 client_p->localClient->last = CurrentTime;
267 /* Straight up the maximum rate of flooding... */
268 source_p->localClient->allow_read = MAX_FLOOD_BURST;
269
270 /* XXX - fixme. we shouldnt have to build a users buffer twice.. */
271 if(!IsGotId(source_p) && (strchr(username, '[') != NULL))
272 {
273 const char *p;
274 int i = 0;
275
276 p = username;
277
278 while(*p && i < USERLEN)
279 {
280 if(*p != '[')
281 myusername[i++] = *p;
282 p++;
283 }
284
285 myusername[i] = '\0';
286 username = myusername;
287 }
288
289 if((status = check_client(client_p, source_p, username)) < 0)
290 return (CLIENT_EXITED);
291
292 /* Apply nick override */
293 if(*source_p->preClient->spoofnick)
294 {
295 del_from_client_hash(source_p->name, source_p);
296 strlcpy(source_p->name, source_p->preClient->spoofnick, NICKLEN + 1);
297 add_to_client_hash(source_p->name, source_p);
298 comm_note(source_p->localClient->fd, "Nick: %s", source_p->name);
299 }
300
301 if(!valid_hostname(source_p->host))
302 {
303 sendto_one_notice(source_p, ":*** Notice -- You have an illegal character in your hostname");
304
305 strlcpy(source_p->host, source_p->sockhost, sizeof(source_p->host));
306
307 #ifdef IPV6
308 if(ConfigFileEntry.dot_in_ip6_addr == 1)
309 strlcat(source_p->host, ".", sizeof(source_p->host));
310 #endif
311 }
312
313
314 aconf = source_p->localClient->att_conf;
315
316 if(aconf == NULL)
317 {
318 exit_client(client_p, source_p, &me, "*** Not Authorised");
319 return (CLIENT_EXITED);
320 }
321
322 if(!IsGotId(source_p))
323 {
324 const char *p;
325 int i = 0;
326
327 if(IsNeedIdentd(aconf))
328 {
329 ServerStats->is_ref++;
330 sendto_one_notice(source_p, ":*** Notice -- You need to install identd to use this server");
331 exit_client(client_p, source_p, &me, "Install identd");
332 return (CLIENT_EXITED);
333 }
334
335 /* dont replace username if its supposed to be spoofed --fl */
336 if(!IsConfDoSpoofIp(aconf) || !strchr(aconf->name, '@'))
337 {
338 p = username;
339
340 if(!IsNoTilde(aconf))
341 source_p->username[i++] = '~';
342
343 while (*p && i < USERLEN)
344 {
345 if(*p != '[')
346 source_p->username[i++] = *p;
347 p++;
348 }
349
350 source_p->username[i] = '\0';
351 }
352 }
353
354 if(IsNeedSasl(aconf) && !*user->suser)
355 {
356 ServerStats->is_ref++;
357 sendto_one_notice(source_p, ":*** Notice -- You need to identify via SASL to use this server");
358 exit_client(client_p, source_p, &me, "SASL access only");
359 return (CLIENT_EXITED);
360 }
361
362 /* password check */
363 if(!EmptyString(aconf->passwd))
364 {
365 const char *encr;
366
367 if(EmptyString(source_p->localClient->passwd))
368 encr = "";
369 else if(IsConfEncrypted(aconf))
370 encr = crypt(source_p->localClient->passwd, aconf->passwd);
371 else
372 encr = source_p->localClient->passwd;
373
374 if(strcmp(encr, aconf->passwd))
375 {
376 ServerStats->is_ref++;
377 sendto_one(source_p, form_str(ERR_PASSWDMISMATCH), me.name, source_p->name);
378 exit_client(client_p, source_p, &me, "Bad Password");
379 return (CLIENT_EXITED);
380 }
381
382 /* clear password only if used now, otherwise send it
383 * to services -- jilles */
384 if(source_p->localClient->passwd)
385 {
386 memset(source_p->localClient->passwd, 0, strlen(source_p->localClient->passwd));
387 MyFree(source_p->localClient->passwd);
388 source_p->localClient->passwd = NULL;
389 }
390 }
391
392 /* report if user has &^>= etc. and set flags as needed in source_p */
393 report_and_set_user_flags(source_p, aconf);
394
395 /* Limit clients */
396 /*
397 * We want to be able to have servers and F-line clients
398 * connect, so save room for "buffer" connections.
399 * Smaller servers may want to decrease this, and it should
400 * probably be just a percentage of the MAXCLIENTS...
401 * -Taner
402 */
403 /* Except "F:" clients */
404 if(((dlink_list_length(&lclient_list) + 1) >=
405 ((unsigned long)GlobalSetOptions.maxclients + MAX_BUFFER) ||
406 (dlink_list_length(&lclient_list) + 1) >=
407 ((unsigned long)GlobalSetOptions.maxclients - 5)) && !(IsExemptLimits(source_p)))
408 {
409 sendto_realops_snomask(SNO_FULL, L_ALL,
410 "Too many clients, rejecting %s[%s].", source_p->name, source_p->host);
411
412 ServerStats->is_ref++;
413 exit_client(client_p, source_p, &me, "Sorry, server is full - try later");
414 return (CLIENT_EXITED);
415 }
416
417 /* valid user name check */
418
419 if(!valid_username(source_p->username))
420 {
421 sendto_realops_snomask(SNO_REJ, L_ALL,
422 "Invalid username: %s (%s@%s)",
423 source_p->name, source_p->username, source_p->host);
424 ServerStats->is_ref++;
425 ircsprintf(tmpstr2, "Invalid username [%s]", source_p->username);
426 exit_client(client_p, source_p, &me, tmpstr2);
427 return (CLIENT_EXITED);
428 }
429
430 /* end of valid user name check */
431
432 /* kline exemption extends to xline too */
433 if(!IsExemptKline(source_p) &&
434 find_xline(source_p->info, 1) != NULL)
435 {
436 ServerStats->is_ref++;
437 add_reject(source_p);
438 exit_client(client_p, source_p, &me, "Bad user info");
439 return CLIENT_EXITED;
440 }
441
442 /* dnsbl check */
443 if (source_p->preClient->dnsbl_listed != NULL)
444 {
445 if (IsExemptKline(source_p) || IsConfExemptDNSBL(aconf))
446 sendto_one_notice(source_p, ":*** Your IP address %s is listed in %s, but you are exempt",
447 source_p->sockhost, source_p->preClient->dnsbl_listed->host);
448 else
449 {
450 dlink_list varlist;
451
452 substitution_append_var(&varlist, "nick", source_p->name);
453 substitution_append_var(&varlist, "ip", source_p->sockhost);
454 substitution_append_var(&varlist, "host", source_p->host);
455 substitution_append_var(&varlist, "dnsbl-host", source_p->preClient->dnsbl_listed->host);
456 substitution_append_var(&varlist, "network-name", ServerInfo.network_name);
457
458 ServerStats->is_ref++;
459
460 sendto_one(source_p, form_str(ERR_YOUREBANNEDCREEP),
461 me.name, source_p->name,
462 substitution_parse(source_p->preClient->dnsbl_listed->reject_reason, &varlist));
463
464 substitution_free(&varlist);
465
466 sendto_one_notice(source_p, ":*** Your IP address %s is listed in %s",
467 source_p->sockhost, source_p->preClient->dnsbl_listed->host);
468 source_p->preClient->dnsbl_listed->hits++;
469 add_reject(source_p);
470 exit_client(client_p, source_p, &me, "*** Banned (DNS blacklist)");
471 return CLIENT_EXITED;
472 }
473 }
474
475 /* Store original hostname -- jilles */
476 strlcpy(source_p->orighost, source_p->host, HOSTLEN + 1);
477
478 /* Spoof user@host */
479 if(*source_p->preClient->spoofuser)
480 strlcpy(source_p->username, source_p->preClient->spoofuser, USERLEN + 1);
481 if(*source_p->preClient->spoofhost)
482 {
483 strlcpy(source_p->host, source_p->preClient->spoofhost, HOSTLEN + 1);
484 if (irccmp(source_p->host, source_p->orighost))
485 SetDynSpoof(source_p);
486 }
487
488 if(IsAnyDead(client_p))
489 return CLIENT_EXITED;
490
491 inetntop_sock((struct sockaddr *)&source_p->localClient->ip, ipaddr, sizeof(ipaddr));
492
493 sendto_realops_snomask(SNO_CCONN, L_ALL,
494 "Client connecting: %s (%s@%s) [%s] {%s} [%s]",
495 source_p->name, source_p->username, source_p->orighost,
496 show_ip(NULL, source_p) ? ipaddr : "255.255.255.255",
497 get_client_class(source_p), source_p->info);
498
499 sendto_realops_snomask(SNO_CCONNEXT, L_ALL,
500 "CLICONN %s %s %s %s %s %s 0 %s",
501 source_p->name, source_p->username, source_p->orighost,
502 show_ip(NULL, source_p) ? ipaddr : "255.255.255.255",
503 get_client_class(source_p),
504 /* mirc can sometimes send ips here */
505 show_ip(NULL, source_p) ? source_p->localClient->fullcaps : "<hidden> <hidden>",
506 source_p->info);
507
508 /* If they have died in send_* don't do anything. */
509 if(IsAnyDead(source_p))
510 return CLIENT_EXITED;
511
512 add_to_hostname_hash(source_p->orighost, source_p);
513
514 /* Allocate a UID if it was not previously allocated.
515 * If this already occured, it was probably during SASL auth...
516 */
517 if(!*source_p->id)
518 {
519 strcpy(source_p->id, generate_uid());
520 add_to_id_hash(source_p->id, source_p);
521 }
522
523 source_p->umodes |= ConfigFileEntry.default_umodes & ~ConfigFileEntry.oper_only_umodes;
524
525 if (source_p->umodes & UMODE_INVISIBLE)
526 Count.invisi++;
527
528 s_assert(!IsClient(source_p));
529 dlinkMoveNode(&source_p->localClient->tnode, &unknown_list, &lclient_list);
530 SetClient(source_p);
531
532 /* XXX source_p->servptr is &me, since local client */
533 source_p->servptr = find_server(NULL, user->server);
534 dlinkAdd(source_p, &source_p->lnode, &source_p->servptr->serv->users);
535 /* Increment our total user count here */
536 if(++Count.total > Count.max_tot)
537 Count.max_tot = Count.total;
538 source_p->localClient->allow_read = MAX_FLOOD_BURST;
539
540 Count.totalrestartcount++;
541
542 s_assert(source_p->localClient != NULL);
543
544 if(dlink_list_length(&lclient_list) > (unsigned long)Count.max_loc)
545 {
546 Count.max_loc = dlink_list_length(&lclient_list);
547 if(!(Count.max_loc % 10))
548 sendto_realops_snomask(SNO_GENERAL, L_ALL,
549 "New Max Local Clients: %d", Count.max_loc);
550 }
551
552 /* they get a reduced limit */
553 if(find_tgchange(source_p->sockhost))
554 USED_TARGETS(source_p) = 6;
555
556 call_hook(h_new_local_user, source_p);
557
558 monitor_signon(source_p);
559 user_welcome(source_p);
560
561 free_pre_client(source_p);
562
563 return (introduce_client(client_p, source_p, user, source_p->name, 1));
564 }
565
566 /*
567 * introduce_clients
568 *
569 * inputs -
570 * output -
571 * side effects - This common function introduces a client to the rest
572 * of the net, either from a local client connect or
573 * from a remote connect.
574 */
575 int
576 introduce_client(struct Client *client_p, struct Client *source_p, struct User *user, const char *nick, int use_euid)
577 {
578 static char ubuf[12];
579 struct Client *identifyservice_p;
580 char *p;
581 hook_data_umode_changed hdata;
582 hook_data_client hdata2;
583
584 if(MyClient(source_p))
585 send_umode(source_p, source_p, 0, 0, ubuf);
586 else
587 send_umode(NULL, source_p, 0, 0, ubuf);
588
589 if(!*ubuf)
590 {
591 ubuf[0] = '+';
592 ubuf[1] = '\0';
593 }
594
595 /* if it has an ID, introduce it with its id to TS6 servers,
596 * otherwise introduce it normally to all.
597 */
598 if(has_id(source_p))
599 {
600 char sockhost[HOSTLEN];
601 if(source_p->sockhost[0] == ':')
602 {
603 sockhost[0] = '0';
604 sockhost[1] = '\0';
605 strlcat(sockhost, source_p->sockhost, sizeof(sockhost));
606 } else
607 strcpy(sockhost, source_p->sockhost);
608
609 if (use_euid)
610 sendto_server(client_p, NULL, CAP_EUID | CAP_TS6, NOCAPS,
611 ":%s EUID %s %d %ld %s %s %s %s %s %s %s :%s",
612 source_p->servptr->id, nick,
613 source_p->hopcount + 1,
614 (long) source_p->tsinfo, ubuf,
615 source_p->username, source_p->host,
616 IsIPSpoof(source_p) ? "0" : sockhost,
617 source_p->id,
618 IsDynSpoof(source_p) ? source_p->orighost : "*",
619 EmptyString(source_p->user->suser) ? "*" : source_p->user->suser,
620 source_p->info);
621
622 sendto_server(client_p, NULL, CAP_TS6, use_euid ? CAP_EUID : NOCAPS,
623 ":%s UID %s %d %ld %s %s %s %s %s :%s",
624 source_p->servptr->id, nick,
625 source_p->hopcount + 1,
626 (long) source_p->tsinfo, ubuf,
627 source_p->username, source_p->host,
628 IsIPSpoof(source_p) ? "0" : sockhost,
629 source_p->id, source_p->info);
630
631 sendto_server(client_p, NULL, NOCAPS, CAP_TS6,
632 "NICK %s %d %ld %s %s %s %s :%s",
633 nick, source_p->hopcount + 1,
634 (long) source_p->tsinfo,
635 ubuf, source_p->username, source_p->host,
636 user->server, source_p->info);
637 }
638 else
639 sendto_server(client_p, NULL, NOCAPS, NOCAPS,
640 "NICK %s %d %ld %s %s %s %s :%s",
641 nick, source_p->hopcount + 1,
642 (long) source_p->tsinfo,
643 ubuf, source_p->username, source_p->host,
644 user->server, source_p->info);
645
646 if (IsDynSpoof(source_p))
647 {
648 sendto_server(client_p, NULL, CAP_TS6, use_euid ? CAP_EUID : NOCAPS, ":%s ENCAP * REALHOST %s",
649 use_id(source_p), source_p->orighost);
650 sendto_server(client_p, NULL, NOCAPS, CAP_TS6, ":%s ENCAP * REALHOST %s",
651 source_p->name, source_p->orighost);
652 }
653 if (!EmptyString(source_p->user->suser))
654 {
655 sendto_server(client_p, NULL, CAP_TS6, use_euid ? CAP_EUID : NOCAPS, ":%s ENCAP * LOGIN %s",
656 use_id(source_p), source_p->user->suser);
657 sendto_server(client_p, NULL, NOCAPS, CAP_TS6, ":%s ENCAP * LOGIN %s",
658 source_p->name, source_p->user->suser);
659 }
660
661 if(MyConnect(source_p) && source_p->localClient->passwd)
662 {
663 if (ConfigFileEntry.identifyservice[0] != '\0' &&
664 ConfigFileEntry.identifycommand[0] != '\0')
665 {
666 /* use user@server */
667 p = strchr(ConfigFileEntry.identifyservice, '@');
668 if (p != NULL)
669 identifyservice_p = find_named_client(p + 1);
670 else
671 identifyservice_p = NULL;
672 if (identifyservice_p != NULL)
673 sendto_one(identifyservice_p, ":%s PRIVMSG %s :%s %s",
674 get_id(source_p, identifyservice_p),
675 ConfigFileEntry.identifyservice,
676 ConfigFileEntry.identifycommand,
677 source_p->localClient->passwd);
678 }
679 memset(source_p->localClient->passwd, 0, strlen(source_p->localClient->passwd));
680 MyFree(source_p->localClient->passwd);
681 source_p->localClient->passwd = NULL;
682 }
683
684 /* let modules providing usermodes know that we've got a new user,
685 * why is this here? -- well, some modules need to be able to send out new
686 * information about a client, so this was the best place to do it
687 * --nenolod
688 */
689 hdata.client = source_p;
690 hdata.oldumodes = 0;
691 hdata.oldsnomask = 0;
692 call_hook(h_umode_changed, &hdata);
693
694 /* On the other hand, some modules need to know when a client is
695 * being introduced, period.
696 * --gxti
697 */
698 hdata2.client = client_p;
699 hdata2.target = source_p;
700 call_hook(h_introduce_client, &hdata2);
701
702 return 0;
703 }
704
705 /*
706 * valid_hostname - check hostname for validity
707 *
708 * Inputs - pointer to user
709 * Output - YES if valid, NO if not
710 * Side effects - NONE
711 *
712 * NOTE: this doesn't allow a hostname to begin with a dot and
713 * will not allow more dots than chars.
714 */
715 int
716 valid_hostname(const char *hostname)
717 {
718 const char *p = hostname;
719 int found_sep = 0;
720
721 s_assert(NULL != p);
722
723 if(hostname == NULL)
724 return NO;
725
726 if('.' == *p || ':' == *p)
727 return NO;
728
729 while (*p)
730 {
731 if(!IsHostChar(*p))
732 return NO;
733 if(*p == '.' || *p == ':')
734 found_sep++;
735 p++;
736 }
737
738 if(found_sep == 0)
739 return(NO);
740
741 return (YES);
742 }
743
744 /*
745 * valid_username - check username for validity
746 *
747 * Inputs - pointer to user
748 * Output - YES if valid, NO if not
749 * Side effects - NONE
750 *
751 * Absolutely always reject any '*' '!' '?' '@' in an user name
752 * reject any odd control characters names.
753 * Allow '.' in username to allow for "first.last"
754 * style of username
755 */
756 int
757 valid_username(const char *username)
758 {
759 int dots = 0;
760 const char *p = username;
761
762 s_assert(NULL != p);
763
764 if(username == NULL)
765 return NO;
766
767 if('~' == *p)
768 ++p;
769
770 /* reject usernames that don't start with an alphanum
771 * i.e. reject jokers who have '-@somehost' or '.@somehost'
772 * or "-hi-@somehost", "h-----@somehost" would still be accepted.
773 */
774 if(!IsAlNum(*p))
775 return NO;
776
777 while (*++p)
778 {
779 if((*p == '.') && ConfigFileEntry.dots_in_ident)
780 {
781 dots++;
782 if(dots > ConfigFileEntry.dots_in_ident)
783 return NO;
784 if(!IsUserChar(p[1]))
785 return NO;
786 }
787 else if(!IsUserChar(*p))
788 return NO;
789 }
790 return YES;
791 }
792
793 /* report_and_set_user_flags
794 *
795 * Inputs - pointer to source_p
796 * - pointer to aconf for this user
797 * Output - NONE
798 * Side effects -
799 * Report to user any special flags they are getting, and set them.
800 */
801
802 static void
803 report_and_set_user_flags(struct Client *source_p, struct ConfItem *aconf)
804 {
805 /* If this user is being spoofed, tell them so */
806 if(IsConfDoSpoofIp(aconf))
807 {
808 sendto_one_notice(source_p, ":*** Spoofing your IP. congrats.");
809 }
810
811 /* If this user is in the exception class, Set it "E lined" */
812 if(IsConfExemptKline(aconf))
813 {
814 SetExemptKline(source_p);
815 sendto_one_notice(source_p, ":*** You are exempt from K/D/G/X lines. congrats.");
816 }
817
818 if(IsConfExemptGline(aconf))
819 {
820 SetExemptGline(source_p);
821
822 /* dont send both a kline and gline exempt notice */
823 if(!IsConfExemptKline(aconf))
824 sendto_one_notice(source_p, ":*** You are exempt from G lines.");
825 }
826
827 if(IsConfExemptDNSBL(aconf))
828 /* kline exempt implies this, don't send both */
829 if(!IsConfExemptKline(aconf))
830 sendto_one_notice(source_p, ":*** You are exempt from DNS blacklists.");
831
832 /* If this user is exempt from user limits set it F lined" */
833 if(IsConfExemptLimits(aconf))
834 {
835 SetExemptLimits(source_p);
836 sendto_one_notice(source_p, "*** You are exempt from user limits. congrats.");
837 }
838
839 /* If this user is exempt from idle time outs */
840 if(IsConfIdlelined(aconf))
841 {
842 SetIdlelined(source_p);
843 sendto_one_notice(source_p, ":*** You are exempt from idle limits. congrats.");
844 }
845
846 if(IsConfExemptFlood(aconf))
847 {
848 SetExemptFlood(source_p);
849 sendto_one_notice(source_p, ":*** You are exempt from flood limits.");
850 }
851
852 if(IsConfExemptSpambot(aconf))
853 {
854 SetExemptSpambot(source_p);
855 sendto_one_notice(source_p, ":*** You are exempt from spambot checks.");
856 }
857
858 if(IsConfExemptJupe(aconf))
859 {
860 SetExemptJupe(source_p);
861 sendto_one_notice(source_p, ":*** You are exempt from juped channel warnings.");
862 }
863
864 if(IsConfExemptResv(aconf))
865 {
866 SetExemptResv(source_p);
867 sendto_one_notice(source_p, ":*** You are exempt from resvs.");
868 }
869
870 if(IsConfExemptShide(aconf))
871 {
872 SetExemptShide(source_p);
873 sendto_one_notice(source_p, ":*** You are exempt from serverhiding.");
874 }
875 }
876
877 /*
878 * user_mode - set get current users mode
879 *
880 * m_umode() added 15/10/91 By Darren Reed.
881 * parv[0] - sender
882 * parv[1] - username to change mode for
883 * parv[2] - modes to change
884 */
885 int
886 user_mode(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
887 {
888 int flag;
889 int i;
890 char *m;
891 const char *pm;
892 struct Client *target_p;
893 int what, setflags;
894 int badflag = NO; /* Only send one bad flag notice */
895 int showsnomask = NO;
896 unsigned int setsnomask;
897 char buf[BUFSIZE];
898 hook_data_umode_changed hdata;
899
900 what = MODE_ADD;
901
902 if(parc < 2)
903 {
904 sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS), me.name, source_p->name, "MODE");
905 return 0;
906 }
907
908 if((target_p = MyClient(source_p) ? find_named_person(parv[1]) : find_person(parv[1])) == NULL)
909 {
910 if(MyConnect(source_p))
911 sendto_one_numeric(source_p, ERR_NOSUCHCHANNEL,
912 form_str(ERR_NOSUCHCHANNEL), parv[1]);
913 return 0;
914 }
915
916 /* Dont know why these were commented out..
917 * put them back using new sendto() funcs
918 */
919
920 if(IsServer(source_p))
921 {
922 sendto_realops_snomask(SNO_GENERAL, L_ADMIN,
923 "*** Mode for User %s from %s", parv[1], source_p->name);
924 return 0;
925 }
926
927 if(source_p != target_p || target_p->from != source_p->from)
928 {
929 sendto_one(source_p, form_str(ERR_USERSDONTMATCH), me.name, source_p->name);
930 return 0;
931 }
932
933 if(parc < 3)
934 {
935 m = buf;
936 *m++ = '+';
937
938 for (i = 0; i < 128; i++) /* >= 127 is extended ascii */
939 if (source_p->umodes & user_modes[i])
940 *m++ = (char) i;
941
942 *m = '\0';
943 sendto_one(source_p, form_str(RPL_UMODEIS), me.name, source_p->name, buf);
944 if (source_p->snomask != 0)
945 sendto_one(source_p, form_str(RPL_SNOMASK), me.name, source_p->name,
946 construct_snobuf(source_p->snomask));
947 return 0;
948 }
949
950 /* find flags already set for user */
951 setflags = source_p->umodes;
952 setsnomask = source_p->snomask;
953
954 /*
955 * parse mode change string(s)
956 */
957 for (pm = parv[2]; *pm; pm++)
958 switch (*pm)
959 {
960 case '+':
961 what = MODE_ADD;
962 break;
963 case '-':
964 what = MODE_DEL;
965 break;
966
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 dlinkAddAlloc(source_p, &oper_list);
975 }
976 }
977 else
978 {
979 /* Only decrement the oper counts if an oper to begin with
980 * found by Pat Szuta, Perly , perly@xnet.com
981 */
982
983 if(!IsOper(source_p))
984 break;
985
986 ClearOper(source_p);
987
988 Count.oper--;
989
990 if(MyConnect(source_p))
991 {
992 source_p->umodes &= ~ConfigFileEntry.oper_only_umodes;
993 if (!(source_p->umodes & UMODE_SERVNOTICE) && source_p->snomask != 0)
994 {
995 source_p->snomask = 0;
996 showsnomask = YES;
997 }
998 source_p->flags2 &= ~OPER_FLAGS;
999
1000 MyFree(source_p->localClient->opername);
1001 source_p->localClient->opername = NULL;
1002
1003 dlinkFindDestroy(source_p, &local_oper_list);
1004 }
1005
1006 dlinkFindDestroy(source_p, &oper_list);
1007 }
1008 break;
1009
1010 /* we may not get these,
1011 * but they shouldnt be in default
1012 */
1013
1014 /* can only be set on burst */
1015 case 'S':
1016 case ' ':
1017 case '\n':
1018 case '\r':
1019 case '\t':
1020 break;
1021
1022 case 's':
1023 if (MyConnect(source_p))
1024 {
1025 if(!IsOper(source_p)
1026 && (ConfigFileEntry.oper_only_umodes & UMODE_SERVNOTICE))
1027 {
1028 if (what == MODE_ADD || source_p->umodes & UMODE_SERVNOTICE)
1029 badflag = YES;
1030 continue;
1031 }
1032 showsnomask = YES;
1033 if(what == MODE_ADD)
1034 {
1035 if (parc > 3)
1036 source_p->snomask = parse_snobuf_to_mask(source_p->snomask, parv[3]);
1037 else
1038 source_p->snomask |= SNO_GENERAL;
1039 }
1040 else
1041 source_p->snomask = 0;
1042 if (source_p->snomask != 0)
1043 source_p->umodes |= UMODE_SERVNOTICE;
1044 else
1045 source_p->umodes &= ~UMODE_SERVNOTICE;
1046 break;
1047 }
1048 /* FALLTHROUGH */
1049 default:
1050 if (MyConnect(source_p) && *pm == 'Q' && !ConfigChannel.use_forward) {
1051 badflag = YES;
1052 break;
1053 }
1054
1055 if((flag = user_modes[(unsigned char) *pm]))
1056 {
1057 if(MyConnect(source_p)
1058 && !IsOper(source_p)
1059 && (ConfigFileEntry.oper_only_umodes & flag))
1060 {
1061 if (what == MODE_ADD || source_p->umodes & flag)
1062 badflag = YES;
1063 }
1064 else
1065 {
1066 if(what == MODE_ADD)
1067 source_p->umodes |= flag;
1068 else
1069 source_p->umodes &= ~flag;
1070 }
1071 }
1072 else
1073 {
1074 if(MyConnect(source_p))
1075 badflag = YES;
1076 }
1077 break;
1078 }
1079
1080 if(badflag)
1081 sendto_one(source_p, form_str(ERR_UMODEUNKNOWNFLAG), me.name, source_p->name);
1082
1083 if(MyClient(source_p) && (source_p->snomask & SNO_NCHANGE) && !IsOperN(source_p))
1084 {
1085 sendto_one_notice(source_p, ":*** You need oper and N flag for +s +n");
1086 source_p->snomask &= ~SNO_NCHANGE; /* only tcm's really need this */
1087 }
1088
1089 if(MyClient(source_p) && (source_p->umodes & UMODE_OPERWALL) && !IsOperOperwall(source_p))
1090 {
1091 sendto_one_notice(source_p, ":*** You need oper and operwall flag for +z");
1092 source_p->umodes &= ~UMODE_OPERWALL;
1093 }
1094
1095 if(MyConnect(source_p) && (source_p->umodes & UMODE_ADMIN) &&
1096 (!IsOperAdmin(source_p) || IsOperHiddenAdmin(source_p)))
1097 {
1098 sendto_one_notice(source_p, ":*** You need oper and A flag for +a");
1099 source_p->umodes &= ~UMODE_ADMIN;
1100 }
1101
1102 /* let modules providing usermodes know that we've changed our usermode --nenolod */
1103 hdata.client = source_p;
1104 hdata.oldumodes = setflags;
1105 hdata.oldsnomask = setsnomask;
1106 call_hook(h_umode_changed, &hdata);
1107
1108 if(!(setflags & UMODE_INVISIBLE) && IsInvisible(source_p))
1109 ++Count.invisi;
1110 if((setflags & UMODE_INVISIBLE) && !IsInvisible(source_p))
1111 --Count.invisi;
1112 /*
1113 * compare new flags with old flags and send string which
1114 * will cause servers to update correctly.
1115 */
1116 send_umode_out(client_p, source_p, setflags);
1117 if (showsnomask && MyConnect(source_p))
1118 sendto_one(source_p, form_str(RPL_SNOMASK), me.name, source_p->name,
1119 construct_snobuf(source_p->snomask));
1120
1121 return (0);
1122 }
1123
1124 /*
1125 * send the MODE string for user (user) to connection client_p
1126 * -avalon
1127 */
1128 void
1129 send_umode(struct Client *client_p, struct Client *source_p, int old, int sendmask, char *umode_buf)
1130 {
1131 int i;
1132 int flag;
1133 char *m;
1134 int what = 0;
1135
1136 /*
1137 * build a string in umode_buf to represent the change in the user's
1138 * mode between the new (source_p->flag) and 'old'.
1139 */
1140 m = umode_buf;
1141 *m = '\0';
1142
1143 for (i = 0; i < 128; i++)
1144 {
1145 flag = user_modes[i];
1146
1147 if((flag & old) && !(source_p->umodes & flag))
1148 {
1149 if(what == MODE_DEL)
1150 *m++ = (char) i;
1151 else
1152 {
1153 what = MODE_DEL;
1154 *m++ = '-';
1155 *m++ = (char) i;
1156 }
1157 }
1158 else if(!(flag & old) && (source_p->umodes & flag))
1159 {
1160 if(what == MODE_ADD)
1161 *m++ = (char) i;
1162 else
1163 {
1164 what = MODE_ADD;
1165 *m++ = '+';
1166 *m++ = (char) i;
1167 }
1168 }
1169 }
1170 *m = '\0';
1171
1172 if(*umode_buf && client_p)
1173 sendto_one(client_p, ":%s MODE %s :%s", source_p->name, source_p->name, umode_buf);
1174 }
1175
1176 /*
1177 * send_umode_out
1178 *
1179 * inputs -
1180 * output - NONE
1181 * side effects -
1182 */
1183 void
1184 send_umode_out(struct Client *client_p, struct Client *source_p, int old)
1185 {
1186 struct Client *target_p;
1187 char buf[BUFSIZE];
1188 dlink_node *ptr;
1189
1190 send_umode(NULL, source_p, old, 0, buf);
1191
1192 DLINK_FOREACH(ptr, serv_list.head)
1193 {
1194 target_p = ptr->data;
1195
1196 if((target_p != client_p) && (target_p != source_p) && (*buf))
1197 {
1198 sendto_one(target_p, ":%s MODE %s :%s",
1199 get_id(source_p, target_p),
1200 get_id(source_p, target_p), buf);
1201 }
1202 }
1203
1204 if(client_p && MyClient(client_p))
1205 send_umode(client_p, source_p, old, 0, buf);
1206 }
1207
1208 /*
1209 * user_welcome
1210 *
1211 * inputs - client pointer to client to welcome
1212 * output - NONE
1213 * side effects -
1214 */
1215 void
1216 user_welcome(struct Client *source_p)
1217 {
1218 sendto_one(source_p, form_str(RPL_WELCOME), me.name, source_p->name,
1219 ServerInfo.network_name, source_p->name);
1220 sendto_one(source_p, form_str(RPL_YOURHOST), me.name,
1221 source_p->name,
1222 get_listener_name(source_p->localClient->listener), ircd_version);
1223
1224 sendto_one(source_p, form_str(RPL_CREATED), me.name, source_p->name, creation);
1225 sendto_one(source_p, form_str(RPL_MYINFO), me.name, source_p->name, me.name, ircd_version, umodebuf);
1226
1227 show_isupport(source_p);
1228
1229 show_lusers(source_p);
1230
1231 if(ConfigFileEntry.short_motd)
1232 {
1233 sendto_one_notice(source_p, ":*** Notice -- motd was last changed at %s", user_motd_changed);
1234 sendto_one_notice(source_p, ":*** Notice -- Please read the motd if you haven't read it");
1235
1236 sendto_one(source_p, form_str(RPL_MOTDSTART),
1237 me.name, source_p->name, me.name);
1238
1239 sendto_one(source_p, form_str(RPL_MOTD),
1240 me.name, source_p->name, "*** This is the short motd ***");
1241
1242 sendto_one(source_p, form_str(RPL_ENDOFMOTD), me.name, source_p->name);
1243 }
1244 else
1245 send_user_motd(source_p);
1246 }
1247
1248 /* oper_up()
1249 *
1250 * inputs - pointer to given client to oper
1251 * - pointer to ConfItem to use
1252 * output - none
1253 * side effects - opers up source_p using aconf for reference
1254 */
1255 int
1256 oper_up(struct Client *source_p, struct oper_conf *oper_p)
1257 {
1258 unsigned int old = source_p->umodes, oldsnomask = source_p->snomask;
1259 hook_data_umode_changed hdata;
1260
1261 SetOper(source_p);
1262
1263 if(oper_p->umodes)
1264 source_p->umodes |= oper_p->umodes;
1265 else if(ConfigFileEntry.oper_umodes)
1266 source_p->umodes |= ConfigFileEntry.oper_umodes;
1267 else
1268 source_p->umodes |= DEFAULT_OPER_UMODES;
1269
1270 if (oper_p->snomask)
1271 {
1272 source_p->snomask |= oper_p->snomask;
1273 source_p->umodes |= UMODE_SERVNOTICE;
1274 }
1275 else if (source_p->umodes & UMODE_SERVNOTICE)
1276 {
1277 /* Only apply these if +s is already set -- jilles */
1278 if (ConfigFileEntry.oper_snomask)
1279 source_p->snomask |= ConfigFileEntry.oper_snomask;
1280 else
1281 source_p->snomask |= DEFAULT_OPER_SNOMASK;
1282 }
1283
1284 Count.oper++;
1285
1286 SetExemptKline(source_p);
1287
1288 source_p->flags2 |= oper_p->flags;
1289 DupString(source_p->localClient->opername, oper_p->name);
1290
1291 dlinkAddAlloc(source_p, &local_oper_list);
1292 dlinkAddAlloc(source_p, &oper_list);
1293
1294 if(IsOperAdmin(source_p) && !IsOperHiddenAdmin(source_p))
1295 source_p->umodes |= UMODE_ADMIN;
1296 if(!IsOperN(source_p))
1297 source_p->snomask &= ~SNO_NCHANGE;
1298 if(!IsOperOperwall(source_p))
1299 source_p->umodes &= ~UMODE_OPERWALL;
1300 hdata.client = source_p;
1301 hdata.oldumodes = old;
1302 hdata.oldsnomask = oldsnomask;
1303 call_hook(h_umode_changed, &hdata);
1304
1305 sendto_realops_snomask(SNO_GENERAL, L_ALL,
1306 "%s (%s@%s) is now an operator", source_p->name,
1307 source_p->username, source_p->host);
1308 send_umode_out(source_p, source_p, old);
1309 sendto_one(source_p, form_str(RPL_SNOMASK), me.name, source_p->name,
1310 construct_snobuf(source_p->snomask));
1311 sendto_one(source_p, form_str(RPL_YOUREOPER), me.name, source_p->name);
1312 sendto_one_notice(source_p, ":*** Oper privs are %s", get_oper_privs(oper_p->flags));
1313 send_oper_motd(source_p);
1314
1315 return (1);
1316 }
1317
1318 void
1319 construct_umodebuf(void)
1320 {
1321 int i;
1322 char *ptr = umodebuf;
1323
1324 *ptr = '\0';
1325
1326 for (i = 0; i < 128; i++)
1327 if (user_modes[i])
1328 *ptr++ = (char) i;
1329
1330 *ptr++ = '\0';
1331 }
1332
1333 void
1334 change_nick_user_host(struct Client *target_p, const char *nick, const char *user,
1335 const char *host, int newts, char *format, ...)
1336 {
1337 dlink_node *ptr;
1338 struct Channel *chptr;
1339 struct membership *mscptr;
1340 int changed = irccmp(target_p->name, nick);
1341 int changed_case = strcmp(target_p->name, nick);
1342 int do_qjm = irccmp(target_p->username, user) || irccmp(target_p->host, host);
1343 char mode[10], modeval[NICKLEN * 2 + 2], reason[256], *mptr;
1344 va_list ap;
1345
1346 modeval[0] = '\0';
1347
1348 if(changed)
1349 {
1350 target_p->tsinfo = newts;
1351 monitor_signoff(target_p);
1352 }
1353 invalidate_bancache_user(target_p);
1354
1355 if(do_qjm)
1356 {
1357 va_start(ap, format);
1358 vsnprintf(reason, 255, format, ap);
1359 va_end(ap);
1360
1361 sendto_common_channels_local_butone(target_p, ":%s!%s@%s QUIT :%s",
1362 target_p->name, target_p->username, target_p->host,
1363 reason);
1364
1365 DLINK_FOREACH(ptr, target_p->user->channel.head)
1366 {
1367 mscptr = ptr->data;
1368 chptr = mscptr->chptr;
1369 mptr = mode;
1370
1371 if(is_chanop(mscptr))
1372 {
1373 *mptr++ = 'o';
1374 strcat(modeval, nick);
1375 strcat(modeval, " ");
1376 }
1377
1378 if(is_voiced(mscptr))
1379 {
1380 *mptr++ = 'v';
1381 strcat(modeval, nick);
1382 }
1383
1384 *mptr = '\0';
1385
1386 sendto_channel_local_butone(target_p, ALL_MEMBERS, chptr, ":%s!%s@%s JOIN :%s",
1387 nick, user, host, chptr->chname);
1388 if(*mode)
1389 sendto_channel_local_butone(target_p, ALL_MEMBERS, chptr,
1390 ":%s MODE %s +%s %s",
1391 target_p->servptr->name,
1392 chptr->chname, mode, modeval);
1393
1394 *modeval = '\0';
1395 }
1396
1397 if(MyClient(target_p) && changed_case)
1398 sendto_one(target_p, ":%s!%s@%s NICK %s",
1399 target_p->name, target_p->username, target_p->host, nick);
1400 }
1401 else if(changed_case)
1402 {
1403 sendto_common_channels_local(target_p, ":%s!%s@%s NICK :%s",
1404 target_p->name, target_p->username,
1405 target_p->host, nick);
1406 }
1407
1408 strlcpy(target_p->username, user, USERLEN);
1409 strlcpy(target_p->host, host, HOSTLEN);
1410
1411 if (changed)
1412 add_history(target_p, 1);
1413
1414 del_from_client_hash(target_p->name, target_p);
1415 strlcpy(target_p->name, nick, NICKLEN);
1416 add_to_client_hash(target_p->name, target_p);
1417
1418 if(changed)
1419 {
1420 monitor_signon(target_p);
1421 del_all_accepts(target_p);
1422 }
1423 }