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