51 |
|
#include "watch.h" |
52 |
|
|
53 |
|
static char umode_buffer[IRCD_BUFSIZE]; |
54 |
– |
|
55 |
– |
static void user_welcome(struct Client *); |
56 |
– |
static void report_and_set_user_flags(struct Client *, const struct MaskItem *); |
57 |
– |
static int check_xline(struct Client *); |
58 |
– |
static void introduce_client(struct Client *); |
54 |
|
static const char *uid_get(void); |
55 |
|
|
56 |
|
/* Used for building up the isupport string, |
57 |
|
* used with init_isupport, add_isupport, delete_isupport |
58 |
|
*/ |
64 |
– |
|
59 |
|
struct Isupport |
60 |
|
{ |
61 |
|
dlink_node node; |
218 |
|
sendto_one_numeric(source_p, &me, RPL_ISUPPORT, ptr->data); |
219 |
|
} |
220 |
|
|
221 |
+ |
|
222 |
+ |
/* report_and_set_user_flags() |
223 |
+ |
* |
224 |
+ |
* inputs - pointer to source_p |
225 |
+ |
* - pointer to conf for this user |
226 |
+ |
* output - NONE |
227 |
+ |
* side effects - Report to user any special flags |
228 |
+ |
* they are getting, and set them. |
229 |
+ |
*/ |
230 |
+ |
static void |
231 |
+ |
report_and_set_user_flags(struct Client *source_p, const struct MaskItem *conf) |
232 |
+ |
{ |
233 |
+ |
/* If this user is being spoofed, tell them so */ |
234 |
+ |
if (IsConfDoSpoofIp(conf)) |
235 |
+ |
sendto_one_notice(source_p, &me, ":*** Spoofing your IP. Congrats."); |
236 |
+ |
|
237 |
+ |
/* If this user is in the exception class, Set it "E lined" */ |
238 |
+ |
if (IsConfExemptKline(conf)) |
239 |
+ |
{ |
240 |
+ |
SetExemptKline(source_p); |
241 |
+ |
sendto_one_notice(source_p, &me, ":*** You are exempt from K/D/G lines. Congrats."); |
242 |
+ |
} |
243 |
+ |
|
244 |
+ |
/* |
245 |
+ |
* The else here is to make sure that G line exempt users |
246 |
+ |
* do not get noticed twice. |
247 |
+ |
*/ |
248 |
+ |
else if (IsConfExemptGline(conf)) |
249 |
+ |
{ |
250 |
+ |
SetExemptGline(source_p); |
251 |
+ |
sendto_one_notice(source_p, &me, ":*** You are exempt from G lines. Congrats."); |
252 |
+ |
} |
253 |
+ |
|
254 |
+ |
if (IsConfExemptResv(conf)) |
255 |
+ |
{ |
256 |
+ |
SetExemptResv(source_p); |
257 |
+ |
sendto_one_notice(source_p, &me, ":*** You are exempt from resvs. Congrats."); |
258 |
+ |
} |
259 |
+ |
|
260 |
+ |
/* If this user is exempt from user limits set it "F lined" */ |
261 |
+ |
if (IsConfExemptLimits(conf)) |
262 |
+ |
{ |
263 |
+ |
SetExemptLimits(source_p); |
264 |
+ |
sendto_one_notice(source_p, &me, ":*** You are exempt from user limits. Congrats."); |
265 |
+ |
} |
266 |
+ |
|
267 |
+ |
if (IsConfCanFlood(conf)) |
268 |
+ |
{ |
269 |
+ |
SetCanFlood(source_p); |
270 |
+ |
sendto_one_notice(source_p, &me, ":*** You are exempt from flood " |
271 |
+ |
"protection, aren't you fearsome."); |
272 |
+ |
} |
273 |
+ |
} |
274 |
+ |
|
275 |
+ |
/* introduce_client() |
276 |
+ |
* |
277 |
+ |
* inputs - source_p |
278 |
+ |
* output - NONE |
279 |
+ |
* side effects - This common function introduces a client to the rest |
280 |
+ |
* of the net, either from a local client connect or |
281 |
+ |
* from a remote connect. |
282 |
+ |
*/ |
283 |
+ |
static void |
284 |
+ |
introduce_client(struct Client *source_p) |
285 |
+ |
{ |
286 |
+ |
dlink_node *ptr = NULL; |
287 |
+ |
char ubuf[IRCD_BUFSIZE] = ""; |
288 |
+ |
|
289 |
+ |
if (MyClient(source_p)) |
290 |
+ |
send_umode(source_p, source_p, 0, SEND_UMODES, ubuf); |
291 |
+ |
else |
292 |
+ |
send_umode(NULL, source_p, 0, SEND_UMODES, ubuf); |
293 |
+ |
|
294 |
+ |
watch_check_hash(source_p, RPL_LOGON); |
295 |
+ |
|
296 |
+ |
if (ubuf[0] == '\0') |
297 |
+ |
{ |
298 |
+ |
ubuf[0] = '+'; |
299 |
+ |
ubuf[1] = '\0'; |
300 |
+ |
} |
301 |
+ |
|
302 |
+ |
DLINK_FOREACH(ptr, serv_list.head) |
303 |
+ |
{ |
304 |
+ |
struct Client *server = ptr->data; |
305 |
+ |
|
306 |
+ |
if (server == source_p->from) |
307 |
+ |
continue; |
308 |
+ |
|
309 |
+ |
if (IsCapable(server, CAP_SVS)) |
310 |
+ |
sendto_one(server, ":%s UID %s %d %lu %s %s %s %s %s %s :%s", |
311 |
+ |
source_p->servptr->id, |
312 |
+ |
source_p->name, source_p->hopcount+1, |
313 |
+ |
(unsigned long)source_p->tsinfo, |
314 |
+ |
ubuf, source_p->username, source_p->host, |
315 |
+ |
(MyClient(source_p) && IsIPSpoof(source_p)) ? |
316 |
+ |
"0" : source_p->sockhost, source_p->id, |
317 |
+ |
source_p->svid, |
318 |
+ |
source_p->info); |
319 |
+ |
else |
320 |
+ |
sendto_one(server, ":%s UID %s %d %lu %s %s %s %s %s :%s", |
321 |
+ |
source_p->servptr->id, |
322 |
+ |
source_p->name, source_p->hopcount+1, |
323 |
+ |
(unsigned long)source_p->tsinfo, |
324 |
+ |
ubuf, source_p->username, source_p->host, |
325 |
+ |
(MyClient(source_p) && IsIPSpoof(source_p)) ? |
326 |
+ |
"0" : source_p->sockhost, source_p->id, source_p->info); |
327 |
+ |
|
328 |
+ |
if (!EmptyString(source_p->certfp)) |
329 |
+ |
sendto_one(server, ":%s CERTFP %s", source_p->id, source_p->certfp); |
330 |
+ |
} |
331 |
+ |
} |
332 |
+ |
|
333 |
+ |
/* user_welcome() |
334 |
+ |
* |
335 |
+ |
* inputs - client pointer to client to welcome |
336 |
+ |
* output - NONE |
337 |
+ |
* side effects - |
338 |
+ |
*/ |
339 |
+ |
static void |
340 |
+ |
user_welcome(struct Client *source_p) |
341 |
+ |
{ |
342 |
+ |
#if defined(__TIME__) && defined(__DATE__) |
343 |
+ |
static const char built_date[] = __DATE__ " at " __TIME__; |
344 |
+ |
#else |
345 |
+ |
static const char built_date[] = "unknown"; |
346 |
+ |
#endif |
347 |
+ |
|
348 |
+ |
#ifdef HAVE_LIBCRYPTO |
349 |
+ |
if (HasFlag(source_p, FLAGS_SSL)) |
350 |
+ |
{ |
351 |
+ |
AddUMode(source_p, UMODE_SSL); |
352 |
+ |
sendto_one_notice(source_p, &me, ":*** Connected securely via %s", |
353 |
+ |
ssl_get_cipher(source_p->localClient->fd.ssl)); |
354 |
+ |
} |
355 |
+ |
#endif |
356 |
+ |
|
357 |
+ |
sendto_one_numeric(source_p, &me, RPL_WELCOME, ServerInfo.network_name, |
358 |
+ |
source_p->name); |
359 |
+ |
sendto_one_numeric(source_p, &me, RPL_YOURHOST, |
360 |
+ |
get_listener_name(source_p->localClient->listener), ircd_version); |
361 |
+ |
sendto_one_numeric(source_p, &me, RPL_CREATED, built_date); |
362 |
+ |
sendto_one_numeric(source_p, &me, RPL_MYINFO, me.name, ircd_version, umode_buffer); |
363 |
+ |
show_isupport(source_p); |
364 |
+ |
|
365 |
+ |
if (source_p->id[0]) |
366 |
+ |
sendto_one_numeric(source_p, &me, RPL_YOURID, source_p->id); |
367 |
+ |
|
368 |
+ |
show_lusers(source_p); |
369 |
+ |
motd_signon(source_p); |
370 |
+ |
} |
371 |
+ |
|
372 |
+ |
/* check_xline() |
373 |
+ |
* |
374 |
+ |
* inputs - pointer to client to test |
375 |
+ |
* outupt - 1 if exiting 0 if ok |
376 |
+ |
* side effects - |
377 |
+ |
*/ |
378 |
+ |
static int |
379 |
+ |
check_xline(struct Client *source_p) |
380 |
+ |
{ |
381 |
+ |
struct MaskItem *conf = NULL; |
382 |
+ |
const char *reason = NULL; |
383 |
+ |
|
384 |
+ |
if ((conf = find_matching_name_conf(CONF_XLINE, source_p->info, NULL, NULL, 0))) |
385 |
+ |
{ |
386 |
+ |
++conf->count; |
387 |
+ |
|
388 |
+ |
if (conf->reason) |
389 |
+ |
reason = conf->reason; |
390 |
+ |
else |
391 |
+ |
reason = CONF_NOREASON; |
392 |
+ |
|
393 |
+ |
sendto_realops_flags(UMODE_REJ, L_ALL, SEND_NOTICE, |
394 |
+ |
"X-line Rejecting [%s] [%s], user %s [%s]", |
395 |
+ |
source_p->info, reason, |
396 |
+ |
get_client_name(source_p, HIDE_IP), |
397 |
+ |
source_p->sockhost); |
398 |
+ |
|
399 |
+ |
++ServerStats.is_ref; |
400 |
+ |
exit_client(source_p, "Bad user info"); |
401 |
+ |
return 1; |
402 |
+ |
} |
403 |
+ |
|
404 |
+ |
return 0; |
405 |
+ |
} |
406 |
+ |
|
407 |
|
/* |
408 |
|
** register_local_user |
409 |
|
** This function is called when both NICK and USER messages |
433 |
|
const char *id = NULL; |
434 |
|
const struct MaskItem *conf = NULL; |
435 |
|
|
256 |
– |
assert(source_p != NULL); |
436 |
|
assert(source_p == source_p->from); |
437 |
|
assert(MyConnect(source_p)); |
438 |
|
assert(!source_p->localClient->registration); |
476 |
|
|
477 |
|
if (!IsGotId(source_p)) |
478 |
|
{ |
479 |
< |
char username[USERLEN + 1]; |
479 |
> |
char username[USERLEN + 1] = ""; |
480 |
|
const char *p = username; |
481 |
|
unsigned int i = 0; |
482 |
|
|
549 |
|
/* valid user name check */ |
550 |
|
if (!valid_username(source_p->username, 1)) |
551 |
|
{ |
552 |
< |
char tmpstr2[IRCD_BUFSIZE]; |
552 |
> |
char tmpstr2[IRCD_BUFSIZE] = ""; |
553 |
|
|
554 |
|
sendto_realops_flags(UMODE_REJ, L_ALL, SEND_NOTICE, |
555 |
|
"Invalid username: %s (%s@%s)", |
564 |
|
if (check_xline(source_p)) |
565 |
|
return; |
566 |
|
|
567 |
< |
while (hash_find_id((id = uid_get())) != NULL) |
567 |
> |
while (hash_find_id((id = uid_get()))) |
568 |
|
; |
569 |
|
|
570 |
|
strlcpy(source_p->id, id, sizeof(source_p->id)); |
633 |
|
{ |
634 |
|
struct Client *target_p = NULL; |
635 |
|
|
457 |
– |
assert(source_p != NULL); |
636 |
|
assert(source_p->username != username); |
637 |
|
|
638 |
|
strlcpy(source_p->host, host, sizeof(source_p->host)); |
656 |
|
source_p->host, source_p->from->name); |
657 |
|
sendto_one(source_p->from, |
658 |
|
":%s KILL %s :%s (Ghosted, server %s doesn't exist)", |
659 |
< |
ID(&me), ID(source_p), me.name, server); |
659 |
> |
me.id, source_p->id, me.name, server); |
660 |
|
|
661 |
|
AddFlag(source_p, FLAGS_KILLED); |
662 |
|
exit_client(source_p, "Ghosted Client"); |
672 |
|
target_p->name, target_p->from->name); |
673 |
|
sendto_one(source_p->from, |
674 |
|
":%s KILL %s :%s (NICK from wrong direction (%s != %s))", |
675 |
< |
ID(&me), ID(source_p), me.name, source_p->servptr->name, |
675 |
> |
me.id, source_p->id, me.name, source_p->servptr->name, |
676 |
|
target_p->from->name); |
677 |
|
|
678 |
|
AddFlag(source_p, FLAGS_KILLED); |
706 |
|
introduce_client(source_p); |
707 |
|
} |
708 |
|
|
531 |
– |
/* introduce_client() |
532 |
– |
* |
533 |
– |
* inputs - source_p |
534 |
– |
* output - NONE |
535 |
– |
* side effects - This common function introduces a client to the rest |
536 |
– |
* of the net, either from a local client connect or |
537 |
– |
* from a remote connect. |
538 |
– |
*/ |
539 |
– |
static void |
540 |
– |
introduce_client(struct Client *source_p) |
541 |
– |
{ |
542 |
– |
dlink_node *server_node = NULL; |
543 |
– |
char ubuf[IRCD_BUFSIZE]; |
544 |
– |
|
545 |
– |
if (MyClient(source_p)) |
546 |
– |
send_umode(source_p, source_p, 0, SEND_UMODES, ubuf); |
547 |
– |
else |
548 |
– |
send_umode(NULL, source_p, 0, SEND_UMODES, ubuf); |
549 |
– |
|
550 |
– |
watch_check_hash(source_p, RPL_LOGON); |
551 |
– |
|
552 |
– |
if (ubuf[0] == '\0') |
553 |
– |
{ |
554 |
– |
ubuf[0] = '+'; |
555 |
– |
ubuf[1] = '\0'; |
556 |
– |
} |
557 |
– |
|
558 |
– |
DLINK_FOREACH(server_node, serv_list.head) |
559 |
– |
{ |
560 |
– |
struct Client *server = server_node->data; |
561 |
– |
|
562 |
– |
if (server == source_p->from) |
563 |
– |
continue; |
564 |
– |
|
565 |
– |
if (IsCapable(server, CAP_SVS)) |
566 |
– |
sendto_one(server, ":%s UID %s %d %lu %s %s %s %s %s %s :%s", |
567 |
– |
source_p->servptr->id, |
568 |
– |
source_p->name, source_p->hopcount+1, |
569 |
– |
(unsigned long)source_p->tsinfo, |
570 |
– |
ubuf, source_p->username, source_p->host, |
571 |
– |
(MyClient(source_p) && IsIPSpoof(source_p)) ? |
572 |
– |
"0" : source_p->sockhost, source_p->id, |
573 |
– |
source_p->svid, |
574 |
– |
source_p->info); |
575 |
– |
else |
576 |
– |
sendto_one(server, ":%s UID %s %d %lu %s %s %s %s %s :%s", |
577 |
– |
source_p->servptr->id, |
578 |
– |
source_p->name, source_p->hopcount+1, |
579 |
– |
(unsigned long)source_p->tsinfo, |
580 |
– |
ubuf, source_p->username, source_p->host, |
581 |
– |
(MyClient(source_p) && IsIPSpoof(source_p)) ? |
582 |
– |
"0" : source_p->sockhost, source_p->id, source_p->info); |
583 |
– |
|
584 |
– |
if (!EmptyString(source_p->certfp)) |
585 |
– |
sendto_one(server, ":%s CERTFP %s", ID(source_p), source_p->certfp); |
586 |
– |
} |
587 |
– |
} |
588 |
– |
|
709 |
|
/* valid_hostname() |
710 |
|
* |
711 |
|
* Inputs - pointer to hostname |
720 |
|
{ |
721 |
|
const char *p = hostname; |
722 |
|
|
723 |
< |
assert(p != NULL); |
723 |
> |
assert(p); |
724 |
|
|
725 |
|
if (EmptyString(p) || *p == '.' || *p == ':') |
726 |
|
return 0; |
749 |
|
int dots = 0; |
750 |
|
const char *p = username; |
751 |
|
|
752 |
< |
assert(p != NULL); |
752 |
> |
assert(p); |
753 |
|
|
754 |
|
if (*p == '~') |
755 |
|
++p; |
800 |
|
const char *p = nickname; |
801 |
|
assert(nickname && *nickname); |
802 |
|
|
803 |
+ |
assert(p); |
804 |
+ |
|
805 |
|
/* nicks can't start with a digit or - or be 0 length */ |
806 |
|
/* This closer duplicates behaviour of hybrid-6 */ |
807 |
|
if (*p == '-' || (IsDigit(*p) && local) || *p == '\0') |
814 |
|
return p - nickname <= NICKLEN; |
815 |
|
} |
816 |
|
|
695 |
– |
/* report_and_set_user_flags() |
696 |
– |
* |
697 |
– |
* inputs - pointer to source_p |
698 |
– |
* - pointer to conf for this user |
699 |
– |
* output - NONE |
700 |
– |
* side effects - Report to user any special flags |
701 |
– |
* they are getting, and set them. |
702 |
– |
*/ |
703 |
– |
static void |
704 |
– |
report_and_set_user_flags(struct Client *source_p, const struct MaskItem *conf) |
705 |
– |
{ |
706 |
– |
/* If this user is being spoofed, tell them so */ |
707 |
– |
if (IsConfDoSpoofIp(conf)) |
708 |
– |
sendto_one_notice(source_p, &me, ":*** Spoofing your IP. Congrats."); |
709 |
– |
|
710 |
– |
/* If this user is in the exception class, Set it "E lined" */ |
711 |
– |
if (IsConfExemptKline(conf)) |
712 |
– |
{ |
713 |
– |
SetExemptKline(source_p); |
714 |
– |
sendto_one_notice(source_p, &me, ":*** You are exempt from K/D/G lines. Congrats."); |
715 |
– |
} |
716 |
– |
|
717 |
– |
/* |
718 |
– |
* The else here is to make sure that G line exempt users |
719 |
– |
* do not get noticed twice. |
720 |
– |
*/ |
721 |
– |
else if (IsConfExemptGline(conf)) |
722 |
– |
{ |
723 |
– |
SetExemptGline(source_p); |
724 |
– |
sendto_one_notice(source_p, &me, ":*** You are exempt from G lines. Congrats."); |
725 |
– |
} |
726 |
– |
|
727 |
– |
if (IsConfExemptResv(conf)) |
728 |
– |
{ |
729 |
– |
SetExemptResv(source_p); |
730 |
– |
sendto_one_notice(source_p, &me, ":*** You are exempt from resvs. Congrats."); |
731 |
– |
} |
732 |
– |
|
733 |
– |
/* If this user is exempt from user limits set it "F lined" */ |
734 |
– |
if (IsConfExemptLimits(conf)) |
735 |
– |
{ |
736 |
– |
SetExemptLimits(source_p); |
737 |
– |
sendto_one_notice(source_p, &me, ":*** You are exempt from user limits. Congrats."); |
738 |
– |
} |
739 |
– |
|
740 |
– |
if (IsConfCanFlood(conf)) |
741 |
– |
{ |
742 |
– |
SetCanFlood(source_p); |
743 |
– |
sendto_one_notice(source_p, &me, ":*** You are exempt from flood " |
744 |
– |
"protection, aren't you fearsome."); |
745 |
– |
} |
746 |
– |
} |
747 |
– |
|
748 |
– |
/* set_user_mode() |
749 |
– |
* |
750 |
– |
* added 15/10/91 By Darren Reed. |
751 |
– |
* parv[0] - command |
752 |
– |
* parv[1] - username to change mode for |
753 |
– |
* parv[2] - modes to change |
754 |
– |
*/ |
755 |
– |
void |
756 |
– |
set_user_mode(struct Client *source_p, const int parc, char *parv[]) |
757 |
– |
{ |
758 |
– |
unsigned int flag, setflags; |
759 |
– |
char **p, *m, buf[IRCD_BUFSIZE]; |
760 |
– |
struct Client *target_p; |
761 |
– |
int what = MODE_ADD, badflag = 0, i; |
762 |
– |
|
763 |
– |
assert(!(parc < 2)); |
764 |
– |
|
765 |
– |
if ((target_p = find_person(source_p, parv[1])) == NULL) |
766 |
– |
{ |
767 |
– |
if (MyConnect(source_p)) |
768 |
– |
sendto_one_numeric(source_p, &me, ERR_NOSUCHCHANNEL, parv[1]); |
769 |
– |
return; |
770 |
– |
} |
771 |
– |
|
772 |
– |
if (source_p != target_p) |
773 |
– |
{ |
774 |
– |
sendto_one_numeric(source_p, &me, ERR_USERSDONTMATCH); |
775 |
– |
return; |
776 |
– |
} |
777 |
– |
|
778 |
– |
if (parc < 3) |
779 |
– |
{ |
780 |
– |
m = buf; |
781 |
– |
*m++ = '+'; |
782 |
– |
|
783 |
– |
for (i = 0; i < 128; ++i) |
784 |
– |
if (HasUMode(source_p, user_modes[i])) |
785 |
– |
*m++ = (char)i; |
786 |
– |
*m = '\0'; |
787 |
– |
|
788 |
– |
sendto_one_numeric(source_p, &me, RPL_UMODEIS, buf); |
789 |
– |
return; |
790 |
– |
} |
791 |
– |
|
792 |
– |
/* find flags already set for user */ |
793 |
– |
setflags = source_p->umodes; |
794 |
– |
|
795 |
– |
/* parse mode change string(s) */ |
796 |
– |
for (p = &parv[2]; p && *p; ++p) |
797 |
– |
{ |
798 |
– |
for (m = *p; *m; ++m) |
799 |
– |
{ |
800 |
– |
switch (*m) |
801 |
– |
{ |
802 |
– |
case '+': |
803 |
– |
what = MODE_ADD; |
804 |
– |
break; |
805 |
– |
case '-': |
806 |
– |
what = MODE_DEL; |
807 |
– |
break; |
808 |
– |
case 'o': |
809 |
– |
if (what == MODE_ADD) |
810 |
– |
{ |
811 |
– |
if (!MyConnect(source_p) && !HasUMode(source_p, UMODE_OPER)) |
812 |
– |
{ |
813 |
– |
++Count.oper; |
814 |
– |
SetOper(source_p); |
815 |
– |
} |
816 |
– |
} |
817 |
– |
else |
818 |
– |
{ |
819 |
– |
if (!HasUMode(source_p, UMODE_OPER)) |
820 |
– |
break; |
821 |
– |
|
822 |
– |
ClearOper(source_p); |
823 |
– |
Count.oper--; |
824 |
– |
|
825 |
– |
if (MyConnect(source_p)) |
826 |
– |
{ |
827 |
– |
dlink_node *dm = NULL; |
828 |
– |
|
829 |
– |
detach_conf(source_p, CONF_OPER); |
830 |
– |
ClrOFlag(source_p); |
831 |
– |
DelUMode(source_p, ConfigFileEntry.oper_only_umodes); |
832 |
– |
|
833 |
– |
if ((dm = dlinkFindDelete(&oper_list, source_p)) != NULL) |
834 |
– |
free_dlink_node(dm); |
835 |
– |
} |
836 |
– |
} |
837 |
– |
|
838 |
– |
break; |
839 |
– |
|
840 |
– |
case 'S': /* Only servers may set +S in a burst */ |
841 |
– |
case 'W': /* Only servers may set +W in a burst */ |
842 |
– |
case 'r': /* Only services may set +r */ |
843 |
– |
case 'x': /* Only services may set +x */ |
844 |
– |
break; |
845 |
– |
|
846 |
– |
default: |
847 |
– |
if ((flag = user_modes[(unsigned char)*m])) |
848 |
– |
{ |
849 |
– |
if (MyConnect(source_p) && !HasUMode(source_p, UMODE_OPER) && |
850 |
– |
(ConfigFileEntry.oper_only_umodes & flag)) |
851 |
– |
badflag = 1; |
852 |
– |
else |
853 |
– |
{ |
854 |
– |
if (what == MODE_ADD) |
855 |
– |
AddUMode(source_p, flag); |
856 |
– |
else |
857 |
– |
DelUMode(source_p, flag); |
858 |
– |
} |
859 |
– |
} |
860 |
– |
else if (MyConnect(source_p)) |
861 |
– |
badflag = 1; |
862 |
– |
|
863 |
– |
break; |
864 |
– |
} |
865 |
– |
} |
866 |
– |
} |
867 |
– |
|
868 |
– |
if (badflag) |
869 |
– |
sendto_one_numeric(source_p, &me, ERR_UMODEUNKNOWNFLAG); |
870 |
– |
|
871 |
– |
if (MyConnect(source_p) && HasUMode(source_p, UMODE_ADMIN) && |
872 |
– |
!HasOFlag(source_p, OPER_FLAG_ADMIN)) |
873 |
– |
{ |
874 |
– |
sendto_one_notice(source_p, &me, ":*** You have no admin flag;"); |
875 |
– |
DelUMode(source_p, UMODE_ADMIN); |
876 |
– |
} |
877 |
– |
|
878 |
– |
if (!(setflags & UMODE_INVISIBLE) && HasUMode(source_p, UMODE_INVISIBLE)) |
879 |
– |
++Count.invisi; |
880 |
– |
if ((setflags & UMODE_INVISIBLE) && !HasUMode(source_p, UMODE_INVISIBLE)) |
881 |
– |
--Count.invisi; |
882 |
– |
|
883 |
– |
/* |
884 |
– |
* compare new flags with old flags and send string which |
885 |
– |
* will cause servers to update correctly. |
886 |
– |
*/ |
887 |
– |
send_umode_out(source_p, source_p, setflags); |
888 |
– |
} |
889 |
– |
|
817 |
|
/* send_umode() |
818 |
|
* send the MODE string for user (user) to connection client_p |
819 |
|
* -avalon |
889 |
|
send_umode_out(struct Client *client_p, struct Client *source_p, |
890 |
|
unsigned int old) |
891 |
|
{ |
892 |
< |
char buf[IRCD_BUFSIZE] = { '\0' }; |
966 |
< |
dlink_node *ptr = NULL; |
892 |
> |
char buf[IRCD_BUFSIZE] = ""; |
893 |
|
|
894 |
|
send_umode(NULL, source_p, old, SEND_UMODES, buf); |
895 |
|
|
896 |
|
if (buf[0]) |
897 |
|
sendto_server(source_p, NOCAPS, NOCAPS, ":%s MODE %s :%s", |
898 |
< |
ID(source_p), ID(source_p), buf); |
898 |
> |
source_p->id, source_p->id, buf); |
899 |
|
|
900 |
|
if (client_p && MyClient(client_p)) |
901 |
|
send_umode(client_p, source_p, old, 0xffffffff, buf); |
947 |
|
|
948 |
|
DLINK_FOREACH(ptr, target_p->channel.head) |
949 |
|
{ |
950 |
< |
char modebuf[4], nickbuf[NICKLEN * 3 + 3] = { '\0' }; |
950 |
> |
char modebuf[4], nickbuf[NICKLEN * 3 + 3] = ""; |
951 |
|
char *p = modebuf; |
952 |
|
int len = 0; |
953 |
|
const struct Membership *ms = ptr->data; |
989 |
|
target_p->host, target_p->away); |
990 |
|
} |
991 |
|
|
1066 |
– |
/* user_welcome() |
1067 |
– |
* |
1068 |
– |
* inputs - client pointer to client to welcome |
1069 |
– |
* output - NONE |
1070 |
– |
* side effects - |
1071 |
– |
*/ |
1072 |
– |
static void |
1073 |
– |
user_welcome(struct Client *source_p) |
1074 |
– |
{ |
1075 |
– |
#if defined(__TIME__) && defined(__DATE__) |
1076 |
– |
static const char built_date[] = __DATE__ " at " __TIME__; |
1077 |
– |
#else |
1078 |
– |
static const char built_date[] = "unknown"; |
1079 |
– |
#endif |
1080 |
– |
|
1081 |
– |
#ifdef HAVE_LIBCRYPTO |
1082 |
– |
if (HasFlag(source_p, FLAGS_SSL)) |
1083 |
– |
{ |
1084 |
– |
AddUMode(source_p, UMODE_SSL); |
1085 |
– |
sendto_one_notice(source_p, &me, ":*** Connected securely via %s", |
1086 |
– |
ssl_get_cipher(source_p->localClient->fd.ssl)); |
1087 |
– |
} |
1088 |
– |
#endif |
1089 |
– |
|
1090 |
– |
sendto_one_numeric(source_p, &me, RPL_WELCOME, ServerInfo.network_name, |
1091 |
– |
source_p->name); |
1092 |
– |
sendto_one_numeric(source_p, &me, RPL_YOURHOST, |
1093 |
– |
get_listener_name(source_p->localClient->listener), ircd_version); |
1094 |
– |
sendto_one_numeric(source_p, &me, RPL_CREATED, built_date); |
1095 |
– |
sendto_one_numeric(source_p, &me, RPL_MYINFO, me.name, ircd_version, umode_buffer); |
1096 |
– |
show_isupport(source_p); |
1097 |
– |
|
1098 |
– |
if (source_p->id[0] != '\0') |
1099 |
– |
sendto_one_numeric(source_p, &me, RPL_YOURID, source_p->id); |
1100 |
– |
|
1101 |
– |
show_lusers(source_p); |
1102 |
– |
motd_signon(source_p); |
1103 |
– |
} |
1104 |
– |
|
1105 |
– |
/* check_xline() |
1106 |
– |
* |
1107 |
– |
* inputs - pointer to client to test |
1108 |
– |
* outupt - 1 if exiting 0 if ok |
1109 |
– |
* side effects - |
1110 |
– |
*/ |
1111 |
– |
static int |
1112 |
– |
check_xline(struct Client *source_p) |
1113 |
– |
{ |
1114 |
– |
struct MaskItem *conf = NULL; |
1115 |
– |
const char *reason = NULL; |
1116 |
– |
|
1117 |
– |
if ((conf = find_matching_name_conf(CONF_XLINE, source_p->info, NULL, NULL, 0))) |
1118 |
– |
{ |
1119 |
– |
++conf->count; |
1120 |
– |
|
1121 |
– |
if (conf->reason != NULL) |
1122 |
– |
reason = conf->reason; |
1123 |
– |
else |
1124 |
– |
reason = "No Reason"; |
1125 |
– |
|
1126 |
– |
sendto_realops_flags(UMODE_REJ, L_ALL, SEND_NOTICE, |
1127 |
– |
"X-line Rejecting [%s] [%s], user %s [%s]", |
1128 |
– |
source_p->info, reason, |
1129 |
– |
get_client_name(source_p, HIDE_IP), |
1130 |
– |
source_p->sockhost); |
1131 |
– |
|
1132 |
– |
++ServerStats.is_ref; |
1133 |
– |
exit_client(source_p, "Bad user info"); |
1134 |
– |
return 1; |
1135 |
– |
} |
1136 |
– |
|
1137 |
– |
return 0; |
1138 |
– |
} |
1139 |
– |
|
992 |
|
/* oper_up() |
993 |
|
* |
994 |
|
* inputs - pointer to given client to oper |
1057 |
|
void |
1058 |
|
init_uid(void) |
1059 |
|
{ |
1208 |
– |
unsigned int i; |
1209 |
– |
|
1060 |
|
memset(new_uid, 0, sizeof(new_uid)); |
1061 |
|
|
1062 |
|
if (!EmptyString(ServerInfo.sid)) |
1063 |
|
strlcpy(new_uid, ServerInfo.sid, sizeof(new_uid)); |
1064 |
|
|
1065 |
< |
for (i = 0; i < IRC_MAXSID; ++i) |
1065 |
> |
for (unsigned int i = 0; i < IRC_MAXSID; ++i) |
1066 |
|
if (new_uid[i] == '\0') |
1067 |
|
new_uid[i] = 'A'; |
1068 |
|
|