diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/cmd_rehash.cpp | 4 | ||||
-rw-r--r-- | src/configreader.cpp | 10 | ||||
-rw-r--r-- | src/inspircd.cpp | 28 | ||||
-rw-r--r-- | src/modules/extra/m_ssl_gnutls.cpp | 2 | ||||
-rw-r--r-- | src/modules/extra/m_ssl_openssl.cpp | 2 |
5 files changed, 26 insertions, 20 deletions
diff --git a/src/cmd_rehash.cpp b/src/cmd_rehash.cpp index 815e241f0..4d4b97c8e 100644 --- a/src/cmd_rehash.cpp +++ b/src/cmd_rehash.cpp @@ -25,7 +25,7 @@ extern "C" command_t* init_command(InspIRCd* Instance) CmdResult cmd_rehash::Handle (const char** parameters, int pcnt, userrec *user) { - user->WriteServ("382 %s %s :Rehashing",user->nick,ServerConfig::CleanFilename(CONFIG_FILE)); + user->WriteServ("382 %s %s :Rehashing",user->nick,ServerConfig::CleanFilename(ServerInstance->ConfigFileName)); std::string parameter = ""; std::string old_disabled = ServerInstance->Config->DisabledCommands; if (pcnt) @@ -34,7 +34,7 @@ CmdResult cmd_rehash::Handle (const char** parameters, int pcnt, userrec *user) } else { - ServerInstance->WriteOpers("*** %s is rehashing config file %s",user->nick,ServerConfig::CleanFilename(CONFIG_FILE)); + ServerInstance->WriteOpers("*** %s is rehashing config file %s",user->nick,ServerConfig::CleanFilename(ServerInstance->ConfigFileName)); ServerInstance->CloseLog(); ServerInstance->OpenLog(ServerInstance->Config->argv, ServerInstance->Config->argc); ServerInstance->RehashUsersAndChans(); diff --git a/src/configreader.cpp b/src/configreader.cpp index 315c1eb08..26e9634d1 100644 --- a/src/configreader.cpp +++ b/src/configreader.cpp @@ -682,7 +682,7 @@ void ServerConfig::Read(bool bail, userrec* user) /* Make a copy here so if it fails then we can carry on running with an unaffected config */ ConfigDataHash newconfig; - if (this->LoadConf(newconfig, CONFIG_FILE, errstr)) + if (this->LoadConf(newconfig, ServerInstance->ConfigFileName, errstr)) { /* If we succeeded, set the ircd config to the new one */ this->config_data = newconfig; @@ -1211,7 +1211,7 @@ bool ServerConfig::DoInclude(ConfigDataHash &target, const std::string &file, st std::string newfile; std::string::size_type pos; - confpath = CONFIG_FILE; + confpath = ServerInstance->ConfigFileName; newfile = file; for (std::string::iterator c = newfile.begin(); c != newfile.end(); c++) @@ -1224,7 +1224,7 @@ bool ServerConfig::DoInclude(ConfigDataHash &target, const std::string &file, st if (file[0] != '/') { - if((pos = confpath.find("/inspircd.conf")) != std::string::npos) + if((pos = confpath.rfind("/")) != std::string::npos) { /* Leaves us with just the path */ newfile = confpath.substr(0, pos) + std::string("/") + newfile; @@ -1436,8 +1436,8 @@ bool ServerConfig::ReadFile(file_cache &F, const char* fname) if (*fname != '/') { std::string::size_type pos; - std::string confpath = CONFIG_FILE; - if((pos = confpath.find("/inspircd.conf")) != std::string::npos) + std::string confpath = ServerInstance->ConfigFileName; + if((pos = confpath.rfind("/")) != std::string::npos) { /* Leaves us with just the path */ std::string newfile = confpath.substr(0, pos) + std::string("/") + fname; diff --git a/src/inspircd.cpp b/src/inspircd.cpp index 14bff2bef..7390661dd 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -161,7 +161,7 @@ void InspIRCd::Start() void InspIRCd::Rehash(int status) { - SI->WriteOpers("*** Rehashing config file %s due to SIGHUP",ServerConfig::CleanFilename(CONFIG_FILE)); + SI->WriteOpers("*** Rehashing config file %s due to SIGHUP",ServerConfig::CleanFilename(SI->ConfigFileName)); SI->CloseLog(); SI->OpenLog(SI->Config->argv, SI->Config->argc); SI->RehashUsersAndChans(); @@ -270,8 +270,8 @@ void InspIRCd::WritePID(const std::string &filename) if (*(fname.begin()) != '/') { std::string::size_type pos; - std::string confpath = CONFIG_FILE; - if ((pos = confpath.find("/inspircd.conf")) != std::string::npos) + std::string confpath = this->ConfigFileName; + if ((pos = confpath.rfind("/")) != std::string::npos) { /* Leaves us with just the path */ fname = confpath.substr(0, pos) + std::string("/") + fname; @@ -326,20 +326,14 @@ InspIRCd::InspIRCd(int argc, char** argv) this->next_call = this->TIME + 3; srand(this->TIME); - if (!ServerConfig::FileExists(CONFIG_FILE)) - { - printf("ERROR: Cannot open config file: %s\nExiting...\n",CONFIG_FILE); - this->Log(DEFAULT,"main: no config"); - printf("ERROR: Your config file is missing, this IRCd will self destruct in 10 seconds!\n"); - Exit(EXIT_STATUS_CONFIG); - } - *this->LogFileName = 0; + strlcpy(this->ConfigFileName, CONFIG_FILE, MAXBUF); struct option longopts[] = { { "nofork", no_argument, &do_nofork, 1 }, { "logfile", required_argument, NULL, 'f' }, + { "config", required_argument, NULL, 'c' }, { "debug", no_argument, &do_debug, 1 }, { "nolog", no_argument, &do_nolog, 1 }, { "restart", no_argument, &do_restart, 1 }, @@ -355,6 +349,11 @@ InspIRCd::InspIRCd(int argc, char** argv) strlcpy(LogFileName, optarg, MAXBUF); printf("LOG: Setting logfile to %s\n", LogFileName); break; + case 'c': + /* Config filename was set */ + strlcpy(ConfigFileName, optarg, MAXBUF); + printf("CONFIG: Setting config file to %s\n", ConfigFileName); + break; case 0: /* getopt_long_only() set an int variable, just keep going */ break; @@ -366,6 +365,13 @@ InspIRCd::InspIRCd(int argc, char** argv) } } + if (!ServerConfig::FileExists(this->ConfigFileName)) + { + printf("ERROR: Cannot open config file: %s\nExiting...\n", this->ConfigFileName); + this->Log(DEFAULT,"Unable to open config file %s", this->ConfigFileName); + Exit(EXIT_STATUS_CONFIG); + } + /* Set the finished argument values */ Config->nofork = do_nofork; Config->forcedebug = do_debug; diff --git a/src/modules/extra/m_ssl_gnutls.cpp b/src/modules/extra/m_ssl_gnutls.cpp index daaa8b422..6abc5c1de 100644 --- a/src/modules/extra/m_ssl_gnutls.cpp +++ b/src/modules/extra/m_ssl_gnutls.cpp @@ -158,7 +158,7 @@ class ModuleSSLGnuTLS : public Module } } - std::string confdir(CONFIG_FILE); + std::string confdir(ServerInstance->ConfigFileName); // +1 so we the path ends with a / confdir = confdir.substr(0, confdir.find_last_of('/') + 1); diff --git a/src/modules/extra/m_ssl_openssl.cpp b/src/modules/extra/m_ssl_openssl.cpp index 9ced3a246..def8a0061 100644 --- a/src/modules/extra/m_ssl_openssl.cpp +++ b/src/modules/extra/m_ssl_openssl.cpp @@ -195,7 +195,7 @@ class ModuleSSLOpenSSL : public Module } } - std::string confdir(CONFIG_FILE); + std::string confdir(ServerInstance->ConfigFileName); // +1 so we the path ends with a / confdir = confdir.substr(0, confdir.find_last_of('/') + 1); |