From 9f33bf7fc83cffccae96eb622bf39e8f4838b809 Mon Sep 17 00:00:00 2001 From: brain Date: Tue, 13 May 2008 17:16:26 +0000 Subject: Check for windows drive letters on the start of paths and treat them the same as paths that start with /, this makes insp more friendly for windows filesystems git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@9724 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/configreader.cpp | 9 +++++++-- src/inspircd.cpp | 3 ++- src/modules/extra/m_ssl_gnutls.cpp | 8 ++++---- src/modules/extra/m_ssl_openssl.cpp | 8 ++++---- 4 files changed, 17 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/configreader.cpp b/src/configreader.cpp index 5b582b713..3f99a52e2 100644 --- a/src/configreader.cpp +++ b/src/configreader.cpp @@ -1649,6 +1649,11 @@ bool ServerConfig::DoPipe(ConfigDataHash &target, const std::string &file, std:: return ret; } +bool ServerConfig::StartsWithWindowsDriveLetter(const std::string &path) +{ + return (path.length() > 2 && isalpha(path[0]) && path[1] == ':'); +} + bool ServerConfig::DoInclude(ConfigDataHash &target, const std::string &file, std::ostringstream &errorstream) { std::string confpath; @@ -1661,7 +1666,7 @@ bool ServerConfig::DoInclude(ConfigDataHash &target, const std::string &file, st std::replace(newfile.begin(),newfile.end(),'\\','/'); std::replace(confpath.begin(),confpath.end(),'\\','/'); - if ((newfile[0] != '/') && (newfile.find("://") == std::string::npos)) + if ((newfile[0] != '/') && (!StartsWithWindowsDriveLetter(newfile))) { if((pos = confpath.rfind("/")) != std::string::npos) { @@ -1883,7 +1888,7 @@ bool ServerConfig::ReadFile(file_cache &F, const char* fname) F.clear(); - if ((*fname != '/') && (*fname != '\\')) + if ((*fname != '/') && (*fname != '\\') && (!StartsWithWindowsDriveLetter(fname))) { std::string::size_type pos; std::string confpath = ServerInstance->ConfigFileName; diff --git a/src/inspircd.cpp b/src/inspircd.cpp index 97e2c77e3..50e76b2a2 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -351,7 +351,8 @@ bool InspIRCd::DaemonSeed() void InspIRCd::WritePID(const std::string &filename) { std::string fname = (filename.empty() ? "inspircd.pid" : filename); - if (*(fname.begin()) != '/') + std::replace(fname.begin(), fname.end(), '\\', '/'); + if ((fname[0] != '/') && (!Config->StartsWithWindowsDriveLetter(filename))) { std::string::size_type pos; std::string confpath = this->ConfigFileName; diff --git a/src/modules/extra/m_ssl_gnutls.cpp b/src/modules/extra/m_ssl_gnutls.cpp index 4b9d0fc4e..70c87d5fa 100644 --- a/src/modules/extra/m_ssl_gnutls.cpp +++ b/src/modules/extra/m_ssl_gnutls.cpp @@ -220,16 +220,16 @@ class ModuleSSLGnuTLS : public Module dh_bits = 1024; // Prepend relative paths with the path to the config directory. - if(cafile[0] != '/') + if ((cafile[0] != '/') && (!ServerInstance->Config->StartsWithWindowsDriveLetter(cafile))) cafile = confdir + cafile; - if(crlfile[0] != '/') + if ((crlfile[0] != '/') && (!ServerInstance->Config->StartsWithWindowsDriveLetter(crlfile))) crlfile = confdir + crlfile; - if(certfile[0] != '/') + if ((certfile[0] != '/') && (!ServerInstance->Config->StartsWithWindowsDriveLetter(certfile))) certfile = confdir + certfile; - if(keyfile[0] != '/') + if ((keyfile[0] != '/') && (!ServerInstance->Config->StartsWithWindowsDriveLetter(keyfile))) keyfile = confdir + keyfile; int ret; diff --git a/src/modules/extra/m_ssl_openssl.cpp b/src/modules/extra/m_ssl_openssl.cpp index 4691b874e..304e57989 100644 --- a/src/modules/extra/m_ssl_openssl.cpp +++ b/src/modules/extra/m_ssl_openssl.cpp @@ -244,16 +244,16 @@ class ModuleSSLOpenSSL : public Module dhfile = "dhparams.pem"; // Prepend relative paths with the path to the config directory. - if (cafile[0] != '/') + if ((cafile[0] != '/') && (!ServerInstance->Config->StartsWithWindowsDriveLetter(cafile))) cafile = confdir + cafile; - if (certfile[0] != '/') + if ((certfile[0] != '/') && (!ServerInstance->Config->StartsWithWindowsDriveLetter(certfile))) certfile = confdir + certfile; - if (keyfile[0] != '/') + if ((keyfile[0] != '/') && (!ServerInstance->Config->StartsWithWindowsDriveLetter(keyfile))) keyfile = confdir + keyfile; - if (dhfile[0] != '/') + if ((dhfile[0] != '/') && (!ServerInstance->Config->StartsWithWindowsDriveLetter(dhfile))) dhfile = confdir + dhfile; /* Load our keys and certificates -- cgit v1.2.3