diff options
author | Sadie Powell <sadie@witchery.services> | 2024-03-19 15:39:41 +0000 |
---|---|---|
committer | Sadie Powell <sadie@witchery.services> | 2024-03-19 15:51:55 +0000 |
commit | bfed2e1bf5cfb250e17e91566546b38b4b9a34d8 (patch) | |
tree | ecf5ba2049ae1752cff533e060d2dce50983c04e /src | |
parent | e488f294a116224d8c7f89c6c4ebad2356ba7814 (diff) |
Use paths relative to data/conf in the config file.
This was done in some places already but not consistently.
Closes #349.
Diffstat (limited to 'src')
-rw-r--r-- | src/init.cpp | 5 | ||||
-rw-r--r-- | src/messages.cpp | 5 | ||||
-rw-r--r-- | src/misc.cpp | 5 |
3 files changed, 11 insertions, 4 deletions
diff --git a/src/init.cpp b/src/init.cpp index 7cb136844..3881d92e8 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -218,7 +218,10 @@ static void remove_pidfile() static void write_pidfile() { - const auto pidfile = Config->GetBlock("serverinfo")->Get<const Anope::string>("pid"); + auto pidfile = Anope::ExpandData(Config->GetBlock("serverinfo")->Get<const Anope::string>("pid")); + if (pidfile.empty()) + return; + std::ofstream stream(pidfile.str()); if (!stream.is_open()) throw CoreException("Can not write to PID file " + pidfile); diff --git a/src/messages.cpp b/src/messages.cpp index 4b2e134ff..9a0a7a539 100644 --- a/src/messages.cpp +++ b/src/messages.cpp @@ -241,10 +241,11 @@ void MOTD::Run(MessageSource &source, const std::vector<Anope::string> ¶ms, if (s != Me) return; - std::ifstream stream(Config->GetBlock("serverinfo")->Get<const Anope::string>("motd").str()); + auto motdfile = Anope::ExpandConfig(Config->GetBlock("serverinfo")->Get<const Anope::string>("motd")); + std::ifstream stream(motdfile.str()); if (!stream.is_open()) { - IRCD->SendNumeric(ERR_NOSUCHNICK, source.GetSource(), "- MOTD file not found! Please contact your IRC administrator."); + IRCD->SendNumeric(ERR_NOSUCHNICK, source.GetSource(), "- MOTD file not readable! Please contact your IRC administrator."); return; } diff --git a/src/misc.cpp b/src/misc.cpp index 861e6ee20..8a0920fc1 100644 --- a/src/misc.cpp +++ b/src/misc.cpp @@ -810,8 +810,11 @@ void Anope::UpdateTime() #endif } -Anope::string Anope::Expand(const Anope::string& base, const Anope::string& fragment) +Anope::string Anope::Expand(const Anope::string &base, const Anope::string &fragment) { + if (fragment.empty()) + return ""; // We can't expand an empty fragment. + // The fragment is an absolute path, don't modify it. if (std::filesystem::path(fragment.str()).is_absolute()) return fragment; |