termux-packages/packages/et/temporaryDirectory.patch

160 lines
7.1 KiB
Diff
Raw Normal View History

2021-01-02 17:45:19 +01:00
diff --git a/src/base/Headers.hpp b/src/base/Headers.hpp
index e1cabeb..405f51e 100644
--- a/src/base/Headers.hpp
+++ b/src/base/Headers.hpp
@@ -294,7 +294,7 @@ inline string GetTempDirectory() {
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t> > converter;
std::string tmpDir = converter.to_bytes(wstring(buf, retval));
#else
- string tmpDir = "/tmp";
+ string tmpDir = _PATH_TMP;
#endif
return tmpDir;
}
diff --git a/src/htm/HtmClientMain.cpp b/src/htm/HtmClientMain.cpp
index 75599f3..1b7d226 100644
--- a/src/htm/HtmClientMain.cpp
+++ b/src/htm/HtmClientMain.cpp
@@ -64,9 +64,9 @@ int main(int argc, char** argv) {
el::Loggers::setVerboseLevel(3);
// default max log file size is 20MB for etserver
string maxlogsize = "20971520";
- LogHandler::setupLogFile(&defaultConf, "/tmp/htm.log", maxlogsize);
+ LogHandler::setupLogFile(&defaultConf, GetTempDirectory() + "htm.log", maxlogsize);
// Redirect std streams to a file
- LogHandler::stderrToFile("/tmp/htm");
+ LogHandler::stderrToFile(GetTempDirectory() + "htm");
// Reconfigure default logger to apply settings above
el::Loggers::reconfigureLogger("default", defaultConf);
diff --git a/src/htm/HtmServer.cpp b/src/htm/HtmServer.cpp
index 0d96a06..ca4eba9 100644
--- a/src/htm/HtmServer.cpp
+++ b/src/htm/HtmServer.cpp
@@ -176,6 +176,6 @@ void HtmServer::recover() {
string HtmServer::getPipeName() {
uid_t myuid = getuid();
- return string("/tmp/htm.") + to_string(myuid) + string(".ipc");
+ return string(GetTempDirectory() + "htm.") + to_string(myuid) + string(".ipc");
}
} // namespace et
diff --git a/src/htm/HtmServerMain.cpp b/src/htm/HtmServerMain.cpp
index e6ab21f..de57897 100644
--- a/src/htm/HtmServerMain.cpp
+++ b/src/htm/HtmServerMain.cpp
@@ -18,9 +18,9 @@ int main(int argc, char **argv) {
el::Loggers::setVerboseLevel(3);
// default max log file size is 20MB for etserver
string maxlogsize = "20971520";
- LogHandler::setupLogFile(&defaultConf, "/tmp/htmd.log", maxlogsize);
+ LogHandler::setupLogFile(&defaultConf, GetTempDirectory() + "htmd.log", maxlogsize);
// Redirect std streams to a file
- LogHandler::stderrToFile("/tmp/htmd");
+ LogHandler::stderrToFile(GetTempDirectory() + "htmd");
// Reconfigure default logger to apply settings above
el::Loggers::reconfigureLogger("default", defaultConf);
diff --git a/src/terminal/TerminalMain.cpp b/src/terminal/TerminalMain.cpp
index e61f72c..0794516 100644
--- a/src/terminal/TerminalMain.cpp
+++ b/src/terminal/TerminalMain.cpp
@@ -14,7 +14,7 @@ using namespace et;
void setDaemonLogFile(string idpasskey, string daemonType) {
string first_idpass_chars = idpasskey.substr(0, 10);
string logFile =
- string("/tmp/etterminal_") + daemonType + "_" + first_idpass_chars;
+ string(GetTempDirectory() + "etterminal_") + daemonType + "_" + first_idpass_chars;
}
int main(int argc, char** argv) {
@@ -140,7 +140,7 @@ int main(int argc, char** argv) {
// etserver with --jump cannot write to the default log file(root)
LogHandler::setupLogFile(&defaultConf,
- "/tmp/etjump-" + username + "-" + id + ".log",
+ GetTempDirectory() + "etjump-" + username + "-" + id + ".log",
maxlogsize);
// Reconfigure default logger to apply settings above
el::Loggers::reconfigureLogger("default", defaultConf);
@@ -173,7 +173,7 @@ int main(int argc, char** argv) {
// etserver with --idpasskey cannot write to the default log file(root)
LogHandler::setupLogFile(&defaultConf,
- "/tmp/etterminal-" + username + "-" + id + ".log",
+ GetTempDirectory() + "etterminal-" + username + "-" + id + ".log",
maxlogsize);
// Reconfigure default logger to apply settings above
el::Loggers::reconfigureLogger("default", defaultConf);
diff --git a/src/terminal/TerminalServerMain.cpp b/src/terminal/TerminalServerMain.cpp
index a8d59c6..23fa0ae 100644
--- a/src/terminal/TerminalServerMain.cpp
+++ b/src/terminal/TerminalServerMain.cpp
@@ -28,11 +28,11 @@ int main(int argc, char **argv) {
2021-01-02 17:45:19 +01:00
("logtostdout", "log to stdout") //
("pidfile", "Location of the pid file",
cxxopts::value<std::string>()->default_value(
- "/var/run/etserver.pid")) //
+ "@TERMUX_PREFIX@/var/run/etserver.pid")) //
("v,verbose", "Enable verbose logging",
cxxopts::value<int>()->default_value("0"), "LEVEL") //
("serverfifo",
- "If set, listens on the matching fifo name", //
+ "If set, listens on the matching server fifo name", //
cxxopts::value<std::string>()->default_value(ROUTER_FIFO_NAME)) //
;
2021-01-02 17:45:19 +01:00
@@ -58,7 +58,7 @@ int main(int argc, char **argv) {
} else {
defaultConf.setGlobally(el::ConfigurationType::ToStandardOutput, "false");
// Redirect std streams to a file
- LogHandler::stderrToFile("/tmp/etserver");
+ LogHandler::stderrToFile(GetTempDirectory() + "etserver");
}
string serverFifo = ROUTER_FIFO_NAME;
@@ -89,7 +89,7 @@ int main(int argc, char **argv) {
{
const char *fifoName =
- ini.GetValue("Debug", "serverfifo", ROUTER_FIFO_NAME);
+ ini.GetValue("Debug", "serverfifo", ROUTER_FIFO_NAME.c_str());
if (fifoName) {
serverFifo = string(fifoName);
}
@@ -129,7 +129,7 @@ int main(int argc, char **argv) {
}
// Set log file for etserver process here.
- LogHandler::setupLogFile(&defaultConf, "/tmp/etserver-%datetime.log",
+ LogHandler::setupLogFile(&defaultConf, GetTempDirectory() + "etserver-%datetime.log",
maxlogsize);
// Reconfigure default logger to apply settings above
el::Loggers::reconfigureLogger("default", defaultConf);
diff --git a/src/terminal/UserTerminalRouter.hpp b/src/terminal/UserTerminalRouter.hpp
index 511e207..40aa7f9 100644
--- a/src/terminal/UserTerminalRouter.hpp
+++ b/src/terminal/UserTerminalRouter.hpp
@@ -6,7 +6,7 @@
#include "PipeSocketHandler.hpp"
#include "ServerConnection.hpp"
-#define ROUTER_FIFO_NAME "/tmp/etserver.idpasskey.fifo"
+const string ROUTER_FIFO_NAME = GetTempDirectory() + "etserver.idpasskey.fifo";
namespace et {
class UserTerminalRouter {
diff --git a/src/terminal/forwarding/PortForwardHandler.cpp b/src/terminal/forwarding/PortForwardHandler.cpp
index f046a86..b2422c1 100644
--- a/src/terminal/forwarding/PortForwardHandler.cpp
+++ b/src/terminal/forwarding/PortForwardHandler.cpp
@@ -45,7 +45,7 @@ PortForwardSourceResponse PortForwardHandler::createSource(
source = pfsr.source();
} else {
// Make a random file to forward the pipe
- string sourcePattern = string("/tmp/et_forward_sock_XXXXXX");
+ string sourcePattern = GetTempDirectory() + string("et_forward_sock_XXXXXX");
string sourceDirectory = string(mkdtemp(&sourcePattern[0]));
FATAL_FAIL(::chmod(sourceDirectory.c_str(), S_IRUSR | S_IWUSR | S_IXUSR));
FATAL_FAIL(::chown(sourceDirectory.c_str(), userid, groupid));