| 22 |
|
* $Id$ |
| 23 |
|
*/ |
| 24 |
|
|
| 25 |
+ |
#ifdef IN_IRCD |
| 26 |
|
#include "stdinc.h" |
| 27 |
|
#include "s_user.h" |
| 28 |
|
#include "ircd.h" |
| 43 |
|
#include "restart.h" |
| 44 |
|
#include "s_auth.h" |
| 45 |
|
#include "s_conf.h" |
| 46 |
< |
#include "s_serv.h" /* try_connections */ |
| 47 |
< |
#include "s_stats.h" |
| 46 |
> |
#include "parse_aline.h" |
| 47 |
> |
#include "s_serv.h" |
| 48 |
|
#include "send.h" |
| 49 |
|
#include "whowas.h" |
| 50 |
< |
#include "modules.h" |
| 50 |
> |
#include "conf/modules.h" |
| 51 |
|
#include "ircd_getopt.h" |
| 52 |
|
#include "motd.h" |
| 53 |
|
#include "supported.h" |
| 54 |
+ |
#include "watch.h" |
| 55 |
|
|
| 56 |
|
/* Try and find the correct name to use with getrlimit() for setting the max. |
| 57 |
|
* number of files allowed to be open by this process. |
| 59 |
|
|
| 60 |
|
/* /quote set variables */ |
| 61 |
|
struct SetOptions GlobalSetOptions; |
| 62 |
< |
|
| 62 |
> |
struct ServerStatistics ServerStats; |
| 63 |
|
/* configuration set from ircd.conf */ |
| 64 |
|
struct config_file_entry ConfigFileEntry; |
| 65 |
|
/* server info set from ircd.conf */ |
| 82 |
|
|
| 83 |
|
int dorehash = 0; |
| 84 |
|
int doremotd = 0; |
| 83 |
– |
time_t nextconnect = 1; /* time for next try_connections call */ |
| 85 |
|
|
| 86 |
|
/* Set to zero because it should be initialized later using |
| 87 |
|
* initialize_server_capabs |
| 130 |
|
*/ |
| 131 |
|
|
| 132 |
|
void *vptr = sbrk(0); |
| 133 |
< |
return((unsigned long)vptr); |
| 133 |
> |
return (unsigned long)vptr; |
| 134 |
|
} |
| 135 |
|
|
| 136 |
|
/* |
| 227 |
|
{ |
| 228 |
|
struct Client *client_p = ptr->data; |
| 229 |
|
assert(client_p->localClient->list_task); |
| 230 |
< |
safe_list_channels(client_p, client_p->localClient->list_task, 0, 0); |
| 230 |
> |
safe_list_channels(client_p, client_p->localClient->list_task, 0); |
| 231 |
|
} |
| 232 |
|
} |
| 233 |
|
|
| 248 |
|
rehash(1); |
| 249 |
|
dorehash = 0; |
| 250 |
|
} |
| 251 |
+ |
|
| 252 |
|
if (doremotd) |
| 253 |
|
{ |
| 254 |
|
read_message_file(&ConfigFileEntry.motd); |
| 264 |
|
* inputs - none |
| 265 |
|
* output - none |
| 266 |
|
* side effects - This sets all global set options needed |
| 267 |
+ |
* XXX to be removed with old s_conf.c |
| 268 |
|
*/ |
| 269 |
|
static void |
| 270 |
|
initialize_global_set_options(void) |
| 296 |
|
|
| 297 |
|
GlobalSetOptions.ident_timeout = IDENT_TIMEOUT; |
| 298 |
|
GlobalSetOptions.idletime = ConfigFileEntry.idletime; |
| 299 |
< |
/* End of global set options */ |
| 299 |
> |
GlobalSetOptions.maxlisters = 10; /* XXX ya ya ya - db */ |
| 300 |
|
} |
| 301 |
|
|
| 302 |
|
/* initialize_message_files() |
| 328 |
|
initialize_server_capabs(void) |
| 329 |
|
{ |
| 330 |
|
add_capability("QS", CAP_QS, 1); |
| 328 |
– |
add_capability("LL", CAP_LL, 1); |
| 331 |
|
add_capability("EOB", CAP_EOB, 1); |
| 332 |
< |
if (ServerInfo.sid != NULL) /* only enable TS6 if we have an SID */ |
| 333 |
< |
add_capability("TS6", CAP_TS6, 0); |
| 332 |
> |
add_capability("HUB", CAP_HUB, 0); |
| 333 |
> |
add_capability("TS6", CAP_TS6, 0); |
| 334 |
|
add_capability("ZIP", CAP_ZIP, 0); |
| 335 |
|
add_capability("CLUSTER", CAP_CLUSTER, 1); |
| 336 |
|
#ifdef HALFOPS |
| 360 |
|
pid, filename, strerror(errno)); |
| 361 |
|
|
| 362 |
|
fbclose(fb); |
| 361 |
– |
return; |
| 363 |
|
} |
| 364 |
|
else |
| 365 |
|
{ |
| 445 |
|
init_ssl(void) |
| 446 |
|
{ |
| 447 |
|
#ifdef HAVE_LIBCRYPTO |
| 448 |
+ |
SSL_library_init(); |
| 449 |
|
SSL_load_error_strings(); |
| 448 |
– |
SSLeay_add_ssl_algorithms(); |
| 450 |
|
|
| 451 |
|
ServerInfo.ctx = SSL_CTX_new(SSLv23_server_method()); |
| 452 |
+ |
|
| 453 |
|
if (!ServerInfo.ctx) |
| 454 |
|
{ |
| 455 |
|
const char *s; |
| 476 |
|
static void |
| 477 |
|
init_callbacks(void) |
| 478 |
|
{ |
| 479 |
< |
iorecv_cb = register_callback("iorecv", NULL); |
| 480 |
< |
iosend_cb = register_callback("iosend", NULL); |
| 479 |
> |
entering_umode_cb = register_callback("entering_umode", NULL); |
| 480 |
> |
iorecv_cb = register_callback("iorecv", iorecv_default); |
| 481 |
> |
iosend_cb = register_callback("iosend", iosend_default); |
| 482 |
|
iorecvctrl_cb = register_callback("iorecvctrl", NULL); |
| 483 |
|
iosendctrl_cb = register_callback("iosendctrl", NULL); |
| 484 |
+ |
uid_get_cb = register_callback("uid_get", uid_get); |
| 485 |
+ |
umode_cb = register_callback("changing_umode", change_simple_umode); |
| 486 |
|
} |
| 487 |
|
|
| 488 |
|
static void * |
| 510 |
|
return NULL; |
| 511 |
|
} |
| 512 |
|
|
| 513 |
< |
int |
| 513 |
> |
EXTERN int |
| 514 |
|
main(int argc, char *argv[]) |
| 515 |
|
{ |
| 516 |
< |
/* Check to see if the user is running |
| 517 |
< |
* us as root, which is a nono |
| 516 |
> |
/* |
| 517 |
> |
* Check to see if the user is running us as root, which is a nono |
| 518 |
|
*/ |
| 519 |
|
#ifndef _WIN32 |
| 520 |
|
if (geteuid() == 0) |
| 530 |
|
initialVMTop = get_vm_top(); |
| 531 |
|
#endif |
| 532 |
|
|
| 528 |
– |
memset(&me, 0, sizeof(me)); |
| 529 |
– |
memset(&meLocalUser, 0, sizeof(meLocalUser)); |
| 530 |
– |
me.localClient = &meLocalUser; |
| 531 |
– |
dlinkAdd(&me, &me.node, &global_client_list); /* Pointer to beginning |
| 532 |
– |
of Client list */ |
| 533 |
– |
|
| 533 |
|
memset(&ServerInfo, 0, sizeof(ServerInfo)); |
| 534 |
< |
|
| 536 |
< |
/* Initialise the channel capability usage counts... */ |
| 537 |
< |
init_chcap_usage_counts(); |
| 534 |
> |
memset(&ServerStats, 0, sizeof(ServerStats)); |
| 535 |
|
|
| 536 |
|
ConfigFileEntry.dpath = DPATH; |
| 537 |
|
ConfigFileEntry.configfile = CPATH; /* Server configuration file */ |
| 573 |
|
outofmemory = ircd_outofmemory; |
| 574 |
|
fdlimit_hook = install_hook(fdlimit_cb, changing_fdlimit); |
| 575 |
|
|
| 576 |
+ |
check_pidfile(pidFileName); |
| 577 |
|
setup_signals(); |
| 580 |
– |
|
| 578 |
|
get_ircd_platform(ircd_platform); |
| 582 |
– |
|
| 579 |
|
init_log(logFileName); |
| 580 |
|
ServerInfo.can_use_v6 = check_can_use_v6(); |
| 581 |
|
|
| 582 |
< |
/* Check if there is pidfile and daemon already running */ |
| 583 |
< |
check_pidfile(pidFileName); |
| 582 |
> |
/* make_dlink_node() cannot be called until after libio_init() */ |
| 583 |
> |
memset(&me, 0, sizeof(me)); |
| 584 |
> |
memset(&meLocalUser, 0, sizeof(meLocalUser)); |
| 585 |
> |
|
| 586 |
> |
me.localClient = &meLocalUser; |
| 587 |
> |
me.from = me.servptr = &me; |
| 588 |
> |
me.lasttime = me.since = me.firsttime = CurrentTime; |
| 589 |
> |
|
| 590 |
> |
SetMe(&me); |
| 591 |
> |
make_server(&me); |
| 592 |
> |
dlinkAdd(&me, &me.node, &global_client_list); |
| 593 |
> |
dlinkAdd(&me, make_dlink_node(), &global_serv_list); |
| 594 |
|
|
| 595 |
|
init_callbacks(); |
| 596 |
|
initialize_message_files(); |
| 601 |
|
init_client(); |
| 602 |
|
init_class(); |
| 603 |
|
init_whowas(); |
| 598 |
– |
init_stats(); |
| 599 |
– |
read_conf_files(1); /* cold start init conf files */ |
| 600 |
– |
initServerMask(); |
| 601 |
– |
me.id[0] = '\0'; |
| 602 |
– |
init_uid(); |
| 604 |
|
init_auth(); /* Initialise the auth code */ |
| 604 |
– |
initialize_server_capabs(); /* Set up default_server_capabs */ |
| 605 |
– |
initialize_global_set_options(); |
| 605 |
|
init_channels(); |
| 606 |
|
init_channel_modes(); |
| 607 |
+ |
initialize_server_capabs(); /* Set up default_server_capabs */ |
| 608 |
+ |
|
| 609 |
+ |
read_conf_files(1); /* cold start init conf files */ |
| 610 |
+ |
check_class(); |
| 611 |
+ |
init_watch(); |
| 612 |
|
|
| 613 |
|
if (ServerInfo.name == NULL) |
| 614 |
|
{ |
| 615 |
< |
ilog(L_CRIT, "No server name specified in serverinfo block."); |
| 615 |
> |
ilog(L_CRIT, "ERROR: No server name specified in serverinfo block."); |
| 616 |
|
exit(EXIT_FAILURE); |
| 617 |
|
} |
| 618 |
+ |
|
| 619 |
|
strlcpy(me.name, ServerInfo.name, sizeof(me.name)); |
| 620 |
|
|
| 621 |
|
/* serverinfo{} description must exist. If not, error out.*/ |
| 625 |
|
"ERROR: No server description specified in serverinfo block."); |
| 626 |
|
exit(EXIT_FAILURE); |
| 627 |
|
} |
| 623 |
– |
strlcpy(me.info, ServerInfo.description, sizeof(me.info)); |
| 624 |
– |
|
| 625 |
– |
me.from = &me; |
| 626 |
– |
me.servptr = &me; |
| 628 |
|
|
| 629 |
< |
SetMe(&me); |
| 629 |
< |
make_server(&me); |
| 629 |
> |
strlcpy(me.info, ServerInfo.description, sizeof(me.info)); |
| 630 |
|
|
| 631 |
– |
me.lasttime = me.since = me.firsttime = CurrentTime; |
| 631 |
|
hash_add_client(&me); |
| 633 |
– |
|
| 634 |
– |
/* add ourselves to global_serv_list */ |
| 635 |
– |
dlinkAdd(&me, make_dlink_node(), &global_serv_list); |
| 632 |
|
|
| 633 |
< |
check_class(); |
| 633 |
> |
init_uid(); /* XXX move this one up after inculcating new conf system */ |
| 634 |
> |
initialize_global_set_options(); /* and this one is going to be deleted */ |
| 635 |
|
|
| 636 |
|
#ifndef STATIC_MODULES |
| 637 |
|
if (chdir(MODPATH)) |
| 640 |
|
exit(EXIT_FAILURE); |
| 641 |
|
} |
| 642 |
|
|
| 643 |
< |
load_all_modules(1); |
| 644 |
< |
load_conf_modules(); |
| 648 |
< |
load_core_modules(1); |
| 643 |
> |
boot_modules(1); |
| 644 |
> |
|
| 645 |
|
/* Go back to DPATH after checking to see if we can chdir to MODPATH */ |
| 646 |
|
chdir(ConfigFileEntry.dpath); |
| 647 |
|
#else |
| 669 |
|
/* Setup the timeout check. I'll shift it later :) -- adrian */ |
| 670 |
|
eventAddIsh("comm_checktimeouts", comm_checktimeouts, NULL, 1); |
| 671 |
|
|
| 672 |
+ |
/* XXX to be removed with old s_conf.c [superseded] */ |
| 673 |
|
if (ConfigServerHide.links_delay > 0) |
| 674 |
|
eventAddIsh("write_links_file", write_links_file, NULL, ConfigServerHide.links_delay); |
| 675 |
|
else |
| 676 |
|
ConfigServerHide.links_disabled = 1; |
| 677 |
|
|
| 678 |
< |
if (splitmode) |
| 678 |
> |
if (splitmode) /* XXX */ |
| 679 |
|
eventAddIsh("check_splitmode", check_splitmode, NULL, 60); |
| 680 |
|
|
| 681 |
|
io_loop(); |
| 682 |
< |
return(0); |
| 682 |
> |
return 0; |
| 683 |
> |
} |
| 684 |
> |
|
| 685 |
> |
#else |
| 686 |
> |
|
| 687 |
> |
#include <windows.h> |
| 688 |
> |
|
| 689 |
> |
extern __declspec(dllimport) main(int, char **); |
| 690 |
> |
|
| 691 |
> |
/* |
| 692 |
> |
* Initial entry point for Win32 GUI applications, called by the C runtime. |
| 693 |
> |
* |
| 694 |
> |
* It should be only a wrapper for main(), since when compiled as a console |
| 695 |
> |
* application, main() is called instead. |
| 696 |
> |
*/ |
| 697 |
> |
int WINAPI |
| 698 |
> |
WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, |
| 699 |
> |
LPSTR lpCmdLine, int nCmdShow) |
| 700 |
> |
{ |
| 701 |
> |
/* Do we really need these pidfile, logfile etc arguments? |
| 702 |
> |
* And we are not on a console, so -help or -foreground is meaningless. */ |
| 703 |
> |
|
| 704 |
> |
char *argv[2] = {"ircd", NULL}; |
| 705 |
> |
|
| 706 |
> |
return main(1, argv); |
| 707 |
|
} |
| 708 |
+ |
|
| 709 |
+ |
#endif |