# HG changeset patch # User dyle@opensecurity.d03.arc.local # Date 1390835553 0 # Node ID 1238895dc6b620202249d88dfce2ad8ed64b0b17 # Parent 9e8fffdb8f47d1bb83e840c7355ac1706428a3ca working on installment and console-less diff -r 9e8fffdb8f47 -r 1238895dc6b6 OpenSecurity/bin/cygwin.py --- a/OpenSecurity/bin/cygwin.py Thu Jan 23 17:03:27 2014 +0000 +++ b/OpenSecurity/bin/cygwin.py Mon Jan 27 15:12:33 2014 +0000 @@ -67,19 +67,25 @@ return path_valid[0] - def execute(self, command, stdin = subprocess.PIPE, stdout = subprocess.PIPE, stderr = subprocess.PIPE): + def execute(self, command, stdin = subprocess.PIPE, stdout = subprocess.PIPE, stderr = subprocess.PIPE, dos_window = False): """execute a cygwin shell command command is list of arguments like ['/bin/ls', '-al', '-h'] a Popen object is returned""" - command_path = Cygwin.root() + os.sep.join(command[0].split('/')) + command_path = os.sep.join([Cygwin.root()] + command[0].split('/')[1:]) command = [command_path] + command[1:] - + + # with or without DOS window + if not dos_window: + run_command = os.sep.join([Cygwin.root()] + ['bin', 'run']) + command = [run_command] + command + try: + print('cygwin: ' + ' '.join(command)) return subprocess.Popen(command, shell = False, stdin = stdin, stdout = stdout, stderr = stderr) except: - sys.stderr.writeln('Failed to execute cygwin command.\n\tcommand="' + command + '"') + sys.stderr.write('Failed to execute cygwin command.\n\tcommand="' + ' '.join(command) + '"\n') @staticmethod diff -r 9e8fffdb8f47 -r 1238895dc6b6 OpenSecurity/bin/launch.pyw --- a/OpenSecurity/bin/launch.pyw Thu Jan 23 17:03:27 2014 +0000 +++ b/OpenSecurity/bin/launch.pyw Mon Jan 27 15:12:33 2014 +0000 @@ -238,7 +238,10 @@ # ensure we have our X11 running Cygwin.start_X11() - + + sys.exit(0) + + # call the OpenSecurity Admin to launch our progie =) # TODO: hard coded PORT url = 'http://127.0.0.1:8080/sdvms/' + args.vm + '/application' + args.command diff -r 9e8fffdb8f47 -r 1238895dc6b6 OpenSecurity/bin/vmmanager.py --- a/OpenSecurity/bin/vmmanager.py Thu Jan 23 17:03:27 2014 +0000 +++ b/OpenSecurity/bin/vmmanager.py Mon Jan 27 15:12:33 2014 +0000 @@ -15,6 +15,9 @@ import time import string +#import shutil +#import stat + DEBUG = True class VMManagerException(Exception): @@ -284,6 +287,57 @@ #generates ISO containing authorized_keys for use with guest VM def genCertificateISO(self, vm_name): machineFolder = self.getDefaultMachineFolder() + + ## create a SSH key pair in a machine subfolder + #vm_folder = os.path.join(machineFolder, vm_name) + #ssh_folder = os.path.join(vm_folder, '.ssh') + #try: + # os.mkdir(ssh_folder) + #except: + # pass + #ssh_keyfile = os.path.join(ssh_folder, 'dvm_key') + # + # delete old key file (if existing) + #try: + # os.remove(ssh_keyfile) + #except: + # pass + # + ## create new key file + #try: + # p = Cygwin()(['/bin/ssh-keygen', '-q', '-t', 'rsa', '-N', '', '-C', vm_name, '-f', ssh_keyfile]) + # p.wait() + #except: + # sys.stderr.write('failed to create a new SSH key pair as: ' + ssh_keyfile + '\n') + # return + #try: + # os.chmod(ssh_keyfile, stat.S_IREAD) + #except: + # pass + # + ## move out private key + #try: + # os.rename(ssh_keyfile, os.path.join(vm_folder, 'dvm_key')) + #except : + # sys.stderr.write('failed to move private SSH key\n') + # return + # + ## rename public key to 'authorized_keys' + #try: + # os.rename(ssh_keyfile + '.pub', os.path.join(ssh_folder, 'authorized_keys')) + #except: + # sys.stderr.write('failed to rename public key to "authorized_keys"\n') + # return + # + ## generate ISO image + #iso_file = os.path.join(vm_folder, vm_name + '.iso') + #try: + # p = Cygwin()(['/bin/genisoimage', '-J', '-R', '-o', iso_file, ssh_folder]) + # p.wait() + #except: + # sys.stderr.write('failed to create ISO image.\n') + # return + # create .ssh folder in vm_name cmd = self.cygwin_path+'bash.exe --login -c \"mkdir -p \\\"' + machineFolder + '\\' + vm_name + '\\.ssh\\\"\"' self.execute(cmd) @@ -468,4 +522,4 @@ time.sleep(60) #cmd = "c:\\cygwin64\\bin\\bash.exe --login -c \"/bin/ls\"" #man.execute(cmd) - \ No newline at end of file + diff -r 9e8fffdb8f47 -r 1238895dc6b6 OpenSecurity/install/initial_vm.bat --- a/OpenSecurity/install/initial_vm.bat Thu Jan 23 17:03:27 2014 +0000 +++ b/OpenSecurity/install/initial_vm.bat Mon Jan 27 15:12:33 2014 +0000 @@ -1,37 +1,58 @@ @echo off rem ensure environment is ready + +rem This gets up VirtualBox VBoxSVC.exe COM Server right +rem and thus helps us not to run in any timing problems +rem due to a lazy VBox COM Server ... o.O +VBoxManage list vms > %TEMP%\VMS.txt +del %TEMP%\VMS.txt + +rem Now, VBox should feel good within the Windows OS space +rem switch into the User's VBox setup folders C: -cd "C:\Documents and Settings\%USERNAME%\VirtualBox VMs" +cd "C:\Users\%USERNAME% +mkdir "VirtualBox VMs" +cd "VirtualBox VMs" rem get recent initial VM and create disk image echo "download initial OpenSecurity VM" rem wget http://service.x-net.at/opensecurity/OsecVM_initialized.ova -VBoxManage.exe import OsecVM_initialized.ova --vsys 0 --vmname SecurityDVM --unit 12 --disk SecurityDVM.vmdk -# launch the SecurityVM the first time to let the user do initial updates +rem I've already downloaded ... this is for convenience --> delete this line +rem This is just for testing. Enbale the real "wget http://service...." line above +rem to get the real VM image from X-Net +copy C:\Users\dyle\Documents\OpenSecurity\setup\OsecVM_initialized.ova . + +rem import the VM +VBoxManage.exe import OsecVM_initialized.ova --vsys 0 --vmname SecurityDVM --unit 12 --disk SecurityDVM\SecurityDVM.vmdk + +rem launch the SecurityVM the first time to let the user do initial updates VBoxManage.exe startvm SecurityDVM -echo "# Start VirtualBox and update the machine " -echo "# " -echo "# login with " -echo "# user: root " -echo "# pass: osecvm " -echo "# " -echo "# issue these commands as root " -echo "# " -echo "# # apt-get update " -echo "# # apt-get upgrade " -echo "# # apt-get dist-upgrade " -echo "# " -echo "# then shutdown the machine with " -echo "# " -echo "# # shutdown -h now " -echo "# " -echo "# press a key when done to proceed " +echo # Start VirtualBox and update the machine +echo # +echo # login with +echo # user: root +echo # pass: osecvm +echo # +echo # issue these commands as root +echo # +echo # # apt-get update +echo # # apt-get upgrade +echo # # apt-get dist-upgrade +echo # +echo # then shutdown the machine with +echo # +echo # # shutdown -h now +echo # +echo # press a key when done to proceed pause rem Turn the VM disk image immutable and attach it +echo sealing disk image ... VBoxManage.exe storageattach SecurityDVM --storagectl SATA --port 0 --medium none -VBoxManage.exe modifyhd SecurityDVM.vmdk settype immutable -VBoxManage.exe storageattach SecurityDVM --storagectl SATA --port 0 --device 0 --type hdd --mtype normal --medium SecurityDVM.vmdk +VBoxManage.exe modifyhd SecurityDVM\SecurityDVM.vmdk --type immutable +VBoxManage.exe storageattach SecurityDVM --storagectl SATA --port 0 --device 0 --type hdd --mtype normal --medium SecurityDVM\SecurityDVM.vmdk +echo done. OpenSecurity is ready to serve +