*/
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
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;
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)
{
F.clear();
- if ((*fname != '/') && (*fname != '\\'))
+ if ((*fname != '/') && (*fname != '\\') && (!StartsWithWindowsDriveLetter(fname)))
{
std::string::size_type pos;
std::string confpath = ServerInstance->ConfigFileName;
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;
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;
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