X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Finspircd.cpp;h=12962d92d6391dcd8b3033477adbe22f58ce2547;hb=98ef89c392a63bb7a78df5e8d8283c848f9dd2af;hp=8336a48473f21d48e180803e6d4b7bdbe68df092;hpb=deb18ee9cfa531a87141aea61171c6899ef7d687;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/inspircd.cpp b/src/inspircd.cpp index 8336a4847..12962d92d 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -107,12 +107,9 @@ void InspIRCd::Cleanup() ports.clear(); /* Close all client sockets, or the new process inherits them */ - LocalUserList::reverse_iterator i = Users->local_users.rbegin(); - while (i != this->Users->local_users.rend()) - { - User* u = *i++; - Users->QuitUser(u, "Server shutdown"); - } + LocalUserList& list = Users->local_users; + for (LocalUserList::iterator i = list.begin(); i != list.end(); ++i) + Users->QuitUser(*i, "Server shutdown"); GlobalCulls.Apply(); Modules->UnloadAll(); @@ -120,7 +117,10 @@ void InspIRCd::Cleanup() /* Delete objects dynamically allocated in constructor (destructor would be more appropriate, but we're likely exiting) */ /* Must be deleted before modes as it decrements modelines */ if (FakeClient) + { + delete FakeClient->server; FakeClient->cull(); + } DeleteZero(this->FakeClient); DeleteZero(this->Users); DeleteZero(this->Modes); @@ -158,13 +158,20 @@ void InspIRCd::QuickExit(int status) exit(status); } +// Required for returning the proper value of EXIT_SUCCESS for the parent process +static void VoidSignalHandler(int signalreceived) +{ + exit(0); +} + bool InspIRCd::DaemonSeed() { #ifdef _WIN32 std::cout << "InspIRCd Process ID: " << con_green << GetCurrentProcessId() << con_reset << std::endl; return true; #else - signal(SIGTERM, InspIRCd::QuickExit); + // Do not use QuickExit here: It will exit with status SIGTERM which would break e.g. daemon scripts + signal(SIGTERM, VoidSignalHandler); int childpid = fork(); if (childpid < 0) @@ -335,7 +342,7 @@ InspIRCd::InspIRCd(int argc, char** argv) : { case 'c': /* Config filename was set */ - ConfigFileName = optarg; + ConfigFileName = ServerInstance->Config->Paths.PrependConfig(optarg); break; case 0: /* getopt_long_only() set an int variable, just keep going */ @@ -380,14 +387,14 @@ InspIRCd::InspIRCd(int argc, char** argv) : Logs->AddLogTypes("*", fls, true); } - if (!ServerConfig::FileExists(ConfigFileName.c_str())) + if (!FileSystem::FileExists(ConfigFileName)) { #ifdef _WIN32 /* Windows can (and defaults to) hide file extensions, so let's play a bit nice for windows users. */ std::string txtconf = this->ConfigFileName; txtconf.append(".txt"); - if (ServerConfig::FileExists(txtconf.c_str())) + if (FileSystem::FileExists(txtconf)) { ConfigFileName = txtconf; } @@ -457,7 +464,7 @@ InspIRCd::InspIRCd(int argc, char** argv) : this->UIDGen.init(Config->sid); // Create the server user for this server - this->FakeClient = new FakeUser(Config->sid, Config->ServerName); + this->FakeClient = new FakeUser(Config->sid, Config->ServerName, Config->ServerDesc); // This is needed as all new XLines are marked pending until ApplyLines() is called this->XLines->ApplyLines(); @@ -567,7 +574,7 @@ InspIRCd::InspIRCd(int argc, char** argv) : if (!g) { - this->Logs->Log("STARTUP", LOG_DEFAULT, "getgrnam() failed (bad user?): %s", strerror(errno)); + this->Logs->Log("STARTUP", LOG_DEFAULT, "getgrnam(%s) failed (wrong group?): %s", SetGroup.c_str(), strerror(errno)); this->QuickExit(0); } @@ -575,7 +582,7 @@ InspIRCd::InspIRCd(int argc, char** argv) : if (ret == -1) { - this->Logs->Log("STARTUP", LOG_DEFAULT, "setgid() failed (bad user?): %s", strerror(errno)); + this->Logs->Log("STARTUP", LOG_DEFAULT, "setgid() failed (wrong group?): %s", strerror(errno)); this->QuickExit(0); } } @@ -590,7 +597,7 @@ InspIRCd::InspIRCd(int argc, char** argv) : if (!u) { - this->Logs->Log("STARTUP", LOG_DEFAULT, "getpwnam() failed (bad user?): %s", strerror(errno)); + this->Logs->Log("STARTUP", LOG_DEFAULT, "getpwnam(%s) failed (wrong user?): %s", SetUser.c_str(), strerror(errno)); this->QuickExit(0); } @@ -598,7 +605,7 @@ InspIRCd::InspIRCd(int argc, char** argv) : if (ret == -1) { - this->Logs->Log("STARTUP", LOG_DEFAULT, "setuid() failed (bad user?): %s", strerror(errno)); + this->Logs->Log("STARTUP", LOG_DEFAULT, "setuid() failed (wrong user?): %s", strerror(errno)); this->QuickExit(0); } }