summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/common/Utilities/StringFormat.cpp14
-rw-r--r--src/common/Utilities/StringFormat.h2
-rw-r--r--src/server/apps/authserver/authserver.conf.dist12
-rw-r--r--src/server/apps/worldserver/worldserver.conf.dist12
-rw-r--r--src/server/database/Updater/DBUpdater.cpp19
-rw-r--r--src/tools/dbimport/dbimport.conf.dist11
6 files changed, 65 insertions, 5 deletions
diff --git a/src/common/Utilities/StringFormat.cpp b/src/common/Utilities/StringFormat.cpp
index 83e2d2a468..c547a2d710 100644
--- a/src/common/Utilities/StringFormat.cpp
+++ b/src/common/Utilities/StringFormat.cpp
@@ -64,5 +64,19 @@ std::string Acore::String::TrimRightInPlace(std::string& str)
return str;
}
+/**
+ * @brief Util function to add a suffix char. Can be used to add a slash at the end of a path
+ *
+ * @param str String where to apply the suffix
+ * @param suffix Character to add at the end of the str
+ * @return std::string Suffixed string
+ */
+std::string Acore::String::AddSuffixIfNotExists(std::string str, const char suffix) {
+ if (str.empty() || (str.at(str.length() - 1) != suffix))
+ str.push_back(suffix);
+
+ return str;
+}
+
// Template Trim
template AC_COMMON_API std::string Acore::String::Trim<std::string>(const std::string& s, const std::locale& loc /*= std::locale()*/);
diff --git a/src/common/Utilities/StringFormat.h b/src/common/Utilities/StringFormat.h
index e0e4d1aac9..b91509181f 100644
--- a/src/common/Utilities/StringFormat.h
+++ b/src/common/Utilities/StringFormat.h
@@ -72,6 +72,8 @@ namespace Acore::String
AC_COMMON_API Str Trim(const Str& s, const std::locale& loc = std::locale());
AC_COMMON_API std::string TrimRightInPlace(std::string& str);
+
+ AC_COMMON_API std::string AddSuffixIfNotExists(std::string str, const char suffix);
}
#endif
diff --git a/src/server/apps/authserver/authserver.conf.dist b/src/server/apps/authserver/authserver.conf.dist
index 923074c332..d11634cf76 100644
--- a/src/server/apps/authserver/authserver.conf.dist
+++ b/src/server/apps/authserver/authserver.conf.dist
@@ -167,7 +167,7 @@ SourceDirectory = ""
# Description: The path to your MySQL CLI binary.
# If the path is left empty, built-in path from cmake is used.
# Example: "C:/Program Files/MariaDB 10.5/bin/mysql.exe"
-# "C:/Program Files/MySQL/MySQL Server 5.6/bin/mysql.exe"
+# "C:/Program Files/MySQL/MySQL Server 8.0/bin/mysql.exe"
# "mysql.exe"
# "/usr/bin/mysql"
# Default: ""
@@ -176,6 +176,16 @@ SourceDirectory = ""
MySQLExecutable = ""
#
+# TempDir
+# Description: Temp directory setting.
+# Important: TempDir needs to be quoted, as the string might contain space characters.
+# TempDir directory must exists, or the server can't work properly
+# Example: "/home/youruser/azerothcore/temp"
+# Default: "" - (Temp files will be stored in the current path)
+
+TempDir = ""
+
+#
# IPLocationFile
# Description: The path to your IP2Location database CSV file.
# Example: "C:/acore/IP2LOCATION-LITE-DB1.CSV"
diff --git a/src/server/apps/worldserver/worldserver.conf.dist b/src/server/apps/worldserver/worldserver.conf.dist
index 65b54feb76..93a40d63fe 100644
--- a/src/server/apps/worldserver/worldserver.conf.dist
+++ b/src/server/apps/worldserver/worldserver.conf.dist
@@ -82,6 +82,16 @@ DataDir = "."
LogsDir = ""
#
+# TempDir
+# Description: Temp directory setting.
+# Important: TempDir needs to be quoted, as the string might contain space characters.
+# TempDir directory must exists, or the server can't work properly
+# Example: "/home/youruser/azerothcore/temp"
+# Default: "" - (Temp files will be stored in the current path)
+
+TempDir = ""
+
+#
# LoginDatabaseInfo
# WorldDatabaseInfo
# CharacterDatabaseInfo
@@ -193,7 +203,7 @@ SourceDirectory = ""
# MySQLExecutable
# Description: The path to your MySQL CLI binary.
# If the path is left empty, built-in path from cmake is used.
-# Example: "C:/Program Files/MySQL/MySQL Server 5.7/bin/mysql.exe"
+# Example: "C:/Program Files/MySQL/MySQL Server 8.0/bin/mysql.exe"
# "mysql.exe"
# "/usr/bin/mysql"
# Default: ""
diff --git a/src/server/database/Updater/DBUpdater.cpp b/src/server/database/Updater/DBUpdater.cpp
index 295c34986e..95371d895c 100644
--- a/src/server/database/Updater/DBUpdater.cpp
+++ b/src/server/database/Updater/DBUpdater.cpp
@@ -442,16 +442,29 @@ template<class T>
void DBUpdater<T>::ApplyFile(DatabaseWorkerPool<T>& pool, std::string const& host, std::string const& user,
std::string const& password, std::string const& port_or_socket, std::string const& database, std::string const& ssl, Path const& path)
{
+ std::string configTempDir = sConfigMgr->GetOption<std::string>("TempDir", "");
+
+ auto tempDir = configTempDir.empty() ? std::filesystem::temp_directory_path().string() : configTempDir;
+
+ tempDir = Acore::String::AddSuffixIfNotExists(tempDir, std::filesystem::path::preferred_separator);
+
+ std::string confFileName = "mysql_ac.conf";
+
+ std::ofstream outfile (tempDir + confFileName);
+
+ outfile << "[client]\npassword = \"" << password << '"' << std::endl;
+
+ outfile.close();
+
std::vector<std::string> args;
args.reserve(9);
+ args.emplace_back("--defaults-extra-file="+tempDir + confFileName+"");
+
// CLI Client connection info
args.emplace_back("-h" + host);
args.emplace_back("-u" + user);
- if (!password.empty())
- args.emplace_back("-p" + password);
-
// Check if we want to connect through ip or socket (Unix only)
#ifdef _WIN32
diff --git a/src/tools/dbimport/dbimport.conf.dist b/src/tools/dbimport/dbimport.conf.dist
index b4c1e77a45..656bdd35b8 100644
--- a/src/tools/dbimport/dbimport.conf.dist
+++ b/src/tools/dbimport/dbimport.conf.dist
@@ -61,6 +61,17 @@ SourceDirectory = ""
#
MySQLExecutable = ""
+
+#
+# TempDir
+# Description: Temp directory setting.
+# Important: TempDir needs to be quoted, as the string might contain space characters.
+# TempDir directory must exists, or the server can't work properly
+# Example: "/home/youruser/azerothcore/temp"
+# Default: "" - (Temp files will be stored in the current path)
+
+TempDir = ""
+
###################################################################################################
###################################################################################################