]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Check for windows drive letters on the start of paths and treat them the same as...
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Tue, 13 May 2008 17:16:26 +0000 (17:16 +0000)
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Tue, 13 May 2008 17:16:26 +0000 (17:16 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@9724 e03df62e-2008-0410-955e-edbf42e46eb7

include/configreader.h
src/configreader.cpp
src/inspircd.cpp
src/modules/extra/m_ssl_gnutls.cpp
src/modules/extra/m_ssl_openssl.cpp

index aea3555833169e2e5014983a2d13779884c8ac63..86191fa6d208327ff71601e19b7c91d06e155413 100644 (file)
@@ -681,6 +681,10 @@ class CoreExport ServerConfig : public Extensible
         */
        bool ReadFile(file_cache &F, const char* fname);
 
+       /* Returns true if the given string starts with a windows drive letter
+        */
+       bool StartsWithWindowsDriveLetter(const std::string &path);
+
        /** Report a configuration error given in errormessage.
         * @param bail If this is set to true, the error is sent to the console, and the program exits
         * @param user If this is set to a non-null value, and bail is false, the errors are spooled to
index 5b582b7138d1f71f2321d4489d6effe84168faec..3f99a52e21791197ad55dbc0bc947ea56f1fb7cc 100644 (file)
@@ -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;
index 97e2c77e352d9da2fecc4f477caaf606687b4484..50e76b2a2427ee9dd3e24e2b58c1bd23580bd72d 100644 (file)
@@ -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;
index 4b9d0fc4e8777e8d9232b59b84dea10d22072d09..70c87d5fa57bdce4f88ca6ded95962b1c745499e 100644 (file)
@@ -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;
index 4691b874e439188a82331929dacfb7b002cbe56e..304e579892e62b9295bcd18d85bf4e66101f6243 100644 (file)
@@ -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