23 |
|
*/ |
24 |
|
|
25 |
|
#include "stdinc.h" |
26 |
< |
#include "tools.h" |
26 |
> |
#include "list.h" |
27 |
|
#include "s_user.h" |
28 |
|
#include "s_misc.h" |
29 |
|
#include "channel.h" |
30 |
|
#include "channel_mode.h" |
31 |
|
#include "client.h" |
32 |
– |
#include "common.h" |
32 |
|
#include "fdlist.h" |
33 |
|
#include "hash.h" |
34 |
|
#include "irc_string.h" |
35 |
|
#include "sprintf_irc.h" |
36 |
|
#include "s_bsd.h" |
38 |
– |
#include "irc_getnameinfo.h" |
37 |
|
#include "ircd.h" |
40 |
– |
#include "list.h" |
38 |
|
#include "listener.h" |
39 |
|
#include "motd.h" |
40 |
|
#include "numeric.h" |
41 |
< |
#include "s_conf.h" |
42 |
< |
#include "s_log.h" |
41 |
> |
#include "conf.h" |
42 |
> |
#include "log.h" |
43 |
|
#include "s_serv.h" |
47 |
– |
#include "s_stats.h" |
44 |
|
#include "send.h" |
45 |
|
#include "supported.h" |
46 |
|
#include "whowas.h" |
47 |
|
#include "memory.h" |
48 |
|
#include "packet.h" |
49 |
+ |
#include "rng_mt.h" |
50 |
|
#include "userhost.h" |
51 |
|
#include "hook.h" |
52 |
|
#include "s_misc.h" |
53 |
< |
#include "msg.h" |
54 |
< |
#include "pcre.h" |
53 |
> |
#include "parse.h" |
54 |
> |
#include "watch.h" |
55 |
> |
|
56 |
|
|
59 |
– |
int MaxClientCount = 1; |
60 |
– |
int MaxConnectionCount = 1; |
57 |
|
struct Callback *entering_umode_cb = NULL; |
58 |
|
struct Callback *umode_cb = NULL; |
63 |
– |
struct Callback *uid_get_cb = NULL; |
59 |
|
|
60 |
|
static char umode_buffer[IRCD_BUFSIZE]; |
61 |
|
|
62 |
|
static void user_welcome(struct Client *); |
63 |
|
static void report_and_set_user_flags(struct Client *, const struct AccessItem *); |
64 |
|
static int check_xline(struct Client *); |
65 |
< |
static int check_regexp_xline(struct Client *); |
66 |
< |
static void introduce_client(struct Client *, struct Client *); |
72 |
< |
static void *uid_get(va_list); |
65 |
> |
static void introduce_client(struct Client *); |
66 |
> |
static const char *uid_get(void); |
67 |
|
|
68 |
|
/* Used for building up the isupport string, |
69 |
|
* used with init_isupport, add_isupport, delete_isupport |
90 |
|
0, /* @ */ |
91 |
|
0, /* A */ |
92 |
|
0, /* B */ |
93 |
< |
0, /* C */ |
93 |
> |
UMODE_CCONN_FULL, /* C */ |
94 |
|
UMODE_DEAF, /* D */ |
95 |
|
0, /* E */ |
96 |
|
0, /* F */ |
97 |
|
UMODE_SOFTCALLERID, /* G */ |
98 |
< |
0, /* H */ |
98 |
> |
UMODE_HIDDEN, /* H */ |
99 |
|
0, /* I */ |
100 |
|
0, /* J */ |
101 |
|
0, /* K */ |
105 |
|
0, /* O */ |
106 |
|
0, /* P */ |
107 |
|
0, /* Q */ |
108 |
< |
0, /* R */ |
108 |
> |
UMODE_REGONLY, /* R */ |
109 |
|
0, /* S */ |
110 |
|
0, /* T */ |
111 |
|
0, /* U */ |
125 |
|
UMODE_CALLERID, /* g */ |
126 |
|
0, /* h */ |
127 |
|
UMODE_INVISIBLE, /* i */ |
128 |
< |
0, /* j */ |
128 |
> |
UMODE_REJ, /* j */ |
129 |
|
UMODE_SKILL, /* k */ |
130 |
|
UMODE_LOCOPS, /* l */ |
131 |
|
0, /* m */ |
133 |
|
UMODE_OPER, /* o */ |
134 |
|
0, /* p */ |
135 |
|
0, /* q */ |
136 |
< |
UMODE_REJ, /* r */ |
136 |
> |
UMODE_REGISTERED, /* r */ |
137 |
|
UMODE_SERVNOTICE, /* s */ |
138 |
|
0, /* t */ |
139 |
|
UMODE_UNAUTH, /* u */ |
160 |
|
unsigned int idx = 0; |
161 |
|
char *umode_buffer_ptr = umode_buffer; |
162 |
|
|
163 |
< |
for (; idx < (sizeof(user_modes) / sizeof(int)); ++idx) |
163 |
> |
for (; idx < (sizeof(user_modes) / sizeof(user_modes[0])); ++idx) |
164 |
|
if (user_modes[idx]) |
165 |
|
*umode_buffer_ptr++ = idx; |
166 |
|
|
189 |
|
to = source_p->name; |
190 |
|
} |
191 |
|
|
192 |
< |
if (!ConfigServerHide.hide_servers || IsOper(source_p)) |
192 |
> |
if (!ConfigServerHide.hide_servers || HasUMode(source_p, UMODE_OPER)) |
193 |
|
sendto_one(source_p, form_str(RPL_LUSERCLIENT), |
194 |
|
from, to, (Count.total-Count.invisi), |
195 |
|
Count.invisi, dlink_list_length(&global_serv_list)); |
209 |
|
sendto_one(source_p, form_str(RPL_LUSERCHANNELS), |
210 |
|
from, to, dlink_list_length(&global_channel_list)); |
211 |
|
|
212 |
< |
if (!ConfigServerHide.hide_servers || IsOper(source_p)) |
212 |
> |
if (!ConfigServerHide.hide_servers || HasUMode(source_p, UMODE_OPER)) |
213 |
|
{ |
214 |
|
sendto_one(source_p, form_str(RPL_LUSERME), |
215 |
|
from, to, Count.local, Count.myserver); |
230 |
|
from, to, Count.total, Count.max_tot, |
231 |
|
Count.total, Count.max_tot); |
232 |
|
|
233 |
< |
if (!ConfigServerHide.hide_servers || IsOper(source_p)) |
233 |
> |
if (!ConfigServerHide.hide_servers || HasUMode(source_p, UMODE_OPER)) |
234 |
|
sendto_one(source_p, form_str(RPL_STATSCONN), from, to, |
235 |
< |
MaxConnectionCount, MaxClientCount, Count.totalrestartcount); |
235 |
> |
Count.max_loc_con, Count.max_loc_cli, Count.totalrestartcount); |
236 |
|
|
237 |
< |
if (Count.local > MaxClientCount) |
238 |
< |
MaxClientCount = Count.local; |
237 |
> |
if (Count.local > Count.max_loc_cli) |
238 |
> |
Count.max_loc_cli = Count.local; |
239 |
|
|
240 |
< |
if ((Count.local + Count.myserver) > MaxConnectionCount) |
241 |
< |
MaxConnectionCount = Count.local + Count.myserver; |
240 |
> |
if ((Count.local + Count.myserver) > Count.max_loc_con) |
241 |
> |
Count.max_loc_con = Count.local + Count.myserver; |
242 |
|
} |
243 |
|
|
244 |
|
/* show_isupport() |
277 |
|
** nick from local user or kill him/her... |
278 |
|
*/ |
279 |
|
void |
280 |
< |
register_local_user(struct Client *client_p, struct Client *source_p, |
287 |
< |
const char *nick, const char *username) |
280 |
> |
register_local_user(struct Client *source_p) |
281 |
|
{ |
282 |
+ |
const char *id = NULL; |
283 |
|
const struct AccessItem *aconf = NULL; |
290 |
– |
char ipaddr[HOSTIPLEN]; |
284 |
|
dlink_node *ptr = NULL; |
292 |
– |
dlink_node *m = NULL; |
285 |
|
|
286 |
|
assert(source_p != NULL); |
287 |
+ |
assert(source_p == source_p->from); |
288 |
|
assert(MyConnect(source_p)); |
296 |
– |
assert(source_p->username != username); |
289 |
|
assert(!source_p->localClient->registration); |
290 |
|
|
291 |
+ |
ClearCap(source_p, CAP_TS6); |
292 |
+ |
|
293 |
|
if (ConfigFileEntry.ping_cookie) |
294 |
|
{ |
295 |
< |
if (!IsPingSent(source_p) && |
302 |
< |
source_p->localClient->random_ping == 0) |
295 |
> |
if (!IsPingSent(source_p) && source_p->localClient->random_ping == 0) |
296 |
|
{ |
297 |
< |
source_p->localClient->random_ping = (unsigned long)rand(); |
298 |
< |
sendto_one(source_p, "PING :%lu", |
297 |
> |
do |
298 |
> |
source_p->localClient->random_ping = genrand_int32(); |
299 |
> |
while (!source_p->localClient->random_ping); |
300 |
> |
|
301 |
> |
sendto_one(source_p, "PING :%u", |
302 |
|
source_p->localClient->random_ping); |
303 |
|
SetPingSent(source_p); |
304 |
|
return; |
308 |
|
return; |
309 |
|
} |
310 |
|
|
311 |
< |
source_p->localClient->last = CurrentTime; |
311 |
> |
source_p->localClient->last_privmsg = CurrentTime; |
312 |
|
/* Straight up the maximum rate of flooding... */ |
313 |
|
source_p->localClient->allow_read = MAX_FLOOD_BURST; |
314 |
|
|
315 |
< |
if (!execute_callback(client_check_cb, source_p, username)) |
315 |
> |
if (!execute_callback(client_check_cb, source_p, source_p->username)) |
316 |
|
return; |
317 |
|
|
318 |
|
if (valid_hostname(source_p->host) == 0) |
328 |
|
|
329 |
|
if (!IsGotId(source_p)) |
330 |
|
{ |
331 |
< |
const char *p = NULL; |
331 |
> |
char username[USERLEN + 1]; |
332 |
> |
const char *p = username; |
333 |
|
unsigned int i = 0; |
334 |
|
|
335 |
|
if (IsNeedIdentd(aconf)) |
336 |
|
{ |
337 |
< |
ServerStats->is_ref++; |
337 |
> |
++ServerStats.is_ref; |
338 |
|
sendto_one(source_p, ":%s NOTICE %s :*** Notice -- You need to install " |
339 |
|
"identd to use this server", me.name, source_p->name); |
340 |
|
exit_client(source_p, &me, "Install identd"); |
341 |
|
return; |
342 |
|
} |
343 |
|
|
344 |
< |
p = username; |
344 |
> |
strlcpy(username, source_p->username, sizeof(username)); |
345 |
|
|
346 |
|
if (!IsNoTilde(aconf)) |
347 |
|
source_p->username[i++] = '~'; |
348 |
|
|
349 |
< |
while (*p && i < USERLEN) |
353 |
< |
{ |
349 |
> |
for (; *p && i < USERLEN; ++p) |
350 |
|
if (*p != '[') |
351 |
|
source_p->username[i++] = *p; |
356 |
– |
p++; |
357 |
– |
} |
352 |
|
|
353 |
|
source_p->username[i] = '\0'; |
354 |
|
} |
360 |
|
|
361 |
|
if (!match_conf_password(pass, aconf)) |
362 |
|
{ |
363 |
< |
ServerStats->is_ref++; |
363 |
> |
++ServerStats.is_ref; |
364 |
|
sendto_one(source_p, form_str(ERR_PASSWDMISMATCH), |
365 |
|
me.name, source_p->name); |
366 |
|
exit_client(source_p, &me, "Bad Password"); |
376 |
|
/* report if user has &^>= etc. and set flags as needed in source_p */ |
377 |
|
report_and_set_user_flags(source_p, aconf); |
378 |
|
|
379 |
+ |
if (IsDead(source_p)) |
380 |
+ |
return; |
381 |
+ |
|
382 |
|
/* Limit clients - |
383 |
|
* We want to be able to have servers and F-line clients |
384 |
|
* connect, so save room for "buffer" connections. |
392 |
|
{ |
393 |
|
sendto_realops_flags(UMODE_FULL, L_ALL, |
394 |
|
"Too many clients, rejecting %s[%s].", |
395 |
< |
nick, source_p->host); |
396 |
< |
ServerStats->is_ref++; |
395 |
> |
source_p->name, source_p->host); |
396 |
> |
++ServerStats.is_ref; |
397 |
|
exit_client(source_p, &me, "Sorry, server is full - try later"); |
398 |
|
return; |
399 |
|
} |
404 |
|
char tmpstr2[IRCD_BUFSIZE]; |
405 |
|
|
406 |
|
sendto_realops_flags(UMODE_REJ, L_ALL, "Invalid username: %s (%s@%s)", |
407 |
< |
nick, source_p->username, source_p->host); |
408 |
< |
ServerStats->is_ref++; |
409 |
< |
ircsprintf(tmpstr2, "Invalid username [%s]", source_p->username); |
407 |
> |
source_p->name, source_p->username, source_p->host); |
408 |
> |
++ServerStats.is_ref; |
409 |
> |
snprintf(tmpstr2, sizeof(tmpstr2), "Invalid username [%s]", |
410 |
> |
source_p->username); |
411 |
|
exit_client(source_p, &me, tmpstr2); |
412 |
|
return; |
413 |
|
} |
414 |
|
|
415 |
< |
assert(source_p == client_p); |
418 |
< |
|
419 |
< |
/* end of valid user name check */ |
420 |
< |
if (check_xline(source_p) || check_regexp_xline(source_p)) |
415 |
> |
if (check_xline(source_p)) |
416 |
|
return; |
417 |
|
|
418 |
< |
if (IsDead(client_p)) |
419 |
< |
return; |
425 |
< |
|
426 |
< |
if (source_p->id[0] == '\0' && me.id[0]) |
427 |
< |
{ |
428 |
< |
char *id = (char *)execute_callback(uid_get_cb, source_p); |
429 |
< |
while (hash_find_id(id) != NULL) |
430 |
< |
id = uid_get(NULL); |
418 |
> |
while (hash_find_id((id = uid_get())) != NULL) |
419 |
> |
; |
420 |
|
|
421 |
< |
strlcpy(source_p->id, id, sizeof(source_p->id)); |
422 |
< |
hash_add_id(source_p); |
434 |
< |
} |
435 |
< |
|
436 |
< |
irc_getnameinfo((struct sockaddr *)&source_p->localClient->ip, |
437 |
< |
source_p->localClient->ip.ss_len, ipaddr, |
438 |
< |
HOSTIPLEN, NULL, 0, NI_NUMERICHOST); |
421 |
> |
strlcpy(source_p->id, id, sizeof(source_p->id)); |
422 |
> |
hash_add_id(source_p); |
423 |
|
|
424 |
|
sendto_realops_flags(UMODE_CCONN, L_ALL, |
425 |
< |
"Client connecting: %s (%s@%s) [%s] {%s} [%s]", |
426 |
< |
nick, source_p->username, source_p->host, |
425 |
> |
"Client connecting: %s (%s@%s) [%s] {%s} [%s] <%s>", |
426 |
> |
source_p->name, source_p->username, source_p->host, |
427 |
> |
ConfigFileEntry.hide_spoof_ips && IsIPSpoof(source_p) ? |
428 |
> |
"255.255.255.255" : source_p->sockhost, |
429 |
> |
get_client_class(source_p), |
430 |
> |
source_p->info, source_p->id); |
431 |
> |
|
432 |
> |
sendto_realops_flags(UMODE_CCONN_FULL, L_ALL, |
433 |
> |
"CLICONN %s %s %s %s %s %s %s 0 %s", |
434 |
> |
source_p->name, source_p->username, source_p->host, |
435 |
|
ConfigFileEntry.hide_spoof_ips && IsIPSpoof(source_p) ? |
436 |
< |
"255.255.255.255" : ipaddr, get_client_class(source_p), |
436 |
> |
"255.255.255.255" : source_p->sockhost, |
437 |
> |
get_client_class(source_p), |
438 |
> |
ConfigFileEntry.hide_spoof_ips && IsIPSpoof(source_p) ? |
439 |
> |
"<hidden>" : source_p->localClient->client_host, |
440 |
> |
ConfigFileEntry.hide_spoof_ips && IsIPSpoof(source_p) ? |
441 |
> |
"<hidden>" : source_p->localClient->client_server, |
442 |
|
source_p->info); |
443 |
|
|
447 |
– |
/* If they have died in send_* don't do anything. */ |
448 |
– |
if (IsDead(source_p)) |
449 |
– |
return; |
444 |
|
|
445 |
|
if (ConfigFileEntry.invisible_on_connect) |
446 |
|
{ |
447 |
< |
source_p->umodes |= UMODE_INVISIBLE; |
448 |
< |
Count.invisi++; |
447 |
> |
AddUMode(source_p, UMODE_INVISIBLE); |
448 |
> |
++Count.invisi; |
449 |
|
} |
450 |
|
|
451 |
|
if ((++Count.local) > Count.max_loc) |
457 |
|
Count.max_loc); |
458 |
|
} |
459 |
|
|
466 |
– |
SetClient(source_p); |
467 |
– |
|
468 |
– |
source_p->servptr = &me; |
469 |
– |
dlinkAdd(source_p, &source_p->lnode, &source_p->servptr->serv->users); |
470 |
– |
|
460 |
|
/* Increment our total user count here */ |
461 |
|
if (++Count.total > Count.max_tot) |
462 |
|
Count.max_tot = Count.total; |
463 |
< |
Count.totalrestartcount++; |
463 |
> |
++Count.totalrestartcount; |
464 |
> |
|
465 |
> |
assert(source_p->servptr == &me); |
466 |
> |
SetClient(source_p); |
467 |
> |
dlinkAdd(source_p, &source_p->lnode, &source_p->servptr->serv->client_list); |
468 |
|
|
469 |
|
source_p->localClient->allow_read = MAX_FLOOD_BURST; |
470 |
|
|
471 |
< |
if ((m = dlinkFindDelete(&unknown_list, source_p)) != NULL) |
472 |
< |
{ |
473 |
< |
free_dlink_node(m); |
474 |
< |
dlinkAdd(source_p, &source_p->localClient->lclient_node, &local_client_list); |
482 |
< |
} |
483 |
< |
else assert(0); |
471 |
> |
assert(dlinkFind(&unknown_list, source_p)); |
472 |
> |
|
473 |
> |
dlink_move_node(&source_p->localClient->lclient_node, |
474 |
> |
&unknown_list, &local_client_list); |
475 |
|
|
476 |
|
user_welcome(source_p); |
477 |
|
add_user_host(source_p->username, source_p->host, 0); |
478 |
|
SetUserHost(source_p); |
479 |
|
|
480 |
< |
introduce_client(client_p, source_p); |
480 |
> |
introduce_client(source_p); |
481 |
|
} |
482 |
|
|
483 |
|
/* register_remote_user() |
484 |
|
* |
485 |
< |
* inputs - client_p directly connected client |
495 |
< |
* - source_p remote or directly connected client |
485 |
> |
* inputs - source_p remote or directly connected client |
486 |
|
* - username to register as |
487 |
|
* - host name to register as |
488 |
|
* - server name |
492 |
|
* is introduced by a server. |
493 |
|
*/ |
494 |
|
void |
495 |
< |
register_remote_user(struct Client *client_p, struct Client *source_p, |
495 |
> |
register_remote_user(struct Client *source_p, |
496 |
|
const char *username, const char *host, const char *server, |
497 |
|
const char *realname) |
498 |
|
{ |
502 |
|
assert(source_p->username != username); |
503 |
|
|
504 |
|
strlcpy(source_p->host, host, sizeof(source_p->host)); |
515 |
– |
strlcpy(source_p->info, realname, sizeof(source_p->info)); |
505 |
|
strlcpy(source_p->username, username, sizeof(source_p->username)); |
506 |
|
|
518 |
– |
/* Increment our total user count here */ |
519 |
– |
if (++Count.total > Count.max_tot) |
520 |
– |
Count.max_tot = Count.total; |
521 |
– |
|
522 |
– |
source_p->from->serv->dep_users++; |
523 |
– |
|
507 |
|
/* |
508 |
|
* coming from another server, take the servers word for it |
509 |
|
*/ |
510 |
< |
source_p->servptr = find_server(server); |
510 |
> |
source_p->servptr = hash_find_server(server); |
511 |
|
|
512 |
|
/* Super GhostDetect: |
513 |
|
* If we can't find the server the user is supposed to be on, |
519 |
|
"No server %s for user %s[%s@%s] from %s", |
520 |
|
server, source_p->name, source_p->username, |
521 |
|
source_p->host, source_p->from->name); |
522 |
< |
kill_client(client_p, source_p, "%s (Server doesn't exist)", me.name); |
522 |
> |
kill_client(source_p->from, source_p, "%s (Server doesn't exist)", me.name); |
523 |
|
|
524 |
< |
SetKilled(source_p); |
524 |
> |
AddFlag(source_p, FLAGS_KILLED); |
525 |
|
exit_client(source_p, &me, "Ghosted Client"); |
526 |
|
return; |
527 |
|
} |
530 |
|
{ |
531 |
|
sendto_realops_flags(UMODE_DEBUG, L_ALL, |
532 |
|
"Bad User [%s] :%s USER %s@%s %s, != %s[%s]", |
533 |
< |
client_p->name, source_p->name, source_p->username, |
533 |
> |
source_p->from->name, source_p->name, source_p->username, |
534 |
|
source_p->host, source_p->servptr->name, |
535 |
|
target_p->name, target_p->from->name); |
536 |
< |
kill_client(client_p, source_p, |
536 |
> |
kill_client(source_p->from, source_p, |
537 |
|
"%s (NICK from wrong direction (%s != %s))", |
538 |
|
me.name, source_p->servptr->name, target_p->from->name); |
539 |
< |
SetKilled(source_p); |
539 |
> |
AddFlag(source_p, FLAGS_KILLED); |
540 |
|
exit_client(source_p, &me, "USER server wrong direction"); |
541 |
|
return; |
542 |
|
} |
543 |
|
|
544 |
+ |
/* |
545 |
+ |
* If the nick has been introduced by a services server, |
546 |
+ |
* make it a service as well. |
547 |
+ |
*/ |
548 |
+ |
if (HasFlag(source_p->servptr, FLAGS_SERVICE)) |
549 |
+ |
AddFlag(source_p, FLAGS_SERVICE); |
550 |
+ |
|
551 |
+ |
/* Increment our total user count here */ |
552 |
+ |
if (++Count.total > Count.max_tot) |
553 |
+ |
Count.max_tot = Count.total; |
554 |
+ |
|
555 |
|
SetClient(source_p); |
556 |
< |
dlinkAdd(source_p, &source_p->lnode, &source_p->servptr->serv->users); |
556 |
> |
dlinkAdd(source_p, &source_p->lnode, &source_p->servptr->serv->client_list); |
557 |
|
add_user_host(source_p->username, source_p->host, 1); |
558 |
|
SetUserHost(source_p); |
559 |
|
|
560 |
< |
introduce_client(client_p, source_p); |
560 |
> |
introduce_client(source_p); |
561 |
|
} |
562 |
|
|
563 |
|
/* introduce_client() |
564 |
|
* |
565 |
< |
* inputs - client_p |
572 |
< |
* - source_p |
565 |
> |
* inputs - source_p |
566 |
|
* output - NONE |
567 |
|
* side effects - This common function introduces a client to the rest |
568 |
|
* of the net, either from a local client connect or |
569 |
|
* from a remote connect. |
570 |
|
*/ |
571 |
|
static void |
572 |
< |
introduce_client(struct Client *client_p, struct Client *source_p) |
572 |
> |
introduce_client(struct Client *source_p) |
573 |
|
{ |
574 |
|
dlink_node *server_node = NULL; |
575 |
|
static char ubuf[12]; |
579 |
|
else |
580 |
|
send_umode(NULL, source_p, 0, SEND_UMODES, ubuf); |
581 |
|
|
582 |
+ |
watch_check_hash(source_p, RPL_LOGON); |
583 |
+ |
|
584 |
|
if (*ubuf == '\0') |
585 |
|
{ |
586 |
|
ubuf[0] = '+'; |
587 |
|
ubuf[1] = '\0'; |
588 |
|
} |
589 |
|
|
590 |
< |
/* arghhh one could try not introducing new nicks to ll leafs |
596 |
< |
* but then you have to introduce them "on the fly" in SJOIN |
597 |
< |
* not fun. |
598 |
< |
* Its not going to cost much more bandwidth to simply let new |
599 |
< |
* nicks just ride on through. |
600 |
< |
*/ |
601 |
< |
|
602 |
< |
/* We now introduce nicks "on the fly" in SJOIN anyway -- |
603 |
< |
* you _need_ to if you aren't going to burst everyone initially. |
604 |
< |
* |
605 |
< |
* Only send to non CAP_LL servers, unless we're a lazylink leaf, |
606 |
< |
* in that case just send it to the uplink. |
607 |
< |
* -davidt |
608 |
< |
* rewritten to cope with SIDs .. eww eww eww --is |
609 |
< |
*/ |
610 |
< |
if (!ServerInfo.hub && uplink && IsCapable(uplink, CAP_LL) && |
611 |
< |
client_p != uplink) |
590 |
> |
DLINK_FOREACH(server_node, serv_list.head) |
591 |
|
{ |
592 |
< |
if (IsCapable(uplink, CAP_TS6) && HasID(source_p)) |
592 |
> |
struct Client *server = server_node->data; |
593 |
> |
|
594 |
> |
if (server == source_p->from) |
595 |
> |
continue; |
596 |
> |
|
597 |
> |
if (IsCapable(server, CAP_SVS)) |
598 |
|
{ |
599 |
< |
sendto_one(uplink, ":%s UID %s %d %lu %s %s %s %s %s :%s", |
600 |
< |
source_p->servptr->id, |
601 |
< |
source_p->name, source_p->hopcount+1, |
602 |
< |
(unsigned long)source_p->tsinfo, |
603 |
< |
ubuf, source_p->username, source_p->host, |
604 |
< |
(MyClient(source_p) && IsIPSpoof(source_p)) ? |
605 |
< |
"0" : source_p->sockhost, source_p->id, source_p->info); |
599 |
> |
if (IsCapable(server, CAP_TS6) && HasID(source_p)) |
600 |
> |
sendto_one(server, ":%s UID %s %d %lu %s %s %s %s %s %lu :%s", |
601 |
> |
source_p->servptr->id, |
602 |
> |
source_p->name, source_p->hopcount+1, |
603 |
> |
(unsigned long)source_p->tsinfo, |
604 |
> |
ubuf, source_p->username, source_p->host, |
605 |
> |
(MyClient(source_p) && IsIPSpoof(source_p)) ? |
606 |
> |
"0" : source_p->sockhost, source_p->id, |
607 |
> |
(unsigned long)source_p->servicestamp, |
608 |
> |
source_p->info); |
609 |
> |
else |
610 |
> |
sendto_one(server, "NICK %s %d %lu %s %s %s %s %lu :%s", |
611 |
> |
source_p->name, source_p->hopcount+1, |
612 |
> |
(unsigned long)source_p->tsinfo, |
613 |
> |
ubuf, source_p->username, source_p->host, |
614 |
> |
source_p->servptr->name, (unsigned long)source_p->servicestamp, |
615 |
> |
source_p->info); |
616 |
> |
|
617 |
|
} |
618 |
|
else |
619 |
|
{ |
625 |
– |
sendto_one(uplink, "NICK %s %d %lu %s %s %s %s :%s", |
626 |
– |
source_p->name, source_p->hopcount+1, |
627 |
– |
(unsigned long)source_p->tsinfo, |
628 |
– |
ubuf, source_p->username, source_p->host, |
629 |
– |
source_p->servptr->name, source_p->info); |
630 |
– |
} |
631 |
– |
} |
632 |
– |
else |
633 |
– |
{ |
634 |
– |
DLINK_FOREACH(server_node, serv_list.head) |
635 |
– |
{ |
636 |
– |
struct Client *server = server_node->data; |
637 |
– |
|
638 |
– |
if (IsCapable(server, CAP_LL) || server == client_p) |
639 |
– |
continue; |
640 |
– |
|
620 |
|
if (IsCapable(server, CAP_TS6) && HasID(source_p)) |
621 |
|
sendto_one(server, ":%s UID %s %d %lu %s %s %s %s %s :%s", |
622 |
|
source_p->servptr->id, |
651 |
|
|
652 |
|
assert(p != NULL); |
653 |
|
|
654 |
< |
if ('.' == *p || ':' == *p) |
654 |
> |
if (*p == '.' || *p == ':') |
655 |
|
return 0; |
656 |
|
|
657 |
< |
while (*p) |
679 |
< |
{ |
657 |
> |
for (; *p; ++p) |
658 |
|
if (!IsHostChar(*p)) |
659 |
|
return 0; |
682 |
– |
p++; |
683 |
– |
} |
660 |
|
|
661 |
|
return 1; |
662 |
|
} |
680 |
|
|
681 |
|
assert(p != NULL); |
682 |
|
|
683 |
< |
if ('~' == *p) |
683 |
> |
if (*p == '~') |
684 |
|
++p; |
685 |
|
|
686 |
|
/* reject usernames that don't start with an alphanum |
694 |
|
{ |
695 |
|
if ((*p == '.') && ConfigFileEntry.dots_in_ident) |
696 |
|
{ |
697 |
< |
dots++; |
722 |
< |
|
723 |
< |
if (dots > ConfigFileEntry.dots_in_ident) |
697 |
> |
if (++dots > ConfigFileEntry.dots_in_ident) |
698 |
|
return 0; |
699 |
< |
if (!IsUserChar(p[1])) |
699 |
> |
if (!IsUserChar(*(p + 1))) |
700 |
|
return 0; |
701 |
|
} |
702 |
|
else if (!IsUserChar(*p)) |
706 |
|
return 1; |
707 |
|
} |
708 |
|
|
709 |
+ |
/* clean_nick_name() |
710 |
+ |
* |
711 |
+ |
* input - nickname |
712 |
+ |
* - whether it's a local nick (1) or remote (0) |
713 |
+ |
* output - none |
714 |
+ |
* side effects - walks through the nickname, returning 0 if erroneous |
715 |
+ |
*/ |
716 |
+ |
int |
717 |
+ |
valid_nickname(const char *nickname, const int local) |
718 |
+ |
{ |
719 |
+ |
const char *p = nickname; |
720 |
+ |
assert(nickname && *nickname); |
721 |
+ |
|
722 |
+ |
/* nicks can't start with a digit or - or be 0 length */ |
723 |
+ |
/* This closer duplicates behaviour of hybrid-6 */ |
724 |
+ |
if (*p == '-' || (IsDigit(*p) && local) || *p == '\0') |
725 |
+ |
return 0; |
726 |
+ |
|
727 |
+ |
for (; *p; ++p) |
728 |
+ |
if (!IsNickChar(*p)) |
729 |
+ |
return 0; |
730 |
+ |
|
731 |
+ |
return p - nickname <= (NICKLEN - 1); |
732 |
+ |
} |
733 |
+ |
|
734 |
|
/* report_and_set_user_flags() |
735 |
|
* |
736 |
|
* inputs - pointer to source_p |
785 |
|
me.name,source_p->name); |
786 |
|
} |
787 |
|
|
789 |
– |
/* If this user is exempt from idle time outs */ |
790 |
– |
if (IsConfIdlelined(aconf)) |
791 |
– |
{ |
792 |
– |
SetIdlelined(source_p); |
793 |
– |
sendto_one(source_p, |
794 |
– |
":%s NOTICE %s :*** You are exempt from idle limits. congrats.", |
795 |
– |
me.name, source_p->name); |
796 |
– |
} |
797 |
– |
|
788 |
|
if (IsConfCanFlood(aconf)) |
789 |
|
{ |
790 |
|
SetCanFlood(source_p); |
794 |
|
} |
795 |
|
} |
796 |
|
|
807 |
– |
/* do_local_user() |
808 |
– |
* |
809 |
– |
* inputs - |
810 |
– |
* output - NONE |
811 |
– |
* side effects - |
812 |
– |
*/ |
813 |
– |
void |
814 |
– |
do_local_user(const char *nick, struct Client *client_p, struct Client *source_p, |
815 |
– |
const char *username, const char *host, const char *server, |
816 |
– |
const char *realname) |
817 |
– |
{ |
818 |
– |
assert(source_p != NULL); |
819 |
– |
assert(source_p->username != username); |
820 |
– |
|
821 |
– |
if (source_p == NULL) |
822 |
– |
return; |
823 |
– |
|
824 |
– |
if (!IsUnknown(source_p)) |
825 |
– |
{ |
826 |
– |
sendto_one(source_p, form_str(ERR_ALREADYREGISTRED), |
827 |
– |
me.name, nick); |
828 |
– |
return; |
829 |
– |
} |
830 |
– |
|
831 |
– |
source_p->localClient->registration &= ~REG_NEED_USER; |
832 |
– |
|
833 |
– |
/* |
834 |
– |
* don't take the clients word for it, ever |
835 |
– |
*/ |
836 |
– |
source_p->servptr = &me; |
837 |
– |
|
838 |
– |
strlcpy(source_p->info, realname, sizeof(source_p->info)); |
839 |
– |
|
840 |
– |
if (!IsGotId(source_p)) |
841 |
– |
{ |
842 |
– |
/* save the username in the client |
843 |
– |
* If you move this you'll break ping cookies..you've been warned |
844 |
– |
*/ |
845 |
– |
strlcpy(source_p->username, username, sizeof(source_p->username)); |
846 |
– |
} |
847 |
– |
|
848 |
– |
if (!source_p->localClient->registration) |
849 |
– |
/* NICK already received, now I have USER... */ |
850 |
– |
register_local_user(client_p, source_p, source_p->name, username); |
851 |
– |
} |
852 |
– |
|
797 |
|
/* change_simple_umode() |
798 |
|
* |
799 |
|
* this callback can be hooked to allow special handling of |
802 |
|
static void * |
803 |
|
change_simple_umode(va_list args) |
804 |
|
{ |
805 |
+ |
struct Client *client_p; |
806 |
|
struct Client *source_p; |
807 |
|
int what; |
808 |
|
unsigned int flag; |
809 |
|
|
810 |
< |
va_arg(args, struct Client *); |
810 |
> |
client_p = va_arg(args, struct Client *); |
811 |
|
source_p = va_arg(args, struct Client *); |
812 |
|
what = va_arg(args, int); |
813 |
|
flag = va_arg(args, unsigned int); |
814 |
|
|
815 |
|
if (what == MODE_ADD) |
816 |
< |
source_p->umodes |= flag; |
816 |
> |
AddUMode(source_p, flag); |
817 |
|
else |
818 |
< |
source_p->umodes &= ~flag; |
818 |
> |
DelUMode(source_p, flag); |
819 |
|
|
820 |
|
return NULL; |
821 |
|
} |
853 |
|
return; |
854 |
|
} |
855 |
|
|
856 |
< |
if (source_p != target_p || target_p->from != source_p->from) |
856 |
> |
if (source_p != target_p) |
857 |
|
{ |
858 |
|
sendto_one(source_p, form_str(ERR_USERSDONTMATCH), |
859 |
|
me.name, source_p->name); |
866 |
|
*m++ = '+'; |
867 |
|
|
868 |
|
for (i = 0; i < 128; i++) |
869 |
< |
if (source_p->umodes & user_modes[i]) |
869 |
> |
if (HasUMode(source_p, user_modes[i])) |
870 |
|
*m++ = (char)i; |
871 |
|
*m = '\0'; |
872 |
|
|
896 |
|
case 'o': |
897 |
|
if (what == MODE_ADD) |
898 |
|
{ |
899 |
< |
if (IsServer(client_p) && !IsOper(source_p)) |
899 |
> |
if (IsServer(client_p) && !HasUMode(source_p, UMODE_OPER)) |
900 |
|
{ |
901 |
|
++Count.oper; |
902 |
|
SetOper(source_p); |
907 |
|
/* Only decrement the oper counts if an oper to begin with |
908 |
|
* found by Pat Szuta, Perly , perly@xnet.com |
909 |
|
*/ |
910 |
< |
if (!IsOper(source_p)) |
910 |
> |
if (!HasUMode(source_p, UMODE_OPER)) |
911 |
|
break; |
912 |
|
|
913 |
|
ClearOper(source_p); |
969 |
– |
source_p->umodes &= ~ConfigFileEntry.oper_only_umodes; |
914 |
|
Count.oper--; |
915 |
|
|
916 |
|
if (MyConnect(source_p)) |
918 |
|
dlink_node *dm; |
919 |
|
|
920 |
|
detach_conf(source_p, OPER_TYPE); |
921 |
< |
ClearOperFlags(source_p); |
921 |
> |
ClrOFlag(source_p); |
922 |
> |
DelUMode(source_p, ConfigFileEntry.oper_only_umodes); |
923 |
|
|
924 |
|
if ((dm = dlinkFindDelete(&oper_list, source_p)) != NULL) |
925 |
|
free_dlink_node(dm); |
931 |
|
/* we may not get these, |
932 |
|
* but they shouldnt be in default |
933 |
|
*/ |
934 |
+ |
case 'r': |
935 |
|
case ' ' : |
936 |
|
case '\n': |
937 |
|
case '\r': |
941 |
|
default: |
942 |
|
if ((flag = user_modes[(unsigned char)*m])) |
943 |
|
{ |
944 |
< |
if (MyConnect(source_p) && !IsOper(source_p) && |
944 |
> |
if (MyConnect(source_p) && !HasUMode(source_p, UMODE_OPER) && |
945 |
|
(ConfigFileEntry.oper_only_umodes & flag)) |
946 |
|
{ |
947 |
|
badflag = 1; |
964 |
|
sendto_one(source_p, form_str(ERR_UMODEUNKNOWNFLAG), |
965 |
|
me.name, source_p->name); |
966 |
|
|
967 |
< |
if ((source_p->umodes & UMODE_NCHANGE) && !IsOperN(source_p)) |
967 |
> |
if (HasUMode(source_p, UMODE_NCHANGE) && !HasOFlag(source_p, OPER_FLAG_N)) |
968 |
|
{ |
969 |
< |
sendto_one(source_p, ":%s NOTICE %s :*** You have no admin flag;", |
969 |
> |
sendto_one(source_p, ":%s NOTICE %s :*** You have no nchange flag;", |
970 |
|
me.name, source_p->name); |
971 |
< |
source_p->umodes &= ~UMODE_NCHANGE; /* only tcm's really need this */ |
971 |
> |
DelUMode(source_p, UMODE_NCHANGE); |
972 |
|
} |
973 |
|
|
974 |
< |
if (MyConnect(source_p) && (source_p->umodes & UMODE_ADMIN) && |
975 |
< |
!IsOperAdmin(source_p) && !IsOperHiddenAdmin(source_p)) |
974 |
> |
if (MyConnect(source_p) && HasUMode(source_p, UMODE_ADMIN) && |
975 |
> |
!HasOFlag(source_p, OPER_FLAG_ADMIN)) |
976 |
|
{ |
977 |
|
sendto_one(source_p, ":%s NOTICE %s :*** You have no admin flag;", |
978 |
|
me.name, source_p->name); |
979 |
< |
source_p->umodes &= ~UMODE_ADMIN; |
979 |
> |
DelUMode(source_p, UMODE_ADMIN); |
980 |
|
} |
981 |
|
|
982 |
< |
if (!(setflags & UMODE_INVISIBLE) && IsInvisible(source_p)) |
982 |
> |
if (!(setflags & UMODE_INVISIBLE) && HasUMode(source_p, UMODE_INVISIBLE)) |
983 |
|
++Count.invisi; |
984 |
< |
if ((setflags & UMODE_INVISIBLE) && !IsInvisible(source_p)) |
984 |
> |
if ((setflags & UMODE_INVISIBLE) && !HasUMode(source_p, UMODE_INVISIBLE)) |
985 |
|
--Count.invisi; |
986 |
|
|
987 |
|
/* |
994 |
|
/* send_umode() |
995 |
|
* send the MODE string for user (user) to connection client_p |
996 |
|
* -avalon |
997 |
+ |
* |
998 |
+ |
* inputs - client_p |
999 |
+ |
* - source_p |
1000 |
+ |
* - int old |
1001 |
+ |
* - sendmask mask of modes to send |
1002 |
+ |
* - suplied umode_buf |
1003 |
+ |
* output - NONE |
1004 |
|
*/ |
1005 |
|
void |
1006 |
|
send_umode(struct Client *client_p, struct Client *source_p, |
1007 |
|
unsigned int old, unsigned int sendmask, char *umode_buf) |
1008 |
|
{ |
1009 |
+ |
char *m = umode_buf; |
1010 |
|
int what = 0; |
1011 |
|
unsigned int i; |
1012 |
|
unsigned int flag; |
1059 |
– |
char *m = umode_buf; |
1013 |
|
|
1014 |
|
/* |
1015 |
|
* build a string in umode_buf to represent the change in the user's |
1024 |
|
if (MyClient(source_p) && !(flag & sendmask)) |
1025 |
|
continue; |
1026 |
|
|
1027 |
< |
if ((flag & old) && !(source_p->umodes & flag)) |
1027 |
> |
if ((flag & old) && !HasUMode(source_p, flag)) |
1028 |
|
{ |
1029 |
|
if (what == MODE_DEL) |
1030 |
|
*m++ = (char)i; |
1035 |
|
*m++ = (char)i; |
1036 |
|
} |
1037 |
|
} |
1038 |
< |
else if (!(flag & old) && (source_p->umodes & flag)) |
1038 |
> |
else if (!(flag & old) && HasUMode(source_p, flag)) |
1039 |
|
{ |
1040 |
|
if (what == MODE_ADD) |
1041 |
|
*m++ = (char)i; |
1051 |
|
*m = '\0'; |
1052 |
|
|
1053 |
|
if (*umode_buf && client_p) |
1054 |
< |
sendto_one(client_p, ":%s MODE %s :%s", |
1055 |
< |
source_p->name, source_p->name, umode_buf); |
1054 |
> |
sendto_one(client_p, ":%s!%s@%s MODE %s :%s", |
1055 |
> |
source_p->name, source_p->username, |
1056 |
> |
source_p->host, source_p->name, umode_buf); |
1057 |
|
} |
1058 |
|
|
1059 |
|
/* send_umode_out() |
1066 |
|
send_umode_out(struct Client *client_p, struct Client *source_p, |
1067 |
|
unsigned int old) |
1068 |
|
{ |
1069 |
< |
char buf[IRCD_BUFSIZE]; |
1069 |
> |
char buf[IRCD_BUFSIZE] = { '\0' }; |
1070 |
|
dlink_node *ptr = NULL; |
1071 |
|
|
1072 |
< |
send_umode(NULL, source_p, old, IsOperHiddenAdmin(source_p) ? |
1119 |
< |
SEND_UMODES & ~UMODE_ADMIN : SEND_UMODES, buf); |
1072 |
> |
send_umode(NULL, source_p, old, SEND_UMODES, buf); |
1073 |
|
|
1074 |
< |
if (*buf) |
1074 |
> |
if (buf[0]) |
1075 |
|
{ |
1076 |
|
DLINK_FOREACH(ptr, serv_list.head) |
1077 |
|
{ |
1078 |
|
struct Client *target_p = ptr->data; |
1079 |
|
|
1080 |
|
if ((target_p != client_p) && (target_p != source_p)) |
1081 |
< |
{ |
1082 |
< |
if ((!(ServerInfo.hub && IsCapable(target_p, CAP_LL))) || |
1083 |
< |
(target_p->localClient->serverMask & |
1131 |
< |
source_p->lazyLinkClientExists)) |
1132 |
< |
sendto_one(target_p, ":%s MODE %s :%s", |
1133 |
< |
ID_or_name(source_p, target_p), |
1134 |
< |
ID_or_name(source_p, target_p), buf); |
1135 |
< |
} |
1081 |
> |
sendto_one(target_p, ":%s MODE %s :%s", |
1082 |
> |
ID_or_name(source_p, target_p), |
1083 |
> |
ID_or_name(source_p, target_p), buf); |
1084 |
|
} |
1085 |
|
} |
1086 |
|
|
1128 |
|
|
1129 |
|
if (ConfigFileEntry.short_motd) |
1130 |
|
{ |
1131 |
< |
sendto_one(source_p, "NOTICE %s :*** Notice -- motd was last changed at %s", |
1132 |
< |
source_p->name, ConfigFileEntry.motd.lastChangedDate); |
1131 |
> |
sendto_one(source_p, ":%s NOTICE %s :*** Notice -- motd was last changed at %s", |
1132 |
> |
me.name, source_p->name, ConfigFileEntry.motd.lastChangedDate); |
1133 |
|
sendto_one(source_p, |
1134 |
< |
"NOTICE %s :*** Notice -- Please read the motd if you haven't " |
1135 |
< |
"read it", source_p->name); |
1134 |
> |
":%s NOTICE %s :*** Notice -- Please read the motd if you haven't " |
1135 |
> |
"read it", me.name, source_p->name); |
1136 |
|
sendto_one(source_p, form_str(RPL_MOTDSTART), |
1137 |
|
me.name, source_p->name, me.name); |
1138 |
|
sendto_one(source_p, form_str(RPL_MOTD), |
1154 |
|
static int |
1155 |
|
check_xline(struct Client *source_p) |
1156 |
|
{ |
1157 |
< |
struct ConfItem *conf; |
1158 |
< |
struct MatchItem *xconf; |
1211 |
< |
const char *reason; |
1157 |
> |
struct ConfItem *conf = NULL; |
1158 |
> |
const char *reason = NULL; |
1159 |
|
|
1160 |
< |
if ((conf = find_matching_name_conf(XLINE_TYPE, source_p->info, |
1161 |
< |
NULL, NULL, 0)) != NULL) |
1160 |
> |
if ((conf = find_matching_name_conf(XLINE_TYPE, source_p->info, NULL, NULL, 0)) || |
1161 |
> |
(conf = find_matching_name_conf(RXLINE_TYPE, source_p->info, NULL, NULL, 0))) |
1162 |
|
{ |
1163 |
< |
xconf = map_to_conf(conf); |
1217 |
< |
xconf->count++; |
1163 |
> |
struct MatchItem *reg = map_to_conf(conf); |
1164 |
|
|
1165 |
< |
if (xconf->reason != NULL) |
1166 |
< |
reason = xconf->reason; |
1165 |
> |
++reg->count; |
1166 |
> |
|
1167 |
> |
if (reg->reason != NULL) |
1168 |
> |
reason = reg->reason; |
1169 |
|
else |
1170 |
|
reason = "No Reason"; |
1171 |
|
|
1175 |
|
get_client_name(source_p, HIDE_IP), |
1176 |
|
source_p->sockhost); |
1177 |
|
|
1178 |
< |
ServerStats->is_ref++; |
1178 |
> |
++ServerStats.is_ref; |
1179 |
|
if (REJECT_HOLD_TIME > 0) |
1180 |
|
{ |
1181 |
|
sendto_one(source_p, ":%s NOTICE %s :Bad user info", |
1191 |
|
return 0; |
1192 |
|
} |
1193 |
|
|
1246 |
– |
static int |
1247 |
– |
check_regexp_xline(struct Client *source_p) |
1248 |
– |
{ |
1249 |
– |
struct ConfItem *conf = NULL; |
1250 |
– |
const char *reason = NULL; |
1251 |
– |
|
1252 |
– |
if ((conf = find_matching_name_conf(RXLINE_TYPE, source_p->info, NULL, NULL, 0))) |
1253 |
– |
{ |
1254 |
– |
struct MatchItem *reg = map_to_conf(conf); |
1255 |
– |
|
1256 |
– |
++reg->count; |
1257 |
– |
|
1258 |
– |
if (reg->reason != NULL) |
1259 |
– |
reason = reg->reason; |
1260 |
– |
else |
1261 |
– |
reason = "No Reason"; |
1262 |
– |
|
1263 |
– |
sendto_realops_flags(UMODE_REJ, L_ALL, |
1264 |
– |
"X-line (REGEX) Rejecting [%s] [%s], user %s [%s]", |
1265 |
– |
source_p->info, reason, |
1266 |
– |
get_client_name(source_p, HIDE_IP), |
1267 |
– |
source_p->sockhost); |
1268 |
– |
|
1269 |
– |
ServerStats->is_ref++; |
1270 |
– |
exit_client(source_p, &me, "Bad user info"); |
1271 |
– |
return 1; |
1272 |
– |
} |
1273 |
– |
|
1274 |
– |
return 0; |
1275 |
– |
} |
1276 |
– |
|
1194 |
|
/* oper_up() |
1195 |
|
* |
1196 |
|
* inputs - pointer to given client to oper |
1213 |
|
SetOper(source_p); |
1214 |
|
|
1215 |
|
if (oconf->modes) |
1216 |
< |
source_p->umodes |= oconf->modes; |
1216 |
> |
AddUMode(source_p, oconf->modes); |
1217 |
|
else if (ConfigFileEntry.oper_umodes) |
1218 |
< |
source_p->umodes |= ConfigFileEntry.oper_umodes; |
1219 |
< |
else |
1220 |
< |
source_p->umodes |= (UMODE_SERVNOTICE|UMODE_OPERWALL| |
1221 |
< |
UMODE_WALLOP|UMODE_LOCOPS); |
1218 |
> |
AddUMode(source_p, ConfigFileEntry.oper_umodes); |
1219 |
> |
|
1220 |
> |
if (!(old & UMODE_INVISIBLE) && HasUMode(source_p, UMODE_INVISIBLE)) |
1221 |
> |
++Count.invisi; |
1222 |
> |
if ((old & UMODE_INVISIBLE) && !HasUMode(source_p, UMODE_INVISIBLE)) |
1223 |
> |
--Count.invisi; |
1224 |
|
|
1225 |
|
assert(dlinkFind(&oper_list, source_p) == NULL); |
1226 |
|
dlinkAdd(source_p, make_dlink_node(), &oper_list); |
1227 |
|
|
1228 |
|
operprivs = oper_privs_as_string(oconf->port); |
1229 |
|
|
1230 |
< |
SetOFlag(source_p, oconf->port); |
1230 |
> |
AddOFlag(source_p, oconf->port); |
1231 |
|
|
1232 |
< |
if (IsOperAdmin(source_p) || IsOperHiddenAdmin(source_p)) |
1233 |
< |
source_p->umodes |= UMODE_ADMIN; |
1234 |
< |
if (!IsOperN(source_p)) |
1235 |
< |
source_p->umodes &= ~UMODE_NCHANGE; |
1232 |
> |
if (HasOFlag(source_p, OPER_FLAG_ADMIN)) |
1233 |
> |
AddUMode(source_p, UMODE_ADMIN); |
1234 |
> |
if (!HasOFlag(source_p, OPER_FLAG_N)) |
1235 |
> |
DelUMode(source_p, UMODE_NCHANGE); |
1236 |
|
|
1237 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, "%s (%s@%s) is now an operator", |
1238 |
|
source_p->name, source_p->username, source_p->host); |
1243 |
|
send_message_file(source_p, &ConfigFileEntry.opermotd); |
1244 |
|
} |
1245 |
|
|
1246 |
< |
/* |
1328 |
< |
* Quick and dirty UID code for new proposed SID on EFnet |
1329 |
< |
* |
1330 |
< |
*/ |
1246 |
> |
static char new_uid[TOTALSIDUID + 1]; /* allow for \0 */ |
1247 |
|
|
1248 |
< |
static char new_uid[TOTALSIDUID+1]; /* allow for \0 */ |
1249 |
< |
static void add_one_to_uid(int i); |
1248 |
> |
int |
1249 |
> |
valid_sid(const char *sid) |
1250 |
> |
{ |
1251 |
> |
if (strlen(sid) == IRC_MAXSID) |
1252 |
> |
if (IsDigit(*sid)) |
1253 |
> |
if (IsAlNum(*(sid + 1)) && IsAlNum(*(sid + 2))) |
1254 |
> |
return 1; |
1255 |
> |
|
1256 |
> |
return 0; |
1257 |
> |
} |
1258 |
|
|
1259 |
|
/* |
1260 |
|
* init_uid() |
1272 |
|
|
1273 |
|
memset(new_uid, 0, sizeof(new_uid)); |
1274 |
|
|
1275 |
< |
if (ServerInfo.sid != NULL) |
1276 |
< |
{ |
1353 |
< |
memcpy(new_uid, ServerInfo.sid, IRCD_MIN(strlen(ServerInfo.sid), |
1354 |
< |
IRC_MAXSID)); |
1355 |
< |
memcpy(&me.id, ServerInfo.sid, IRCD_MIN(strlen(ServerInfo.sid), |
1356 |
< |
IRC_MAXSID)); |
1357 |
< |
hash_add_id(&me); |
1358 |
< |
} |
1275 |
> |
if (!EmptyString(ServerInfo.sid)) |
1276 |
> |
strlcpy(new_uid, ServerInfo.sid, sizeof(new_uid)); |
1277 |
|
|
1278 |
< |
for (i = 0; i < IRC_MAXSID; i++) |
1278 |
> |
for (i = 0; i < IRC_MAXSID; ++i) |
1279 |
|
if (new_uid[i] == '\0') |
1280 |
|
new_uid[i] = 'A'; |
1281 |
|
|
1282 |
< |
/* XXX if IRC_MAXUID != 6, this will have to be rewritten */ |
1282 |
> |
/* NOTE: if IRC_MAXUID != 6, this will have to be rewritten */ |
1283 |
|
/* Yes nenolod, I have known it was off by one ever since I wrote it |
1284 |
|
* But *JUST* for you, though, it really doesn't look as *pretty* |
1285 |
|
* -Dianora |
1286 |
|
*/ |
1287 |
< |
memcpy(new_uid+IRC_MAXSID, "AAAAA@", IRC_MAXUID); |
1287 |
> |
memcpy(new_uid + IRC_MAXSID, "AAAAA@", IRC_MAXUID); |
1288 |
|
|
1289 |
|
entering_umode_cb = register_callback("entering_umode", NULL); |
1290 |
|
umode_cb = register_callback("changing_umode", change_simple_umode); |
1373 |
– |
uid_get_cb = register_callback("uid_get", uid_get); |
1374 |
– |
} |
1375 |
– |
|
1376 |
– |
/* |
1377 |
– |
* uid_get |
1378 |
– |
* |
1379 |
– |
* inputs - struct Client * |
1380 |
– |
* output - new UID is returned to caller |
1381 |
– |
* side effects - new_uid is incremented by one. |
1382 |
– |
*/ |
1383 |
– |
static void * |
1384 |
– |
uid_get(va_list args) |
1385 |
– |
{ |
1386 |
– |
add_one_to_uid(TOTALSIDUID-1); /* index from 0 */ |
1387 |
– |
return ((void *) new_uid); |
1291 |
|
} |
1292 |
|
|
1293 |
|
/* |
1310 |
|
new_uid[i] = 'A'; |
1311 |
|
add_one_to_uid(i-1); |
1312 |
|
} |
1313 |
< |
else new_uid[i] = new_uid[i] + 1; |
1313 |
> |
else |
1314 |
> |
++new_uid[i]; |
1315 |
|
} |
1316 |
|
else |
1317 |
|
{ |
1318 |
< |
/* XXX if IRC_MAXUID != 6, this will have to be rewritten */ |
1318 |
> |
/* NOTE: if IRC_MAXUID != 6, this will have to be rewritten */ |
1319 |
|
if (new_uid[i] == 'Z') |
1320 |
< |
memcpy(new_uid+IRC_MAXSID, "AAAAAA", IRC_MAXUID); |
1320 |
> |
memcpy(new_uid + IRC_MAXSID, "AAAAAA", IRC_MAXUID); |
1321 |
|
else |
1322 |
< |
new_uid[i] = new_uid[i] + 1; |
1322 |
> |
++new_uid[i]; |
1323 |
|
} |
1324 |
|
} |
1325 |
|
|
1326 |
|
/* |
1327 |
+ |
* uid_get |
1328 |
+ |
* |
1329 |
+ |
* inputs - struct Client * |
1330 |
+ |
* output - new UID is returned to caller |
1331 |
+ |
* side effects - new_uid is incremented by one. |
1332 |
+ |
*/ |
1333 |
+ |
static const char * |
1334 |
+ |
uid_get(void) |
1335 |
+ |
{ |
1336 |
+ |
add_one_to_uid(TOTALSIDUID - 1); /* index from 0 */ |
1337 |
+ |
return new_uid; |
1338 |
+ |
} |
1339 |
+ |
|
1340 |
+ |
/* |
1341 |
|
* init_isupport() |
1342 |
|
* |
1343 |
|
* input - NONE |
1351 |
|
|
1352 |
|
add_isupport("CALLERID", NULL, -1); |
1353 |
|
add_isupport("CASEMAPPING", CASEMAP, -1); |
1354 |
+ |
add_isupport("DEAF", "D", -1); |
1355 |
|
add_isupport("KICKLEN", NULL, KICKLEN); |
1356 |
|
add_isupport("MODES", NULL, MAXMODEPARAMS); |
1357 |
|
add_isupport("NICKLEN", NULL, NICKLEN-1); |