1.1 --- a/OpenSecurity/bin/cygwin.py Fri Mar 07 14:32:12 2014 +0100
1.2 +++ b/OpenSecurity/bin/cygwin.py Tue Mar 18 16:28:15 2014 +0100
1.3 @@ -204,6 +204,7 @@
1.4 return
1.5 # launch X11 (forget output and return immediately)
1.6 return Cygwin.execute(Cygwin.cygwin_x11, ':0 -multiwindow', wait_return = False, window = False)
1.7 + #return 0, None, None
1.8
1.9 @staticmethod
1.10 def cygPath(path):
1.11 @@ -220,3 +221,6 @@
1.12
1.13 c.cygPath('C:')
1.14 c.start_X11()
1.15 + logger.info('X11 started')
1.16 + logger.info("X11 running: " + str(c.is_X11_running()))
1.17 +
2.1 --- a/OpenSecurity/bin/opensecurity_tray.pyw Fri Mar 07 14:32:12 2014 +0100
2.2 +++ b/OpenSecurity/bin/opensecurity_tray.pyw Tue Mar 18 16:28:15 2014 +0100
2.3 @@ -44,7 +44,6 @@
2.4 # local
2.5 from about import About
2.6 from environment import Environment
2.7 -from cygwin import Cygwin
2.8
2.9 # ------------------------------------------------------------
2.10 # code
2.11 @@ -103,7 +102,6 @@
2.12 try:
2.13
2.14 # get a proper browsing VM
2.15 - Cygwin.start_X11()
2.16 browsing_vm = urllib2.urlopen('http://127.0.0.1:8080/browsing').readline()
2.17 #dlg_launch_image = os.path.join(sys.path[0], 'launch.pyw')
2.18 #process_command = [sys.executable, dlg_launch_image, browsing_vm, '/usr/bin/iceweasel']
3.1 --- a/OpenSecurity/bin/os-admind.bat Fri Mar 07 14:32:12 2014 +0100
3.2 +++ b/OpenSecurity/bin/os-admind.bat Tue Mar 18 16:28:15 2014 +0100
3.3 @@ -1,4 +1,4 @@
3.4 @echo off
3.5 cd %0%\..
3.6 -C:\Python27\python opensecurityd.pyw 8080
3.7 +C:\Python27\pythonw opensecurityd.pyw 8080
3.8
4.1 --- a/OpenSecurity/bin/vmmanager.pyw Fri Mar 07 14:32:12 2014 +0100
4.2 +++ b/OpenSecurity/bin/vmmanager.pyw Tue Mar 18 16:28:15 2014 +0100
4.3 @@ -220,6 +220,7 @@
4.4
4.5 # list storage snaphots for VM
4.6 def updateTemplate(self):
4.7 +
4.8 self.cleanup()
4.9 self.poweroffVM('SecurityDVM')
4.10 self.waitShutdown('SecurityDVM')
4.11 @@ -303,7 +304,7 @@
4.12
4.13 # stop VM
4.14 def hibernateVM(self, vm_name):
4.15 - logger.info('Sending shutdown signal to ' + vm_name)
4.16 + logger.info('Sending hibernate-disk signal to ' + vm_name)
4.17 checkResult(Cygwin.sshExecute( '"sudo hibernate-disk&"', VMManager.getHostOnlyIP(vm_name), 'osecuser', Cygwin.cygPath(self.machineFolder) + '/' + vm_name + '/dvm_key', wait_return=False))
4.18
4.19 # poweroff VM
4.20 @@ -518,7 +519,7 @@
4.21 return result
4.22
4.23 # handles browsing request
4.24 -class BrowsingHandler(threading.Thread):
4.25 +class BrowsingHandler(threading.Thread):
4.26 vmm = None
4.27 def __init__(self, vmmanager):
4.28 threading.Thread.__init__(self)
4.29 @@ -526,6 +527,7 @@
4.30
4.31 def run(self):
4.32 try:
4.33 + Cygwin.start_X11()
4.34 new_sdvm = self.vmm.generateSDVMName()
4.35 self.vmm.createVM(new_sdvm)
4.36 self.vmm.storageAttach(new_sdvm)
4.37 @@ -536,7 +538,10 @@
4.38 drive = self.vmm.genNetworkDrive()
4.39 if new_ip != None:
4.40 self.vmm.mapNetworkDrive(drive, '\\\\' + new_ip + '\\Download', None, None)
4.41 - result = checkResult(Cygwin.sshExecuteX11('/usr/bin/iceweasel', new_ip, 'osecuser', Cygwin.cygPath(self.vmm.getMachineFolder()) + '/' + new_sdvm + '/dvm_key'))
4.42 + #browser = '/usr/bin/iceweasel'
4.43 + #browser = '/usr/bin/midori'
4.44 + browser = '/usr/bin/chromium'
4.45 + result = checkResult(Cygwin.sshExecuteX11(browser, new_ip, 'osecuser', Cygwin.cygPath(self.vmm.getMachineFolder()) + '/' + new_sdvm + '/dvm_key'))
4.46 except:
4.47 logger.error("BrowsingHandler failed. Cleaning up")
4.48
4.49 @@ -546,7 +551,6 @@
4.50
4.51 class DeviceHandler(threading.Thread):
4.52 vmm = None
4.53 - #handleDeviceChangeLock = threading.Lock()
4.54 attachedRSDs = None
4.55 connectedRSDs = None
4.56 running = True
4.57 @@ -559,9 +563,21 @@
4.58
4.59 def run(self):
4.60 self.connectedRSDs = dict()
4.61 - self.attachedRSDs = self.vmm.getAttachedRSDs()
4.62 while self.running:
4.63 tmp_rsds = self.vmm.getConnectedRSDS()
4.64 +
4.65 + self.attachedRSDs = self.vmm.getAttachedRSDs()
4.66 + for vm_name in self.attachedRSDs.keys():
4.67 + if self.attachedRSDs[vm_name] not in tmp_rsds.values():
4.68 + drive = self.vmm.getNetworkDrive(vm_name)
4.69 + self.vmm.unmapNetworkDrive(drive)
4.70 + #self.stopVM(vm_name)
4.71 + self.vmm.detachRSD(vm_name)
4.72 + self.vmm.poweroffVM(vm_name)
4.73 + self.vmm.removeVM(vm_name)
4.74 + break
4.75 +
4.76 +
4.77 if tmp_rsds.keys() == self.connectedRSDs.keys():
4.78 logger.debug("Nothing's changed. sleep(3)")
4.79 time.sleep(3)
4.80 @@ -569,16 +585,9 @@
4.81
4.82 logger.info("Something's changed")
4.83 self.connectedRSDs = tmp_rsds
4.84 - self.attachedRSDs = self.vmm.getAttachedRSDs()
4.85
4.86 - for vm_name in self.attachedRSDs.keys():
4.87 - if self.attachedRSDs[vm_name] not in self.connectedRSDs.values():
4.88 - drive = self.vmm.getNetworkDrive(vm_name)
4.89 - self.vmm.unmapNetworkDrive(drive)
4.90 - #self.stopVM(vm_name)
4.91 - self.vmm.detachRSD(vm_name)
4.92 - self.vmm.poweroffVM(vm_name)
4.93 - self.vmm.removeVM(vm_name)
4.94 +
4.95 +
4.96 #create new vm for attached device if any
4.97 self.attachedRSDs = self.vmm.getAttachedRSDs()
4.98 self.connectedRSDs = self.vmm.getConnectedRSDS()