X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fuserprocess.cpp;h=2adccc36e5f419d1e1515f1f8b8b3aa08314c76c;hb=84a19a9ab6129deb71cdc24b216b74dd8eb80978;hp=104fff4ee15afd16e5413c361e5bad56916037d8;hpb=421e5985c39943b1193300c0b633cc819d42799c;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/userprocess.cpp b/src/userprocess.cpp index 104fff4ee..2adccc36e 100644 --- a/src/userprocess.cpp +++ b/src/userprocess.cpp @@ -20,7 +20,7 @@ using namespace std; #include "inspircd_config.h" #include "inspircd.h" -#include "inspircd_io.h" +#include "configreader.h" #include #include #include @@ -61,7 +61,6 @@ using namespace std; #include "command_parse.h" #include "cull_list.h" -extern int MODCOUNT; extern struct sockaddr_in client,server; extern socklen_t length; extern std::vector modules; @@ -70,7 +69,7 @@ extern std::vector module_sockets; extern time_t TIME; extern time_t OLDTIME; extern std::vector local_users; -char LOG_FILE[MAXBUF]; +extern InspSocket* socket_ref[MAX_DESCRIPTORS]; extern InspIRCd* ServerInstance; extern ServerConfig *Config; @@ -101,7 +100,7 @@ void ProcessUser(userrec* cu) } catch (ModuleException& modexcept) { - log(DEBUG,"Module exception cought: %s",modexcept.GetReason()); \ + log(DEBUG,"Module exception caught: %s",modexcept.GetReason()); } if (MOD_RESULT < 0) @@ -135,6 +134,8 @@ void ProcessUser(userrec* cu) /* * XXX - potential replacement for the below using my beloved pointers. --w00t + * XXX - no garauntee there's not \0's in the middle of the data, + * and no reason for it to be terminated either. -- Om * * for (char *c = data; data && *data; data++) * { @@ -316,12 +317,13 @@ void DoSocketTimeouts(time_t TIME) for (std::vector::iterator a = module_sockets.begin(); a < module_sockets.end(); a++) { InspSocket* s = (InspSocket*)*a; - if (s->Timeout(TIME)) + if ((s) && (s->GetFd() >= 0) && (s->GetFd() < MAX_DESCRIPTORS) && (socket_ref[s->GetFd()] != NULL) && (s->Timeout(TIME))) { - log(DEBUG,"Socket poll returned false, close and bail"); + log(DEBUG,"userprocess.cpp: Socket poll returned false, close and bail"); + socket_ref[s->GetFd()] = NULL; SE->DelFd(s->GetFd()); - s->Close(); module_sockets.erase(a); + s->Close(); delete s; break; } @@ -415,82 +417,3 @@ void DoBackgroundUserStuff(time_t TIME) /* Remove all the queued users who are due to be quit, free memory used. */ GlobalGoners.Apply(); } - -void OpenLog(char** argv, int argc) -{ - if (!*LOG_FILE) - { - if (Config->logpath == "") - { - Config->logpath = GetFullProgDir(argv,argc) + "/ircd.log"; - } - } - else - { - Config->log_file = fopen(LOG_FILE,"a+"); - - if (!Config->log_file) - { - printf("ERROR: Could not write to logfile %s, bailing!\n\n",Config->logpath.c_str()); - Exit(ERROR); - } - - return; - } - - Config->log_file = fopen(Config->logpath.c_str(),"a+"); - - if (!Config->log_file) - { - printf("ERROR: Could not write to logfile %s, bailing!\n\n",Config->logpath.c_str()); - Exit(ERROR); - } -} - - -void CheckRoot() -{ - if (geteuid() == 0) - { - printf("WARNING!!! You are running an irc server as ROOT!!! DO NOT DO THIS!!!\n\n"); - log(DEFAULT,"InspIRCd: startup: not starting with UID 0!"); - Exit(ERROR); - } -} - - -void CheckDie() -{ - if (*Config->DieValue) - { - printf("WARNING: %s\n\n",Config->DieValue); - log(DEFAULT,"Uh-Oh, somebody didn't read their config file: '%s'",Config->DieValue); - Exit(ERROR); - } -} - -/* We must load the modules AFTER initializing the socket engine, now */ -void LoadAllModules(InspIRCd* ServerInstance) -{ - char configToken[MAXBUF]; - Config->module_names.clear(); - - MODCOUNT = -1; - - for (int count = 0; count < Config->ConfValueEnum("module",&Config->config_f); count++) - { - Config->ConfValue("module","name",count,configToken,&Config->config_f); - printf("[\033[1;32m*\033[0m] Loading module:\t\033[1;32m%s\033[0m\n",configToken); - - if (!ServerInstance->LoadModule(configToken)) - { - log(DEFAULT,"Exiting due to a module loader error."); - printf("\nThere was an error loading a module: %s\n\n",ServerInstance->ModuleError()); - Exit(0); - } - } - - log(DEFAULT,"Total loaded modules: %lu",(unsigned long)MODCOUNT+1); -} - -