2 * ircd-ratbox: A slightly useful ircd.
3 * s_user.c: User related functions.
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
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.
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.
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
39 #include "s_newconf.h"
45 #include "supported.h"
53 #include "blacklist.h"
54 #include "substitution.h"
57 static void report_and_set_user_flags(struct Client
*, struct ConfItem
*);
58 void user_welcome(struct Client
*source_p
);
62 static int orphaned_umodes
= 0;
63 int user_modes
[256] = {
64 /* 0x00 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x0F */
65 /* 0x10 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x1F */
66 /* 0x20 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x2F */
67 /* 0x30 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x3F */
75 UMODE_SCALLERID
, /* G */
85 UMODE_NOFORWARD
, /* Q */
86 UMODE_REGONLYMSG
, /* R */
87 UMODE_SERVICE
, /* S */
90 UMODE_NOINVITE
, /* V */
94 UMODE_SSLCLIENT
, /* Z */
95 /* 0x5B */ 0, 0, 0, 0, 0, 0, /* 0x60 */
102 UMODE_CALLERID
, /* g */
104 UMODE_INVISIBLE
, /* i */
107 UMODE_LOCOPS
, /* l */
111 UMODE_OVERRIDE
, /* p */
114 UMODE_SERVNOTICE
, /* s */
118 UMODE_WALLOP
, /* w */
121 UMODE_OPERWALL
, /* z */
122 /* 0x7B */ 0, 0, 0, 0, 0, /* 0x7F */
123 /* 0x80 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x9F */
124 /* 0x90 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x9F */
125 /* 0xA0 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xAF */
126 /* 0xB0 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xBF */
127 /* 0xC0 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xCF */
128 /* 0xD0 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xDF */
129 /* 0xE0 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xEF */
130 /* 0xF0 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 /* 0xFF */
137 * inputs - pointer to client
139 * side effects - display to client user counts etc.
142 show_lusers(struct Client
*source_p
)
144 if(rb_dlink_list_length(&lclient_list
) > (unsigned long)MaxClientCount
)
145 MaxClientCount
= rb_dlink_list_length(&lclient_list
);
147 if((rb_dlink_list_length(&lclient_list
) + rb_dlink_list_length(&serv_list
)) >
148 (unsigned long)MaxConnectionCount
)
149 MaxConnectionCount
= rb_dlink_list_length(&lclient_list
) +
150 rb_dlink_list_length(&serv_list
);
152 sendto_one_numeric(source_p
, RPL_LUSERCLIENT
, form_str(RPL_LUSERCLIENT
),
153 (Count
.total
- Count
.invisi
),
154 Count
.invisi
, rb_dlink_list_length(&global_serv_list
));
156 if(rb_dlink_list_length(&oper_list
) > 0)
157 sendto_one_numeric(source_p
, RPL_LUSEROP
,
158 form_str(RPL_LUSEROP
), rb_dlink_list_length(&oper_list
));
160 if(rb_dlink_list_length(&unknown_list
) > 0)
161 sendto_one_numeric(source_p
, RPL_LUSERUNKNOWN
,
162 form_str(RPL_LUSERUNKNOWN
),
163 rb_dlink_list_length(&unknown_list
));
165 if(rb_dlink_list_length(&global_channel_list
) > 0)
166 sendto_one_numeric(source_p
, RPL_LUSERCHANNELS
,
167 form_str(RPL_LUSERCHANNELS
),
168 rb_dlink_list_length(&global_channel_list
));
170 sendto_one_numeric(source_p
, RPL_LUSERME
, form_str(RPL_LUSERME
),
171 rb_dlink_list_length(&lclient_list
),
172 rb_dlink_list_length(&serv_list
));
174 sendto_one_numeric(source_p
, RPL_LOCALUSERS
,
175 form_str(RPL_LOCALUSERS
),
176 rb_dlink_list_length(&lclient_list
),
178 rb_dlink_list_length(&lclient_list
),
181 sendto_one_numeric(source_p
, RPL_GLOBALUSERS
, form_str(RPL_GLOBALUSERS
),
182 Count
.total
, Count
.max_tot
,
183 Count
.total
, Count
.max_tot
);
185 sendto_one_numeric(source_p
, RPL_STATSCONN
,
186 form_str(RPL_STATSCONN
),
187 MaxConnectionCount
, MaxClientCount
,
188 Count
.totalrestartcount
);
194 ** register_local_user
195 ** This function is called when both NICK and USER messages
196 ** have been accepted for the client, in whatever order. Only
197 ** after this, is the USER message propagated.
199 ** NICK's must be propagated at once when received, although
200 ** it would be better to delay them too until full info is
201 ** available. Doing it is not so simple though, would have
202 ** to implement the following:
204 ** (actually it has been implemented already for a while) -orabidoo
206 ** 1) user telnets in and gives only "NICK foobar" and waits
207 ** 2) another user far away logs in normally with the nick
208 ** "foobar" (quite legal, as this server didn't propagate
210 ** 3) now this server gets nick "foobar" from outside, but
211 ** has alread the same defined locally. Current server
212 ** would just issue "KILL foobar" to clean out dups. But,
213 ** this is not fair. It should actually request another
214 ** nick from local user or kill him/her...
218 register_local_user(struct Client
*client_p
, struct Client
*source_p
, const char *username
)
220 struct ConfItem
*aconf
, *xconf
;
221 struct User
*user
= source_p
->user
;
222 char tmpstr2
[IRCD_BUFSIZE
];
223 char ipaddr
[HOSTIPLEN
];
224 char myusername
[USERLEN
+1];
227 s_assert(NULL
!= source_p
);
228 s_assert(MyConnect(source_p
));
229 s_assert(source_p
->username
!= username
);
234 if(IsAnyDead(source_p
))
237 if(ConfigFileEntry
.ping_cookie
)
239 if(!(source_p
->flags
& FLAGS_PINGSENT
) && source_p
->localClient
->random_ping
== 0)
241 source_p
->localClient
->random_ping
= (unsigned long) (rand() * rand()) << 1;
242 sendto_one(source_p
, "PING :%08lX",
243 (unsigned long) source_p
->localClient
->random_ping
);
244 source_p
->flags
|= FLAGS_PINGSENT
;
247 if(!(source_p
->flags
& FLAGS_PING_COOKIE
))
253 /* hasnt finished client cap negotiation */
254 if(source_p
->flags
& FLAGS_CLICAP
)
257 /* still has DNSbls to validate against */
258 if(rb_dlink_list_length(&source_p
->preClient
->dnsbl_queries
) > 0)
261 client_p
->localClient
->last
= rb_current_time();
262 /* Straight up the maximum rate of flooding... */
263 source_p
->localClient
->allow_read
= MAX_FLOOD_BURST
;
265 /* XXX - fixme. we shouldnt have to build a users buffer twice.. */
266 if(!IsGotId(source_p
) && (strchr(username
, '[') != NULL
))
273 while(*p
&& i
< USERLEN
)
276 myusername
[i
++] = *p
;
280 myusername
[i
] = '\0';
281 username
= myusername
;
284 if((status
= check_client(client_p
, source_p
, username
)) < 0)
285 return (CLIENT_EXITED
);
287 /* Apply nick override */
288 if(*source_p
->preClient
->spoofnick
)
290 char note
[NICKLEN
+ 10];
292 del_from_client_hash(source_p
->name
, source_p
);
293 rb_strlcpy(source_p
->name
, source_p
->preClient
->spoofnick
, NICKLEN
+ 1);
294 add_to_client_hash(source_p
->name
, source_p
);
296 rb_snprintf(note
, NICKLEN
+ 10, "Nick: %s", source_p
->name
);
297 rb_note(source_p
->localClient
->F
, note
);
300 if(!valid_hostname(source_p
->host
))
302 sendto_one_notice(source_p
, ":*** Notice -- You have an illegal character in your hostname");
304 rb_strlcpy(source_p
->host
, source_p
->sockhost
, sizeof(source_p
->host
));
308 aconf
= source_p
->localClient
->att_conf
;
312 exit_client(client_p
, source_p
, &me
, "*** Not Authorised");
313 return (CLIENT_EXITED
);
316 if(IsConfSSLNeeded(aconf
) && !IsSSL(source_p
))
318 ServerStats
.is_ref
++;
319 sendto_one_notice(source_p
, ":*** Notice -- You need to use SSL/TLS to use this server");
320 exit_client(client_p
, source_p
, &me
, "Use SSL/TLS");
321 return (CLIENT_EXITED
);
324 if(!IsGotId(source_p
))
329 if(IsNeedIdentd(aconf
))
331 ServerStats
.is_ref
++;
332 sendto_one_notice(source_p
, ":*** Notice -- You need to install identd to use this server");
333 exit_client(client_p
, source_p
, &me
, "Install identd");
334 return (CLIENT_EXITED
);
337 /* dont replace username if its supposed to be spoofed --fl */
338 if(!IsConfDoSpoofIp(aconf
) || !strchr(aconf
->info
.name
, '@'))
342 if(!IsNoTilde(aconf
))
343 source_p
->username
[i
++] = '~';
345 while (*p
&& i
< USERLEN
)
348 source_p
->username
[i
++] = *p
;
352 source_p
->username
[i
] = '\0';
356 if(IsNeedSasl(aconf
) && !*user
->suser
)
358 ServerStats
.is_ref
++;
359 sendto_one_notice(source_p
, ":*** Notice -- You need to identify via SASL to use this server");
360 exit_client(client_p
, source_p
, &me
, "SASL access only");
361 return (CLIENT_EXITED
);
365 if(!EmptyString(aconf
->passwd
))
369 if(EmptyString(source_p
->localClient
->passwd
))
371 else if(IsConfEncrypted(aconf
))
372 encr
= rb_crypt(source_p
->localClient
->passwd
, aconf
->passwd
);
374 encr
= source_p
->localClient
->passwd
;
376 if(strcmp(encr
, aconf
->passwd
))
378 ServerStats
.is_ref
++;
379 sendto_one(source_p
, form_str(ERR_PASSWDMISMATCH
), me
.name
, source_p
->name
);
380 exit_client(client_p
, source_p
, &me
, "Bad Password");
381 return (CLIENT_EXITED
);
384 /* clear password only if used now, otherwise send it
385 * to services -- jilles */
386 if(source_p
->localClient
->passwd
)
388 memset(source_p
->localClient
->passwd
, 0, strlen(source_p
->localClient
->passwd
));
389 rb_free(source_p
->localClient
->passwd
);
390 source_p
->localClient
->passwd
= NULL
;
394 /* report if user has &^>= etc. and set flags as needed in source_p */
395 report_and_set_user_flags(source_p
, aconf
);
399 * We want to be able to have servers and F-line clients
400 * connect, so save room for "buffer" connections.
401 * Smaller servers may want to decrease this, and it should
402 * probably be just a percentage of the MAXCLIENTS...
405 /* Except "F:" clients */
406 if(rb_dlink_list_length(&lclient_list
) >=
407 (unsigned long)GlobalSetOptions
.maxclients
&& !IsConfExemptLimits(aconf
))
409 sendto_realops_snomask(SNO_FULL
, L_ALL
,
410 "Too many clients, rejecting %s[%s].", source_p
->name
, source_p
->host
);
412 ServerStats
.is_ref
++;
413 exit_client(client_p
, source_p
, &me
, "Sorry, server is full - try later");
414 return (CLIENT_EXITED
);
417 /* kline exemption extends to xline too */
418 if(!IsExemptKline(source_p
) &&
419 (xconf
= find_xline(source_p
->info
, 1)) != NULL
)
421 ServerStats
.is_ref
++;
422 add_reject(source_p
, xconf
->host
, NULL
);
423 exit_client(client_p
, source_p
, &me
, "Bad user info");
424 return CLIENT_EXITED
;
428 if (source_p
->preClient
->dnsbl_listed
!= NULL
)
430 if (IsExemptKline(source_p
) || IsConfExemptDNSBL(aconf
))
431 sendto_one_notice(source_p
, ":*** Your IP address %s is listed in %s, but you are exempt",
432 source_p
->sockhost
, source_p
->preClient
->dnsbl_listed
->host
);
435 rb_dlink_list varlist
= { NULL
, NULL
, 0 };
437 substitution_append_var(&varlist
, "nick", source_p
->name
);
438 substitution_append_var(&varlist
, "ip", source_p
->sockhost
);
439 substitution_append_var(&varlist
, "host", source_p
->host
);
440 substitution_append_var(&varlist
, "dnsbl-host", source_p
->preClient
->dnsbl_listed
->host
);
441 substitution_append_var(&varlist
, "network-name", ServerInfo
.network_name
);
443 ServerStats
.is_ref
++;
445 sendto_one(source_p
, form_str(ERR_YOUREBANNEDCREEP
),
446 me
.name
, source_p
->name
,
447 substitution_parse(source_p
->preClient
->dnsbl_listed
->reject_reason
, &varlist
));
449 substitution_free(&varlist
);
451 sendto_one_notice(source_p
, ":*** Your IP address %s is listed in %s",
452 source_p
->sockhost
, source_p
->preClient
->dnsbl_listed
->host
);
453 source_p
->preClient
->dnsbl_listed
->hits
++;
455 sendto_realops_snomask(SNO_GENERAL
, L_ALL
,
456 "%s [%s] is being disconnected due to being listed in DNS Blacklist %s",
457 source_p
->name
, source_p
->sockhost
, source_p
->preClient
->dnsbl_listed
->host
);
459 add_reject(source_p
, NULL
, NULL
);
460 exit_client(client_p
, source_p
, &me
, "*** Banned (DNS blacklist)");
461 return CLIENT_EXITED
;
465 /* valid user name check */
467 if(!valid_username(source_p
->username
))
469 sendto_realops_snomask(SNO_REJ
, L_ALL
,
470 "Invalid username: %s (%s@%s)",
471 source_p
->name
, source_p
->username
, source_p
->host
);
472 ServerStats
.is_ref
++;
473 sendto_one_notice(source_p
, ":*** Your username is invalid. Please make sure that your username contains "
474 "only alphanumeric characters.");
475 rb_sprintf(tmpstr2
, "Invalid username [%s]", source_p
->username
);
476 exit_client(client_p
, source_p
, &me
, tmpstr2
);
477 return (CLIENT_EXITED
);
480 /* end of valid user name check */
482 /* Store original hostname -- jilles */
483 rb_strlcpy(source_p
->orighost
, source_p
->host
, HOSTLEN
+ 1);
485 /* Spoof user@host */
486 if(*source_p
->preClient
->spoofuser
)
487 rb_strlcpy(source_p
->username
, source_p
->preClient
->spoofuser
, USERLEN
+ 1);
488 if(*source_p
->preClient
->spoofhost
)
490 rb_strlcpy(source_p
->host
, source_p
->preClient
->spoofhost
, HOSTLEN
+ 1);
491 if (irccmp(source_p
->host
, source_p
->orighost
))
492 SetDynSpoof(source_p
);
495 source_p
->umodes
|= ConfigFileEntry
.default_umodes
& ~ConfigFileEntry
.oper_only_umodes
& ~orphaned_umodes
;
497 call_hook(h_new_local_user
, source_p
);
499 /* If they have died in send_* or were thrown out by the
500 * new_local_user hook don't do anything. */
501 if(IsAnyDead(source_p
))
502 return CLIENT_EXITED
;
504 /* To avoid inconsistencies, do not abort the registration
505 * starting from this point -- jilles
507 rb_inet_ntop_sock((struct sockaddr
*)&source_p
->localClient
->ip
, ipaddr
, sizeof(ipaddr
));
509 sendto_realops_snomask(SNO_CCONN
, L_ALL
,
510 "Client connecting: %s (%s@%s) [%s] {%s} [%s]",
511 source_p
->name
, source_p
->username
, source_p
->orighost
,
512 show_ip(NULL
, source_p
) ? ipaddr
: "255.255.255.255",
513 get_client_class(source_p
), source_p
->info
);
515 sendto_realops_snomask(SNO_CCONNEXT
, L_ALL
,
516 "CLICONN %s %s %s %s %s %s 0 %s",
517 source_p
->name
, source_p
->username
, source_p
->orighost
,
518 show_ip(NULL
, source_p
) ? ipaddr
: "255.255.255.255",
519 get_client_class(source_p
),
520 /* mirc can sometimes send ips here */
521 show_ip(NULL
, source_p
) ? source_p
->localClient
->fullcaps
: "<hidden> <hidden>",
524 add_to_hostname_hash(source_p
->orighost
, source_p
);
526 /* Allocate a UID if it was not previously allocated.
527 * If this already occured, it was probably during SASL auth...
531 strcpy(source_p
->id
, generate_uid());
532 add_to_id_hash(source_p
->id
, source_p
);
536 source_p
->umodes
|= UMODE_SSLCLIENT
;
538 if (source_p
->umodes
& UMODE_INVISIBLE
)
541 s_assert(!IsClient(source_p
));
542 rb_dlinkMoveNode(&source_p
->localClient
->tnode
, &unknown_list
, &lclient_list
);
545 source_p
->servptr
= &me
;
546 rb_dlinkAdd(source_p
, &source_p
->lnode
, &source_p
->servptr
->serv
->users
);
548 /* Increment our total user count here */
549 if(++Count
.total
> Count
.max_tot
)
550 Count
.max_tot
= Count
.total
;
552 source_p
->localClient
->allow_read
= MAX_FLOOD_BURST
;
554 Count
.totalrestartcount
++;
556 s_assert(source_p
->localClient
!= NULL
);
558 if(rb_dlink_list_length(&lclient_list
) > (unsigned long)Count
.max_loc
)
560 Count
.max_loc
= rb_dlink_list_length(&lclient_list
);
561 if(!(Count
.max_loc
% 10))
562 sendto_realops_snomask(SNO_GENERAL
, L_ALL
,
563 "New Max Local Clients: %d", Count
.max_loc
);
566 /* they get a reduced limit */
567 if(find_tgchange(source_p
->sockhost
))
568 source_p
->localClient
->targets_free
= TGCHANGE_INITIAL_LOW
;
570 source_p
->localClient
->targets_free
= TGCHANGE_INITIAL
;
572 monitor_signon(source_p
);
573 user_welcome(source_p
);
575 free_pre_client(source_p
);
577 return (introduce_client(client_p
, source_p
, user
, source_p
->name
, 1));
585 * side effects - This common function introduces a client to the rest
586 * of the net, either from a local client connect or
587 * from a remote connect.
590 introduce_client(struct Client
*client_p
, struct Client
*source_p
, struct User
*user
, const char *nick
, int use_euid
)
592 static char ubuf
[12];
593 struct Client
*identifyservice_p
;
595 hook_data_umode_changed hdata
;
596 hook_data_client hdata2
;
597 char sockhost
[HOSTLEN
];
598 struct ConfItem
*aconf
;
600 if(MyClient(source_p
))
601 send_umode(source_p
, source_p
, 0, 0, ubuf
);
603 send_umode(NULL
, source_p
, 0, 0, ubuf
);
611 s_assert(has_id(source_p
));
613 if(source_p
->sockhost
[0] == ':')
617 rb_strlcat(sockhost
, source_p
->sockhost
, sizeof(sockhost
));
619 strcpy(sockhost
, source_p
->sockhost
);
622 sendto_server(client_p
, NULL
, CAP_EUID
| CAP_TS6
, NOCAPS
,
623 ":%s EUID %s %d %ld %s %s %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
,
630 IsDynSpoof(source_p
) ? source_p
->orighost
: "*",
631 EmptyString(source_p
->user
->suser
) ? "*" : source_p
->user
->suser
,
634 sendto_server(client_p
, NULL
, CAP_TS6
, use_euid
? CAP_EUID
: NOCAPS
,
635 ":%s UID %s %d %ld %s %s %s %s %s :%s",
636 source_p
->servptr
->id
, nick
,
637 source_p
->hopcount
+ 1,
638 (long) source_p
->tsinfo
, ubuf
,
639 source_p
->username
, source_p
->host
,
640 IsIPSpoof(source_p
) ? "0" : sockhost
,
641 source_p
->id
, source_p
->info
);
643 if(!EmptyString(source_p
->certfp
))
644 sendto_server(client_p
, NULL
, CAP_TS6
, NOCAPS
,
645 ":%s ENCAP * CERTFP :%s",
646 use_id(source_p
), source_p
->certfp
);
648 if (IsDynSpoof(source_p
))
650 sendto_server(client_p
, NULL
, CAP_TS6
, use_euid
? CAP_EUID
: NOCAPS
, ":%s ENCAP * REALHOST %s",
651 use_id(source_p
), source_p
->orighost
);
654 if (!EmptyString(source_p
->user
->suser
))
656 sendto_server(client_p
, NULL
, CAP_TS6
, use_euid
? CAP_EUID
: NOCAPS
, ":%s ENCAP * LOGIN %s",
657 use_id(source_p
), source_p
->user
->suser
);
660 if(MyConnect(source_p
) && source_p
->localClient
->passwd
)
662 if (!EmptyString(ConfigFileEntry
.identifyservice
) &&
663 !EmptyString(ConfigFileEntry
.identifycommand
))
665 /* use user@server */
666 p
= strchr(ConfigFileEntry
.identifyservice
, '@');
668 identifyservice_p
= find_named_client(p
+ 1);
670 identifyservice_p
= NULL
;
671 if (identifyservice_p
!= NULL
)
673 if (!EmptyString(source_p
->localClient
->auth_user
))
674 sendto_one(identifyservice_p
, ":%s PRIVMSG %s :%s %s %s",
675 get_id(source_p
, identifyservice_p
),
676 ConfigFileEntry
.identifyservice
,
677 ConfigFileEntry
.identifycommand
,
678 source_p
->localClient
->auth_user
,
679 source_p
->localClient
->passwd
);
681 sendto_one(identifyservice_p
, ":%s PRIVMSG %s :%s %s",
682 get_id(source_p
, identifyservice_p
),
683 ConfigFileEntry
.identifyservice
,
684 ConfigFileEntry
.identifycommand
,
685 source_p
->localClient
->passwd
);
688 memset(source_p
->localClient
->passwd
, 0, strlen(source_p
->localClient
->passwd
));
689 rb_free(source_p
->localClient
->passwd
);
690 source_p
->localClient
->passwd
= NULL
;
693 /* let modules providing usermodes know that we've got a new user,
694 * why is this here? -- well, some modules need to be able to send out new
695 * information about a client, so this was the best place to do it
698 hdata
.client
= source_p
;
700 hdata
.oldsnomask
= 0;
701 call_hook(h_umode_changed
, &hdata
);
703 /* On the other hand, some modules need to know when a client is
704 * being introduced, period.
707 hdata2
.client
= client_p
;
708 hdata2
.target
= source_p
;
709 call_hook(h_introduce_client
, &hdata2
);
711 /* Do all the auth::autojoin wizardry once we're connected */
712 if(MyConnect(source_p
))
714 aconf
= source_p
->localClient
->att_conf
;
716 if(aconf
->autojoin
!= NULL
)
718 user_join(client_p
, source_p
, aconf
->autojoin
, NULL
);
726 * valid_hostname - check hostname for validity
728 * Inputs - pointer to user
729 * Output - YES if valid, NO if not
730 * Side effects - NONE
732 * NOTE: this doesn't allow a hostname to begin with a dot and
733 * will not allow more dots than chars.
736 valid_hostname(const char *hostname
)
738 const char *p
= hostname
, *last_slash
= 0;
746 if('.' == *p
|| ':' == *p
|| '/' == *p
)
753 if(*p
== '.' || *p
== ':')
766 if(last_slash
&& IsDigit(last_slash
[1]))
773 * valid_username - check username for validity
775 * Inputs - pointer to user
776 * Output - YES if valid, NO if not
777 * Side effects - NONE
779 * Absolutely always reject any '*' '!' '?' '@' in an user name
780 * reject any odd control characters names.
781 * Allow '.' in username to allow for "first.last"
785 valid_username(const char *username
)
788 const char *p
= username
;
798 /* reject usernames that don't start with an alphanum
799 * i.e. reject jokers who have '-@somehost' or '.@somehost'
800 * or "-hi-@somehost", "h-----@somehost" would still be accepted.
807 if((*p
== '.') && ConfigFileEntry
.dots_in_ident
)
810 if(dots
> ConfigFileEntry
.dots_in_ident
)
812 if(!IsUserChar(p
[1]))
815 else if(!IsUserChar(*p
))
821 /* report_and_set_user_flags
823 * Inputs - pointer to source_p
824 * - pointer to aconf for this user
827 * Report to user any special flags they are getting, and set them.
831 report_and_set_user_flags(struct Client
*source_p
, struct ConfItem
*aconf
)
833 /* If this user is being spoofed, tell them so */
834 if(IsConfDoSpoofIp(aconf
))
836 sendto_one_notice(source_p
, ":*** Spoofing your IP");
839 /* If this user is in the exception class, Set it "E lined" */
840 if(IsConfExemptKline(aconf
))
842 SetExemptKline(source_p
);
843 sendto_one_notice(source_p
, ":*** You are exempt from K/X lines");
846 if(IsConfExemptDNSBL(aconf
))
847 /* kline exempt implies this, don't send both */
848 if(!IsConfExemptKline(aconf
))
849 sendto_one_notice(source_p
, ":*** You are exempt from DNS blacklists");
851 /* If this user is exempt from user limits set it F lined" */
852 if(IsConfExemptLimits(aconf
))
854 sendto_one_notice(source_p
, ":*** You are exempt from user limits");
857 if(IsConfExemptFlood(aconf
))
859 SetExemptFlood(source_p
);
860 sendto_one_notice(source_p
, ":*** You are exempt from flood limits");
863 if(IsConfExemptSpambot(aconf
))
865 SetExemptSpambot(source_p
);
866 sendto_one_notice(source_p
, ":*** You are exempt from spambot checks");
869 if(IsConfExemptJupe(aconf
))
871 SetExemptJupe(source_p
);
872 sendto_one_notice(source_p
, ":*** You are exempt from juped channel warnings");
875 if(IsConfExemptResv(aconf
))
877 SetExemptResv(source_p
);
878 sendto_one_notice(source_p
, ":*** You are exempt from resvs");
881 if(IsConfExemptShide(aconf
))
883 SetExemptShide(source_p
);
884 sendto_one_notice(source_p
, ":*** You are exempt from serverhiding");
889 show_other_user_mode(struct Client
*source_p
, struct Client
*target_p
)
898 for (i
= 0; i
< 128; i
++) /* >= 127 is extended ascii */
899 if (target_p
->umodes
& user_modes
[i
])
903 if (MyConnect(target_p
) && target_p
->snomask
!= 0)
904 sendto_one_notice(source_p
, ":Modes for %s are %s %s",
906 construct_snobuf(target_p
->snomask
));
908 sendto_one_notice(source_p
, ":Modes for %s are %s",
909 target_p
->name
, buf
);
913 expire_umode_p(void *data
)
915 struct Client
*source_p
= data
;
916 char *parv
[4] = {source_p
->name
, source_p
->name
, "-p", NULL
};
917 source_p
->localClient
->override_timeout_event
= NULL
;
918 user_mode(source_p
, source_p
, 3, parv
);
922 * user_mode - set get current users mode
924 * m_umode() added 15/10/91 By Darren Reed.
925 * parv[1] - username to change mode for
926 * parv[2] - modes to change
929 user_mode(struct Client
*client_p
, struct Client
*source_p
, int parc
, const char *parv
[])
935 struct Client
*target_p
;
937 int badflag
= NO
; /* Only send one bad flag notice */
938 int showsnomask
= NO
;
939 unsigned int setsnomask
;
941 hook_data_umode_changed hdata
;
947 sendto_one(source_p
, form_str(ERR_NEEDMOREPARAMS
), me
.name
, source_p
->name
, "MODE");
951 if((target_p
= MyClient(source_p
) ? find_named_person(parv
[1]) : find_person(parv
[1])) == NULL
)
953 if(MyConnect(source_p
))
954 sendto_one_numeric(source_p
, ERR_NOSUCHCHANNEL
,
955 form_str(ERR_NOSUCHCHANNEL
), parv
[1]);
959 /* Dont know why these were commented out..
960 * put them back using new sendto() funcs
963 if(IsServer(source_p
))
965 sendto_realops_snomask(SNO_GENERAL
, L_ADMIN
,
966 "*** Mode for User %s from %s", parv
[1], source_p
->name
);
970 if(source_p
!= target_p
)
972 if (MyOper(source_p
) && parc
< 3)
973 show_other_user_mode(source_p
, target_p
);
975 sendto_one(source_p
, form_str(ERR_USERSDONTMATCH
), me
.name
, source_p
->name
);
984 for (i
= 0; i
< 128; i
++) /* >= 127 is extended ascii */
985 if (source_p
->umodes
& user_modes
[i
])
989 sendto_one_numeric(source_p
, RPL_UMODEIS
, form_str(RPL_UMODEIS
), buf
);
991 if (source_p
->snomask
!= 0)
992 sendto_one_numeric(source_p
, RPL_SNOMASK
, form_str(RPL_SNOMASK
),
993 construct_snobuf(source_p
->snomask
));
998 /* find flags already set for user */
999 setflags
= source_p
->umodes
;
1000 setsnomask
= source_p
->snomask
;
1003 * parse mode change string(s)
1005 for (pm
= parv
[2]; *pm
; pm
++)
1016 if(what
== MODE_ADD
)
1018 if(IsServer(client_p
) && !IsOper(source_p
))
1022 rb_dlinkAddAlloc(source_p
, &oper_list
);
1027 /* Only decrement the oper counts if an oper to begin with
1028 * found by Pat Szuta, Perly , perly@xnet.com
1031 if(!IsOper(source_p
))
1034 ClearOper(source_p
);
1038 user_metadata_delete(source_p
, "OPERSTRING", 1);
1039 user_metadata_delete(source_p
, "SWHOIS", 1);
1041 if(MyConnect(source_p
))
1043 source_p
->umodes
&= ~ConfigFileEntry
.oper_only_umodes
;
1044 if (!(source_p
->umodes
& UMODE_SERVNOTICE
) && source_p
->snomask
!= 0)
1046 source_p
->snomask
= 0;
1049 source_p
->flags2
&= ~OPER_FLAGS
;
1051 rb_free(source_p
->localClient
->opername
);
1052 source_p
->localClient
->opername
= NULL
;
1054 rb_dlinkFindDestroy(source_p
, &local_oper_list
);
1055 privilegeset_unref(source_p
->localClient
->privset
);
1056 source_p
->localClient
->privset
= NULL
;
1059 rb_dlinkFindDestroy(source_p
, &oper_list
);
1063 /* we may not get these,
1064 * but they shouldnt be in default
1067 /* can only be set on burst */
1077 if (MyConnect(source_p
))
1079 if(!IsOper(source_p
)
1080 && (ConfigFileEntry
.oper_only_umodes
& UMODE_SERVNOTICE
))
1082 if (what
== MODE_ADD
|| source_p
->umodes
& UMODE_SERVNOTICE
)
1087 if(what
== MODE_ADD
)
1090 source_p
->snomask
= parse_snobuf_to_mask(source_p
->snomask
, parv
[3]);
1092 source_p
->snomask
|= SNO_GENERAL
;
1095 source_p
->snomask
= 0;
1096 if (source_p
->snomask
!= 0)
1097 source_p
->umodes
|= UMODE_SERVNOTICE
;
1099 source_p
->umodes
&= ~UMODE_SERVNOTICE
;
1104 if (MyConnect(source_p
) && *pm
== 'Q' && !ConfigChannel
.use_forward
) {
1109 if((flag
= user_modes
[(unsigned char) *pm
]))
1111 if(MyConnect(source_p
)
1112 && ((!IsOper(source_p
)
1113 && (ConfigFileEntry
.oper_only_umodes
& flag
))
1114 || (orphaned_umodes
& flag
)))
1116 if (what
== MODE_ADD
|| source_p
->umodes
& flag
)
1121 if(what
== MODE_ADD
)
1122 source_p
->umodes
|= flag
;
1124 source_p
->umodes
&= ~flag
;
1129 if(MyConnect(source_p
))
1136 sendto_one(source_p
, form_str(ERR_UMODEUNKNOWNFLAG
), me
.name
, source_p
->name
);
1138 if(MyClient(source_p
) && (source_p
->snomask
& SNO_NCHANGE
) && !IsOperN(source_p
))
1140 sendto_one_notice(source_p
, ":*** You need oper and nick_changes flag for +s +n");
1141 source_p
->snomask
&= ~SNO_NCHANGE
; /* only tcm's really need this */
1144 if(MyClient(source_p
) && (source_p
->umodes
& UMODE_OPERWALL
) && !IsOperOperwall(source_p
))
1146 sendto_one_notice(source_p
, ":*** You need oper and operwall flag for +z");
1147 source_p
->umodes
&= ~UMODE_OPERWALL
;
1150 if(MyConnect(source_p
) && (source_p
->umodes
& UMODE_ADMIN
) &&
1151 (!IsOperAdmin(source_p
) || IsOperHiddenAdmin(source_p
)))
1153 sendto_one_notice(source_p
, ":*** You need oper and admin flag for +a");
1154 source_p
->umodes
&= ~UMODE_ADMIN
;
1157 if(MyConnect(source_p
) && (source_p
->umodes
& UMODE_OVERRIDE
) && (!IsOperOverride(source_p
)))
1159 sendto_one_notice(source_p
, ":*** You need oper and the override flag for +p");
1160 source_p
->umodes
&= ~UMODE_OVERRIDE
;
1163 /* let modules providing usermodes know that we've changed our usermode --nenolod */
1164 hdata
.client
= source_p
;
1165 hdata
.oldumodes
= setflags
;
1166 hdata
.oldsnomask
= setsnomask
;
1167 call_hook(h_umode_changed
, &hdata
);
1169 if(!(setflags
& UMODE_INVISIBLE
) && IsInvisible(source_p
))
1171 if((setflags
& UMODE_INVISIBLE
) && !IsInvisible(source_p
))
1174 * compare new flags with old flags and send string which
1175 * will cause servers to update correctly.
1177 send_umode_out(client_p
, source_p
, setflags
);
1178 if (showsnomask
&& MyConnect(source_p
))
1179 sendto_one_numeric(source_p
, RPL_SNOMASK
, form_str(RPL_SNOMASK
),
1180 construct_snobuf(source_p
->snomask
));
1182 /* If we're setting +p, expire it, but only from local clients */
1183 if(ConfigFileEntry
.expire_override_time
&& MyClient(source_p
) && (source_p
->umodes
& ~setflags
) & UMODE_OVERRIDE
)
1185 source_p
->localClient
->override_timeout_event
=
1186 rb_event_addonce("expire_override", expire_umode_p
, source_p
, ConfigFileEntry
.expire_override_time
);
1188 else if(MyClient(source_p
) && source_p
->localClient
->override_timeout_event
&& (setflags
& ~source_p
->umodes
) & UMODE_OVERRIDE
)
1190 rb_event_delete(source_p
->localClient
->override_timeout_event
);
1191 source_p
->localClient
->override_timeout_event
= NULL
;
1199 * send the MODE string for user (user) to connection client_p
1203 send_umode(struct Client
*client_p
, struct Client
*source_p
, int old
, int sendmask
, char *umode_buf
)
1211 * build a string in umode_buf to represent the change in the user's
1212 * mode between the new (source_p->flag) and 'old'.
1217 for (i
= 0; i
< 128; i
++)
1219 flag
= user_modes
[i
];
1221 if((flag
& old
) && !(source_p
->umodes
& flag
))
1223 if(what
== MODE_DEL
)
1232 else if(!(flag
& old
) && (source_p
->umodes
& flag
))
1234 if(what
== MODE_ADD
)
1246 if(*umode_buf
&& client_p
)
1247 sendto_one(client_p
, ":%s MODE %s :%s", source_p
->name
, source_p
->name
, umode_buf
);
1258 send_umode_out(struct Client
*client_p
, struct Client
*source_p
, int old
)
1260 struct Client
*target_p
;
1264 send_umode(NULL
, source_p
, old
, 0, buf
);
1266 RB_DLINK_FOREACH(ptr
, serv_list
.head
)
1268 target_p
= ptr
->data
;
1270 if((target_p
!= client_p
) && (target_p
!= source_p
) && (*buf
))
1272 sendto_one(target_p
, ":%s MODE %s :%s",
1273 get_id(source_p
, target_p
),
1274 get_id(source_p
, target_p
), buf
);
1278 if(client_p
&& MyClient(client_p
))
1279 send_umode(client_p
, source_p
, old
, 0, buf
);
1285 * inputs - client pointer to client to welcome
1290 user_welcome(struct Client
*source_p
)
1292 sendto_one_numeric(source_p
, RPL_WELCOME
, form_str(RPL_WELCOME
), ServerInfo
.network_name
, source_p
->name
);
1293 sendto_one_numeric(source_p
, RPL_YOURHOST
, form_str(RPL_YOURHOST
),
1294 get_listener_name(source_p
->localClient
->listener
), ircd_version
);
1295 sendto_one_numeric(source_p
, RPL_CREATED
, form_str(RPL_CREATED
), creation
);
1296 sendto_one_numeric(source_p
, RPL_MYINFO
, form_str(RPL_MYINFO
), me
.name
, ircd_version
, umodebuf
, cflagsmyinfo
);
1298 show_isupport(source_p
);
1300 show_lusers(source_p
);
1302 if(ConfigFileEntry
.short_motd
)
1304 sendto_one_notice(source_p
, ":*** Notice -- motd was last changed at %s", user_motd_changed
);
1305 sendto_one_notice(source_p
, ":*** Notice -- Please read the motd if you haven't read it");
1307 sendto_one(source_p
, form_str(RPL_MOTDSTART
),
1308 me
.name
, source_p
->name
, me
.name
);
1310 sendto_one(source_p
, form_str(RPL_MOTD
),
1311 me
.name
, source_p
->name
, "*** This is the short motd ***");
1313 sendto_one(source_p
, form_str(RPL_ENDOFMOTD
), me
.name
, source_p
->name
);
1316 send_user_motd(source_p
);
1321 * inputs - pointer to given client to oper
1322 * - pointer to ConfItem to use
1324 * side effects - opers up source_p using aconf for reference
1327 oper_up(struct Client
*source_p
, struct oper_conf
*oper_p
)
1329 unsigned int old
= source_p
->umodes
, oldsnomask
= source_p
->snomask
;
1330 hook_data_umode_changed hdata
;
1331 struct ConfItem
*aconf
;
1336 source_p
->umodes
|= oper_p
->umodes
;
1337 else if(ConfigFileEntry
.oper_umodes
)
1338 source_p
->umodes
|= ConfigFileEntry
.oper_umodes
;
1340 source_p
->umodes
|= DEFAULT_OPER_UMODES
;
1343 user_metadata_add(source_p
, "SWHOIS", oper_p
->swhois
, 1);
1345 if(oper_p
->operstring
)
1346 user_metadata_add(source_p
, "OPERSTRING", oper_p
->operstring
, 1);
1348 if(oper_p
->vhost
|| !EmptyString(GlobalSetOptions
.operhost
))
1351 change_nick_user_host(source_p
, source_p
->name
, source_p
->username
, oper_p
->vhost
, 0, "Changing host");
1353 change_nick_user_host(source_p
, source_p
->name
, source_p
->username
, GlobalSetOptions
.operhost
, 0, "Changing host");
1355 sendto_one_numeric(source_p
, RPL_HOSTHIDDEN
, "%s :is now your hidden host (set by %s)", source_p
->host
, source_p
->servptr
->name
);
1357 sendto_server(NULL
, NULL
,
1358 CAP_EUID
| CAP_TS6
, NOCAPS
, ":%s CHGHOST %s :%s",
1359 use_id(&me
), use_id(source_p
), source_p
->host
);
1360 sendto_server(NULL
, NULL
,
1361 CAP_TS6
, CAP_EUID
, ":%s ENCAP * CHGHOST %s :%s",
1362 use_id(&me
), use_id(source_p
), source_p
->host
);
1364 if (!IsDynSpoof(source_p
))
1365 SetDynSpoof(source_p
);
1368 if (oper_p
->snomask
)
1370 source_p
->snomask
|= oper_p
->snomask
;
1371 source_p
->umodes
|= UMODE_SERVNOTICE
;
1373 else if (source_p
->umodes
& UMODE_SERVNOTICE
)
1375 /* Only apply these if +s is already set -- jilles */
1376 if (ConfigFileEntry
.oper_snomask
)
1377 source_p
->snomask
|= ConfigFileEntry
.oper_snomask
;
1379 source_p
->snomask
|= DEFAULT_OPER_SNOMASK
;
1384 SetExemptKline(source_p
);
1386 source_p
->flags2
|= oper_p
->flags
;
1387 source_p
->localClient
->opername
= rb_strdup(oper_p
->name
);
1388 source_p
->localClient
->privset
= privilegeset_ref(oper_p
->privset
);
1390 rb_dlinkAddAlloc(source_p
, &local_oper_list
);
1391 rb_dlinkAddAlloc(source_p
, &oper_list
);
1393 if(IsOperAdmin(source_p
) && !IsOperHiddenAdmin(source_p
))
1394 source_p
->umodes
|= UMODE_ADMIN
;
1395 if(!IsOperN(source_p
))
1396 source_p
->snomask
&= ~SNO_NCHANGE
;
1397 if(!IsOperOperwall(source_p
))
1398 source_p
->umodes
&= ~UMODE_OPERWALL
;
1399 hdata
.client
= source_p
;
1400 hdata
.oldumodes
= old
;
1401 hdata
.oldsnomask
= oldsnomask
;
1402 call_hook(h_umode_changed
, &hdata
);
1404 sendto_realops_snomask(SNO_GENERAL
, L_ALL
,
1405 "%s (%s!%s@%s) is now an operator", oper_p
->name
, source_p
->name
,
1406 source_p
->username
, source_p
->host
);
1407 if(!(old
& UMODE_INVISIBLE
) && IsInvisible(source_p
))
1409 if((old
& UMODE_INVISIBLE
) && !IsInvisible(source_p
))
1411 send_umode_out(source_p
, source_p
, old
);
1412 sendto_one_numeric(source_p
, RPL_SNOMASK
, form_str(RPL_SNOMASK
),
1413 construct_snobuf(source_p
->snomask
));
1414 sendto_one(source_p
, form_str(RPL_YOUREOPER
), me
.name
, source_p
->name
);
1415 sendto_one_notice(source_p
, ":*** Oper privilege set is %s", oper_p
->privset
->name
);
1416 sendto_one_notice(source_p
, ":*** Oper privs are %s", oper_p
->privset
->privs
);
1417 send_oper_motd(source_p
);
1419 aconf
= source_p
->localClient
->att_conf
;
1421 /* Do the auth::autojoin_opers wizardry here */
1422 if(aconf
->autojoin_opers
!= NULL
)
1424 /* opers should never be banned from the opers channel.
1425 * Plus this is post-umode being set so you'll pass +I $o or +O.
1426 * Hence why we're making this a normal clean join. --jdhore
1428 user_join(&me
, source_p
, aconf
->autojoin_opers
, NULL
);
1438 * outputs - an available umode bitmask or
1439 * 0 if no umodes are available
1440 * side effects - NONE
1443 find_umode_slot(void)
1445 unsigned int all_umodes
= 0, my_umode
= 0, i
;
1447 for (i
= 0; i
< 128; i
++)
1448 all_umodes
|= user_modes
[i
];
1450 for (my_umode
= 1; my_umode
&& (all_umodes
& my_umode
);
1457 construct_umodebuf(void)
1460 char *ptr
= umodebuf
;
1461 static int prev_user_modes
[128];
1465 for (i
= 0; i
< 128; i
++)
1467 if (prev_user_modes
[i
] != 0 && prev_user_modes
[i
] != user_modes
[i
])
1469 if (user_modes
[i
] == 0)
1471 orphaned_umodes
|= prev_user_modes
[i
];
1472 sendto_realops_snomask(SNO_DEBUG
, L_ALL
, "Umode +%c is now orphaned", i
);
1476 orphaned_umodes
&= ~prev_user_modes
[i
];
1477 sendto_realops_snomask(SNO_DEBUG
, L_ALL
, "Orphaned umode +%c is picked up by module", i
);
1479 user_modes
[i
] = prev_user_modes
[i
];
1482 prev_user_modes
[i
] = user_modes
[i
];
1491 change_nick_user_host(struct Client
*target_p
, const char *nick
, const char *user
,
1492 const char *host
, int newts
, const char *format
, ...)
1495 struct Channel
*chptr
;
1496 struct membership
*mscptr
;
1497 int changed
= irccmp(target_p
->name
, nick
);
1498 int changed_case
= strcmp(target_p
->name
, nick
);
1499 int do_qjm
= irccmp(target_p
->username
, user
) || (irccmp(target_p
->host
, host
) && ConfigChannel
.cycle_host_change
);
1500 char mode
[10], modeval
[NICKLEN
* 2 + 2], reason
[256], *mptr
;
1507 target_p
->tsinfo
= newts
;
1508 monitor_signoff(target_p
);
1510 invalidate_bancache_user(target_p
);
1514 va_start(ap
, format
);
1515 vsnprintf(reason
, 255, format
, ap
);
1518 sendto_common_channels_local_butone(target_p
, ":%s!%s@%s QUIT :%s",
1519 target_p
->name
, target_p
->username
, target_p
->host
,
1522 RB_DLINK_FOREACH(ptr
, target_p
->user
->channel
.head
)
1525 chptr
= mscptr
->chptr
;
1528 if(is_admin(mscptr
))
1531 strcat(modeval
, nick
);
1532 strcat(modeval
, " ");
1535 if(is_chanop(mscptr
))
1538 strcat(modeval
, nick
);
1539 strcat(modeval
, " ");
1542 if(is_halfop(mscptr
))
1545 strcat(modeval
, nick
);
1546 strcat(modeval
, " ");
1549 if(is_voiced(mscptr
))
1552 strcat(modeval
, nick
);
1557 sendto_channel_local_butone(target_p
, ALL_MEMBERS
, chptr
, ":%s!%s@%s JOIN :%s",
1558 nick
, user
, host
, chptr
->chname
);
1560 sendto_channel_local_butone(target_p
, ALL_MEMBERS
, chptr
,
1561 ":%s MODE %s +%s %s",
1562 target_p
->servptr
->name
,
1563 chptr
->chname
, mode
, modeval
);
1568 if(MyClient(target_p
) && changed_case
)
1569 sendto_one(target_p
, ":%s!%s@%s NICK %s",
1570 target_p
->name
, target_p
->username
, target_p
->host
, nick
);
1572 else if(changed_case
)
1574 sendto_common_channels_local(target_p
, ":%s!%s@%s NICK :%s",
1575 target_p
->name
, target_p
->username
,
1576 target_p
->host
, nick
);
1579 rb_strlcpy(target_p
->username
, user
, sizeof target_p
->username
);
1580 rb_strlcpy(target_p
->host
, host
, sizeof target_p
->host
);
1583 add_history(target_p
, 1);
1585 del_from_client_hash(target_p
->name
, target_p
);
1586 rb_strlcpy(target_p
->name
, nick
, NICKLEN
);
1587 add_to_client_hash(target_p
->name
, target_p
);
1591 monitor_signon(target_p
);
1592 del_all_accepts(target_p
);