1.1 --- a/OpenSecurity/bin/cygwin.py Fri Aug 22 09:35:02 2014 +0100
1.2 +++ b/OpenSecurity/bin/cygwin.py Fri Aug 29 10:56:26 2014 +0100
1.3 @@ -72,6 +72,7 @@
1.4 theClass.vbox_man = os.path.join(theClass.vbox_root, 'VBoxManage.exe')
1.5 #theClass.user_home = os.path.expanduser("~")
1.6 theClass.user_home = os.environ['APPDATA']#os.path.expandvars("%APPDATA%")
1.7 + theClass.allow_exec = True
1.8 return theClass
1.9
1.10
1.11 @@ -87,6 +88,7 @@
1.12 vbox_man = ''
1.13 win_cmd = ''
1.14 user_home = ''
1.15 + allow_exec = True
1.16 """Some nifty methods working with Cygwin"""
1.17
1.18 def __call__(self, command, arguments, wait_return=True, window = False):
1.19 @@ -140,10 +142,22 @@
1.20 def home():
1.21 return Cygwin.user_home
1.22
1.23 + @staticmethod
1.24 + def allowExec():
1.25 + Cygwin.allow_exec = True
1.26 +
1.27 + @staticmethod
1.28 + def denyExec():
1.29 + Cygwin.allow_exec = False
1.30 +
1.31 executeLock = threading.Lock()
1.32 #executes command on host system
1.33 @staticmethod
1.34 def execute(program, arguments, wait_return=True, window = False, stdin = PIPE, stdout = PIPE, stderr = PIPE):
1.35 + if not Cygwin.allow_exec:
1.36 + logger.error('Execution cancelled by system (shutting down).')
1.37 + raise OpenSecurityException('Execution cancelled by system (shutting down).')
1.38 +
1.39 _startupinfo = STARTUPINFO()
1.40 if not window:
1.41 _startupinfo.dwFlags |= _subprocess.STARTF_USESHOWWINDOW
1.42 @@ -254,13 +268,6 @@
1.43 cmd = 'cygpath -u \'' + path + '\''
1.44 return Cygwin.bashExecute(cmd)[1].rstrip('\n')
1.45
1.46 - @staticmethod
1.47 - def checkResult(result):
1.48 - #if result[0] != 0:
1.49 - # logger.error('Command failed:' + ''.join(result[2]))
1.50 - # raise OpenSecurityException('Command failed:' + ''.join(result[2]))
1.51 - return result
1.52 -
1.53 # start
1.54 import os
1.55 import win32api