fix for UPX linux/macos

This commit is contained in:
Miroslav Stampar 2011-04-21 10:52:34 +00:00
parent 8d8fc2bbd8
commit e1a8d268d8
2 changed files with 10 additions and 1 deletions

View File

@ -1410,7 +1410,11 @@ def decloakToNamedTemporaryFile(filepath, name=None):
return retVal return retVal
def decloakToMkstemp(filepath, **kwargs): 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 = open(name, 'w+b')
retVal.write(decloak(filepath)) retVal.write(decloak(filepath))

View File

@ -9,6 +9,7 @@ See the file 'doc/COPYING' for copying permission
import os import os
import stat
import time import time
from subprocess import PIPE from subprocess import PIPE
@ -19,6 +20,7 @@ from lib.core.common import dataToStdout
from lib.core.common import decloakToMkstemp from lib.core.common import decloakToMkstemp
from lib.core.data import logger from lib.core.data import logger
from lib.core.data import paths from lib.core.data import paths
from lib.core.settings import IS_WIN
from lib.core.settings import PLATFORM from lib.core.settings import PLATFORM
from lib.core.subprocessng import pollProcess from lib.core.subprocessng import pollProcess
@ -51,6 +53,9 @@ class UPX:
self.__upxPath = self.__upxTemp.name self.__upxPath = self.__upxTemp.name
self.__upxTemp.close() #needed for execution rights 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) self.__upxCmd = "%s -9 -qq %s" % (self.__upxPath, srcFile)
if dstFile: if dstFile: