*
* $Id$
*/
-
-
-/*----------------------------------------------------------------------------
- * Platform Includes
- *--------------------------------------------------------------------------*/
-#include <assert.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <pwd.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/socket.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <netdb.h>
-
-
-/*----------------------------------------------------------------------------
- * ircu Includes
- *--------------------------------------------------------------------------*/
-#include "config.h"
+#include "ircd.h"
#include "IPcheck.h"
#include "class.h"
#include "client.h"
#include "crule.h"
#include "hash.h"
-#include "ircd.h"
#include "ircd_alloc.h"
#include "ircd_log.h"
#include "ircd_reply.h"
#include "version.h"
#include "whowas.h"
+#include <assert.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <netdb.h>
+#include <pwd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/socket.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+
/*----------------------------------------------------------------------------
* External stuff
* is called earlier or later...)
*--------------------------------------------------------------------------*/
static time_t try_connections(void) {
- struct ConfItem *aconf;
- struct Client *cptr;
- struct ConfItem **pconf;
- int connecting;
- int confrq;
- time_t next = 0;
- struct ConfClass *cltmp;
- struct ConfItem *cconf;
- struct ConfItem *con_conf = NULL;
- struct Jupe *ajupe;
- unsigned int con_class = 0;
+ struct ConfItem* aconf;
+ struct Client* cptr;
+ struct ConfItem** pconf;
+ int connecting;
+ int confrq;
+ time_t next = 0;
+ struct ConfClass* cltmp;
+ struct ConfItem* con_conf = 0;
+ struct Jupe* ajupe;
+ unsigned int con_class = 0;
connecting = FALSE;
Debug((DEBUG_NOTICE, "Connection check at : %s", myctime(CurrentTime)));
if (!cptr && (Links(cltmp) < MaxLinks(cltmp)) &&
(!connecting || (ConClass(cltmp) > con_class))) {
- /* Check connect rules to see if we're allowed to try */
- for (cconf = GlobalConfList; cconf; cconf = cconf->next) {
- if ((cconf->status & CONF_CRULE) && !match(cconf->host, aconf->name))
- if (crule_eval(cconf->passwd))
- break;
- }
- if (!cconf) {
+ /*
+ * Check connect rules to see if we're allowed to try
+ */
+ if (0 == conf_eval_crule(aconf->name, CRULE_MASK)) {
con_class = ConClass(cltmp);
con_conf = aconf;
/* We connect only one at time... */
continue;
}
- max_ping = IsRegistered(cptr) ? get_client_ping(cptr) : CONNECTTIMEOUT;
+ max_ping = IsRegistered(cptr) ? client_get_ping(cptr) : CONNECTTIMEOUT;
Debug((DEBUG_DEBUG, "check_pings(%s)=status:%s limit: %d current: %d",
cptr->name, (cptr->flags & FLAGS_PINGSENT) ? "[Ping Sent]" : "[]",
/*----------------------------------------------------------------------------
* parse_command_line
+ * Side Effects: changes GLOBALS me, thisServer, dpath, configfile, debuglevel
+ * debugmode
*--------------------------------------------------------------------------*/
static void parse_command_line(int argc, char** argv) {
const char *options = "d:f:h:ntvx:";
else
read_message(IRCD_MIN(delay, TIMESEC));
- Debug((DEBUG_DEBUG, "Got message(s)"));
-
/* ...perhaps should not do these loops every time, but only if there is
* some chance of something happening (but, note that conf->hold times may
* be changed elsewhere--so precomputed next event time might be too far
if (geteuid())
seteuid(0);
- if (chdir(DPATH)) {
- fprintf(stderr, "Fail: Cannot chdir(%s): %s\n", DPATH, strerror(errno));
+ if (chdir(dpath)) {
+ fprintf(stderr, "Fail: Cannot chdir(%s): %s\n", dpath, strerror(errno));
return 0;
}
- if (chroot(DPATH)) {
- fprintf(stderr, "Fail: Cannot chroot(%s): %s\n", DPATH, strerror(errno));
+ if (chroot(dpath)) {
+ fprintf(stderr, "Fail: Cannot chroot(%s): %s\n", dpath, strerror(errno));
return 0;
}
dpath = "/";
#ifdef CHROOTDIR
if (!set_chroot_environment())
- exit(1);
+ return 1;
#endif
#if defined(HAVE_SETRLIMIT) && defined(RLIMIT_CORE)
memset(&me, 0, sizeof(me));
me.fd = -1;
- setup_signals();
- initload();
-
parse_command_line(argc, argv);
if (chdir(dpath)) {
- fprintf(stderr, "Fail: Cannot chdir(%s): %s\n", dpath, strerror(errno));
- exit(2);
+ fprintf(stderr, "Fail: Cannot chdir(%s): %s, check DPATH\n", dpath, strerror(errno));
+ return 2;
}
if (!set_userid_if_needed())
- exit(3);
+ return 3;
/* Check paths for accessibility */
if (!check_file_access(SPATH, 'S', X_OK) ||
- !check_file_access(CPATH, 'C', R_OK) ||
+ !check_file_access(configfile, 'C', R_OK) ||
!check_file_access(MPATH, 'M', R_OK) ||
!check_file_access(RPATH, 'R', R_OK))
- exit(4);
+ return 4;
#ifdef DEBUG
if (!check_file_access(LPATH, 'L', W_OK))
- exit(5);
+ return 5;
#endif
+ debug_init(thisServer.bootopt & BOOT_TTY);
+ daemon_init(thisServer.bootopt & BOOT_TTY);
+
+ setup_signals();
+ open_log(*argv);
+
+ set_nomem_handler(outofmemory);
+
+ if (!init_string()) {
+ ircd_log(L_CRIT, "Failed to initialize string module");
+ return 6;
+ }
+
+ initload();
init_list();
- hash_init();
+ init_hash();
initclass();
initwhowas();
initmsgtree();
initstats();
- debug_init(thisServer.bootopt & BOOT_TTY);
- daemon_init(thisServer.bootopt & BOOT_TTY);
-
- set_nomem_handler(outofmemory);
init_resolver();
- open_log(*argv);
-
- if (!conf_init()) {
- Debug((DEBUG_FATAL, "Failed to read configuration file %s", configfile));
- printf("Couldn't open configuration file %s\n", configfile);
- exit(6);
+ if (!init_conf()) {
+ ircd_log(L_CRIT, "Failed to read configuration file %s", configfile);
+ return 7;
}
if (!init_server_identity()) {
- Debug((DEBUG_FATAL, "Failed to initialize server identity"));
- exit(7);
+ ircd_log(L_CRIT, "Failed to initialize server identity");
+ return 8;
}
uping_init();
rmotd = read_motd(RPATH);
motd = read_motd(MPATH);
CurrentTime = time(NULL);
- me.from = &me;
SetMe(&me);
+ me.from = &me;
make_server(&me);
me.serv->timestamp = TStime(); /* Abuse own link timestamp as start TS */