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