24 |
|
|
25 |
|
#include "stdinc.h" |
26 |
|
#include "s_user.h" |
27 |
< |
#include "tools.h" |
27 |
> |
#include "list.h" |
28 |
|
#include "ircd.h" |
29 |
|
#include "channel.h" |
30 |
|
#include "channel_mode.h" |
34 |
|
#include "fdlist.h" |
35 |
|
#include "hash.h" |
36 |
|
#include "irc_string.h" |
37 |
– |
#include "sprintf_irc.h" |
37 |
|
#include "ircd_signal.h" |
39 |
– |
#include "list.h" |
38 |
|
#include "s_gline.h" |
39 |
|
#include "motd.h" |
40 |
|
#include "ircd_handler.h" |
63 |
|
#include "supported.h" |
64 |
|
#include "watch.h" |
65 |
|
|
68 |
– |
/* Try and find the correct name to use with getrlimit() for setting the max. |
69 |
– |
* number of files allowed to be open by this process. |
70 |
– |
*/ |
66 |
|
|
67 |
|
/* /quote set variables */ |
68 |
|
struct SetOptions GlobalSetOptions; |
73 |
|
struct server_info ServerInfo; |
74 |
|
/* admin info set from ircd.conf */ |
75 |
|
struct admin_info AdminInfo = { NULL, NULL, NULL }; |
76 |
< |
struct Counter Count = { 0, 0, 0, 0, 0, 0, 0, 0 }; |
76 |
> |
struct Counter Count = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; |
77 |
|
struct ServerState_t server_state = { 0 }; |
78 |
|
struct logging_entry ConfigLoggingEntry = { 1, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0} }; |
79 |
|
struct ServerStatistics ServerStats; |
89 |
|
|
90 |
|
int dorehash = 0; |
91 |
|
int doremotd = 0; |
97 |
– |
time_t nextconnect = 1; /* time for next try_connections call */ |
92 |
|
|
93 |
|
/* Set to zero because it should be initialized later using |
94 |
|
* initialize_server_capabs |
99 |
|
int bio_spare_fd = -1; |
100 |
|
#endif |
101 |
|
|
102 |
< |
int splitmode; |
103 |
< |
int splitchecking; |
104 |
< |
int split_users; |
102 |
> |
unsigned int splitmode; |
103 |
> |
unsigned int splitchecking; |
104 |
> |
unsigned int split_users; |
105 |
|
unsigned int split_servers; |
106 |
|
|
107 |
|
/* Do klines the same way hybrid-6 did them, i.e. at the |
191 |
|
|
192 |
|
if (newtime.tv_sec < CurrentTime) |
193 |
|
{ |
194 |
< |
ircsprintf(to_send, "System clock is running backwards - (%lu < %lu)", |
195 |
< |
(unsigned long)newtime.tv_sec, (unsigned long)CurrentTime); |
194 |
> |
snprintf(to_send, sizeof(to_send), |
195 |
> |
"System clock is running backwards - (%lu < %lu)", |
196 |
> |
(unsigned long)newtime.tv_sec, (unsigned long)CurrentTime); |
197 |
|
report_error(L_ALL, to_send, me.name, 0); |
198 |
|
set_back_events(CurrentTime - newtime.tv_sec); |
199 |
|
} |
294 |
|
} |
295 |
|
|
296 |
|
GlobalSetOptions.ident_timeout = IDENT_TIMEOUT; |
302 |
– |
GlobalSetOptions.idletime = ConfigFileEntry.idletime; |
297 |
|
/* End of global set options */ |
298 |
|
} |
299 |
|
|
327 |
|
{ |
328 |
|
add_capability("QS", CAP_QS, 1); |
329 |
|
add_capability("EOB", CAP_EOB, 1); |
330 |
< |
|
337 |
< |
if (ServerInfo.sid != NULL) /* only enable TS6 if we have an SID */ |
338 |
< |
add_capability("TS6", CAP_TS6, 0); |
339 |
< |
|
330 |
> |
add_capability("TS6", CAP_TS6, 0); |
331 |
|
add_capability("ZIP", CAP_ZIP, 0); |
332 |
|
add_capability("CLUSTER", CAP_CLUSTER, 1); |
333 |
+ |
add_capability("SVS", CAP_SVS, 1); |
334 |
|
#ifdef HALFOPS |
335 |
|
add_capability("HOPS", CAP_HOPS, 1); |
336 |
|
#endif |
351 |
|
{ |
352 |
|
char buff[32]; |
353 |
|
unsigned int pid = (unsigned int)getpid(); |
354 |
< |
size_t nbytes = ircsprintf(buff, "%u\n", pid); |
354 |
> |
size_t nbytes = snprintf(buff, sizeof(buff), "%u\n", pid); |
355 |
|
|
356 |
|
if ((fbputs(buff, fb, nbytes) == -1)) |
357 |
|
ilog(L_ERROR, "Error writing %u to pid file %s (%s)", |
498 |
|
/* It ain't random, but it ought to be a little harder to guess */ |
499 |
|
init_genrand(SystemTime.tv_sec ^ (SystemTime.tv_usec | (getpid() << 20))); |
500 |
|
|
509 |
– |
memset(&me, 0, sizeof(me)); |
510 |
– |
memset(&meLocalUser, 0, sizeof(meLocalUser)); |
501 |
|
me.localClient = &meLocalUser; |
502 |
|
dlinkAdd(&me, &me.node, &global_client_list); /* Pointer to beginning |
503 |
|
of Client list */ |
514 |
– |
|
515 |
– |
memset(&ServerInfo, 0, sizeof(ServerInfo)); |
516 |
– |
memset(&ServerStats, 0, sizeof(ServerStats)); |
517 |
– |
|
504 |
|
/* Initialise the channel capability usage counts... */ |
505 |
|
init_chcap_usage_counts(); |
506 |
|
|
555 |
|
/* Check if there is pidfile and daemon already running */ |
556 |
|
check_pidfile(pidFileName); |
557 |
|
|
572 |
– |
#ifndef NOBALLOC |
558 |
|
initBlockHeap(); |
574 |
– |
#endif |
559 |
|
init_dlink_nodes(); |
560 |
|
init_callbacks(); |
561 |
|
initialize_message_files(); |
571 |
|
init_auth(); /* Initialise the auth code */ |
572 |
|
init_resolver(); /* Needs to be setup before the io loop */ |
573 |
|
read_conf_files(1); /* cold start init conf files */ |
590 |
– |
me.id[0] = '\0'; |
574 |
|
init_uid(); |
575 |
|
initialize_server_capabs(); /* Set up default_server_capabs */ |
576 |
|
initialize_global_set_options(); |
577 |
|
init_channels(); |
578 |
|
|
579 |
< |
if (ServerInfo.name == NULL) |
579 |
> |
if (EmptyString(ServerInfo.sid)) |
580 |
|
{ |
581 |
< |
ilog(L_CRIT, "No server name specified in serverinfo block."); |
581 |
> |
ilog(L_CRIT, "ERROR: No server id specified in serverinfo block."); |
582 |
> |
exit(EXIT_FAILURE); |
583 |
> |
} |
584 |
> |
|
585 |
> |
strlcpy(me.id, ServerInfo.sid, sizeof(me.id)); |
586 |
> |
|
587 |
> |
if (EmptyString(ServerInfo.name)) |
588 |
> |
{ |
589 |
> |
ilog(L_CRIT, "ERROR: No server name specified in serverinfo block."); |
590 |
|
exit(EXIT_FAILURE); |
591 |
|
} |
592 |
|
|
593 |
|
strlcpy(me.name, ServerInfo.name, sizeof(me.name)); |
594 |
|
|
595 |
|
/* serverinfo{} description must exist. If not, error out.*/ |
596 |
< |
if (ServerInfo.description == NULL) |
596 |
> |
if (EmptyString(ServerInfo.description)) |
597 |
|
{ |
598 |
< |
ilog(L_CRIT, |
608 |
< |
"ERROR: No server description specified in serverinfo block."); |
598 |
> |
ilog(L_CRIT, "ERROR: No server description specified in serverinfo block."); |
599 |
|
exit(EXIT_FAILURE); |
600 |
|
} |
601 |
|
|
602 |
|
strlcpy(me.info, ServerInfo.description, sizeof(me.info)); |
603 |
|
|
604 |
< |
me.from = &me; |
605 |
< |
me.servptr = &me; |
604 |
> |
me.from = &me; |
605 |
> |
me.servptr = &me; |
606 |
> |
me.localClient->lasttime = CurrentTime; |
607 |
> |
me.localClient->since = CurrentTime; |
608 |
> |
me.localClient->firsttime = CurrentTime; |
609 |
|
|
610 |
|
SetMe(&me); |
611 |
|
make_server(&me); |
612 |
|
|
613 |
< |
me.lasttime = me.since = me.firsttime = CurrentTime; |
613 |
> |
hash_add_id(&me); |
614 |
|
hash_add_client(&me); |
615 |
|
|
616 |
|
/* add ourselves to global_serv_list */ |
617 |
|
dlinkAdd(&me, make_dlink_node(), &global_serv_list); |
618 |
|
|
626 |
– |
check_class(); |
627 |
– |
|
628 |
– |
#ifndef STATIC_MODULES |
619 |
|
if (chdir(MODPATH)) |
620 |
|
{ |
621 |
< |
ilog (L_CRIT, "Could not load core modules. Terminating!"); |
621 |
> |
ilog(L_CRIT, "Could not load core modules. Terminating!"); |
622 |
|
exit(EXIT_FAILURE); |
623 |
|
} |
624 |
|
|
625 |
|
load_all_modules(1); |
626 |
|
load_conf_modules(); |
627 |
|
load_core_modules(1); |
628 |
+ |
|
629 |
|
/* Go back to DPATH after checking to see if we can chdir to MODPATH */ |
630 |
< |
chdir(ConfigFileEntry.dpath); |
631 |
< |
#else |
632 |
< |
load_all_modules(1); |
633 |
< |
#endif |
630 |
> |
if (chdir(ConfigFileEntry.dpath)) |
631 |
> |
{ |
632 |
> |
perror("chdir"); |
633 |
> |
exit(EXIT_FAILURE); |
634 |
> |
} |
635 |
> |
|
636 |
|
/* |
637 |
|
* assemble_umode_buffer() has to be called after |
638 |
|
* reading conf/loading modules. |