termux-packages/packages/megacmd/src-comunicationsmanagerfil...

57 lines
2.6 KiB
Diff

--- a/src/comunicationsmanagerfilesockets.cpp
+++ b/src/comunicationsmanagerfilesockets.cpp
@@ -76,10 +76,10 @@ int ComunicationsManagerFileSockets::cre
return -1;
}
- char socket_path[60];
+ char socket_path[] = "@TERMUX_PREFIX@/tmp/megaCMD_XXXXXXXXXXXXXXXXXXXX/srv_XXXXXXXXXXX";
*sockId = get_next_comm_id();
bzero(socket_path, sizeof( socket_path ) * sizeof( *socket_path ));
- sprintf(socket_path, "/tmp/megaCMD_%d/srv_%d", getuid(), *sockId);
+ sprintf(socket_path, "@TERMUX_PREFIX@/tmp/megaCMD_%d/srv_%d", getuid(), *sockId);
struct sockaddr_un addr;
socklen_t saddrlen = sizeof( addr );
@@ -140,8 +140,8 @@ ComunicationsManagerFileSockets::Comunic
int ComunicationsManagerFileSockets::initialize()
{
MegaFileSystemAccess *fsAccess = new MegaFileSystemAccess();
- char csocketsFolder[34]; // enough to hold all numbers up to 64-bits
- sprintf(csocketsFolder, "/tmp/megaCMD_%d", getuid());
+ char csocketsFolder[] = "@TERMUX_PREFIX@/tmp/megaCMD_XXXXXXXXXXXXXXXXXXXX"; // enough to hold all numbers up to 64-bits
+ sprintf(csocketsFolder, "@TERMUX_PREFIX@/tmp/megaCMD_%d", getuid());
LocalPath socketsFolder = LocalPath::fromLocalname(csocketsFolder);
fsAccess->setdefaultfolderpermissions(0700);
@@ -169,9 +169,9 @@ int ComunicationsManagerFileSockets::ini
memset(&addr, 0, sizeof( addr ));
addr.sun_family = AF_UNIX;
- char socketPath[60];
+ char socketPath[] = "@TERMUX_PREFIX@/tmp/megaCMD_XXXXXXXXXXXXXXXXXXXX/srv";
bzero(socketPath, sizeof( socketPath ) * sizeof( *socketPath ));
- sprintf(socketPath, "/tmp/megaCMD_%d/srv", getuid());
+ sprintf(socketPath, "@TERMUX_PREFIX@/tmp/megaCMD_%d/srv", getuid());
strncpy(addr.sun_path, socketPath, sizeof( addr.sun_path ) - 1);
@@ -236,7 +236,7 @@ void ComunicationsManagerFileSockets::st
{ //shutdown failed. we need to send something to the blocked thread so as to wake up from select
int clientsocket = socket(AF_UNIX, SOCK_STREAM, 0);
- char socket_path[60];
+ char socket_path[] = "@TERMUX_PREFIX@/tmp/megaCMD_XXXXXXXXXXXXXXXXXXXX/srv";
if (clientsocket < 0 )
{
LOG_err << "ERROR opening client socket to exit select: " << errno;
@@ -250,7 +250,7 @@ void ComunicationsManagerFileSockets::st
}
bzero(socket_path, sizeof( socket_path ) * sizeof( *socket_path ));
{
- sprintf(socket_path, "/tmp/megaCMD_%d/srv", getuid() );
+ sprintf(socket_path, "@TERMUX_PREFIX@/tmp/megaCMD_%d/srv", getuid() );
}
struct sockaddr_un addr;