aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Sadie Powell2025-02-15 14:24:43 +0000
committerGravatar Sadie Powell2025-02-15 14:44:39 +0000
commit6c2100a2e4b6a4d77af615bcd300aa5e5a077358 (patch)
treeee3ed2adf45e2a589b326d764fea94e9d197fa55
parentMove RPL_TIME to the numeric header, unify TIME and ALLTIME. (diff)
Fix expanding paths on portable installations.
Closes #2148.
-rw-r--r--include/inspircd.h2
-rw-r--r--src/configreader.cpp10
-rw-r--r--src/inspircd.cpp2
3 files changed, 11 insertions, 3 deletions
diff --git a/include/inspircd.h b/include/inspircd.h
index 9a2fc34f4..08b1d80f8 100644
--- a/include/inspircd.h
+++ b/include/inspircd.h
@@ -237,7 +237,7 @@ public:
XLineManager* XLines = nullptr;
/** The current server configuration file from --config or configure. */
- std::string ConfigFileName = INSPIRCD_CONFIG_PATH "/inspircd.conf";
+ std::string ConfigFileName;
/** Fills a buffer with random bytes. */
std::function<void(char*, size_t)> GenRandom = &DefaultGenRandom;
diff --git a/src/configreader.cpp b/src/configreader.cpp
index 804406ec4..d49878baa 100644
--- a/src/configreader.cpp
+++ b/src/configreader.cpp
@@ -71,14 +71,22 @@ std::string ServerConfig::ServerPaths::ExpandPath(const std::string& base, const
if (std::filesystem::path(fragment).is_absolute())
return fragment;
- // The fragment is relative to a home directory, expand that.
if (!fragment.compare(0, 2, "~/", 2))
{
+ // The fragment is relative to a home directory, expand that.
const char* homedir = getenv("HOME");
if (homedir && *homedir)
return std::string(homedir) + '/' + fragment.substr(2);
}
+ if (std::filesystem::path(base).is_relative())
+ {
+ // The base is relative to the working directory, expand that.
+ const auto cwd = std::filesystem::current_path();
+ if (!cwd.empty())
+ return INSP_FORMAT("{}/{}/{}", cwd.string(), base, fragment);
+ }
+
return base + '/' + fragment;
}
diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index 5b1f332c9..b9018ea7d 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -255,7 +255,7 @@ namespace
// Parses the command line options.
void ParseOptions()
{
- std::string config;
+ std::string config = ServerInstance->Config->Paths.PrependConfig("inspircd.conf");
bool do_debug = false;
bool do_help = false;
bool do_nofork = false;