1.1 --- a/OpenSecurity/bin/cygwin.py Thu May 22 12:17:57 2014 +0200
1.2 +++ b/OpenSecurity/bin/cygwin.py Thu Jul 17 10:20:10 2014 +0100
1.3 @@ -52,14 +52,14 @@
1.4 def once(theClass):
1.5 """get the path to our local cygwin installment"""
1.6 home_drive = os.path.expandvars("%HOMEDRIVE%") + os.sep
1.7 + e = Environment('OpenSecurity')
1.8 path_hint = [
1.9 - os.path.abspath(os.path.join(Environment('OpenSecurity').prefix_path, 'cygwin')),
1.10 - os.path.abspath(os.path.join(Environment('OpenSecurity').prefix_path, 'cygwin64')),
1.11 + os.path.abspath(os.path.join(e.prefix_path, 'cygwin')),
1.12 + os.path.abspath(os.path.join(e.prefix_path, 'cygwin64')),
1.13 os.path.abspath(os.path.join(home_drive, 'cygwin')),
1.14 os.path.abspath(os.path.join(home_drive, 'cygwin64'))
1.15 ]
1.16 path_valid = [ p for p in path_hint if os.path.exists(p) ]
1.17 -
1.18 theClass.cygwin_root = path_valid[0]
1.19 theClass.cygwin_bin = os.path.join(theClass.cygwin_root, 'bin') + os.path.sep
1.20 theClass.cygwin_bash = os.path.join(theClass.cygwin_bin, 'bash.exe')
1.21 @@ -150,8 +150,7 @@
1.22 _startupinfo.wShowWindow = _subprocess.SW_HIDE
1.23 #logger.debug('trying to launch: ' + program + ' ' + ''.join(arguments))
1.24
1.25 - result, res_stdout, res_stderr = None, None, None
1.26 -
1.27 + result, res_stdout, res_stderr = None, None, None
1.28 try:
1.29 # quote the executable otherwise we run into troubles
1.30 # when the path contains spaces and additonal arguments
1.31 @@ -163,11 +162,11 @@
1.32 process = Popen(args, startupinfo = _startupinfo, stdin = stdin, stdout = stdout, stderr = stderr, shell = False)
1.33 if not wait_return:
1.34 return [0, 'working in background', '']
1.35 -
1.36 +
1.37 res_stdout, res_stderr = process.communicate()
1.38 result = process.returncode
1.39 logger.debug('Finished: ' + program + ' ' + ''.join(arguments))
1.40 - #result = process.wait()
1.41 + #result = process.wait()
1.42 #res_stdout = process.stdout.read();
1.43 #res_stderr = process.stderr.read();
1.44
1.45 @@ -178,10 +177,10 @@
1.46 return result, res_stdout, res_stderr
1.47
1.48 @staticmethod
1.49 - def vboxExecute(command, wait_return=True, window = False, bash_opts=''):
1.50 + def vboxExecute(command, wait_return=True, window = False, bash_opts='', try_count = 3):
1.51 retry = 0
1.52 result = None
1.53 - while retry < 3:
1.54 + while retry < try_count:
1.55 if Cygwin.executeLock.acquire(True):
1.56 result = Cygwin.execute(Cygwin.vbox_man, command, wait_return, window)
1.57 Cygwin.executeLock.release()
1.58 @@ -209,8 +208,8 @@
1.59 def sshExecute(command, address, user_name, certificate, wait_return=True, window = False):
1.60 command = ' -v -o StrictHostKeyChecking=no -i "' + certificate + '" ' + user_name + '@' + address + ' ' + command
1.61 return Cygwin.execute(Cygwin.cygwin_ssh, command, wait_return, window)
1.62 -
1.63 - # executes command over ssh on guest vm
1.64 +
1.65 + # executes command over ssh on guest vm
1.66 @staticmethod
1.67 def sshBackgroundExecute(command, address, user_name, certificate, wait_return=True, window = False):
1.68 command = ' -f -v -o StrictHostKeyChecking=no -i "' + certificate + '" ' + user_name + '@' + address + ' ' + command
1.69 @@ -263,12 +262,12 @@
1.70 if __name__ == "__main__":
1.71 logger = setupLogger('Cygwin')
1.72 c = Cygwin()
1.73 - #logger.info(c.root())
1.74 - #logger.info(c.bin())
1.75 - #logger.info(c.bash())
1.76 - #logger.info(c.ssh())
1.77 - #logger.info(c.x11())
1.78 - #logger.info(c.home())
1.79 + logger.info(c.root())
1.80 + logger.info(c.bin())
1.81 + logger.info(c.bash())
1.82 + logger.info(c.ssh())
1.83 + logger.info(c.x11())
1.84 + logger.info(c.home())
1.85
1.86 #PSEXEC -i -s -d CMD
1.87 #tasklist /v /fo list /fi "IMAGENAME eq explorer.exe"
1.88 @@ -277,8 +276,6 @@
1.89 #runner.start()
1.90
1.91 #Cygwin.start_X11()
1.92 -
1.93 -
1.94
1.95 #time.sleep(500)
1.96