From e1a8d268d8353d40cd5f257b05b5b5e02c8a2b1a Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Thu, 21 Apr 2011 10:52:34 +0000 Subject: [PATCH] fix for UPX linux/macos --- lib/core/common.py | 6 +++++- lib/takeover/upx.py | 5 +++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/core/common.py b/lib/core/common.py index 6e1e6b3c2..4a7b13267 100644 --- a/lib/core/common.py +++ b/lib/core/common.py @@ -1410,7 +1410,11 @@ def decloakToNamedTemporaryFile(filepath, name=None): return retVal def decloakToMkstemp(filepath, **kwargs): - name = mkstemp(**kwargs)[1] + handle, name = mkstemp(**kwargs) + + fptr = os.fdopen(handle) + fptr.close() # close low level handle (causing problems latter) + retVal = open(name, 'w+b') retVal.write(decloak(filepath)) diff --git a/lib/takeover/upx.py b/lib/takeover/upx.py index 20324619f..37cb2eb9b 100644 --- a/lib/takeover/upx.py +++ b/lib/takeover/upx.py @@ -9,6 +9,7 @@ See the file 'doc/COPYING' for copying permission import os +import stat import time from subprocess import PIPE @@ -19,6 +20,7 @@ from lib.core.common import dataToStdout from lib.core.common import decloakToMkstemp from lib.core.data import logger from lib.core.data import paths +from lib.core.settings import IS_WIN from lib.core.settings import PLATFORM from lib.core.subprocessng import pollProcess @@ -51,6 +53,9 @@ class UPX: self.__upxPath = self.__upxTemp.name self.__upxTemp.close() #needed for execution rights + if not IS_WIN: + os.chmod(self.__upxPath, stat.S_IXUSR) + self.__upxCmd = "%s -9 -qq %s" % (self.__upxPath, srcFile) if dstFile: